 |
|  |
 |
|  |
 |
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:25
|
|
It was getting late. 
enadv[]got changed from being a local array to a global EN_ADV[] in the new version.
When you have a long sequence of 'if's the computer will start at the top and work it's way down, examining each and every one of them. But if only one of them can be true, then it's better to use 'elseif's because, AFAIK, as soon as it finds the true one it ignores the rest of them and so is slightly faster. I broke the sequence in half to eliminate the stack overflow error. [edit: Actually, after thinking about it, in a function where the 'if' triggers a return, I doubt that it makes any difference.]
Pedrunn, I wouldn't be mad at you. The reason I kept working on this is because I've added a few things like you can only update certain units in certain locations.
Attachment: apol_updater2.slc
This has been downloaded 12 time(s).
Last edited by Peter Triggs on 01-02-2003 at 19:06
|
|
|  |
 |
|
Pedrunn
|
 |
of Natal, Brazil
Jul 2001 time: 02:25
|
|
quote: Originally posted by Peter Triggs
Pedrunn, I wouldn't be mad at you. The reason I kept working on this is because I've added a few things like you can only update certain units in certain locations. |
Ity is just that our codes look so much like each other. We hould have worked together on this but i believe you are the kind of guy that likes to work alone.
My new version of the updater is here. I did some changes:
1) The broken messages for one unit upgrade are fixed!
In the messages I added what is the name of the unit to be updated and the name of the one that is going to update.
2) I have changed the order from 'Fortify' to 'Sleep' since there seem to be a problem with the first order (eg. when grouping 5 units with one that is fortified all other five units get fortified so the updater was being launched when grouping units what is something i do not want).
3) Some invisible changes to fixes the found bugs.
------------------------------------------------------------------------------------
KNOWN BUG: The first unit of an army to be updated is broken for an unknown reason! You have to say no always in order to upgrade the other units.
Eg. If you have 5 obsolete units in a army. It will scroll over the units. In the first "Do you want to upgrade" if you say "yes" it the messages to update the other units wont show up If you say "No" the update will continue working as it should.
------------------------------------------------------------------------------------
Anyway here is the improved code. You just need to write the line
code:
#include "updater.slc"
At the bottom of the /gamedata/default/gamedata/script.slc file and the content of the messages copied inside the /gamedata/english/gamedata/info_str.txt.
It can be used in the the Apolyton Pack (APOL_script, APOL_main_str.txt).
Here is the code:
Attachment: newupdater.zip
This has been downloaded 8 time(s).
Last edited by Pedrunn on 01-02-2003 at 17:45
|
|
|  |
 |
|  |
 |
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:25
|
|
1) One of those triggers should have been disabled on startup. I had done this in a different file but just copy and paste
code:
HandleEvent(BeginTurn) 'APOL_DisableTriggers' pre {
DisableTrigger('AutoUpdateUnit');
DisableTrigger('APOL_DisableTriggers');
}
right above the handler 'InitUpdateArrays' (line 33).
2) I left it like that on purpose. It would be no problem to zero out their movement if that's what people want. See what kind of feedback we get.
3) See what happens here after you've put the above handler in. BTW, you should only get the 'additional types' warning with ADVANCED_COMPOSITES or PLASMA_WEAPONRY where the advance allows you to update more than one type of unit.
|
|
|  |
 |
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:25
|
|
Oops. 12 should be the value in the PowerPoints field. And I just glanced over the file and noticed that the longship should have a PowerPoints value of 10.
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:25
|
|
It wouldn't be at all difficult to charge the AI for updates; getting it to make sure that it's got enough gold to pay for the updates is another question. I would be quite surprised if this could be consistently done: you would more than likely find that you're often sending your modern units to fight antiquated ones.
Originally, this was my motivation in writing the updater script. I thought that as you progressed through time, there was just too many old units lying around in the game and it wasn't much fun killing them off. It turned out to have a few unexpected side effects: 1) charging the human meant that he had to make added decisions about what to do with his gold, and 2) not charging the AI is like adding another difficulty factor to the game (remember, everybody always used to complain about how easy the game was).
|
|
|  |
 |
|
Pedrunn
|
 |
