 |
|  |
 |
|
Pedrunn
|
 |
of Natal, Brazil
Jul 2001 time: 02:19
|
|
I am giving a try in Slic writting. My first slic was to add the rush improvements using Entrench order for a new kind of Special Unit: The Worker.
I want to know if its correct and bug free.
code:
HandleEvent(EntrenchOrder) 'FinishImprovementsOrder' pre {
unit_t tmpUnit;
GetUnitFromArmy(army[0], i, tmpUnit);
unit[0] = tmpUnit;
if ((unit[0].type == UnitDB(UNIT_WORKER))) {
FinishImprovements(unit[0].location);
}
}
My biggest problemcomes when i wanted to make the AI to knows how to use it. But the best i could do was make the unit finish improvent as it goes over tiles for the AI.
There is some function to trigger the code if the tile has an unfinished imp? Can someone help me with this issue?
I want to make the AI always entrench if this units pass by an tile with unfinished imp.
code:
HandleEvent(MoveToOrder) 'AIUsingFinishImprovement' post {
unit_t tmpUnit;
if(!=IsHumanPlayer(player[0])){
GetUnitFromArmy(army[0], i, tmpUnit);
unit[0] = tmpUnit;
if ((unit[0].type == UnitDB(UNIT_WORKER))) {
FinishImprovements(unit[0].location);
}
}
}
Last edited by Pedrunn on 28-04-2002 at 22:11
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:19
|
|
I'd suggest using the MoveOrder event:
code:
HandleEvent(MoveOrder) 'FinishImprovementsOrder' post {
unit_t tmpUnit;
int_t i;
for (i=0;i < army[0].size;i=i+1 ){
GetUnitFromArmy(army[0], i, tmpUnit);
if (tmpUnit.type == UnitDB(UNIT_WORKER)) {
FinishImprovements(tmpUnit.location);
}
}
}
You put the improvement down as normal and then move your Worker (whose on an adjacent tile) on to it. The next turn, you move the Worker off the tile and, presto, there's the improvement. (I tried it using a Hoplite to stand in for your Worker.) This works fine for the Human and it should 'work' for the AI, too, in the way you described. To get the AI to actually try to do this would be much more difficult, if possible at all.
Note: You don't need "unit[0]=tmpUnit". Once you've declared "tmpUnit" to be a unit type variable you can access the members of the unit array in the same way as with a builtin variable.
|
|
|  |
All times are GMT. The time now is 05:19. Apolyton Time is 00:19. |
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
|
|
|
|
|
|