Force Loyal Question
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Force Loyal Question
This has probably been addressed before, but I'm fairly new to this community and there is A LOT of information to sift through; also I've been trying to muck around with this for quite a while, so maybe someone can help me.
I am trying to force all of the units of a particular side (actually sides 3-9; all of the AI players) which are recruited normally during the game to be (or to have) the LOYAL trait.
I'm using the "prerecruit" event, and filtering the 'unit' for side=3,4,5,6,7,8,9 and then I've tried several iterations of using first just [effect] and then [set_variable] with a nested [effect] and finally trying to use [modifications] within [set_variable] accessing the "unit" filtered from the main [event] code. My latest attempt looks like this:
[event]
name=prerecruit
[filter]
side=3,4,5,6,7,8,9
[/filter]
[set_variable]
name=unit
[modifications]
[trait]
id=force_loyal
[effect]
apply_to=loyal
[/effect]
[/trait]
[/modifications]
[/set_variable]
first_time_only=no
[/event]
and my first version looks like this:
[event]
name=prerecruit
[filter]
side=3,4,5,6,7,8,9
[/filter]
[effect]
[filter]
side=3,4,5,6,7,8,9
[/filter]
apply_to=loyal
[/effect]
first_time_only=no
[/event]
Although I haven't been able to get either to work. Please advise -- thanks.
I am trying to force all of the units of a particular side (actually sides 3-9; all of the AI players) which are recruited normally during the game to be (or to have) the LOYAL trait.
I'm using the "prerecruit" event, and filtering the 'unit' for side=3,4,5,6,7,8,9 and then I've tried several iterations of using first just [effect] and then [set_variable] with a nested [effect] and finally trying to use [modifications] within [set_variable] accessing the "unit" filtered from the main [event] code. My latest attempt looks like this:
[event]
name=prerecruit
[filter]
side=3,4,5,6,7,8,9
[/filter]
[set_variable]
name=unit
[modifications]
[trait]
id=force_loyal
[effect]
apply_to=loyal
[/effect]
[/trait]
[/modifications]
[/set_variable]
first_time_only=no
[/event]
and my first version looks like this:
[event]
name=prerecruit
[filter]
side=3,4,5,6,7,8,9
[/filter]
[effect]
[filter]
side=3,4,5,6,7,8,9
[/filter]
apply_to=loyal
[/effect]
first_time_only=no
[/event]
Although I haven't been able to get either to work. Please advise -- thanks.
Re: Force Loyal Question
You've got it real wrong.
First of all, you used your filters the wrong way. You must define what you want to pass, not want you do not want to pass.
Second, you can't use [modification] inside [set_variable]. This is silly. You must first store your unit inside and event. Luckily, lots of useful variables are automatically stored when initiating an event handler, and this includes the concerned units. Then, you manipulate its variables and you unstore it. AFAIK, [modifications] is used only in [unit]. Another way of doing this would be to give the unit an object containing the desired effects, but this must be done AFTER unstoring the unit. I tend to find that the variable way is more efficient, though.
So hopefully you'll read all of the above, but in short your code could look like this:
Put it in you [scenario].
First of all, you used your filters the wrong way. You must define what you want to pass, not want you do not want to pass.
Second, you can't use [modification] inside [set_variable]. This is silly. You must first store your unit inside and event. Luckily, lots of useful variables are automatically stored when initiating an event handler, and this includes the concerned units. Then, you manipulate its variables and you unstore it. AFAIK, [modifications] is used only in [unit]. Another way of doing this would be to give the unit an object containing the desired effects, but this must be done AFTER unstoring the unit. I tend to find that the variable way is more efficient, though.
So hopefully you'll read all of the above, but in short your code could look like this:
Code: Select all
[event]
name=recruit
first_time_only=no
[filter]
side=1
[/filter]
[unstore_unit]
variable=unit
[/unstore_unit]
[object]
silent=yes
[filter]
find_in=unit
[/filter]
[effect]
apply_to=loyal
[/effect]
[/object]
[/event]
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
Current projects: Internet meme Era, The Settlers of Wesnoth
Re: Force Loyal Question
Well clearly YOU just read my code and not my question because I UNDERSTAND how filters work and it IS sides 3,4,5,6,7,8 and 9 I want to be loyal all my computer enemies.
A) So it looks like you are saying that I cannot modify the variable "unit" that is stored inside the event cannot be modified without unstoring it - is that true?
B) you recommended using a silent object to make all these units (every unit on 7 sides) loyal - will this many objects have any negative effects on the game's operation, specifically in multiplayer?
C) is there any way to do this by modifying the units directly (before or after unstoring them) without giving them objects?
D) will unstoring the unit as/after it's recruited affect it's normal creation on the map?
Thanks very much for your help.
A) So it looks like you are saying that I cannot modify the variable "unit" that is stored inside the event cannot be modified without unstoring it - is that true?
B) you recommended using a silent object to make all these units (every unit on 7 sides) loyal - will this many objects have any negative effects on the game's operation, specifically in multiplayer?
C) is there any way to do this by modifying the units directly (before or after unstoring them) without giving them objects?
D) will unstoring the unit as/after it's recruited affect it's normal creation on the map?
Thanks very much for your help.
Re: Force Loyal Question
Yeah according to the points of the wiki you referred me to (which I have read previously) it seems like I can change some of the variables in the "unit" array inside of the "recruit" event and then unstore_unit to effect the actual unit that has just been created - is this possible?
Really, it would be fine with me if EVERY unit that is on all 7 sides is made to be loyal every time any of them recruited a unit (which is what I _thought_ my first version was going to do)
Really, it would be fine with me if EVERY unit that is on all 7 sides is made to be loyal every time any of them recruited a unit (which is what I _thought_ my first version was going to do)
Re: Force Loyal Question
Also will a silent object cause the unit's status window to display "loyal"?
Re: Force Loyal Question
Ok - silent object does Not display loyal; but it IS loyal which is really all I need since it is enemy ai controlled units. I did manage to get my code working the way I want, thanks to your advice, so thank you.
If you have any insight into my earlier questions, my ultimate goal is still to actually become as knowledgable about and proficient with the code as possible, so I would appreciate any further advice from anyone about modifying "unit" found in [event] directly..
If you have any insight into my earlier questions, my ultimate goal is still to actually become as knowledgable about and proficient with the code as possible, so I would appreciate any further advice from anyone about modifying "unit" found in [event] directly..
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Force Loyal Question
a) Correct
b) No
c) You can store/unstore units to modify them, however any affects given to them this way are lost when they level up (among a few other times, don't remember what they are though)
d) No
also, I just tested this code out and it should work fine:
b) No
c) You can store/unstore units to modify them, however any affects given to them this way are lost when they level up (among a few other times, don't remember what they are though)
d) No
also, I just tested this code out and it should work fine:
Code: Select all
[event]
name=recruit
first_time_only=no
[if]
[variable]
name=unit.side
greater_than_equal_to=3
[/variable]
[then]
[object]
silent=yes
[effect]
apply_to=loyal
[/effect]
[/object]
[/then]
[/if]
[/event]
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: Force Loyal Question
Looks like everyone's getting it wrong.
I didn't test so I might have forgotten something.
Objects can't add traits. If you want to add a trait, you need to use [set_variables] or just create a new unit. [set_variables] would work if you wanted to add the loyal trait to the unit, not force one of the traits to be loyal or force it to be the only trait. I'm assuming the latter, because having three traits is ugly. If you don't want the other trait to be random, just change random_traits= to no.
Code: Select all
[event]
name=prerecruit
first_time_only=no
[filter]
side=3,4,5,6,7,8,9
[/filter]
[unit]
side=$unit.side
type=$unit.type
generate_name=yes
moves=0
attacks_left=0
facing=$unit.facing
{IS_LOYAL} # the loyal overlay icon
x,y=$x1,$y1
placement=map_overwrite
animate=yes
random_traits=yes
[modifications]
{TRAIT_LOYAL}
[/modifications]
[/unit]
[/event]
Objects can't add traits. If you want to add a trait, you need to use [set_variables] or just create a new unit. [set_variables] would work if you wanted to add the loyal trait to the unit, not force one of the traits to be loyal or force it to be the only trait. I'm assuming the latter, because having three traits is ugly. If you don't want the other trait to be random, just change random_traits= to no.
- krotop
- 2009 Map Contest Winner
- Posts: 433
- Joined: June 8th, 2006, 3:05 pm
- Location: Bordeaux, France
Re: Force Loyal Question
In case there's a confusion, the 'silent' key within the [object] tag is not related to the fact that 'loyal' is not displayed to the player.
If you want to display additional traits' name and description to the user, you have to write them into the appropriate variables. These variables are
my_unit.modifications.trait[$latest_trait_index].id
my_unit.modifications.trait[$latest_trait_index].name
my_unit.modifications.trait[$latest_trait_index].description
and a convenient way to do it is, as zookeeper said, to use the [set_variables] tag.
That does not apply the effect of the loyal trait, you need the [object] in addition.
If you want to display additional traits' name and description to the user, you have to write them into the appropriate variables. These variables are
my_unit.modifications.trait[$latest_trait_index].id
my_unit.modifications.trait[$latest_trait_index].name
my_unit.modifications.trait[$latest_trait_index].description
and a convenient way to do it is, as zookeeper said, to use the [set_variables] tag.
Code: Select all
[set_variables]
name=unit.modifications.trait
mode=append
[value]
id="my_trait_id"
name="my_trait_name"
description="my_trait_description"
[/value]
[/set_variables]
Don't trust me, I'm just average player.
***
Game feedback for the Nightmares of Meloen
Art feedback by mystic x the unknown
***
Game feedback for the Nightmares of Meloen
Art feedback by mystic x the unknown
Re: Force Loyal Question
Yes zookeeper; thank you, that is EXACTLY what I was trying to do. I did not realize that I could physically replace on the map "unit" by using the [unit] command though. Nice -- you are indeed a Wizard as your title indicates; thanks again.
Last edited by Zenogias on August 13th, 2010, 10:35 pm, edited 1 time in total.
Re: Force Loyal Question
(Off topic)
(The name is zookeeper – WML Wizard is a title given for his good work.)Zenogias wrote:Yes WML Wizard; thank you, that is EXACTLY what I was trying to do. [...] Nice -- you are indeed a Wizard as your name indicates; thanks again.