of Natal, Brazil
Jul 2001 time: 02:25
|
|
Peter, your code is indeed better than mine. Pretty much bug free. So that should be the official one! And we can forget about mine
I must remind you that like Tamerlin I dont like your cheat of free upgrading. But you could make modification in the following handler in which makes the AI upgrades its units in parts depending of the size of the stack it belong (The bigger the stack the more likely to ugrade) and the distance to the nearest city (The unit can only upgrade if in a radius 4 of the city). The only cheat is that the upgrade cost half the gold and the toleranc on the nearest city distance.
This code can not immediatly be added in you code because there are some different vaariable (Very few ons though). But you may consider thinking about that
code:
HandleEvent(BeginTurn) 'UpgradeAIUnits' post {
int_t j;
int_t i;
int_t k;
int_t c;
int_t num;
int_t tmpPlayer;
int_t cityCount;
int_t unitNum;
unit_t tmpUnit;
army_t tmpArmy;
city_t tmpCity;
location_t tmpLoc;
num = 9;
tmpPlayer = player[0];
if(!IsHumanPlayer(tmpPlayer)) {
while(num > 0 && PlayerGold(tmpPlayer) > 300) {
for(j = 0; j < player[0].armies; j = j + 1) {
GetArmyByIndex(player[0], j, tmpArmy);
cityCount = PlayerCityCount(tmpPlayer);
for(c = 0; c < cityCount; c = c + 1) {
GetCityByIndex(tmpPlayer, c, tmpCity);
if(CityIsValid(tmpCity)
&& distance(tmpCity.location, tmpArmy.location) < 4
&& tmpArmy.size > num) {
for(k = 0; k < tmpArmy.size; k = k + 1) {
GetUnitFromArmy(tmpArmy, k, tmpUnit);
tmpLoc = tmpArmy.location;
for (i = 0; i < OLD_UNIT_TYPE.#; i = i + 1){
if(tmpUnit.type == OLD_UNIT_TYPE[i]
&& HasDataBaseAdvance(tmpPlayer, enadv[i])
&& PlayerGold(tmpPlayer) > PER_UNIT_UPDATE_COST[i]) {
CreateUnit(tmpPlayer, NEW_UNIT_TYPE[i], tmpLoc, 0);
Event: DisbandUnit(tmpUnit);
AddGold(tmpPlayer, -PER_UNIT_UPDATE_COST[i]);
}
}
}
}
}
}
num = num - 3;
}
}
}
Last edited by Pedrunn on 28-02-2003 at 06:43
|
|
|  |
 |
|  |
 |
|  |
 |
|
itsamic
|
|
I tried the newupdater in a game without modswapper and without mods like APOLPack, cradle etc. and, after minor problems, it seems to work fine. But I get regular messages about global warming??? I tried with a new game so there is no pollution. I have the messages for the updater in a separate file and load this file in strings.txt via import "updater.txt"
Last edited by itsamic on 19-03-2003 at 21:52
|
|
|  |
 |
|
Zaphod Beeblebrox
|
|
aachen, germany
Aug 1999 time: 05:25
|
|
as i just finished (well it became boring) my cradle game with the modified updater i was curious about one thing:
what did the powerpoints thingy do in the vanilla game?
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:25
|
|
itsamic,
I doubt that has anything to do with the updater code. IIRC, this has occured before in one of the mods, but I can't remember which one.
Zaphod,
Nothing. They were a freebe data field; that's why I could expropriate it.
|
|
|  |
 |
|
itsamic
|
|
I've changed the messages from a separate file to a part of info_str.txt. Now the message appears only once, in the first round after loading the game. I'll ignore it....
But now I have an other question:
I have changed the Update event from the sleep to the move order. Is there an influence to the unit update of the AI? I ask because the AI seems not to update their units.
Or can someone give me a tip how to check this?
Last edited by itsamic on 23-03-2003 at 03:05
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:25
|
|
That shouldn't make any difference, the AI updates when it gets the advance. But I did change it so that the AI only updates it's units that are not on Human owned land. This is so that you don't instantaneously find yourself fighting a more modern army. You might have to wait a few turns before you see its' more modern units.
|
|
|  |
 |
|
itsamic
|
|
I use a cheated game to test different things (tech tree, see how diplomod works etc.) If I change to an other civ I can see they have the whole range from Hoplit to Marine. Most units are on their own territory, some are fortyfied, some moves. I looked into the slic but I can't figure out the problem. For my own units the update works fine and it is a great improve at all.
|
|
|  |
 |
|
tlatoani
|
|
Mexico
Aug 2001 time: 23:25
|
|
I'm in a Good Mood-SAP game but I forgot to add the "include APOL_updater2.slc" to GM1_APOL_script.slc. I f I do this now, can I reload slic and continue with the game or should I start a new one.
|
|
|  |
All times are GMT. The time now is 05:25. Apolyton Time is 00:25. |
top of page
|
| archivepost |
|
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
|
|
|
|
|
|