0
\$\begingroup\$

Ok, so in my game you have a party of four characters that you control one at a time, each of which can lose health and die independently of each other. All of the player character objects use essentially the exact same code controlling their "deaths", (just with their own object variables and flags that get set and triggered etc.), but for whatever reason identical code does not produce identical results for all of the characters.

In particular, one of the character classes, the Alchemist, absolutely refuses to either set their "dead" flag to True properly, or at the very least the sections of code that are dependent upon "dead" being true do not appear to be acknowledging that it is. I've gone over all its events several times and monitored its behaviors in-game very closely, and everything about its malfunctioning behavior can be traced to the fact that it's completely ignoring the "dead = true;" line in one of its events while still executing the remaining code that follows it. Absolutely nothing else in any of its events sets or modifies this variable outside of its initialization in the Create event; it's just this one line of code that works perfectly for every other character object refuses to do its one job for this object in particular, and everything is falling apart because of it.

Does anyone know why this might be happening? Is there some quirk of proper GML practice that I'm not using?

If it helps, here's the code that gets triggered when a character is made "dead"

else if(wounded and position == 0 and !dead)
{
    dead = true;
    instance_create_layer(x,y,layer,obj_alchemist_corpse);
    death_sort();
}

Everything else is just a series of If statements that are triggered by 'dead' being true, but again, it would appear that one object in particular is executing the code in the above statement without actually setting 'dead' to true, and I would like to know why or why not.

EDIT: Forget what I said about an alchemist; further testing indicates it's just the second character in your party line of four that isn't getting their flag properly set.

\$\endgroup\$
  • \$\begingroup\$ Can you provide some more code? If the second character can't set its own flag to true it may be due to the first character's actions, so the cause can be found into the code executed before the snippet you included in your question. \$\endgroup\$ – liggiorgio Jun 7 '18 at 16:21
  • \$\begingroup\$ Is position the index in your party? So that the second character is expecting value '1' though you are checking on '0' as well? \$\endgroup\$ – liggiorgio Jun 7 '18 at 16:22
1
\$\begingroup\$

Nevermind

Turns out, the problem was with the way I handled generating your selected party and the fact that modifying an object in a room with Creation Code doesn't completely replace the contents of the Create event, which long story short was secretly making hidden instances of the second character in your party underneath all the correct ones and throwing everything askew. This has since been rectified and now everything works just the way it should.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.