 |
|  |
 |
|
tigger
|
|
I'm trying to adapt the sogdia rebellion code form the Alexander scenario. The scenario.slc code refers to a SwapCity function. The function in AG_func.slc is aso follows:
// Swaps City to Player. Kills all units first if flag is set to 1.
int_f SwapCity (city_t swCity, int_t swPlayer, int_t killUnits)
{
int_t i;
int_t tmpPlayer;
int_t tmpNum;
int_t numUnits;
int_t noSwap;
unit_t tmpUnit;
city_t tmpCity;
location_t tmpLoc;
tmpCity = swCity;
if (CityIsValid(tmpCity)) {
tmpPlayer = swPlayer;
numUnits = GetUnitsAtLocation(tmpCity.location);
tmpLoc = tmpCity.location;
for (i = 0; i < numUnits; i = i + 1) { // Check for special units
GetUnitFromCell(tmpLoc, i, tmpUnit);
tmpNum = tmpUnit.type;
if (tmpNum >= 72 && tmpNum <= 88) {
noSwap = 1;
}
}
if (noSwap == 0) {
if (killUnits == 1) {
for (i = 0; i < numUnits; i = i + 1) { //If no special units, kill all units
GetUnitFromCell(tmpLoc, i, tmpUnit);
Event: KillUnit(tmpUnit, 0, tmpUnit.owner);
}
}
Event:GiveCity(tmpCity, tmpPlayer);
} else {
return -1; // Can't swap due to Special unit
}
} else {
return -2; // Can't swap due to invalid city
}
}
Initially it threw up syntax errors when I used it. I assumed this was due to the special unit checks as I have no special units. But I can't seem to get it working. All I want is all player 1s units killed in the city and then the city swapped to player0.
Help!!!!
|
|
|  |
 |
|
Immortal Wombat
|
 |
in perpetuity
Dec 2000 time: 05:17
|
|
This code revolves around the fact that there are special units. Without them, the whole code becomes a lot simpler. You should set the last integer (KillUnits) to onoe each time so the units are killed first.
This should work though, I've basically just cut out all the special unit stuff, and restructured what's left.
code:
// Swaps City to Player. Kills all units first if flag is set to 1.
int_f SwapCity (city_t swCity, int_t swPlayer, int_t killUnits)
{
int_t i;
int_t tmpPlayer;
int_t tmpNum;
int_t numUnits;
unit_t tmpUnit;
city_t tmpCity;
location_t tmpLoc;
tmpCity = swCity;
if (CityIsValid(tmpCity)) {
tmpPlayer = swPlayer;
numUnits = GetUnitsAtLocation(tmpCity.location);
tmpLoc = tmpCity.location;
if (killUnits == 1) {
for (i = 0; i < numUnits; i = i + 1) {
GetUnitFromCell(tmpLoc, i, tmpUnit);
Event: KillUnit(tmpUnit, 0, tmpUnit.owner);
}
}
Event:GiveCity(tmpCity, tmpPlayer);
} else {
return -1; // Can't swap due to invalid city
}
}
|
|
|  |
 |
|
tigger
|
|
Cheers IW, that works great. I'm still a little clumsy when it comes to SLIC, but the sceanrio is almost finsihed now.
Cheers Mate
|
|
|  |
All times are GMT. The time now is 05:17. Apolyton Time is 00:17. |
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
|
|
|
|
|
|