[Solved] [filter] for [modify_unit] in [prerecruit] event
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.
- Chief_Chasso
- Posts: 132
- Joined: December 15th, 2012, 2:36 am
[Solved] [filter] for [modify_unit] in [prerecruit] event
I'm trying to find the appropriate unit [filter] for a unit that has just been recently recruited. I want to be able to modify a single unit that has just been recruited within a prerecruit event before the unit is displayed.
This is what I want:
Can you modify a single individual recruited unit during a prerecruit event? I think, ideally, you would filter the unit's id, however, you wouldn't know the unit's id that has just been recruited (I believe the unit is automatically assigned an id internally).
Or am I approaching this incorrectly? Any thoughts?
This is what I want:
Code: Select all
# all units recruited for side 1 will start with only 75% of the unit's total HP.
[event]
name=prerecruit
first_time_only=no
[filter]
side=1
[/filter]
[filter_second]
id=leader
[/filter_second]
[modify_unit]
[filter]
side=1 # I need a filter tag here to filter just the most recently recruited single unit
[/filter]
hitpoints=$($this_unit.hitpoints*0.75)
[/modify_unit]
[/event]
Can you modify a single individual recruited unit during a prerecruit event? I think, ideally, you would filter the unit's id, however, you wouldn't know the unit's id that has just been recruited (I believe the unit is automatically assigned an id internally).
Or am I approaching this incorrectly? Any thoughts?
Last edited by Chief_Chasso on June 5th, 2015, 11:20 pm, edited 1 time in total.
SP Campaign: Rally For Roanic
Re: Need unit [filter] for [modify_unit] in [prerecruit] eve
Use eitherChief_Chasso wrote:I think, ideally, you would filter the unit's id, however, you wouldn't know the unit's id that has just been recruited (I believe the unit is automatically assigned an id internally).
id=$unit.id
or x,y=$unit.x,$unit.y
in the action’s [filter]
— both will work just the same. prerecruit
events, like every other event that takes a unit, autostore the primary and secondary units in unit
and second_unit
respectively.EDIT: Whoops, I somehow forgot
x1
and y1
. See below and use those instead, since they make for cleaner code and are considerably more efficient.Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm.
Re: Need unit [filter] for [modify_unit] in [prerecruit] eve
Code: Select all
[filter]
x,y=$x1,$y1
[/filter]
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
- Chief_Chasso
- Posts: 132
- Joined: December 15th, 2012, 2:36 am
Re: Need unit [filter] for [modify_unit] in [prerecruit] eve
Thanks shadowm and tekelili-
$x1,$y1
worked perfectly. I'll get the hang of these variables eventually SP Campaign: Rally For Roanic
-
- Double Style Tourney #1 Champ
- Posts: 121
- Joined: November 26th, 2009, 5:46 am
- Location: Egypt
Re: [Solved] [filter] for [modify_unit] in [prerecruit] even
shouldn't hitpoints be placed inside an effect tag?
I am trying to edit hp of all peasants , not a single unit, how to do so?
I am trying to edit hp of all peasants , not a single unit, how to do so?
Code: Select all
[event]
name=recruit
first_time_only=yes
[modify_unit]
[filter]
type=Peasant
side=1
[/filter]
[object]
duration=forever
[filter]
type=Peasants
#x,y=$unit.x,$unit.y
[/filter]
[effect]
apply_to=hitpoints
increase_total=20%
heal_full=yes
hitpoints="$(this_unit.hitpoints * 1.2)"
[/effect]
[/object]
[/modify_unit]
[/event]
Ports: Velensk's tower defense, dov's deep shrine, Scrolling survival, Scrolling survival Co-op, Temples of the nagas.
Addons: Tower defense maps , some ANL scenarios like: ANL 3p "A New Land" survival type, and ANL Co-operative map for 2p
Addons: Tower defense maps , some ANL scenarios like: ANL 3p "A New Land" survival type, and ANL Co-operative map for 2p
Re: [Solved] [filter] for [modify_unit] in [prerecruit] even
You use [effect] when you use [object]. Other ways of modifying units do not use it. And [modify_unit] does not need any [object].
Re: [Solved] [filter] for [modify_unit] in [prerecruit] even
modyfying units with [object] or via direct modification has different effects. Changes done via [object] will for example stay if the unit advances to another type, but also other things, specially undoing objects with durations will remove all changed done via direct modification.
Also there are some things (animations) that can only be changed uing [object] while there are other things that can only be done via direct modifications.
Also there are some things (animations) that can only be changed uing [object] while there are other things that can only be done via direct modifications.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.