Healing + strengthening all units of a side at once
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.
- revansurik
- Posts: 604
- Joined: October 17th, 2012, 11:40 pm
- Location: Brazil
- Contact:
Healing + strengthening all units of a side at once
Been a while since I last was here
So, there's this effect I want to apply in a scenario of my campaign where all units of two given sides get healed in 10hp, strengthened by 25% and their resistances increased by 50%. This effect is supposed to last only a few turns, and at every turn when the variable ascendant_spells equals 1, the effect is "renewed" (it was the only way I knew without having the effect last till the scenario's end).
I tried using [object], but it's not working. Am I doing something wrong, or is the intended effect simply not possible?
So, there's this effect I want to apply in a scenario of my campaign where all units of two given sides get healed in 10hp, strengthened by 25% and their resistances increased by 50%. This effect is supposed to last only a few turns, and at every turn when the variable ascendant_spells equals 1, the effect is "renewed" (it was the only way I knew without having the effect last till the scenario's end).
I tried using [object], but it's not working. Am I doing something wrong, or is the intended effect simply not possible?
Code: Select all
[event]
name=new turn
first_time_only=no
[if]
[variable]
name=ascendant_spells
numerical_equals=1
[/variable]
[then]
[object]
id=ascendants_spells
take_only_once=no
duration=turn end
silent=yes
[filter]
side=1,3,5,6
[/filter]
[effect]
apply_to=resistance
replace=no
[resistance]
blade=-50
pierce=-50
impact=-50
[/resistance]
[/effect]
[effect]
apply_to=attack
increase_damage=25%
[/effect]
[effect]
apply_to=hitpoints
increase=10
violate_maximum=no
[/effect]
[/object]
[/then]
[/if]
[/event]
Author of the Dragon Trilogy.
If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy ;-)
If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy ;-)
- Lord-Knightmare
- Discord Moderator
- Posts: 2363
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: Healing + strengthening all units of a side at once
Am I doing something wrong, or is the intended effect simply not possible?
Here is my recommendation for a possible solution:The Wiki wrote: The first unit found that matches the filter will be given the object. Only on-map units are considered. If no unit matches or no [filter] is supplied, it is tried to apply the object to the unit at the $x1,$y1 location of the event where this [object] is in. The case of no unit being at that spot is handled in the same way as no unit matching a given filter ([else] commands executed, cannot_use_message displayed).
- in a new turn event, store all units matching your SUF into a variable array
- Take a
[foreach]
loop with the array variable and apply[do]
your Superbly Unbalanced Overkill Buff object to each of the units stored. - Unstore all units with
find_vacant=no
and then clear the variable array.
[heal_unit][/heal_unit]
is better than the object healing method.Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Re: Healing + strengthening all units of a side at once
Don't know if this will work. Try putting the object (without the filter) inside [modify_unit] + [filter]
- revansurik
- Posts: 604
- Joined: October 17th, 2012, 11:40 pm
- Location: Brazil
- Contact:
Re: Healing + strengthening all units of a side at once
Like this?Lord-Knightmare wrote: ↑March 2nd, 2021, 7:59 pm Here is my recommendation for a possible solution:Additionally, the
- in a new turn event, store all units matching your SUF into a variable array
- Take a
[foreach]
loop with the array variable and apply[do]
your Superbly Unbalanced Overkill Buff object to each of the units stored.- Unstore all units with
find_vacant=no
and then clear the variable array.[heal_unit][/heal_unit]
is better than the object healing method.
edit: Forgot to add the unstore bit, but how would I unstore all units right at their respective locations?
Code: Select all
[store_unit]
[filter]
side=1
type=(all the unit IDs from the sides to be affected)
[/filter]
kill=no
variable=spell_units
[/store_unit]
[foreach]
variable=spell_units
[do]
[object]
id=ascendants_spells
take_only_once=no
duration=turn end
silent=yes
[filter]
side=1,3,5,6
[/filter]
[effect]
apply_to=resistance
replace=no
[resistance]
blade=-50
pierce=-50
impact=-50
[/resistance]
[/effect]
[effect]
apply_to=attack
increase_damage=25%
[/effect]
[/object]
[/do]
[/foreach]
{CLEAR_VARIABLE spell_units}
Author of the Dragon Trilogy.
If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy ;-)
If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy ;-)
- Lord-Knightmare
- Discord Moderator
- Posts: 2363
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: Healing + strengthening all units of a side at once
This should work.
Code: Select all
[store_unit]
[filter]
side=1,3,5,6
type=Weaver, Scribe, Gatekeeper, Courier, Seeker, Aragwaith Swordsman
[/filter]
kill=no
variable=spell_units
[/store_unit]
[foreach]
variable=spell_units
[do]
[object]
id=ascendants_spells
take_only_once=no
duration=turn end
silent=yes
[filter]
id=spell_units[$i].id
[/filter]
[effect]
apply_to=resistance
replace=no
[resistance]
blade=-50
pierce=-50
impact=-50
[/resistance]
[/effect]
[effect]
apply_to=attack
increase_damage=25%
[/effect]
[/object]
[/do]
[/foreach]
[unstore_unit]
variable=spell_units
find_vacant=no
[/unstore_unit]
{CLEAR_VARIABLE spell_units}
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
- IIIO_METAL
- Posts: 202
- Joined: January 18th, 2017, 5:03 pm
- Location: japan
Re: Healing + strengthening all units of a side at once
Change "duration = turn end" to "duration = forever" and apply the object only once. Then, use [remove_object] when the effect expires. I often use this method.
Creator of "Mountain Witch" & "Castle of evil spirit"
- revansurik
- Posts: 604
- Joined: October 17th, 2012, 11:40 pm
- Location: Brazil
- Contact:
Re: Healing + strengthening all units of a side at once
There's a 'missing array' error... what should I write in 'array'? the wiki isn't very detailed about that...
Author of the Dragon Trilogy.
If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy ;-)
If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy ;-)
- Lord-Knightmare
- Discord Moderator
- Posts: 2363
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: Healing + strengthening all units of a side at once
It should be therevansurik wrote: ↑March 3rd, 2021, 4:41 amThere's a 'missing array' error... what should I write in 'array'? the wiki isn't very detailed about that...
array=
key and not variable=
.
Code: Select all
[foreach]
array="spell_units"
# rest of the code
[/foreach]
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
- revansurik
- Posts: 604
- Joined: October 17th, 2012, 11:40 pm
- Location: Brazil
- Contact:
Re: Healing + strengthening all units of a side at once
The healing works now, but the units' attack and resistance are unaffected...Lord-Knightmare wrote: ↑March 3rd, 2021, 4:45 amIt should be therevansurik wrote: ↑March 3rd, 2021, 4:41 amThere's a 'missing array' error... what should I write in 'array'? the wiki isn't very detailed about that...array=
key and notvariable=
.Code: Select all
[foreach] array="spell_units" # rest of the code [/foreach]
Author of the Dragon Trilogy.
If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy ;-)
If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy ;-)
- IIIO_METAL
- Posts: 202
- Joined: January 18th, 2017, 5:03 pm
- Location: japan
Re: Healing + strengthening all units of a side at once
attack seems to need a key to filter.
resistance doesn't seem to need 'replace = no'.
It worked.
resistance doesn't seem to need 'replace = no'.
It worked.
Code: Select all
[effect]
apply_to=resistance
[resistance]
blade=-50
pierce=-50
impact=-50
[/resistance]
[/effect]
[effect]
apply_to=attack
range="melee"
increase_damage=100%
[/effect]
[effect]
apply_to=attack
range="ranged"
increase_damage=100%
[/effect]
Creator of "Mountain Witch" & "Castle of evil spirit"
- revansurik
- Posts: 604
- Joined: October 17th, 2012, 11:40 pm
- Location: Brazil
- Contact:
Re: Healing + strengthening all units of a side at once
Still not working for me (neither the attack increase, nor the resistance increase)IIIO_METAL wrote: ↑March 3rd, 2021, 1:17 pm attack seems to need a key to filter.
resistance doesn't seem to need 'replace = no'.
It worked.
Code: Select all
[effect] apply_to=resistance [resistance] blade=-50 pierce=-50 impact=-50 [/resistance] [/effect] [effect] apply_to=attack range="melee" increase_damage=100% [/effect] [effect] apply_to=attack range="ranged" increase_damage=100% [/effect]
Author of the Dragon Trilogy.
If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy ;-)
If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy ;-)
- IIIO_METAL
- Posts: 202
- Joined: January 18th, 2017, 5:03 pm
- Location: japan
Re: Healing + strengthening all units of a side at once
I tried a little different code written by Lord-Knightmare. The result with the 1.15 version is successful.
Changed part
object filter: id = $spell_units[$i].id|
[unstore_unit]: Delete
Changed part
object filter: id = $spell_units[$i].id|
[unstore_unit]: Delete
Code: Select all
[store_unit]
[filter]
side=1
[/filter]
kill=no
variable = spell_units
[/store_unit]
[foreach]
array = spell_units
[do]
[object]
id=ascendants_spells
take_only_once=no
duration=turn end
silent=yes
[filter]
id = $spell_units[$i].id|
[/filter]
[effect]
apply_to=resistance
[resistance]
blade=-50
pierce=-50
impact=-50
[/resistance]
[/effect]
[effect]
apply_to=attack
range="melee"
increase_damage=25%
[/effect]
[effect]
apply_to=attack
range="ranged"
increase_damage=25%
[/effect]
[effect]
apply_to=hitpoints
increase=10
violate_maximum=no
[/effect]
[/object]
[/do]
[/foreach]
{CLEAR_VARIABLE spell_units}
Creator of "Mountain Witch" & "Castle of evil spirit"
- revansurik
- Posts: 604
- Joined: October 17th, 2012, 11:40 pm
- Location: Brazil
- Contact:
Re: Healing + strengthening all units of a side at once
NOW it worked!IIIO_METAL wrote: ↑March 4th, 2021, 4:34 am I tried a little different code written by Lord-Knightmare. The result with the 1.15 version is successful.
Changed part
object filter: id = $spell_units[$i].id|
Thanks so much to both of you!
Author of the Dragon Trilogy.
If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy ;-)
If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy ;-)
- Celtic_Minstrel
- Developer
- Posts: 2216
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Healing + strengthening all units of a side at once
Usingrevansurik wrote: ↑March 2nd, 2021, 7:37 pm I tried using [object], but it's not working. Am I doing something wrong, or is the intended effect simply not possible?
[object]
is correct, but since you want it to apply to everyone who matches the filter, it needs to be used inside [modify_unit]
, like this:Code: Select all
[event]
name=new turn
first_time_only=no
[if]
[variable]
name=ascendant_spells
numerical_equals=1
[/variable]
[then]
[modify_unit]
[filter]
side=1,3,5,6
[/filter]
[object]
duration=turn end
[effect]
apply_to=resistance
replace=no
[resistance]
blade=-50
pierce=-50
impact=-50
[/resistance]
[/effect]
[effect]
apply_to=attack
increase_damage=25%
[/effect]
[effect]
apply_to=hitpoints
increase=10
violate_maximum=no
[/effect]
[/object]
[/modify_unit]
[/then]
[/if]
[/event]
This is also a good idea. You need an id= in theIIIO_METAL wrote: ↑March 3rd, 2021, 4:00 am Change "duration = turn end" to "duration = forever" and apply the object only once. Then, use [remove_object] when the effect expires. I often use this method.
[object]
to support this.- revansurik
- Posts: 604
- Joined: October 17th, 2012, 11:40 pm
- Location: Brazil
- Contact:
Re: Healing + strengthening all units of a side at once
Well, that code did work even though I didn't use [modify_unit]... Though now that I think about it I only tested in 1.15; maybe 1.14 would require that...Celtic_Minstrel wrote: ↑March 4th, 2021, 1:57 pmUsingrevansurik wrote: ↑March 2nd, 2021, 7:37 pm I tried using [object], but it's not working. Am I doing something wrong, or is the intended effect simply not possible?[object]
is correct, but since you want it to apply to everyone who matches the filter, it needs to be used inside[modify_unit]
, like this:
Author of the Dragon Trilogy.
If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy ;-)
If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy ;-)