Announcement

Collapse
No announcement yet.

SLIC help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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!!!!
    Diplomacy is the art of saying 'Nice doggie' until you can find a rock.
    Will Rogers (1879 - 1935)

  • #2
    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

    Comment


    • #3
      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
      Diplomacy is the art of saying 'Nice doggie' until you can find a rock.
      Will Rogers (1879 - 1935)

      Comment


      • #4
        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

        Comment

        Working...
        X