Thread Tools
Old February 23, 2002, 06:49   #1
tigger
Chieftain
 
Local Time: 20:56
Local Date: October 31, 2010
Join Date: Feb 2002
Location: UK
Posts: 91
SLIC help
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!!!!
tigger is offline  
Old February 23, 2002, 11:16   #2
Immortal Wombat
Apolytoners Hall of Fame
Prince
 
Immortal Wombat's Avatar
 
Local Time: 21:56
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
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 
      } 
}
__________________
Concrete, Abstract, or Squoingy?
"I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis
Immortal Wombat is offline  
Old February 23, 2002, 15:45   #3
tigger
Chieftain
 
Local Time: 20:56
Local Date: October 31, 2010
Join Date: Feb 2002
Location: UK
Posts: 91
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
tigger is offline  
Old February 23, 2002, 19:00   #4
Immortal Wombat
Apolytoners Hall of Fame
Prince
 
Immortal Wombat's Avatar
 
Local Time: 21:56
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
No probs, can't wait to see the scenario
__________________
Concrete, Abstract, or Squoingy?
"I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis
Immortal Wombat is offline  
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 16:56.


Design by Vjacheslav Trushkin, color scheme by ColorizeIt!.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Apolyton Civilization Site | Copyright © The Apolyton Team