Bug with my ability code
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.
- LordAwsomeness
- Posts: 203
- Joined: August 12th, 2013, 2:20 pm
- Location: U.S.A.
Bug with my ability code
hi so im trying to code in the following:
it all activates fine. however after the unit that has the ability goes into the last breath event, it repeats multiple times (like 4-6 times) and heals the unit completely. This is strange considering I took this code and only slightly modified it from some of my other code that prevents units from dying and those dont have this issue. Can anybody find out why my code is repeating multiple times? Also the event is supposed to remove the ability soul protection however it does not.
EDIT: the message fires the same amount of times as the heal as well. somehow both of those are firing and I cannot figure it out...
Code: Select all
#define LA_SOUL_PROTECTION_EVENT SIDE
[event]
name=last breath
first_time_only=no
[filter]
ability=la_soul_protection
[/filter]
{VARIABLE la_temp.hitpoints $unit.hitpoints}
[object]
take_only_once=no
silent=yes
[filter]
side=$unit.side
id=$unit.id
[/filter]
[effect]
apply_to=hitpoints
increase=$la_temp.hitpoints
[/effect]
[/object]
{VARIABLE la_temp.hitpoints $unit.max_hitpoints}
{VARIABLE_OP la_temp.hitpoints divide 3}
{VARIABLE_OP la_temp.hitpoints round ceiling}
{MESSAGE_THINGY narrator "As $unit.name was drawing their last breath, the soul protection cast upon saved them from the etneral abyss."}
[object]
take_only_once=no
silent=yes
[filter]
side=$unit.side
id=$unit.id
[/filter]
[effect]
apply_to=hitpoints
increase=$la_temp.hitpoints
[/effect]
[effect]
apply_to=remove_ability
id=la_soul_protection
[/effect]
[/object]
#{SIDE}
[store_unit]
[filter]
side=$unit.side
id=$unit.id
[/filter]
variable=soul_store
[/store_unit]
{VARIABLE unit.hitpoints $la_temp.hitpoints}
[unstore_unit]
variable=soul_store
text="$unit.hitpoints"
red,green,blue=0,255,0
[/unstore_unit]
[sound]
name={SOUND_LIST:HOLY}
[/sound]
{CLEAR_VARIABLE soul_store}
[/event]
#enddef
EDIT: the message fires the same amount of times as the heal as well. somehow both of those are firing and I cannot figure it out...
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
Re: Bug with my ability code
Depending on your setup around this code, you may be running into https://wiki.wesnoth.org/EventWML#A_Trap_for_the_Unwary
- LordAwsomeness
- Posts: 203
- Joined: August 12th, 2013, 2:20 pm
- Location: U.S.A.
Re: Bug with my ability code
yep im pretty sure that was the issue. it would make a lot of sense anyways knowing my code and how much I commit that fraud . it worked out though. I created a workaround since the store_unit wasn't working it stopped the bug altogether which enabled everything to fire just once. it actually saved me a lot of time and headaches since store_unit forces the entire action to stop because the code causing it is so far embedded and needed so badly that it would take me a long time to actually fix that issue. for anybody who would like a reference on how I fixed the issue, here's the workaround I came up with:Ravana wrote: ↑February 16th, 2020, 10:43 pm Depending on your setup around this code, you may be running into https://wiki.wesnoth.org/EventWML#A_Trap_for_the_Unwary
Code: Select all
#define LA_SOUL_PROTECTION_EVENT SIDE
[event]
name=last breath
first_time_only=no
[filter]
side=$unit.side
ability=la_soul_protection
[/filter]
{VARIABLE la_temp.hitpoints $unit.hitpoints}
#{VARIABLE la_hero[unit.side].revived1 not_yet}
[object]
take_only_once=no
silent=yes
[filter]
side=$unit.side
id=$unit.id
ability=la_soul_protection
[/filter]
[effect]
apply_to=hitpoints
increase=$la_temp.hitpoints
[/effect]
[/object]
{VARIABLE la_temp.hitpoints $unit.max_hitpoints}
{VARIABLE_OP la_temp.hitpoints divide 3}
{VARIABLE_OP la_temp.hitpoints round ceiling}
{MESSAGE_THINGY narrator "As $unit.name was drawing their last breath, the soul protection cast upon them saved them from the etneral abyss."}
{LA_STORE_FLOATING_TEXT_COLORS_FILTER (
side=$unit.side
id=$unit.id
ability=la_soul_protection
) "$la_temp.hitpoints" 0 255 0}
[object]
take_only_once=no
silent=yes
[filter]
side=$unit.side
id=$unit.id
ability=la_soul_protection
[/filter]
[effect]
apply_to=hitpoints
increase=$la_temp.hitpoints
[/effect]
[effect]
apply_to=remove_ability
[abilities]
[dummy]
id=la_soul_protection
[/dummy]
[/abilities]
[/effect]
[/object]
[sound]
name={SOUND_LIST:HOLY}
[/sound]
[chat]
speaker="Creator"
message="Don't worry about the 'Invalid WML found' bug. The ability still works as intended (I just had to find a small work-around)."
[/chat]
{VARIABLE la_hero[$unit.side].revived1 yes}
#{SIDE}
[store_unit]
[filter]
side=$unit.side
id=$unit.id
ability=la_soul_protection
[/filter]
variable=soul_store
[/store_unit]
{VARIABLE unit.hitpoints $la_temp.hitpoints}
[unstore_unit]
variable=soul_store
text="$unit.hitpoints"
red,green,blue=0,255,0
[/unstore_unit]
{CLEAR_VARIABLE soul_store}
[/event]
#enddef
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA