Problems with [object] and [remove_object]

The place to post your WML questions and answers.

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.
User avatar
Bob_The_Mighty
Posts: 824
Joined: July 13th, 2006, 1:15 pm

Re: Problems with [object] and [remove_object]

Post by Bob_The_Mighty »

I am still having problems on 1.14.11 with [remove_object] causing changes to things like max movement being lost (as well as removing slow/poison). The wiki says:
Note that some unit properties are not restored ideally, e.g. current unit's health reversion might not work as expected (max_hitpoints will though). (Version 1.15.0 and later only) This was fixed.
However, I can't find any reference to this on the changelog. Does anyone know what was fixed and whether this tag is safe to use now? I am debating whether to rewrite a ton of code for the inventory system in Bob's RPG Era or to live with the bugs in the hope it will be fixed in 1.15.
My current projects:
MP pirate campaign: The Altaz Mariners
RPG sequel: Return to Trent
MP stealth campaign: Den of Thieves
gfgtdf
General Code Maintainer
Posts: 1343
Joined: February 10th, 2013, 2:25 pm

Re: Problems with [object] and [remove_object]

Post by gfgtdf »

The bug was fixed was about remove_object sometimes changing current hitpoints/moves, even though the object did not change them.

If you are having problem with max hitpoints, i can tell you: [remove_object] will reset the units stats like max_hitpoints, it is reccomended to never change a units max hitpoints via for example [modify_unit] or set_variables, in particular if your addon uses [remove_object] its reccomended that you try to do all your unit modifications via [object]s/effect]s, even if you don't want to remove them afterwards.

To explain it a little more:

The units properties can be seperated in two types, lets call them 'persistent' and 'current', properties of type 'pertsistent' include max_hitpoints, movetype, attacks, abilities etc, basicially all attributes that are usually given by a unit type, properties of type 'current' include hitpoibnts, moves, status etc. that describe the current units. I really reccomend to change properties of the type 'persitent' always via [effect] and properties of the type 'current' always via direct unit modifications ([set_variable]/[modify_unit]), otherwise you will run into problems in certain situations like this, unless you know really well how the engine works.


EDIT: wait i just read the beginning of the tread and noticed that i already said this. maybe i misunderdtood your question.
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.
User avatar
Bob_The_Mighty
Posts: 824
Joined: July 13th, 2006, 1:15 pm

Re: Problems with [object] and [remove_object]

Post by Bob_The_Mighty »

Thanks for explaining. That's good to know about how to handle persistent/current stats.
gfgtdf wrote: April 3rd, 2020, 5:27 pmThe bug was fixed was about remove_object sometimes changing current hitpoints/moves, even though the object did not change them.
Do you mean this was fixed in 1.15 or before?

The problem I am encountering is this: changes to max movement via objects are being lost somehow. I think it might be to do with using remove_object to change other stats, as if the unit is being rebuilt without the max movement object.
My current projects:
MP pirate campaign: The Altaz Mariners
RPG sequel: Return to Trent
MP stealth campaign: Den of Thieves
gfgtdf
General Code Maintainer
Posts: 1343
Joined: February 10th, 2013, 2:25 pm

Re: Problems with [object] and [remove_object]

Post by gfgtdf »

Bob_The_Mighty wrote: April 3rd, 2020, 6:00 pm The problem I am encountering is this: changes to max movement via objects are being lost somehow. I think it might be to do with using remove_object to change other stats, as if the unit is being rebuilt without the max movement object.
Hmm this shouldn't happen, maybe you can give a example code to reproduce this issue?, without further information i have to assume that there is just a bug somewhere in your code.
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.
User avatar
Bob_The_Mighty
Posts: 824
Joined: July 13th, 2006, 1:15 pm

Re: Problems with [object] and [remove_object]

Post by Bob_The_Mighty »

I've just noticed that I've been using [filter] inside [remove_object] when the wiki explicitly says not to. :oops:
I guess this means without a filter the object is removed from all players who had it, thus causing odd behaviour.
My current projects:
MP pirate campaign: The Altaz Mariners
RPG sequel: Return to Trent
MP stealth campaign: Den of Thieves
Post Reply