Query unit action - max charges flag wrong

A forum for discussing map making ideas and problems for the Myth series.
Post Reply
hmp
Posts: 146
Joined: Fri Dec 14, 2007 3:00 am

Query unit action - max charges flag wrong

Post by hmp »

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.
User avatar
Pyro
Bug Finder Extraordinaire
Posts: 4751
Joined: Sun Mar 21, 2004 2:14 pm
Location: Texas

Re: Query unit action - max charges flag wrong

Post by Pyro »

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?
Myrd
Site Admin
Posts: 4034
Joined: Fri Mar 19, 2004 10:17 pm

Re: Query unit action - max charges flag wrong

Post by Myrd »

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.
Post Reply