Query unit action - max charges flag wrong

A forum for discussing map making ideas and problems for the Myth series.

Moderator: Doobie

Query unit action - max charges flag wrong

Postby hmp » Thu Oct 27, 2016 11:01 pm

It seems in the query unit action, the max charges parameter actually returns the max charges + 1. I'm trying to script it so that starting artifacts are maxed out on charges (the artifacts normally have a random range of charges). However, I keep ending up with having one more charge than the max. I added a debug flag to check what was going on and got:

@game_time 160 (0:05) ### MA [quni] chrg? trigger
@game_time 160 (0:05) ### MA [quni] chrg? succeeded
@game_time 160 (0:05) ### MA [quni] chrg? deactivated
@game_time 160 (0:05) ### MA [math] chrg math trigger
@game_time 160 (0:05) ### MA [math] chrg math 4.000000 - 2.000000 = 2.000000
@game_time 160 (0:05) ### MA [math] chrg math succeeded
@game_time 160 (0:05) ### MA [math] chrg math deactivated
@game_time 160 (0:05) ### MA [ctrl] add chrg trigger
@game_time 160 (0:05) ### MA [ctrl] add chrg succeeded
@game_time 160 (0:05) ### MA [ctrl] add chrg deactivated

Script is just a query unit with max charges and current charges, math action pulls those numbers and subtracts current from max, then feeds result to a ctrl to add that amount of charges. The above is from an artifact with a max of 3 charges (same result of max+1 for all the other artifacts).

I should be able to work around it with another math action, just wanted to point out the bug.
Posts: 54
Joined: Fri Dec 14, 2007 3:00 am

Re: Query unit action - max charges flag wrong

Postby Pyro » Wed Jan 31, 2018 11:55 pm

HMP mentioned this thread to me, so I looked into this with a test map. There is some unexpected behavior here but it is not a one off error that HMP claims. In my test map, I used the solo level Shiver. I modified the warlock staff artifact to give it a max charges of 6. The initial is 4-4, which I left alone. I added scripting for Query and Math to know what the current charge count was as well as the max charge count. Added debug flags so the myth log could show me those numbers. Both came back as 4 when the max should be 6.

When I changed the initial range to 4-5, the max charge count would correctly be reported by the log as 6. I went back to 4-4. Used up one charge before the scripting kicked in and the max was reported as 4 (should be 6) but matches the initial count. Using other numbers changed the max charge value reported by the log. Changed some values around and I did see the one off error, but with other values such as initial 4-6 with max 10, the max was reported as 7. Could this be some sort of rounding issue with how Myth stores that value and the parameter does not use the same method to extract it?
User avatar
Bug Finder Extraordinaire
Posts: 4687
Joined: Sun Mar 21, 2004 2:14 pm
Location: Texas

Re: Query unit action - max charges flag wrong

Postby Filorarynut » Sat Feb 03, 2018 12:02 am

I am like you I want to know if I can fix it myself? Or do I have to wait for a fix?
Posts: 2
Joined: Fri Feb 02, 2018 10:31 pm

Re: Query unit action - max charges flag wrong

Postby Myrd » Tue Feb 06, 2018 1:17 am

There's two cases. If the held object is flagged _artifact_projectile_pickup_adds_charges_flag, then it will return the maximum_charges value (without the off-by-one).

If not, then it will return the max of the range + 1. So indeed if it's 4-4, it would return "5" incorrectly. I agree it's a bug, but at this point, I'd rather not change it, in case plugins are using it and are doing the logic to subtract 1 themselves.
Site Admin
Posts: 3755
Joined: Fri Mar 19, 2004 10:17 pm

Return to Map Making Support

Who is online

Users browsing this forum: No registered users and 1 guest