May 20, 2002, 11:32
|
#1
|
Settler
Local Time: 00:57
Local Date: November 1, 2010
Join Date: Dec 2000
Location: Greenville, Tx, USA
Posts: 21
|
SLIC Questions
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.
__________________
Roluce
What profit to gain the whole world?
|
|
|
|
May 20, 2002, 12:01
|
#2
|
Deity
Local Time: 02:57
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
Welcome!
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
|
|
|
|
May 20, 2002, 12:25
|
#3
|
Settler
Local Time: 00:57
Local Date: November 1, 2010
Join Date: Dec 2000
Location: Greenville, Tx, USA
Posts: 21
|
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
What profit to gain the whole world?
|
|
|
|
May 20, 2002, 12:30
|
#4
|
Deity
Local Time: 02:57
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
These functions:
mod_CanPlayerHaveAdvance
mod_CanCityBuildUnit
mod_CanCityBuildBuilding
mod_CanCityBuildWonder
mod_CityHappiness
mod_UnitAttack
mod_UnitRangedAttack
mod_UnitDefense
We have many examples of the first few functions in action but the ones that are most interesting for you are the last 3 and we've never seen any of those in action yet. We don't even know what arguments they need and finding out might turn out to be tricky...
|
|
|
|
May 20, 2002, 12:34
|
#5
|
Settler
Local Time: 00:57
Local Date: November 1, 2010
Join Date: Dec 2000
Location: Greenville, Tx, USA
Posts: 21
|
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
What profit to gain the whole world?
|
|
|
|
May 20, 2002, 12:45
|
#6
|
Deity
Local Time: 02:57
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
Uhmm, good question. This has been mentioned on the forums plenty of times but I'm not sure if there is any good documentation about them anywhere. I do know they're in the Excel file on my website, together with all other SLIC functions (although I'm not 100% sure if the patch function are included in that)... In any case, I'm still supposed to be working on proper (complete) documentation
|
|
|
|
May 20, 2002, 12:50
|
#7
|
Prince
Local Time: 01:57
Local Date: November 1, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
|
5. No, you can't, and it bugs me no end
The mod_* functions.
Locutus, I actually got the attack and defense ones to load, it is just a unit_t and int_t in both cases. However, I have no idea if they have any effect. I never did a macro-scale test.
What you can do is use the Alexander Scenario code for making units under Alexander all veterans, that will increase their performance slightly.
__________________
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
|
|
|
|
May 20, 2002, 14:20
|
#8
|
Settler
Local Time: 00:57
Local Date: November 1, 2010
Join Date: Dec 2000
Location: Greenville, Tx, USA
Posts: 21
|
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
What profit to gain the whole world?
|
|
|
|
May 20, 2002, 14:50
|
#9
|
Deity
Local Time: 02:57
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
Quote:
|
Originally posted by Roluce
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.
|
Is the stuff here on Apolyton all the documentation you have? If so, you will want to have a look at this thread as well. The stuff posted by Immortal Wombat and me is the most interesting.
Quote:
|
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?
|
Well, I agree supply is something that's still missing from the game (from the entire genre actually), but modelling it wouldn't be easy. I think you can get very far with your idea but the hardest part would be to get the AI to deal with it: to learn AI to build, move and protect its own supplies in an intelligent manner and and to destroy the supplies of its enemies. It would probably require a combination of SLIC coding and AI file editing to accomplish this...
|
|
|
|
May 20, 2002, 15:40
|
#10
|
Settler
Local Time: 00:57
Local Date: November 1, 2010
Join Date: Dec 2000
Location: Greenville, Tx, USA
Posts: 21
|
Hmmmm, I think I am going to take a stab at it. That is, if those more knowledgable will continue to field questions along the way! I know nothing of slic, but have some programming knowledge, so maybe I can bluff my way though it.
__________________
Roluce
What profit to gain the whole world?
|
|
|
|
May 20, 2002, 15:43
|
#11
|
Deity
Local Time: 02:57
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
Yes, if you can program already, SLIC shouldn't be too hard. It's just like C, only without the pointers
|
|
|
|
May 21, 2002, 03:56
|
#12
|
King
Local Time: 00:57
Local Date: November 1, 2010
Join Date: Oct 2001
Location: Of the universe / England
Posts: 2,061
|
I found slic hard to start with but then I learnt Pascal and c++ and it is easier for me now
__________________
"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
|
|
|
|
May 21, 2002, 09:52
|
#13
|
Settler
Local Time: 00:57
Local Date: November 1, 2010
Join Date: Dec 2000
Location: Greenville, Tx, USA
Posts: 21
|
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
What profit to gain the whole world?
|
|
|
|
May 21, 2002, 10:00
|
#14
|
King
Local Time: 00:57
Local Date: November 1, 2010
Join Date: Oct 2001
Location: Of the universe / England
Posts: 2,061
|
try using the kill army order may work better for you.
__________________
"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
|
|
|
|
May 21, 2002, 10:02
|
#15
|
Deity
Local Time: 02:57
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
From memory, MoveUnits doesn't use unit[0] but army[0]. So you'd have to add the line GetUnitFromArmy(army[0], 0 unit[0]); to make it work...
|
|
|
|
May 21, 2002, 10:05
|
#16
|
King
Local Time: 00:57
Local Date: November 1, 2010
Join Date: Oct 2001
Location: Of the universe / England
Posts: 2,061
|
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
|
|
|
|
May 21, 2002, 10:22
|
#17
|
Deity
Local Time: 02:57
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
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...
|
|
|
|
May 21, 2002, 12:03
|
#18
|
Settler
Local Time: 00:57
Local Date: November 1, 2010
Join Date: Dec 2000
Location: Greenville, Tx, USA
Posts: 21
|
I added the line you suggested, but no go.
__________________
Roluce
What profit to gain the whole world?
|
|
|
|
May 21, 2002, 12:52
|
#19
|
Prince
Local Time: 01:57
Local Date: November 1, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
|
This may be being picky, but ...
Quote:
|
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
|
|
|
|
May 21, 2002, 15:53
|
#20
|
Settler
Local Time: 00:57
Local Date: November 1, 2010
Join Date: Dec 2000
Location: Greenville, Tx, USA
Posts: 21
|
heheh, no, that was just a typo....sorry.
__________________
Roluce
What profit to gain the whole world?
|
|
|
|
May 21, 2002, 16:14
|
#21
|
King
Local Time: 00:57
Local Date: November 1, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
|
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.
|
|
|
|
May 21, 2002, 16:17
|
#22
|
Deity
Local Time: 02:57
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
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).
|
|
|
|
May 21, 2002, 17:39
|
#23
|
Settler
Local Time: 00:57
Local Date: November 1, 2010
Join Date: Dec 2000
Location: Greenville, Tx, USA
Posts: 21
|
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?
|
|
|
|
May 21, 2002, 18:21
|
#24
|
Deity
Local Time: 02:57
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
Well, glad to hear it works...
|
|
|
|
May 23, 2002, 04:46
|
#25
|
King
Local Time: 00:57
Local Date: November 1, 2010
Join Date: Oct 2001
Location: Of the universe / England
Posts: 2,061
|
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
|
|
|
|
May 23, 2002, 17:14
|
#26
|
Settler
Local Time: 00:57
Local Date: November 1, 2010
Join Date: May 2002
Location: Texas
Posts: 1
|
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?
|
|
|
|
May 23, 2002, 17:47
|
#27
|
Deity
Local Time: 02:57
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
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 at 19:28.
|
|
|
|
May 24, 2002, 10:31
|
#28
|
Settler
Local Time: 00:57
Local Date: November 1, 2010
Join Date: Dec 2000
Location: Greenville, Tx, USA
Posts: 21
|
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?
|
|
|
|
May 24, 2002, 10:52
|
#29
|
Settler
Local Time: 00:57
Local Date: November 1, 2010
Join Date: Dec 2000
Location: Greenville, Tx, USA
Posts: 21
|
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?
|
|
|
|
May 24, 2002, 11:42
|
#30
|
Deity
Local Time: 02:57
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
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; May 24, 2002 at 11:52.
|
|
|
|
Posting 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
|
|
|
All times are GMT -4. The time now is 20:57.
|
|