Announcement

Collapse
No announcement yet.

SLIC Questions

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

  • #16
    or use the kill army like I suggested to get rid of all of them
    "Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
    The BIG MC making ctp2 a much unsafer place.
    Visit the big mc’s website

    Comment


    • #17
      Sorry, we crossposted. I dont' think there is a KillArmy function/event.

      Edit: there's a DisbandArmyOrder event though, but of course when you use that inside a city it will give you extra production points, which you may not always want. Also, it's sometimes dubious if the AI actually listens to these orders. With KillUnit you're 100% certain it works flawless without side-effects...
      Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

      Comment


      • #18
        I added the line you suggested, but no go.
        Roluce

        What profit to gain the whole world?

        Comment


        • #19
          This may be being picky, but ...

          I then created a file called "waw-myslic.slc in the folder with the other slc files. I inserted the following code which I took basically took from the thread discussion....
          Then I went into waw_main.slc and added the a line....

          #include "WAW_myslic.slc"
          Do you mean waw-myslic.slc and then waw_myslic.slc or is that a typo?
          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


          • #20
            heheh, no, that was just a typo....sorry.
            Roluce

            What profit to gain the whole world?

            Comment


            • #21
              Speaking of typos, there was one in the line that Locutus posted (missing comma). This will work:

              Code:
              // Learning Test 
              HandleEvent(MoveUnits) 'Killtheunittest' pre { 
              unit_t tmpUnit;
              
                   GetUnitFromArmy(Army[0],0,tmpUnit); 
                   KillUnit(tmpUnit); 
              }
              Whenever an Army moves, it will kill it's first member. To kill the lot of them, use this segment from Mr Ogre's 'location of death' example handler:

              Code:
              // Learning Test 
              HandleEvent(MoveUnits) 'Killtheunittest' pre { 
              unit_t tmpUnit;
              int_t i;
              
                   for(i=0;i < Army[0].size;i=i+1){
                        GetUnitFromArmy(Army[0],i,tmpUnit); 
                        event:KillUnit(tmpUnit,0,-1); 
                   }
              }
              The funny thing is that if you try to do this with the KillUnit function, it doesn't kill the last member. Can't think why.

              Comment


              • #22
                What error exactly are you getting now? Still the same? If so, it might be a problem with how the variables are assigned, in which case you could try the following:

                Code:
                HandleEvent(MoveUnits) 'Killtheunittest' pre { 
                int_t tmpUnit;
                   GetUnitFromArmy(army[0], 0, tmpUnit);
                   KillUnit(Unit[0]);
                }
                (note also that I forgot a comma in the post where I posted that GetUnitFromArmy line, if you didn't spot that that could have caused a syntax error).
                Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                Comment


                • #23
                  thanks to all. Got it working, not sure what did it, but suddenly it works perfectly. Perhaps placing unit[0] in a variable did the trick.?!
                  Roluce

                  What profit to gain the whole world?

                  Comment


                  • #24
                    Well, glad to hear it works...
                    Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                    Comment


                    • #25
                      well it seams to me, you beat my record for my first bit of slic which is 2 weeks.
                      "Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
                      The BIG MC making ctp2 a much unsafer place.
                      Visit the big mc’s website

                      Comment


                      • #26
                        Well, I had lots of help.

                        Question: Does TileHasImprovement only return a true/false or does it return the improvement? And/or is there anyway to determine what tile improvements are on a given location?

                        Comment


                        • #27
                          Roluce,
                          You're not allowed to register more than one account on this forum. You will have to give one of them up. Why did you register a second time? (if you can't login with one or both of your accounts anymore, they were already restricted by the mods; if both accounts were restricted, email me or Ming and we will figure this out).

                          Edit: nevermind, I see it's been dealt with...


                          To answer your question, TileHasImprovement requires 2 arguments: a location and an integer. The latter is an index into tileimp.txt, you can use TerrainImprovementDB(TILEIMP_ROAD) for that. It returns a boolean (true/false), depending on whether or not this tile has this tileimp.
                          Last edited by Locutus; May 23, 2002, 19:28.
                          Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                          Comment


                          • #28
                            Question: Will the pre argument used with moveunits give me the location before the unit actually moves, and then does post give me the location moved into? For example, I'm trying to test whether a unit is moving down a railroad. So I need to know the location before and after the moveunit event happens.

                            Also is there anyway to flag all player units, then access that flag while they are moving, fighting, etc... For example, at the beginning of the turn, determine which units are in supply and flag them using an array. Then in a handle for moveunits check that particular unit for whether it is supplied or not. I guess this question is asking if I can determine which unit is actually being referenced by that particular event at that moment. I need to flag units and be able to determine their flag status in other handle events.

                            Thanks for the patience.
                            Roluce

                            What profit to gain the whole world?

                            Comment


                            • #29
                              Also, what does....ConsiderDiplomaticState(?)...do? I need to determine the diplomatic relationship between 2 players. What information do we have on this?
                              Roluce

                              What profit to gain the whole world?

                              Comment


                              • #30
                                Originally posted by Roluce
                                Question: Will the pre argument used with moveunits give me the location before the unit actually moves, and then does post give me the location moved into?
                                No, that's not how it works. Events are basically just flags that are thrown. The Battle event is thrown on the beginning of a battle, rather than being activated at the beginning of a battle and remaining active throughout the battle to be deactivated only once the battle is over. Same with movement. MoveUnits is basically a flag which is thrown right before a unit moves, so I'm fairly certain that the position of the unit is the same regardless of whether you use pre or post. You can access the locations of the moving units with the location array. Unless I'm very much mistaken location[0] holds the source and location[1] the destination.

                                For example, I'm trying to test whether a unit is moving down a railroad. So I need to know the location before and after the moveunit event happens.
                                I suppose you would want something like this then (untested, might have bugs):

                                Code:
                                HandleEvent(MoveUnits) 'LOQ_RailroadTest' post {
                                	if (TileHasImprovement(location[0], TerrainImprovementDB(TILEIMP_RAILROAD)) &&
                                	TileHasImprovement(location[1], TerrainImprovementDB(TILEIMP_RAILROAD))) {
                                		// units are moving over railroad
                                	}
                                }
                                Also is there anyway to flag all player units, then access that flag while they are moving, fighting, etc... For example, at the beginning of the turn, determine which units are in supply and flag them using an array. Then in a handle for moveunits check that particular unit for whether it is supplied or not. I guess this question is asking if I can determine which unit is actually being referenced by that particular event at that moment. I need to flag units and be able to determine their flag status in other handle events.
                                Sure, piece of cake. You mean something like this (as above, untested, may be buggy)?

                                Code:
                                unit_t	supplyunits[];			// define array with all units
                                int_t	supplyindex;			// last element of array
                                
                                int_f IsSupplied(int_t theUnit) {	// returns true if unit is supplied
                                	// (not implemented)
                                }
                                
                                HandleEvent(BeginTurn) 'LOQ_TestSupply' post {
                                unit_t	tmpUnit;
                                int_t	i;
                                
                                	supplyindex = 0;
                                	for (i = 0; i < player[0].units; i = i + 1) {	// cycle through all units
                                		GetUnitByIndex(player[0], i, tmpUnit);
                                		if (IsSupplied(tmpUnit)) {		// if unit supplied
                                			supplyunits[supplyindex] = tmpUnit;
                                			supplyindex = supplyindex + 1;	// add to array
                                		}
                                	}
                                }
                                
                                int_f IsInSupplyArray(int_t theUnit) {
                                unit_t	tmpUnit;
                                unit_t	tmpUnit2;
                                int_t	i;
                                	tmpUnit = theUnit;
                                
                                	for (i = 0; i < supplyindex; i = i + 1) {	// cycle through all units in array
                                		tmpUnit2 = supplyunits[i];
                                		if (tmpUnit2 == tmpUnit) {		// if unit in array
                                			return 1;			// return true
                                		}
                                	}
                                	return 0;					// if unit not in array, return false
                                }
                                
                                HandleEvent(MoveUnits) 'LOQ_TestSupply2' post {
                                unit_t	tmpUnit;
                                int_t	i;
                                
                                	for (i = 0; i < army[0].size; i = i + 1) {
                                		GetUnitFromArmy(army[0], i, tmpUnit);	// cycle through all units in army
                                		if (IsInSupplyArray(tmpUnit)) {		// if unit in supplyunits array
                                			// do something (not implemented)
                                		}
                                	}
                                }
                                This is a rather simple example of course, if you also want to keep track of addition information, you could define other arrays from that and store the info in there (using the array index as a unique identifier). You could also write code to modify the arrays rather than to rebuild them all the time.
                                Last edited by Locutus; May 24, 2002, 11:52.
                                Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                                Comment

                                Working...
                                X