 |
|  |
 |
|
stankarp
|
|
australia
Feb 2002 time: 05:34
|
|
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
|
 |
Berlin, Germany
Mar 2001 time: 06:34
|
|
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:
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
|
|
australia
Feb 2002 time: 05:34
|
|
Thanks Martin, I will give that a try.:-)))
|
|
|  |
 |
|
stankarp
|
|
australia
Feb 2002 time: 05:34
|
|
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
|
|
australia
Feb 2002 time: 05:34
|
|
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_MOUN
TAIN_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
|
 |
Berlin, Germany
Mar 2001 time: 06:34
|
|
quote: 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:
code:
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:
code:
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
|
|
australia
Feb 2002 time: 05:34
|
|
Thanks Martin, will give that a try.
|
|
|  |
 |
|
stankarp
|
|
australia
Feb 2002 time: 05:34
|
|
Sorry, forgot to update and thank Martin.
Code now working fine, thanks:-))
|
|
|  |
 |
|
stankarp
|
|
australia
Feb 2002 time: 05:34
|
|
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
|
|
australia
Feb 2002 time: 05:34
|
|
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.
|
|
|  |
 |
|
stankarp
|
|
australia
Feb 2002 time: 05:34
|
|
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.
|
|
|  |
 |
|
stankarp
|
|
australia
Feb 2002 time: 05:34
|
|
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
|
 |
Berlin, Germany
Mar 2001 time: 06:34
|
|
quote: 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:
code:
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:
code:
if(CellOwner(tmpLoc)){
by
code:
if(CellOwner(tmpLoc) == player[0].owner){
And you should be fine.
-Martin
|
|
|  |
 |
|
stankarp
|
|
australia
Feb 2002 time: 05:34
|
|
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.
|
|
|  |
 |
|
stankarp
|
|
australia
Feb 2002 time: 05:34
|
|
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.
|
|
|  |
 |
|
stankarp
|
|
australia
Feb 2002 time: 05:34
|
|
OK,
When you are ready.
As a matter of interest, where is the "Religion.slic"?
|
|
|  |
 |
|
stankarp
|
|
australia
Feb 2002 time: 05:34
|
|
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.
|
|
|  |
 |
|
stankarp
|
|
australia
Feb 2002 time: 05:34
|
|
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
|
|
australia
Feb 2002 time: 05:34
|
|
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.
|
|
|  |
 |
|
stankarp
|
|
australia
Feb 2002 time: 05:34
|
|
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.
|
|
|  |
All times are GMT. The time now is 05:34. Apolyton Time is 00:34. |
top of page
|
|
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|