Announcement

Collapse
No announcement yet.

SLIC for Mars

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

  • SLIC for Mars

    Though directly related to my scenario, a SLIC question probably fits in better here.

    I tried this SLIC to get a settler into every capital city every 24 turns, and I get no error messages, so far so good...
    Then it doesn't work - no settlers, no errors, what am I doing wrong?

    Code:
    HandleEvent(beginturn) 'settlercount' pre{
    int_t	SettlerCount;
    city_t	tmpCity;
    int_t	i;
    (SettlerCount = SettlerCount + 1);
    		if(SettlerCount == 3){
    			for(i = 0; i < 8; i = i + 1){           //how do I get "number of players" instead of 8 ?
    				if(isplayeralive(i)){
    				tmpCity = player[i].capital;
    					createunit(player[i], UnitDB(UNIT_SETTLER), tmpCity.location, 0);
    					}
    				}
    			settlercount = 0;
    		}
    }
    Any ideas?

    *cough* Dale *cough*
    Thanks
    Ben
    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

  • #2
    *cough* OK *cough*

    Let's have a look shall we.......

    Code:
    HandleEvent(beginturn) 'SettlerCaptialCreate' pre{     // SettlerCount won't work as it's a variable below
         int_t SettlerCount;
         city_t tmpCity;
         int_t i;
         int_t NumOfPlayers;     // What it says
         location_t tmpLoc;     // Location of Capital
         NumOfPlayers = preference("NumPlayers");     // How to 'get' # of players
         if(IsHumanPlayer(player[0])) {     // Increases SettlerCount only once per turn, not NumOfPlayers times per turn
              SettlerCount = SettlerCount + 1;     // Take out brackets
         }
         if(SettlerCount == 3){
              for(i = 1; i < NumOfPlayers; i = i + 1){     // i=1 means don't do for barbs
                   if(IsPlayerAlive(i)){     // Note capital letters.....
                        GetCityByIndex(i, 0, tmpCity);     // Get Capital city
                        tmpLoc = tmpCity.location;     // Get location of city
                        CreateUnit(i, UnitDB(UNIT_SETTLER), tmpLoc, 0);
                   }
              }
         SettlerCount = 0;
         }
    }
    ------------------
    Rommell to a sub-commander outside Tobruk: "Those Australians are in there somewhere. But where? Let's advance and wait till they shoot, then shoot back."

    Comment


    • #3
      Thanks a lot Dale, if I ask enough times I might get it right once in a while

      One thing though, I read in the Activision documentation that Slic was case-insensitive, or is that just for ElSeiF statements ?

      What was my code actually doing then? ?
      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


      • #4
        Only some things are case-sensitive. For example, events are case sensitive, routines are case-sensitive, variables are case-sensitive. Plus, after doing a few years programming I'm just in the habit of using capitals.

        Your script was actually doing this.

        1. Enter the script and initialise the variables.
        2. Pass over the SettlerCount = line as it was in brackets.
        3. Check SettlerCount to see if it's 3, but it's never 3 (see line above).
        4. Exit script.

        ------------------
        Rommell to a sub-commander outside Tobruk: "Those Australians are in there somewhere. But where? Let's advance and wait till they shoot, then shoot back."

        Comment


        • #5
          Thanks for clearing those things up Dale, I might get the hang of this some time...

          ------------------
          Whoever said SLIC was easy once you got used to it, was probably telling the truth. If anyone tells you that getting used to it was easy - they're lying
          [This message has been edited by Immortal Wombat (edited April 10, 2001).]
          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


          • #6
            Problem Number 2:
            Assume all the variables are defined at the top of the slc page. I'm sure I have pretty much used the code in the same way its used in Alex.scn and samurai scenario, and I'm fed up. Can you help again? thanks

            Code:
            HandleEvent(BeginTurn) 'GiveResourcesA' pre {
            int_t	tmpPlayer;
            
            player[0] = tmpPlayer;                                        //player[0] - the player whose turn is beginning is stored
            if(tmpPlayer == 1) {					     //  if the stored player is player 1...
            	PwcountA = PwcountA + 1;			                              //then their pw counter is added to
            	if(PwcountA == 3){						// if it is now 3...
            		player[0].publicworkslevel = tmpPwA;                    // then store it  ([b]Error[/b]: Symbol player is not a struct)
            		tmpPw2A = tmpPwA + 5000;                                 // add 5000 to it, and store that as another variable
            		setPW(tmpPlayer, tmpPw2A);                               // make the player's pw the new variable
            		PwcountA = 0;						  // and set the counter to zero
            		}
            	}
            }

            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


            • #7
              player[0].publicworkslevel = tmpPwA;

              needs to be:

              tmpPwA = player[0].publicworkslevel;

              you assign values from the left side of "=" to the right side.

              you could put it like this:

              tmpPwa "is set equal to" player[0].publicworkslevel

              -klaus

              Comment


              • #8
                these are my notes to all the code:

                Code:
                HandleEvent(BeginTurn) 'GiveResourcesA' pre {
                int_t tmpPlayer;
                tmpPlayer = g.player;                  // g.player is the current player 
                  if(tmpPlayer == 1) {                 // why player 1 ???
                    PwcountA = PwcountA + 1;
                    if(PwcountA == 3){                 // this line will only run if 
                                                       // tmpPlayer = 1 , see above
                      tmpPwA = tmpPlayer.publicworkslevel;
                      tmpPw2A = tmpPwA + 5000;         // why not tmpPwA = tmpPwA + 5000;
                      setPW(tmpPlayer, tmpPw2A);       // if above then 
                                                       // setPW(tmpPlayer, tmpPwA);
                      PwcountA = 0;
                    }
                  }
                }
                -klaus

                Comment


                • #9
                  Goddamnit, I HATE SLIC

                  but I'll carry on trying. There are too few things I find challenging

                  Thanks a lot klaus!!

                  quote:

                  Originally posted by kaan on 04-10-2001 09:12 AM
                  these are my notes to all the code:

                  Code:
                  HandleEvent(BeginTurn) 'GiveResourcesA' pre {
                  int_t tmpPlayer;
                  tmpPlayer = g.player;                  // g.player is the current player 
                    if(tmpPlayer == 1) {                 // why player 1 ???
                      PwcountA = PwcountA + 1;
                      if(PwcountA == 3){                 // this line will only run if 
                                                         // tmpPlayer = 1 , see above
                        tmpPwA = tmpPlayer.publicworkslevel;
                        tmpPw2A = tmpPwA + 5000;         // why not tmpPwA = tmpPwA + 5000;
                        setPW(tmpPlayer, tmpPw2A);       // if above then 
                                                         // setPW(tmpPlayer, tmpPwA);
                        PwcountA = 0;
                      }
                    }
                  }



                  right...
                  player1 only because I need to have separate triggers to disable for each player, there will be duplicate triggers for each player.
                  tmpPw2 is in there so it is more easy for me to see where I'm going wrong.

                  Anyway, thanks a lot to you klaus, and Dale also for the first answer, things are looking up.

                  Ben
                  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