 |
|  |
 |
|
Roluce
|
|
Greenville, Tx, USA
Dec 2000 time: 05:19
|
|
Am pondering a scenario and have some slic questions. I've looked over the slic reference material on this sight, but didn't see an obvious answer. Or at least I didn't get it.
1. Can you determine ownership of tile improvements such as railroads when moving units. I don't want military units using enemy railroads to their advantage.
2. Can you affect the outcome of battles based on the presence of a special unit. For example, if a special leader is present, then can you give some attack/defend bonus or detriment to the whole army.
3. Can you add or subtract food from a city?
4. Can you add or subtract production from a city?
5. Can you determine what good are being traded to a city?
6. Can you determine who owns the land? For example if my unit is within my boundaries or within enemy territory. Is that what - INT CellOwner(location) does?
I've tried to ask questions that involve a simple yes/no answer, but any other help would be appreciated. Sorry if they are obvious and I've missed it. Thanks in advance.
|
|
|  |
 |
|
Locutus
|
|
ACS CTP1/2 Manager & Civ4 Co-Manager
|
 |
Hengelo, The Netherlands
Nov 1999 time: 06:19
|
|
quote: Originally posted by Roluce
1. Can you determine ownership of tile improvements such as railroads when moving units. I don't want military units using enemy railroads to their advantage. |
Yes. If you know the owner of the tile the tile imp is on, you know the owner of the tile imp. See Q6.
quote: 2. Can you affect the outcome of battles based on the presence of a special unit. For example, if a special leader is present, then can you give some attack/defend bonus or detriment to the whole army. |
Yes. You can either replace the units in advance, ala the Alexander the Great scenario, or use the mod_* functions. Unfortunately the second category is unexplored territory but I'm fairly certain it can work...
quote: 3. Can you add or subtract food from a city?
4. Can you add or subtract production from a city? |
The answer to both these questions is the same: yes and no. You can't change it directly but by adding a building/wonder to the city through SLIC or by terraforming the terrain around the city you can accomplish the same result.
quote: 5. Can you determine what good are being traded to a city? |
No clue here.
quote: 6. Can you determine who owns the land? For example if my unit is within my boundaries or within enemy territory. Is that what - INT CellOwner(location) does? |
Yes. Yes, that's exactly what CellOwner does.
quote: I've tried to ask questions that involve a simple yes/no answer, but any other help would be appreciated. Sorry if they are obvious and I've missed it. Thanks in advance. |
I hope this helped. Do let us know if you need more help, we'll gladly do so. And don't worry, complicated questions don't deter us at all 
|
|
|  |
 |
|
Roluce
|
|
Greenville, Tx, USA
Dec 2000 time: 05:19
|
|
quote: or use the mod_* functions. Unfortunately the second category is unexplored territory but I'm fairly certain it can work... | What are the mod_* functions?
|
|
|  |
 |
|
Roluce
|
|
Greenville, Tx, USA
Dec 2000 time: 05:19
|
|
Where did the info on these come from, I didn't know of them? Are there others places to look, where up to date info on slic is found?
|
|
|  |
 |
|  |
 |
|  |
 |
|
Roluce
|
|
Greenville, Tx, USA
Dec 2000 time: 05:19
|
|
Thanks for the help. I checked out the website and found that your spreadsheet is more informative (has more stuff) than what's on apolyton in the modification section. I suppose there is a lot of experimenting going on, and some things are yet untested/unproven. I am working on an idea involving supply, and its effect on armies in the field. Keeping combat units supplied was of major importance. If supply was lost, units were practically powerless. I am interested in a ww2 scenario that includes the concept of supply. My initial idea was to create supply units which must be transported/airdropped to armies in the field (enemy territory) and then are used up as units move and fight. This would require the ability to negatively affect units if supply wasn't present or limited. And to restore that ability when supply is regained. It would seem easy to accomplish assuming I could directly change unit stats such as attack/defend. Supply would also need to be protected from enemy attacks. Does this sound like a reasonable idea? I would also need to code the ai to seek out and destroy supply units. Is this beyond the scope of reasonalbe slic? Is there anyone else trying to do this, or something like it?
|
|
|  |
 |
|  |
 |
|
Roluce
|
|
Greenville, Tx, USA
Dec 2000 time: 05:19
|
|
Grrr, bad start. Ok, let me explain what I did, then maybe you can help me out. First, I read through some of the material on the thread you mentioned. 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....
// Learning Test
HandleEvent(MoveUnits) 'Killtheunittest' pre {
KillUnit(Unit[0]);
}
I assumed that anytime a unit moved, that unit would be killed.
Then I went into waw_main.slc and added the a line....
#include "WAW_myslic.slc"
Then I started a waw game, and when I moved the first unit, I get the error that line 3 has an array index 0 out of bounds.
From what I had read, I thought Unit[0] would refer to the current unit?!?

|
|
|  |
 |
|
Roluce
|
|
Greenville, Tx, USA
Dec 2000 time: 05:19
|
|
heheh, no, that was just a typo....sorry.
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:19
|
|
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.
|
|
|  |
 |
|
Roluce
|
|
Greenville, Tx, USA
Dec 2000 time: 05:19
|
|
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.?!
|
|
|  |
 |
|
Roluce2
|
|
Texas
May 2002 time: 05:19
|
|
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?
|
|
|  |
 |
|
Roluce
|
|
Greenville, Tx, USA
Dec 2000 time: 05:19
|
|
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
|
|
Greenville, Tx, USA
Dec 2000 time: 05:19
|
|
Also, what does....ConsiderDiplomaticState(?)...do? I need to determine the diplomatic relationship between 2 players. What information do we have on this?
|
|
|  |
 |
|
Locutus
|
|
ACS CTP1/2 Manager & Civ4 Co-Manager
|
 |
Hengelo, The Netherlands
Nov 1999 time: 06:19
|
|
quote: 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.
quote: 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
}
}
quote: 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 on 24-05-2002 at 20:52
|
|
|  |
 |
|  |
All times are GMT. The time now is 05:19. Apolyton Time is 00:19. |
top of page
|
| archivepost |
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|