[remove_object] removing status
Moderator: Forum Moderators
Forum rules
Before reporting issues in this section, you must read the following topic:
Before reporting issues in this section, you must read the following topic:
[remove_object] removing status
I can't properly reproduce the problem, I've only been able to reproduce it in the first video. This event, by removing the item (a blue eye icon, which can be seen in the third video on other units) removed the unit's poisoned status.
In the second video I fixed this problem with this code, editing the savegame to edit the event (basically save the status>remove_object>store_unit>restore status with previous variable>unstore_unit :
In the third video, I tried to reproduce the first event code (the one with the problem) with the same unit, the fugitive, an avenger, a wose... and the poisoned state was preserved correctly this time:
I don't know whether to keep the second code as "backup" in case this problem occurs again, or to look for the true cause of the problem to fix it. Can someone help me find the difference between the videos/situations, and a possible solution?
Note: kill or no the enemy unit on the attack doesn't make a difference, happens (or not) on both cases.
The object, just in case:
Code: Select all
[event]
name=attack_end
id=aww_13_cooldown_refresh_attack
first_time_only=no
[filter_condition]
{VARIABLE_CONDITIONAL unit.hitpoints greater_than 0}
[/filter_condition]
[filter]
ability_type=hides
[/filter]
[modify_unit]
[filter]
x,y=$x1,$y1
[/filter]
{VARIABLE preambush no}
{VARIABLE_OP aww_ambush_cooldown_turn add $aww_ambush_cooldown_attack}
[/modify_unit]
[remove_object]
x,y=$x1,$y1
object_id=aww_preambush_icon
[/remove_object]
[/event]
Code: Select all
[event]
name=attack_end
id=aww_13_cooldown_refresh_attack
first_time_only=no
[filter_condition]
{VARIABLE_CONDITIONAL unit.hitpoints greater_than 0}
[/filter_condition]
[filter]
ability_type=hides
[/filter]
[modify_unit]
[filter]
x,y=$x1,$y1
[/filter]
{VARIABLE preambush no}
{VARIABLE_OP aww_ambush_cooldown_turn add $aww_ambush_cooldown_attack}
[/modify_unit]
[set_variables]
name=unit_prestatus
to_variable=unit.status
[/set_variables]
[remove_object]
x,y=$x1,$y1
object_id=aww_preambush_icon
[/remove_object]
[store_unit]
variable=unit_post
[filter]
x,y=$x1,$y1
[/filter]
[/store_unit]
[set_variables]
name=unit_post.status
to_variable=unit_prestatus
[/set_variables]
[unstore_unit]
variable=unit_post
[/unstore_unit]
[/event]
I don't know whether to keep the second code as "backup" in case this problem occurs again, or to look for the true cause of the problem to fix it. Can someone help me find the difference between the videos/situations, and a possible solution?
Note: kill or no the enemy unit on the attack doesn't make a difference, happens (or not) on both cases.
The object, just in case:
Code: Select all
#define AWW_AMBUSH_ICON_OBJECT
[object]
id=aww_preambush_icon
[effect]
[filter]
ability_type_active=hides
[not]
[filter_adjacent]
is_enemy=yes
formula="self.hitpoints > 0"
[/filter_adjacent]
[/not]
[/filter]
apply_to=overlay
add="misc/aww-ambush-attack.png"
[/effect]
[/object]
#enddef
- Atreides
- Posts: 1075
- Joined: March 30th, 2019, 10:38 pm
- Location: On the 2nd story of the centre village of Merwuerdigliebe turning the lights on and off
Re: [remove_object] removing status
I've just discovered this problem also. Check the notes under modify_unit, remove_object only partly restores a unit's customizations. All the rest is reread from the unit_type it seems.
Re: [remove_object] removing status
On modify_unit it says:
Attack with Hudell and Inna, no matter the result or the order, Hudell lost poison status and Inna not. (ignore possible overlay errors, it's an addon)
"Not sure of this one" is still valid xD Because normally the status is preserved, (I guess 99% of the time). But I've seen a situation where no, the only thing I can provide to replicate it is the savegame where it occurs.Attack with Hudell and Inna, no matter the result or the order, Hudell lost poison status and Inna not. (ignore possible overlay errors, it's an addon)
Re: [remove_object] removing status
I'm not really sure what the intended behavior is, but it seems like this problem has come up before:
See also here:Bob_The_Mighty wrote: ↑November 1st, 2017, 6:07 pm Hey chaps. I'm still getting problems with [remove_object], this time on 1.13.10. It seems to me that using this tag to remove an object from a unit inadvertently also removes poison and slow.
Bob_The_Mighty wrote: ↑April 30th, 2020, 2:38 am Thanks for the ongoing bug reports! Changing your stance isn't meant to cure poison, it's a problem with [remove_object] that I keep trying and failing to fix. Your max xp increases whenever you level up, so unless it was that it might be a similar bug to the poison.
- Atreides
- Posts: 1075
- Joined: March 30th, 2019, 10:38 pm
- Location: On the 2nd story of the centre village of Merwuerdigliebe turning the lights on and off
Re: [remove_object] removing status
One thing is for sure, using remove_object will wipe out things like a custom berserk special added to a unit for one turn if it was not done using an object itself. Most addons use a lot of store/edit/unstore and all that is vulnerable to remove_object.
Re: [remove_object] removing status
Based on what you say, my recommendations (which work well for me, so far):
Use lua instead of WML when you need to remove all objects with the same id (without standardunitfilter). I know it is also possible to do it with standardunitfilter, but I don't know how to do it right. Add this function as lua code:
Then use this WML tag when you want to delete all object with the same id. An additional advantage that [remove_object] does not have is that it will also search the recall list:
I've been using this for a long time and I can pretty much say that it respects statuses.
In case you need to delete objects on one specific unit, to be 100% sure that all the status are preserved, both the official ones and the custom ones in any addon, era or campaign, you would have to do this:
Use lua instead of WML when you need to remove all objects with the same id (without standardunitfilter). I know it is also possible to do it with standardunitfilter, but I don't know how to do it right. Add this function as lua code:
Code: Select all
function wesnoth.wml_actions.remove_all_objects(cfg)
local object_id = cfg.object_id
for _,unit in ipairs(wesnoth.units.find(cfg)) do
wesnoth.units.remove_modifications(unit, {id = object_id})
end
end
Code: Select all
[remove_all_objects]
object_id=id_of_the_object
[/remove_all_objects]
In case you need to delete objects on one specific unit, to be 100% sure that all the status are preserved, both the official ones and the custom ones in any addon, era or campaign, you would have to do this:
Code: Select all
[set_variables]
name=unit_prestatus
to_variable=unit.status
[/set_variables]
[remove_object]
ANY STANDARDUNITFILTER
object_id=id_of_the_object
[/remove_object]
[store_unit]
variable=unit_post
[filter]
SAME STANDARDUNITFILTER
[/filter]
[/store_unit]
[set_variables]
name=unit_post.status
to_variable=unit_prestatus
[/set_variables]
[unstore_unit]
variable=unit_post
[/unstore_unit]
New ideas will be welcome, the more general and simple they are, the better.- note the final "s" in [set_variables]
- If you want to do it with several units (but not all), use [for] or [foreach]