View Full Version : Slic
stankarp
July 19, 2004, 09:14
Wonder if I could get a little advice on SLIC please.
Have ben doing a bit for myself but cant get this bit to work. Curiously, it works sometimes but not others.
I have incorporated Locutu's repair code into a cradle mod expansion. Works fine for cities. Have developed a new unit, the supply train, wanted the code to work for units stacked with a supply train.
Code-
for (a = 0; a < player[0].armies; a = a + 1) {
GetArmyByIndex(player[0], a, tmpArmy);
army[0] = tmpArmy;
i = 0;
while(i < army[0].size && success == 0) {
GetUnitFromArmy(army[0], i, tmpUnit);
if(tmpUnit.type == UnitDB(UNIT_SUPPLY_TRAIN)) {
success = 1;
//}
}
i = i + 1;
}
if(success == 1) {
tmpLoc = tmpUnit.location;
for (k = 0; k < GetUnitsAtLocation(tmpLoc); k = k + 1) {
GetUnitFromCell(tmpLoc, k, tmpUnit);
Then the repair code goes here, have declared all things, returns no errors, just does not work most of the time.
I hope the line format comes across ok in the post.
Martin Gühmann
July 19, 2004, 13:31
The only thing I can think of is that there might be a problem with the army array. There is a bug with built in arrays, for instance if you assign a variable to a field of it and you used this it loses its value. Therfore you should better use this code:
for (a = 0; a < player[0].armies; a = a + 1) {
GetArmyByIndex(player[0], a, tmpArmy);
i = 0;
while(i < tmpArmy.size && success == 0) {
GetUnitFromArmy(tmpArmy, i, tmpUnit);
if(tmpUnit.type == UnitDB(UNIT_SUPPLY_TRAIN)) {
success = 1;
}
i = i + 1;
}
if(success == 1) {
tmpLoc = tmpUnit.location;
for (k = 0; k < GetUnitsAtLocation(tmpLoc); k = k + 1) {
GetUnitFromCell(tmpLoc, k, tmpUnit);
In theory your code should work, but it might not work, however this way, you also save an assignement.
-Martin
stankarp
July 19, 2004, 17:36
Thanks Martin, I will give that a try.:-)))
stankarp
July 22, 2004, 00:42
I tried the above and it did not work so in frustration I deleted it all and started again. Copied the repair code again, deleted the 3 lines that referred to cities and changed two others where it said tmpCity to tmpUnit then went back to IW's introduction to SLIC.
Inserted-
for (i = 0; i < player[0].units; i = i + 1) {
GetUnitByIndex(player[0], i, tmpUnit);
if(tmpUnit.type == UnitDB(UNIT_SUPPLY_TRAIN)){
And, hey presto it has worked half a dozen times in tests using cheat mode.
stankarp
July 22, 2004, 03:05
New Problem.
Cant figure out how to write into this bit of code the following. I am using this to give an advance if I build a colony on a good (iron ore). It works fine.
elseif (HasGood(ColonyLoc)==ResourceDB(TERRAIN_WHITE_MOUNTAIN_GOOD_TWO)){ //iron ore
if(HasAdvance(tmpPlayer, ID_ADVANCE_BRONZE_WORKING)) {
Event:GrantAdvance(tmpPlayer, AdvanceDB(ADVANCE_METAL_WORKING),0);
}
else {
Event:GrantAdvance(tmpPlayer, AdvanceDB(ADVANCE_BRONZE_WORKING),0);
}
}
What I wanted to do is -
Check for Bronze Working and give it to the player if he does not have it,
else give metal working if the player already has bronze working,
else give iron working if the player already has metal working.
Not experienced enough to write it.
Help appreciated.
Martin Gühmann
July 22, 2004, 13:57
Originally posted by stankarp
What I wanted to do is -
Check for Bronze Working and give it to the player if he does not have it,
else give metal working if the player already has bronze working,
else give iron working if the player already has metal working.
Not experienced enough to write it.
Help appreciated.
You should do something like this:
if(!HasAdvance(tmpPlayer, ID_ADVANCE_BRONZE_WORKING)) {
Event:GrantAdvance(tmpPlayer, AdvanceDB(ADVANCE_BRONZE_WORKING),0);
}
else if(!HasAdvance(tmpPlayer, ID_ADVANCE_METAL_WORKING)){
Event:GrantAdvance(tmpPlayer, AdvanceDB(ADVANCE_METAL_WORKING),0);
}
else if(!HasAdvance(tmpPlayer, ID_ADVANCE_IRON_WORKING)){
Event:GrantAdvance(tmpPlayer, AdvanceDB(ADVANCE_IRON_WORKING),0);
}
For the other code you should check the retuen value of GetUnitByIndex so that you new if the function filled the tmpUnit variable with a value:
for (i = 0; i < player[0].units; i = i + 1) {
if( GetUnitByIndex(player[0], i, tmpUnit)){
if(tmpUnit.type == UnitDB(UNIT_SUPPLY_TRAIN)){
-Martin
stankarp
July 22, 2004, 18:42
Thanks Martin, will give that a try.
stankarp
July 30, 2004, 08:01
Sorry, forgot to update and thank Martin.
Code now working fine, thanks:-))
stankarp
August 4, 2004, 19:02
Hi, wondering if I could get someone to verify this will work. My programming ability doesnt match my big ideas, its from the disasters number generator.
tmpPlayer = player[0];
if((g.year >= 3) && (g.year <= 150)) {
PlagueChance = random(80);
}
elseif((g.year >= 151) && (g.year <= 300)) {
PlagueChance = random(120);
}
elseif((g.year >= 301) && (g.year <= 1000)) {
PlagueChance = random(80);
}
The idea is that the chance of the event starts of higher, drops back then gets greater again. It does not return any errors but because of the nature of the code, it is hard to check accurately.
Help much appreciated.
stankarp
August 4, 2004, 22:27
Another small one, this one returns no errors but does not work as it should.
I have a new tileimp, Outpost. I want to prevent the human player pillaging his OWN Outposts but not other players Outposts.
HandleEvent(CutImprovements)'Stan_PillageOutpost' pre {
location_t tmpLoc;
if(IsHumanPlayer(player[0])){
if (TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_OUTPOST))){
if(CellOwner(tmpLoc)){
return STOP;
}
}
}
}
I can prevent any Outposts being pillaged but cant work out the correct code to limit it to pillaging your own Outposts.
Maquiladora
August 4, 2004, 23:46
Silly question time: Wouldnt the human just know not to pillage their own outposts? :D
stankarp
August 5, 2004, 03:22
Bit more to it.
I am working on a code that gives an advance to the human if he disbands a nomad type and spends 300-600 pw on a particular good to create a new tile improvement-OUTPOST, eg, on copper, you get copper smelting, a different way of treating strategic goods.
If you already have copper smelting you get bronze working. Iron is better, with 6 potential advances from copper smelting to paper (after Barracks).
The obvious cheat is that the human keeps disbanding nomads on the same good which is not what I had in mind. I have altered the code so that if you disband a nomad type on an existing outpost, you get nothing.
But the loophole is you pillage the Outpost away and then disband the nomad. Thats why I want to prevent the human from pillaging his own Outposts, so he has to find another good of the type to get the next advance.
The code also collects gold and/or pw from the outpost, so every good on the map can be used in theory. Some also fight plague and famine in my disasters code variation.
Ekmek
August 5, 2004, 17:03
Sounds cool Stankarp (can the AI handle it?) maybe another option is that you have to upgrade to a different unit to get the next advance. like after nomad you get colonist and a colonist has to disband. colonists would be available in a diffferent age so it will keep the players from advance to fast by goods.
If you need graphics I'd like to help, alas my stuff is in storage until october :(
stankarp
August 5, 2004, 18:30
Hi E,
To some extent it starts to cost more for advances because in Cradle, nomads become obsolete at Tribunal Empire and the new settler costs heaps, so by then you really think about disbanding such units for an advance. Especially as the code only gives you early advances.
Normally a player would not pillage a valuable tilimp of theirs but Iron is such a valuable resource, it might be worth it to get to phalanx quickly before the AI.
The ai does not build outposts on resources. It does build it as a normal tileimp. It already gets heaps of pw and gold from a cheat slic code and tilimp as well so it is always well ahead on tech. My code was a way of keeping pace for a while.
BTW E, did you see my comment re bad shadow files in the sprite editor thread? I am sure the bad shadows come from running makespr in win XP.
Martin Gühmann
August 7, 2004, 15:29
Originally posted by stankarp
Hi, wondering if I could get someone to verify this will work. My programming ability doesnt match my big ideas, its from the disasters number generator.
tmpPlayer = player[0];
if((g.year >= 3) && (g.year <= 150)) {
PlagueChance = random(80);
}
elseif((g.year >= 151) && (g.year <= 300)) {
PlagueChance = random(120);
}
elseif((g.year >= 301) && (g.year <= 1000)) {
PlagueChance = random(80);
}
The idea is that the chance of the event starts of higher, drops back then gets greater again. It does not return any errors but because of the nature of the code, it is hard to check accurately.
Help much appreciated.
I would do it rather like this:
PlagueRan = Random(100);
if((g.year > 150) && (g.year <= 300)){
PlagueChance = 80;
}
else{
PlagueChance = 40;
}
if(PlagueRan < PlagueChance)
//Do something
}
This code does something in 80 of 100 cases from turn 151 to turn 300, while the other turns the chance is only 40%. Your code is a little bit different, probably you have a threshold as well, but as it is not part of the code you posted I assume it is fixed. Let's say your threshold is 60 and if the PlagueChance is bigger a plague happens, this means in that case the plague chance is 50% when it is high and 25% when it is low. And that leads me two the conclusion that your code works as well, but might be not so obvious what it does as my code.
For your second problem replace the line:
if(CellOwner(tmpLoc)){
by
if(CellOwner(tmpLoc) == player[0].owner){
And you should be fine.
-Martin
stankarp
August 7, 2004, 22:04
Thanks Martin,
The first bit, disasters is followed by if statements that give a 1 in (PlagueChance) of events happening each turn. There are 3 good and 2 bad events based on the old disatsers code and also involve a spec effect on your capital that looks like a wonders size avi. So there is a 1/80 or 1/120 chance of plague in turn depending on the game year.
It sems to be working ok as is but I will have to play the current test for a while to gauge.
I will change the sencond line as suggested, knew it was something obvious that i overlooked.
Many thanks.
Ekmek
August 12, 2004, 19:58
Originally posted by stankarp
BTW E, did you see my comment re bad shadow files in the sprite editor thread? I am sure the bad shadows come from running makespr in win XP.
I saw it and commented on it. I use xp and I didnt have that problem. I made them with makespr and saw the lines in sprite edit and it was a problem in the game. Once I fixed the pixels on the edges the problem was fixed. Are you working on new graphics, I might be able to help (but more so in a few months)
Ekmek
October 7, 2004, 16:00
Stankarp,
How is the mod coming along? With some of the new changes coming out I'm itching to make a mod myself (but I got to do graphics first and learn SLIC better). Can you post some of the SLIC files you've made?
I'm looking to do some new SLICs:
RefugeesI'm thinking of taking the Patisian.slc if I can find it and have refugees made that if killed cost gold andd make people unhappy, something to complicate the modern age)
Guerrillas something for the modern age too, but just like Alex barbspawn where you have to hunt down the leaders. I'm looking to do the same for terrorists but have them create bombard units.
Resources i like what you did but I'm thinking of taking the point scoring from alex and have the system calculate the values but then modify the upgrade.slic so you can upgrade units to special units depending on your resource.
It should work like some of the abstracts on resources already talked about but it will have a small spreadsheet tracking each point and then when you upggrade it will deduct points based on the hungershield value per unit.
Code wise i'm thinking of using the hasgood and and the cityscore code and then linking it to the upgrade.slic. i may need a lot of help with this but one concern I have is how to create a button so the player can access the upgrade when they want to instead of the random pop-up in the upgrade text. I know Flinx added a new tab through the slic code, but I think I may have to beg to allow that ability to be available through SLICing.
I have a few other ideas that I'll post later, but I'm seeing if any experienced SLIC could comment on some ideas.
Ekmek
October 7, 2004, 16:17
Stankarp,
How is the mod coming along? With some of the new changes coming out I'm itching to make a mod myself (but I got to do graphics first and learn SLIC better). Can you post some of the SLIC files you've made?
I'm looking to do some new SLICs:
RefugeesI'm thinking of taking the Patisian.slc if I can find it and have refugees made that if killed cost gold andd make people unhappy, something to complicate the modern age)
Guerrillas something for the modern age too, but just like Alex barbspawn where you have to hunt down the leaders. I'm looking to do the same for terrorists but have them create bombard units.
Resources i like what you did but I'm thinking of taking the point scoring from alex and have the system calculate the values but then modify the upgrade.slic so you can upgrade units to special units depending on your resource.
It should work like some of the abstracts on resources already talked about but it will have a small spreadsheet tracking each point and then when you upggrade it will deduct points based on the hungershield value per unit.
Code wise i'm thinking of using the hasgood and and the cityscore code and then linking it to the upgrade.slic. i may need a lot of help with this but one concern I have is how to create a button so the player can access the upgrade when they want to instead of the random pop-up in the upgrade text. I know Flinx added a new tab through the slic code, but I think I may have to beg to allow that ability to be available through SLICing.
I have a few other ideas that I'll post later, but I'm seeing if any experienced SLIC could comment on some ideas.
stankarp
October 7, 2004, 18:32
Hi E,
My mod unfortunately is too big to publish on Apolyton. Cut down to its minimum, it would be nearly 100 meg. I have 50 meg in special effect sprites which are in effect, small AVI's that play when you get disasters, good events, a leader dies, you capture a capital or kill an AI and when Attila the Hun arrives or dies.
If you can help me with some graphics, I could post you a disk. I have a few sprites where I have those shadow lines and I have fixed some but have been concentrating on Slic. However, I am not so good at it (Slic) where I have to declare identities of players, still having trouble, thats where I want it to effect other than the human player.
The best updater is in Peter Trigg's CTC mod, I am using a copy of it. You simply click on the sentinel button if a unit is in a city or fortress and it upgrades if you have the advance and necessary gold. Great feature. You just change the data arrays to suit your game. When you see it, its obvious how to change it. There are data statements at the start in blocks of 4, giving the advance, old unit, new unit and cost, then further down the code is a list of the advances. You only need to change these.
Ekmek
October 7, 2004, 18:40
stankarp,
Thanks for info. If anything I'd love to see only your slic files or a list of what you used.
I'd like to help with graphics but right now by resources are limited (I waiting on my townhome to be built and all my stuff is in storage) but after that I'll be happy to help. In fact I'm hoping Martin the Dane will release a new build of his sprite editor...
PS I saw the religion.slic and I think it would be great to modify it and make it like Nationality in Civ3. Except I'm going to make the refugees do the "converting" (when it gets to modern ages). But thats still a ways away, I'll work on graphics first (clean up my terrain stuff, then sprites) and SLIC a bit a long the way.
stankarp
October 7, 2004, 21:34
OK,
When you are ready.
As a matter of interest, where is the "Religion.slic"?
stankarp
October 7, 2004, 21:36
The slic files I used where Cradle 130B as a base.
Then I changed a heap. Give me your email address and I'll email you the readme.
Ekmek
October 8, 2004, 14:39
Religion SLIC is in the files section under mods.
mapfi
October 11, 2004, 16:41
hey - cool if Pedrunn's and my work will be of use for you - if you need any help with the religion slics, just ask - I think I'll be able to remember what I did ;)
Ekmek
October 11, 2004, 17:08
cool mapfi,
actually I'd like to just trim it to simulate Civ3-ish (but better) nationality concept. If you got any ideas please add...
stankarp
October 11, 2004, 17:28
Actually, I was thinking about it and thought that there should be 4 religions, rather than 1 per starting player, this sort of includes a culture component as well. Too many religions would be a bit complicating.
Say East(hindu/budhism), West(chrisitanity), Middle(islam), and pagan (other). You select yours but ai is random.
I havnt read the code fully, but though it might be easy to trim it down to that. This would then have 2 ramifications-
1) civs of the same religion would be a little friendlier than normal frenzy, and
2) captured cities of a different religion would have an extra unhappiness until converted, either by a lot of gold or gradually by a cleric/prophet.
stankarp
October 11, 2004, 17:31
Then of course you have to be able to build a religious war which when built, is a unit a bit like a diplomat and when it arrives at a ai of the same religion causes them to declare war on a nominated target of a diferent religion.
Ekmek
October 11, 2004, 17:44
That would be cool. If possible I'd like to see the Religion SLIC "split" to have more religion aspects and have a separte nationality SLIC as well.
I was also thinking abot having culture, but I wanted to make cultural buildings that created culture points and at a certain number of points it would randomly pick either: nothing, a special attribute, or a great leader.
the attributes would be kind of like Civ3, but better since ctp2 is so moddable, insteadof preset each civ gets an attribute at certain points and as time goes on it creates different bonuses. i.e. Agraria eventually goes to better farms in later ages, or sea faring better ships. Just to add a different feel.
stankarp
October 11, 2004, 17:57
Hi E,
I always thought that the culture issue in civ 3 was unrealistic. Can anyone point out where people of different cultures voluntarily merged? History is riddled with examples of the opposite, and many wars were fought because if this difference. Cultural difference may lead to economic refugees going to a more prosperous culture, but not merging.
Ekmek
October 11, 2004, 18:05
I agree and I hated how "culture" defined borders in civ3. i dont like how it does in ctp2 either, I wish there was a way to "capture" teritory with units or if anything certain improvements (not related to pop) would increase the control of your territory.
As for culture thats why i felt different attributes being the culture would work better and hopefuly give a different feel when you are up against different civilizations. I hope I see your readme soon.
mapfi
October 11, 2004, 19:38
Actually, I was thinking about it and thought that there should be 4 religions, rather than 1 per starting player, this sort of includes a culture component as well. Too many religions would be a bit complicating.
If possible I'd like to see the Religion SLIC "split" to have more religion aspects and have a separte nationality SLIC as well.
this all depends on how you're planning to use the ingame religion stuff...
while you can use e.g. the first 4 playercolors as religion at the start you'll run into big trouble as soon as those players get annihilated, it won't work
as for splitting it up - you only have one ingame religion setting - you could use the franchise for the other one though
i remember the hours I spent on this stuff trying to figure out ways and getting it to work, especially the player array stuff and sending the messages, it was very tiring - check out the slic oddities thread, that might save you some work ;)
stankarp
October 11, 2004, 22:19
"I wish there was a way to "capture" teritory with units or if anything certain improvements (not related to pop) would increase the control of your territory."
Forts and Watchtowers extend borders, but I cant remember if watchtowers were in the original or SAP games.
In my mod I introduced a new unit, the MIGRANT for transferring population from city to city. It's basically a very low value combat unit that cuses a pop point when built, then returns the pop point if disbanded in a city. I aded a cost of 250 gold for the function and extended that to all settler/nomad types.
In addition, I created a new tile improvement, the BORDER FORT, if you disband a migrant in the open inside existing territory and have 100 gold and 100-250 pw, you get a border fort which is like a watchtower, extends borders, but has no defence.
Ekmek
October 12, 2004, 20:00
elseif (HasGood(roadLoc)==ResourceDB(TERRAIN_WHITE_MOUN
TAIN_GOOD_TWO)){ //iron ore
if(HasAdvance(tmpPlayer, ID_ADVANCE_IRON_WORKING)) {
Event:add 1 point to Iron
}
else {
}
}
What I wanted to do is -
If a player has the advance Iron Working and
When a player has a road on an iron good it will give the player 1 point.
(I'm looking at Alex Scenario SLIC for how it calculates cityscore, heirscore, etc.)
I also want to add that when there is a mine on that good it gives 5 points.
I am then looking to incorporate the the updater SLIC but when you upgrade a warrior to a legion it will subrtact from the iron score (and PW and gold)
I'll add that in a bit, and I'll continue to learn more on the SLIC but I wanted to get this idea out there and if interested feel free to help.
ignore the attachment..for now
Not experienced enough to write it.
Help appreciated.
Immortal Wombat
October 12, 2004, 20:25
So you want a running total of resource points, that should be easy enough to calculate, probably. Though it may mean scanning the map.
- Does it count if the resource is outside a city radius?
- If there is a mine, must there also be a road? If not, does a road = +1 and a mine = +5 or is 5 the maximum?
Then when you upgrade a unit, you want to subtract a point. What if there are no more points? If you plan to hijack the existing upgrade code, this could get pretty complicated I would think: you'd have to check for gold availability and PW availability and iron-points availability before upgrading! Strings aplenty to be working with.
Then does the iron score then reset to the total the following turn, or later that turn. i.e. is the amount needed to upgrade a comparison to or a depletion of the points? Do points only get added when the tile improvement is built (and deducted when pillaged), or is the points total a function of their existence?
stankarp
October 12, 2004, 20:34
Hi Ben,
Sent you an email a few minutes ago.
Can you clarify this for me please?
Not sure how CTP2 represents buildings from wonders. In civ 3 the building shows up in the inventory and is removed when the wonder is obsolete.
I was certain in the past that after I built a wonder like VOK, the building (apothecary) appeared in the inventory for each city, can remember selling apothecaries when preparing to get rid of cities.
However, I ran a test game and checked an old game and neither showed apothecaries in the inventory after VOK was built.
In my current game VOK has just become obsolete and cities do not have an apothecary in the inventory, but new cities also do not show apothecary as a building option.
Do you know exactly how wonder buildings are represented, is it effect only? and they dont show up in the build list?
stankarp
October 12, 2004, 20:40
E,
While it is feasible to do what you want, as IW said, I think that level of detail is not really applicable to a game of this scale. You would have to do it for Rubber, oil, aluminium, horses, copper etc.
If you are wanting a detailed scenario based on a particular period, then its probably worth while. The existing system generalises resources into three things, gold, food and PW which is better than civ 3.
stankarp
October 12, 2004, 20:45
An then of course, you have to get the AI to do things with the new concepts.
Immortal Wombat
October 12, 2004, 20:51
Originally posted by stankarp
Hi Ben,
Sent you an email a few minutes ago.
Hey, I'm having some troubles with my email at the minute. I'll reply by PM.
stankarp
October 12, 2004, 21:01
Thanks Ben, I figured that out by changing the name of the function and running the game, and when it returned no error I figured that that type of function was called every turn.
Hope you are back on line fully soon. Thanks.
Does anyone else know about how the Wonder Buildings are handled?
stankarp
October 13, 2004, 03:10
I think I figured out the problem.
Buildings from wonders do not show up in inventory for cities.
The buildings do still show up in the build queue if a wonder is built (we knew that, thats why wonderbuildings.slc was written).
However, when a wonder is obsolete, the building does not return to the build list, applicable only to cities built after obseleting, here being the problem.
I am very sure that unless the wonder is destroyed by it's city being destroyed, the player still is counted as having the wonder even after it is obsolete. It still shows up in the wonder list. Anyways, wonderbuildings.slc does not return the building to the build queue.
I solve the problem by altering wonderunits.slc so when a wonder is created, the buildings are built in the city and I removed the buildings from wonders.txt. The remaining issue is to build the building when a city is created until the obseleting advance is reached. I have written this amendment to militia creation. Cant quiet get the code right, can anyone see what I did wrong. Does not return any errors but does not work.
HandleEvent(CreateCity) 'CRA_MilitiaCityCreated' post { // triggers if a city is founded
location_t tmpLoc;
int_t tmpPlayer;
tmpPlayer = player[0];
tmpLoc = location[0];
city_t tmpCity;
CRA_CreateMilitia(1, tmpPlayer, tmpLoc); // create 1 Militia
tmpCity = city[0];
player[0] = tmpPlayer;
if (PlayerHasWonder(tmpPlayer, WonderDB(WONDER_VALLEY_OF_THE_KINGS)) && (!HasAdvance(tmpPlayer, ID_ADVANCE_DARK_AGES))) {
Event:CreateBuilding(tmpCity, BuildingDB(IMPROVE_APOTHECARY));
}
elseif (PlayerHasWonder(tmpPlayer, WonderDB(WONDER_HANGING_GARDENS))&& (!HasAdvance(tmpPlayer, ID_ADVANCE_DARK_AGES))) {
Event:CreateBuilding(tmpCity, BuildingDB(IMPROVE_AQUEDUCT));
}
elseif (PlayerHasWonder(tmpPlayer, WonderDB(WONDER_HADRIANS_WALL))&& (!HasAdvance(tmpPlayer, ID_ADVANCE_BANKING))) {
Event:CreateBuilding(tmpCity, BuildingDB(IMPROVE_WALL));
}
}
Thanks if anyone can help.
hexagonian
October 13, 2004, 10:23
Originally posted by stankarp
My mod unfortunately is too big to publish on Apolyton. Cut down to its minimum, it would be nearly 100 meg. I have 50 meg in special effect sprites which are in effect, small AVI's that play when you get disasters, good events, a leader dies, you capture a capital or kill an AI and when Attila the Hun arrives or dies.
This Mod has a lot of potential. (I've been fortunate enough to have access to it, thanks to stankarp sending me a CD copy) But it may not be reasonable for stankarp to send a file to everyone who asks for it - though the traffic here for CTP2 files is light. A 4-year old game does that...
Although the AVIs and soundfiles are a nice atmospheric touch, I'd suggest setting up a 'bare bones' public version of your Mod that only includes stuff essential to the actual gamplay.
You can also possibly merge the use of sprites, using tga files (which are a lot smaller than spritefiles) to differentiate your generals.
It would be a little more work at your end (keeping track of multiple file setups), but the important thing for you is to get the Mod into the public's hands - not only for playing, but for some playtesting.
Ekmek
October 13, 2004, 16:41
Originally posted by Immortal Wombat
So you want a running total of resource points, that should be easy enough to calculate, probably. Though it may mean scanning the map.
- Does it count if the resource is outside a city radius?
- If there is a mine, must there also be a road? If not, does a road = +1 and a mine = +5 or is 5 the maximum?
Then when you upgrade a unit, you want to subtract a point. What if there are no more points? If you plan to hijack the existing upgrade code, this could get pretty complicated I would think: you'd have to check for gold availability and PW availability and iron-points availability before upgrading! Strings aplenty to be working with.
Then does the iron score then reset to the total the following turn, or later that turn. i.e. is the amount needed to upgrade a comparison to or a depletion of the points? Do points only get added when the tile improvement is built (and deducted when pillaged), or is the points total a function of their existence?
Thats IW and Stankarp. Essentialy I'd like to work a resources concept via SLIc. The community seems split on having resources at all, and those that do have different opinions on how to implement it.
I'm oping to make SLIC for a scenario, probably only using iron, horses, and oil. Somethig to make the late game more interesting.
As for your questions
I want the score to be totaled at the beginig of the turn and then subtracted as you upgrade by the end of the turn. That total score then gets added to anything is "produced" each turn.
i'm loking to have the points geberated if they have tile improvement os them and you get no bonus if they are pillaged (Maybe I could add a resource bonus for pillaging but that can be discussed later)
I think the resource should be counted only when its in a civs radius and have some improvement on it, to show an active use of it (road, mine, etc)
And I'm thinking the upgrade would require looking at availability of gold, pw, and iron before bing allowed to upgrade for certain units.
Immortal Wombat
October 13, 2004, 16:55
So you want something like this:
HandleEvent(BeginTurn) 'countupresources' pre{
for(player's cities)
check for goods
if good, does it have a road
if yes, points ++
or a mine, points + 5
}
The upgrade code is going to be really tricky though, I would guess. You'll need to check for all resources beforehand, work out which is the limiting factor (if at all) and tell the player how many units he can upgrade. Then it should be as normal, maybe.
Ekmek
October 13, 2004, 17:42
I'll take a look at the upgrade code...
but I might make the point score calculate a little more complex too. Like for instance in using oil I'd like to have every city with a powerplant cost 1 oil point per population. And if you don't have enough oil for the power plants it hurts productivity or happiness. Still thinking on this one...
stankarp
October 13, 2004, 18:40
Hi Ben,
Can you see why my code above does not work, something to do with the declarations again.
Thanks if you can help.
stankarp
October 14, 2004, 03:34
Phew, problem figured out. I recommend anyone who wants to write slic should seek a medical opinion first, it is very, very frustrating.
The problem is that, I am 99% sure, you cannot build a building in a city in the turn the city is created. I eventually added a getcitybyindex loop to my code and still did not get a building, then had a thought and created cities on successive turns. The city created the previous turn then got the building.
The Big Mc
October 14, 2004, 03:55
Try destroying a building and moding settlers to make it on city creation.
Hint: look at urban planers unit entry.
stankarp
October 14, 2004, 11:13
Thanks Big Mc,
However, that will involve a different settler type for each wonder that provides buildings, and restricitng that unit ala med mod or AG scenario to the player with the wonder. Then you would need one nomad type for each possible combination of wonders, eg,
has VOK but not HG and HW, or has HG but not HW and VOK, etc, etc, etc.
I now have it all worked out except that the last city built by the wonder owner does not have the building, since its lev 1, plenty of time to build the buildings and its not critical to that city that is does not have the wonder.
The reason why I persevered with this is I am sure that building effect supplied by a wonder, does not mean the city has the building if you do a hasbuilding check, such as in the disaster code.
Ekmek
October 14, 2004, 19:28
TOTAL_COST=((NUM_OBS_UNITS)*PER_UNIT_UPDATE_COST[UPDATE_TYPES_ARRAY[UPDATE_TYPES_INDEX]]);
if (TOTAL_COST <= Playergold(player[0]) && (NUM_OBS_UNITS ==1) ){
//special case: slightly different message and text
message(player[0], 'ObsUnitsCostOKand1unit');
}
elseif (TOTAL_COST <= PlayerGold(player[0]) && (OBS_UNIT_ARRAY.# >1) ){
message(player[0], 'ObsUnitsCostOK');
}
else {
message(player[0], 'ObsUnitsCostNotEnoughGold');
}
}
I found the updater only address gold, should I just copy this code for PW and the iron score or do they have to be all together?
Immortal Wombat
October 14, 2004, 20:09
That depends. From what I remember of the code, the messages called above lead into the main updating sequence. If you simply copied that for PW and resource points, it would try and update three times, horrible things would happen.
What I think you need to do is to work out before that block of code the total cost in gold, PW and iron points (and this will probably involve two more arrays similar in form and function to PER_UNIT_UPDATE_COST[]), work out if any of the three resources (gold, pw, iron) are too small to do the whole lot, and then message accordingly. If two (or all three) resources are too small, you'll have to message the player using the least one I guess.
The good news is that you might be able to hijack the existing messages once you have worked that out, using variable string text to tell the player which resource is limited, and then use the same updater code.
If none of the three things are limited, you need the code to go into the "enough gold" loop. And of course, alll the messages will have to be changed to tell the player how much public works he's putting into the updating so that he/she can tell the code when to stop.
stankarp
October 14, 2004, 20:38
Very Quick Question
Does reloadslic reset global variables?
stankarp
October 14, 2004, 20:44
E,
this bit of code searches the map for a particular tile_imp belonging to the each player.
if(IsHumanPlayer(player[0])){ // once each player-cycle. This means that AI players will get gold early, but
// it saves scanning the map 8 times
for(i=0; i < GetMapWidth(); i = i + 1){
for(j=0; j < GetMapHeight(); j = j + 1){
MakeLocation(tmpLoc,i,j); // scan map for locations
if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_OUTPOST))){ // if it's a outpost
if(CellOwner(tmpLoc)){ // and owned
AddGold(CellOwner(tmpLoc),10); // gift some gold
}
if(CellOwner(tmpLoc)){
if (HasGood(tmpLoc)>=0){
AddGold(CellOwner(tmpLoc),10);
}
}
Note, it does not have the right number of "}" at the end of code, its copy and paste job from part of a 30 page code.
stankarp
October 14, 2004, 20:45
Forgot, adds 10 gold for the tile_imp and another 10 gold if there is a good there.
Immortal Wombat
October 14, 2004, 20:47
Yeah, but an easier way to do that, since you only need to check city radii would be to do as HasGood call first, which identifies if you even need to scan the city, and then use BlueO's or Pedrunn's city-radius scanning pattern to check for the tile improvement.
Yes, reloadslic does reset globals.
stankarp
October 15, 2004, 00:56
Hi Ben,
Any idea how to maintain a separate in game score that wont reset with reloadslic. I have set up a system that adds to a global variable when-
a) a capital is captured,
b) a AI is killed.
c) a wonder is built
then once per 100 turns, adds that value to a score worked out on number and size of cities. This gives a score and an appropriate message to the human player and displays the score.
The problem, if I have to reloadslic for the occassional crash, the score resets to 0.
stankarp
October 15, 2004, 01:19
Actually, I figured out how to do it, as long as local variables are not reset to 0 with a reloadslic.
Instead of simply having a line
score = score +25;
in each part of code where I want the score to increase, replace it with a function that simply adds 25 to a variable inside the function then writes it to the global variable. That way if the global variable is reset, it gets updated next time the score function is run.
So the simple question is, do local variables reset to 0 with reloadslic?
stankarp
October 15, 2004, 02:12
Answered my own question with a test, local variables do reset with reloadslic, even inside a function.
So back to Ben for any ideas. Sigh.
Immortal Wombat
October 15, 2004, 18:39
Don't reloadslic.
stankarp
October 16, 2004, 07:46
Immortal Wombat "Don't reloadslic. "
Wish it was that easy but I am getting an ocasional crash betwen turns 200-300. Its a bit wierd, will start keeping a record of them, but the ones where I have to reloadslic almost always seem to be the same AI player, think its no 5. I get an occasional other one but I think thats a windows thing, I am on Directx 9 now and suspect that might cause it.
I have worked out a way to calculate the score from scratch each time, using a tilimprovement check , a visible wonder check from a map scan, then a wonder check for other wonders. The trick was capturing enemy capitals and killing an AI. So I created a monument for each one, which is built when you achieve that, then the map scan picks it up. Havn't quiet perfected the code that places the monument following the event.
Thats really testing my limited skill.:b:
Ekmek
October 20, 2004, 19:53
IW
I thought of a more simpler possibility.
if player hasgood & road in teritory
& hasadvance
then let the city build the unit
I saw the Alex slic that assigns elephants to cities, but can I assign no city to build an elephant unless the player hasgood and hasadvance?
stankarp
October 20, 2004, 20:42
Yes, to see an example, go to Med Mod. There is a code that restricts the building of units. Its one of the Slic files with a persons name. Also, wonderbuildings.slc gives an example of how to prevent a city building something, in that case, if a player has a wonder.
You just need to interchange the combination of (has )or (!has) to get what you want.
stankarp
October 20, 2004, 20:46
New topic, does anyone know how to use the "AccomplishFeat" command?
I tried this but it returns a "no function AccomplishFeat" error.
if (AccomplishFeat(FeatDB(FEAT_THEATERS),player[0]))) {
humanscore = humanscore + 25;
}
I also tried substituting number 7 for the "FEAT_THEATERS)," bit and that did not work either.
Immortal Wombat
October 21, 2004, 10:53
Originally posted by E
I saw the Alex slic that assigns elephants to cities, but can I assign no city to build an elephant unless the player hasgood and hasadvance?
Yes, that was going to be the basis for the Strategic Resources code we nearly did pre-Civ3. You can even add a line that saves the AI the bother if you want to avoid that issue. You probably wouldn't need to code HasAdvance either, since the text file takes care of that.
The two major flaws is that:
1/ There's no way of accessing which goods are being traded. Under your system it either becomes a non-issue (it doesn't count via trade) or an even more complicated issue (does the city it's coming from have a mine on that resource).
2/ The AI can't cope with it, and won't be able to without a lot of source code work.
Locutus
October 21, 2004, 11:19
Originally posted by stankarp
New topic, does anyone know how to use the "AccomplishFeat" command?
I tried this but it returns a "no function AccomplishFeat" error.
if (AccomplishFeat(FeatDB(FEAT_THEATERS),player[0]))) {
humanscore = humanscore + 25;
}
I also tried substituting number 7 for the "FEAT_THEATERS)," bit and that did not work either.
That's because AccomplishFeat is an event, not a fuction. So it should look like this (untested, no warranties):
HandleEvent(AccomplishFeat) 'blah' post {
if (value[0] == FeatDB(FEAT_THEATERS)) {
humanscore = humanscore + 25;
}
}
stankarp
October 21, 2004, 18:11
Thanks Locutus.
stankarp
October 21, 2004, 21:11
Next Question, can you add feats to the game, I have asked and looked elsewhere and can't find anything on how to do it.
Thanks if anyone can help.
Martin Gühmann
October 22, 2004, 04:54
Originally posted by stankarp
Next Question, can you add feats to the game, I have asked and looked elsewhere and can't find anything on how to do it.
What about feat.txt? And with slic you can also add some non-predefined effects.
-Martin
stankarp
October 22, 2004, 07:39
So what you are saying Martin is that all I have to do is add something like this to feats.txt
FEAT_SHRINES {
Duration 15
Description str_ldl_0
EffectIncreaseHappiness 3
SlicMessage "FeatBuiltShrines"
Building { Building IMPROVE_SHRINE Num 8 }
}
And then add the appropriate message and messagebox details and information in the Great Library? I thought there was more too it.
stankarp
October 22, 2004, 07:45
One more question, forgot to ask it in previous questions.
This is the messagebox from the AG scenario.
alertbox 'AGGameover' {
Show(); Title(ID_AG_BLANK);
Text(ID_AG_GAMEOVER);
Button(ID_AG_BUTTON_OK) {
Kill();
GameOver(1, 1);
}
}
Anyone know what "GameOver(1, 1);" does?
Thanks.
Locutus
October 22, 2004, 11:40
Stankarp, don't you have access to a full list of SLIC functions? To say that that would be useful when programming SLIC is a severe understatement... You can find loads of useful documentation (including function & event lists) in one of the topped threads in this forum: 'Resources for Modmakers'.
From that documentation:
INT GameOver(player, reason)
End the game for the given player. reason can be either 1 or 2, 1 meaning the player won, 2 meaning they lost. This is especially useful for scenarios with specific victory conditions. Example:
GameOver(player[0], 1); //player[0] wins the game
Martin Gühmann
October 22, 2004, 12:22
Originally posted by stankarp
So what you are saying Martin is that all I have to do is add something like this to feats.txt
FEAT_SHRINES {
Duration 15
Description str_ldl_0
EffectIncreaseHappiness 3
SlicMessage "FeatBuiltShrines"
Building { Building IMPROVE_SHRINE Num 8 }
}
And then add the appropriate message and messagebox details and information in the Great Library? I thought there was more too it.
Yes, and if your feat trigger condition is not in the FeatDB then you can use slic, there is the feat accomplished event and a give feat function.
-Martin
stankarp
October 22, 2004, 18:23
Hi Locutus, I have a list but must have missed that bit, thanks. I suspected that was the caseYend game), but was not sure. I have printed copies of most things from the 'Resources for Modmakers'. bUt there is so much there for an amateur programmer but I am getting better.
Thanks.
Thanks Martin.
stankarp
October 28, 2004, 00:13
Quick question re messageboxes.
Can you code in or call a function from a message box such as this?
messagebox 'RiotA' {
show();
Title(ID_RIOT_TITLE);
Text(ID_RIOT_YOU);
// Do you want to spend money on happiness?
Button(ID_YES) {
Festivities(player[0]) ;
Kill();
}
Button(ID_NO) {
Kill();
}
}
Havn't had any success so far so was wondering if its not possible?
I Can call messages and have seen examples of enable/disable trigger but not code or calling a function.
stankarp
October 28, 2004, 03:43
Figured it out. After finding example of code in a messagebox, I worked it out.
The trigger for the message was the "trigger"command to open a menu. While the menu is open, it blocks other things happening. All working now, thanks.
Locutus
October 28, 2004, 05:04
Originally posted by stankarp
I have printed copies of most things from the 'Resources for Modmakers'. bUt there is so much there for an amateur programmer but I am getting better.
I can certainly understand that. It's just that the combination of your attempt to use an event and a function and your unfamiliarity with the GameOver function got me thinking: wouldn't want you to miss out on any useful info...
Good to see you're making progress though :b:
stankarp
October 28, 2004, 07:12
Only by dogged perserverance:o
stankarp
October 28, 2004, 07:15
And I occassionaly find an error in someone else's code, or, if I can't understand it, cut out all the bits I don't understand and then put in bits I do understand till it works:D
Ekmek
December 1, 2004, 14:45
Stankarp,
It looks like you are doing cool stuff with SLIC any chance you can just post your SLIC files only so others can take a look at. I havent found anythinglike a SLIC library for (potential) modders to go through to get ideas etc.
If you see this Stankarp.
In a mod I tried I had it where a unit built roads that acted like forts. it extended the boundaries and it was great when I wentto war and pillaged roads it started reducing the enemys territory and I built roads in its place. So I'm looking to make an improvent maybe with a small mark or flag to allow capture territory in view.
2) on your migrant, I was thinking that using mapfi and pendrun religion slic to make nationality and if a player uses a migrant that "attacks" by adding one foriegn population to a city it can eventualy make the city more ethnically different and if the city revolts then it may join the other civ. Its better than culture flipping in Civ3.
Originally posted by stankarp
"I wish there was a way to "capture" teritory with units or if anything certain improvements (not related to pop) would increase the control of your territory."
Forts and Watchtowers extend borders, but I cant remember if watchtowers were in the original or SAP games.
In my mod I introduced a new unit, the MIGRANT for transferring population from city to city. It's basically a very low value combat unit that cuses a pop point when built, then returns the pop point if disbanded in a city. I aded a cost of 250 gold for the function and extended that to all settler/nomad types.
In addition, I created a new tile improvement, the BORDER FORT, if you disband a migrant in the open inside existing territory and have 100 gold and 100-250 pw, you get a border fort which is like a watchtower, extends borders, but has no defence.
stankarp
December 17, 2005, 04:54
Has anyone ever used the 'AttachRobot' or 'DetachRobot' handlers?
I tried them a couple of times and they appear to do nothing, i.e., not what the slic manual says they should do.
Thanks for any help.
Martin Gühmann
December 17, 2005, 12:03
Originally posted by stankarp
Has anyone ever used the 'AttachRobot' or 'DetachRobot' handlers?
I tried them a couple of times and they appear to do nothing, i.e., not what the slic manual says they should do.
Thanks for any help.
I tried them, but however they seemed not to work properly. Sometimes I got an effect sometimes I didn't got one. At least from the source code I know that it has only an effect for player 0 or 1 to 9.
I usually switch to the Barbarian player and use the /rnd command to let the AIs play.
Well that's for the chat window commands.
For the slic function, its source code looks ok. And if the network is inactive there shouldn't be a problem. But of course there might be a problem that I cannot see by just looking on the code.
-Martin
Ekmek
February 7, 2006, 17:06
I'm looking to do slic where if you have a tile imp outside your city radius then it just gives you PW or gold. The idea here is that you can set up imps by building a colony tile imp but each turn it givesgold or PW. I looked in Stan's code and didnt see anything like that
I drafted this:
HandleEvent(BeginTurn) 'FindOilPW' post {
int_t tmpPlayer;
tmpPlayer = thePlayer;
int_t i;
int_t j;
for(i=0; i < GetMapWidth(); i = i + 1){
for(j=0; j < GetMapHeight(); j = j + 1){
MakeLocation(tmpLoc,i,j); // scan map for locations
if (TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_OIL_REFINERY))){
if(CellOwner(tmpLoc)== player[0]){ // and owned
AddPW(player[0], 500);
}
}
}
}
BUT i think checking each turn will really slow the game down. How do I create an array so that everytime I build a tileimp outside the radius it adds the imp to it and everytime it is pillaged it subtracts it. Is it by an array or should I keep a score and then just multiple the score? Any recomendations?
stankarp
February 7, 2006, 18:25
I looked in Stan's code and didnt see anything like that
By E.
?? Look in my disasters.slc file, this is precisely what my outposts do. In addition to acting as a normal tile imp if in a city radius, they also gather some gold and/or public works as well, regardless of location (as long as they are in your owned territory). Used inconjunction with border forts or watch towers, outposts let you use any, and potentially EVERY, resource on the land map
With public works you need to use this type of code to add PW.
player[0]=CellOwner(tmpLoc); ppw = player[0].publicworkslevel;
ppw = ppw + 20;
SetPW(player[0],ppw);
A warning, when I was setting this up, I had trouble with the slic and eventually gave up in frustration. At that time I was using "colony" as the tile improvement. I tried changing it all to "outpost" and everything worked. Do not know why, it was a long time ago.
Ekmek
February 9, 2006, 15:24
Thanks Stan,
That stuff is exactly what i was looking for. I guess I overlooked it because it was in disasters and not in a tileimp slic file.
I havent fired up AoM or any game in awhile but I cant recall if the Ai builds outposts. I dont think it does...if I'm wrong how did you get it to do it?
and for those that can help here is a draft of my gift code, I know STan wasnt for it, but I tend to try to build up AI and do balance of power (when I actually play) so a gift code works for me. But I'm not sure about the war part is this right?
HandleEvent(DisbandUnit) 'GiftUnit' post {
location_t UnitLoc;
unit_t tmpUnit;
unitLoc = unit[0].location;
player[0] = unit[0].owner;
player[1]= CellOwner(unitLoc )
tmpUnit0=unit[0];
If(player[1] != 0) {
if (!AtWarWith(player[1],i){
if(CellOwner(unitLoc ) > 0 && CellOwner(unitLoc ) != player[0].owner){
KillUnit(tmpUnit);
CreateUnit (player[1], tmpUnit, unitLoc, 0, tmpDist);
}
}
}
}
stankarp
February 9, 2006, 16:38
I havent fired up AoM or any game in awhile but I cant recall if the Ai builds outposts. I dont think it does...if I'm wrong how did you get it to do it?
By making them tile improvements, the AI builds them automatically anyway. Hex noted than in AOM V 1.00, the AI public works cheat meant the AI could spam the map with outposts which are quiet powerful. So we greatly reduced the ai pw cheat. I found it not uncommon for the ai to have 500,000 plus in pw it did not use because of the pw cheat and the fact the ai could allocate up to 30% on pw. I reduced that to 20%.
If you look in the disasters code,
if(CellOwner(tmpLoc)>1 && HasGood(tmpLoc)>=0 //ai tiles with good and no outpost
&& g.year > 100
&& !TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_OUTPOST))){
player[0] =CellOwner(tmpLoc);
ppw = player[0].publicworkslevel;
if (ppw > 2500){
Event:CreateImprovement(player[0], tmpLoc, TerrainImprovementDB(TILEIMP_OUTPOST), 0);
}
}
This also helps the ai build outposts on goods it owns.
In this line of your code, you have not defined i anywhere.
"if (!AtWarWith(player[1],i){"
Replace i with player[0].
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.