 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:17
|
|
quote: Originally posted by The Big Mc
You need to keep the fort loc in an array to allow this script to work. |
what do you mean about array? I have to have a separte set of slic that says: find all forts???
Last edited by E on 16-12-2004 at 02:33
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:17
|
|
DP
Last edited by E on 23-12-2004 at 23:24
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:17
|
|
ok this is my first attempt at (finishing) SLIC. How do I define arrays? and what else did I miss on this. PS since units already have a PW update cost I'm just subtracting gold since you are paying to get that PW to the unit (and food)
code:
if(IsHumanPlayer(player[0])) //logistics is challenge for humans only
HandleEvent(BeginTurn) 'Startturn' pre {
for (i = 0; i < GetUnitsAtLocation(tmpLoc); i = i + 1) {
int_f FindTheNearestCity( int_t thePlayer, location_t theLocation, int_t theDistance){
theNearestCity = tmpCity;
if (HasAdvance(tmpPlayer, ID_ADVANCE_AERODYNAMICS)) { // if player has airpower,
return 25;
} elseif (HasAdvance(tmpPlayer, ID_ADVANCE_AUTOMOBILE)) {
return 15;
} elseif (HasAdvance(tmpPlayer, ID_ADVANCE_RAILROAD)) {
return 10;
} elseif (HasAdvance(tmpPlayer, ID_ADVANCE_HORSE)) {
return 5;
} else { // if none of above advances present,
return 1; // basic logistics
}
}
UNIT_TYPE=UnitDB(UNIT_ARTILLERY) return 5 //unitgold
tmpcity-tmpunit/advbonus*unitgold*-1=unitlogistics
GetTotalUnitlogistics
AddGold(player[0], - totallogistics cost); //subtractgold gold
DisableTrigger('StartTurn'); //run once only
|
|
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:17
|
|
Well the code above doesn't run at all, first we should reoder it a little bit and fix the fomarting of the white space for readibility. Well of course the following code still doesn't work.
code:
HandleEvent(BeginTurn) 'Startturn' pre {
if(IsHumanPlayer(player[0])){ //logistics is challenge for humans only
for (i = 0; i < GetUnitsAtLocation(tmpLoc); i = i + 1) {
int_f FindTheNearestCity( int_t thePlayer, location_t theLocation, int_t theDistance){
theNearestCity = tmpCity;
if (HasAdvance(tmpPlayer, ID_ADVANCE_AERODYNAMICS)) { // if player has airpower,
return 25;
}
elseif (HasAdvance(tmpPlayer, ID_ADVANCE_AUTOMOBILE)) {
return 15;
}
elseif (HasAdvance(tmpPlayer, ID_ADVANCE_RAILROAD)) {
return 10;
}
elseif (HasAdvance(tmpPlayer, ID_ADVANCE_HORSE)) {
return 5;
}
else { // if none of above advances present,
return 1; // basic logistics
}
}
UNIT_TYPE=UnitDB(UNIT_ARTILLERY) return 5 //unitgold
tmpcity-tmpunit/advbonus*unitgold*-1=unitlogistics
GetTotalUnitlogistics
AddGold(player[0], - totallogistics cost); //subtractgold gold
DisableTrigger('StartTurn'); //run once only
}
}
}
First thing to consider is that slic is an event driven language so you have to encapsulate your code by an event no statement can be placed outside of an event handle or outside of a function, except for global variable definition.
Second you cannot define local functions at least I never tried that, and I don't see any sense in it doing it in the middle of a for loop.
Third you disable the trigger afterwards it has been run once. Well what happens with all the other players in an MP game?
By the way you should check all the other pieces of slic lying around here.
-Martin
|
|
|  |
 |
|  |
All times are GMT. The time now is 05:17. Apolyton Time is 00:17. |
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
|
|
|
|
|
|