or use the kill army like I suggested to get rid of all of them
Announcement
Collapse
No announcement yet.
SLIC Questions
Collapse
X
-
"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
-
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...
Comment
-
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"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
-
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); }
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); } }
Comment
-
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]); }
Comment
-
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
-
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.
Comment
-
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
-
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?
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.
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.
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) } } }
Last edited by Locutus; May 24, 2002, 11:52.
Comment
Comment