April 10, 2002, 16:40
|
#1
|
Prince
Local Time: 22:50
Local Date: October 31, 2010
Join Date: Apr 2002
Location: England
Posts: 310
|
SLIC Question
Hey everyone I've been lurking round this forum and trying out mods etc for a few weeks now and I've finally decided to join. Anyway I started learning SLIC today thanks to some of the guides here and it's alot easier than it looks but I've a question (and probably will have a load more soon):
Could somone tell me the expression to use in an if statement when a type of unit is attacked. e.g if an archer is attacked I want x to happen, I just don't know the expression to use in the if () bit.
Thanks!
|
|
|
|
April 10, 2002, 17:06
|
#2
|
Deity
Local Time: 00:50
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
Well, welcome to the forums, I'm very glad to hear you decided to join and even gladder to see you're interested in SLIC
The answer to your question is simple. The type of a unit is a unit property and therefore, logically (but unfortunately SLIC isn't always this logical), it is a variable of the unit[0] array. So the expression to use in the if statement would be 'unit[0].type == UnitDB(UNIT_ARCHER)', assuming that you have the unit stored in unit[0].
Note that in this case (an unit in the attack), the logical event to use is 'Battle' (not sure if any others could be used as well). However, from 'Battle' you can't directly access each and every unit involved, you must use army[0] (the attacking army) instead. So you should use the GetUnitFromArmy function to extract the unit(s) from this army before you can check the type.
Let me know if you have any more questions, I love to help (especially with simple questions like this one ).
|
|
|
|
April 10, 2002, 18:31
|
#3
|
Prince
Local Time: 23:50
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
|
Welcome to the wonderful world of SLIC
Using the event (Battle); if you want the defending army, you can't just use the army[0], as that will give the attacking army.
So...
You'll have to use the location of the battle (location[0] from the event) and then using a for loop, for the number of units in the cell (UnitsInCell(location[0]) do GetUnitFromCell(location[0], index, tmpUnit)
This will store each unit in turn in the defending army (at the location being attacked) as tmpUnit. THEN you can check whether it is an archer, and if it is, do the action.
Pain in the arse, no?
__________________
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
|
|
|
|
April 10, 2002, 19:30
|
#4
|
Deity
Local Time: 00:50
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
D'oh! Misread the question, I thought Turambar said attacking...
Quote:
|
Originally posted by Immortal Wombat
Pain in the arse, no?
|
Nah, that's what makes SLIC fun
|
|
|
|
April 10, 2002, 19:32
|
#5
|
Prince
Local Time: 23:50
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
|
Quote:
|
Originally posted by Locutus
Nah, that's what makes SLIC fun
|
You enjoy pains in your arse?
__________________
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
|
|
|
|
April 10, 2002, 19:33
|
#6
|
Deity
Local Time: 00:50
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
Quote:
|
Originally posted by Immortal Wombat
You enjoy pains in your arse?
|
No, I enjoy being creative...
|
|
|
|
April 11, 2002, 15:00
|
#7
|
Prince
Local Time: 22:50
Local Date: October 31, 2010
Join Date: Apr 2002
Location: England
Posts: 310
|
Thanks for the responses . I'll try it out soon. I'll probably have a load more questions for you soon anyway.
|
|
|
|
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 18:50.
|
|