Dink Engine bug - global variables get confused
I've come across a bug... or rather WC did, in PQ in which the powerful magic spells are instantly recharged.
It seems that the global varilables &magic_level and &magic_cost get confused with the variable &magic (as all three have the first 5 letters in common) so that if your &magic is say 18 then &magic_level becomes 18_level and &magic_cost becomes 18_cost.
When this happens and you arm a new weapon (not magic, arming a new magic resets things properly, though I don't know why) - you get instant (in human time) magic... be it Deus Strike or whatever.
I can't think of a way around this as I can't guarantee what magic is in which slot (or I'd do a quick change magic to fireball, arm it, change to &cur_magic and re-arm it) - compare_magic doesn't work, of course.
Any takers on this one?
It seems that the global varilables &magic_level and &magic_cost get confused with the variable &magic (as all three have the first 5 letters in common) so that if your &magic is say 18 then &magic_level becomes 18_level and &magic_cost becomes 18_cost.
When this happens and you arm a new weapon (not magic, arming a new magic resets things properly, though I don't know why) - you get instant (in human time) magic... be it Deus Strike or whatever.
I can't think of a way around this as I can't guarantee what magic is in which slot (or I'd do a quick change magic to fireball, arm it, change to &cur_magic and re-arm it) - compare_magic doesn't work, of course.
Any takers on this one?
I have seen the effect once (one of other DMods, not PQ) - but the source of the problem was in the weapon's script. It reset the magic_cost to 0.
: I've come across a bug... or rather WC did, in PQ in which the powerful magic spells are instantly recharged.
: It seems that the global varilables &magic_level and &magic_cost get confused with the variable &magic (as all three have the first 5 letters in common) so that if your &magic is say 18 then &magic_level becomes 18_level and &magic_cost becomes 18_cost.
: When this happens and you arm a new weapon (not magic, arming a new magic resets things properly, though I don't know why) - you get instant (in human time) magic... be it Deus Strike or whatever.
: I can't think of a way around this as I can't guarantee what magic is in which slot (or I'd do a quick change magic to fireball, arm it, change to &cur_magic and re-arm it) - compare_magic doesn't work, of course.
: Any takers on this one?
I've incountered similar, though I not quite sure I understand the problem your're describing. I know that &magic_level will become 18_level (where 18 is &magic) if used in a say command and I think also be treated as 18 in an if statment, but it work correctly in an an assignment statment (which may be the only place it works right), does that explain anything?
I don't quite understand the bug, I didn't notice anything odd when arming weapons.
: It seems that the global varilables &magic_level and &magic_cost get confused with the variable &magic (as all three have the first 5 letters in common) so that if your &magic is say 18 then &magic_level becomes 18_level and &magic_cost becomes 18_cost.
: When this happens and you arm a new weapon (not magic, arming a new magic resets things properly, though I don't know why) - you get instant (in human time) magic... be it Deus Strike or whatever.
: I can't think of a way around this as I can't guarantee what magic is in which slot (or I'd do a quick change magic to fireball, arm it, change to &cur_magic and re-arm it) - compare_magic doesn't work, of course.
: Any takers on this one?
I've incountered similar, though I not quite sure I understand the problem your're describing. I know that &magic_level will become 18_level (where 18 is &magic) if used in a say command and I think also be treated as 18 in an if statment, but it work correctly in an an assignment statment (which may be the only place it works right), does that explain anything?
I don't quite understand the bug, I didn't notice anything odd when arming weapons.
: : I've come across a bug... or rather WC did, in PQ in which the powerful magic spells are instantly recharged.
: : It seems that the global varilables &magic_level and &magic_cost get confused with the variable &magic (as all three have the first 5 letters in common) so that if your &magic is say 18 then &magic_level becomes 18_level and &magic_cost becomes 18_cost.
: : When this happens and you arm a new weapon (not magic, arming a new magic resets things properly, though I don't know why) - you get instant (in human time) magic... be it Deus Strike or whatever.
: : I can't think of a way around this as I can't guarantee what magic is in which slot (or I'd do a quick change magic to fireball, arm it, change to &cur_magic and re-arm it) - compare_magic doesn't work, of course.
: : Any takers on this one?
: I've incountered similar, though I not quite sure I understand the problem your're describing. I know that &magic_level will become 18_level (where 18 is &magic) if used in a say command and I think also be treated as 18 in an if statment, but it work correctly in an an assignment statment (which may be the only place it works right), does that explain anything?
: I don't quite understand the bug, I didn't notice anything odd when arming weapons.
Yeah, I didn't seem to have any problems with it in PQ either... odd.
Anyway, there is an easy work-around, as Paul hinted at. Just do something like this:
int &temp = &magic_level;
if (&temp > &sillynumber)
{
&temp -= 5;
}
&magic_level = &temp;
Or whatever else you need to do. I had to do something similar with FIAT v0.99 in order to get the mana potions to work.
: : It seems that the global varilables &magic_level and &magic_cost get confused with the variable &magic (as all three have the first 5 letters in common) so that if your &magic is say 18 then &magic_level becomes 18_level and &magic_cost becomes 18_cost.
: : When this happens and you arm a new weapon (not magic, arming a new magic resets things properly, though I don't know why) - you get instant (in human time) magic... be it Deus Strike or whatever.
: : I can't think of a way around this as I can't guarantee what magic is in which slot (or I'd do a quick change magic to fireball, arm it, change to &cur_magic and re-arm it) - compare_magic doesn't work, of course.
: : Any takers on this one?
: I've incountered similar, though I not quite sure I understand the problem your're describing. I know that &magic_level will become 18_level (where 18 is &magic) if used in a say command and I think also be treated as 18 in an if statment, but it work correctly in an an assignment statment (which may be the only place it works right), does that explain anything?
: I don't quite understand the bug, I didn't notice anything odd when arming weapons.
Yeah, I didn't seem to have any problems with it in PQ either... odd.
Anyway, there is an easy work-around, as Paul hinted at. Just do something like this:
int &temp = &magic_level;
if (&temp > &sillynumber)
{
&temp -= 5;
}
&magic_level = &temp;
Or whatever else you need to do. I had to do something similar with FIAT v0.99 in order to get the mana potions to work.
Hmmm, so having a choice menu pop up all globals is not reliable - which is where I got &magic_level and &magic_cost becoming 18_level and 18_magic.
I will try a temp variable reassign. I had tried creating 2 new globals which record and load at save machines (Basically Paul's fix for magic not being armed on loading) but this didn't fix things...
The bug is basically - Load a game, magic is loaded status bar shows fully charged. Change weapon... doesn't matter what... and then the charged bar goes, but magic is fully charged and remains so no matter how many times you use it. This doesn't change until you arm a new magic.
I will try a temp variable reassign. I had tried creating 2 new globals which record and load at save machines (Basically Paul's fix for magic not being armed on loading) but this didn't fix things...
The bug is basically - Load a game, magic is loaded status bar shows fully charged. Change weapon... doesn't matter what... and then the charged bar goes, but magic is fully charged and remains so no matter how many times you use it. This doesn't change until you arm a new magic.
: I have seen the effect once (one of other DMods, not PQ) - but the source of the problem was in the weapon's script. It reset the magic_cost to 0.
Bingo! You're right. Thank you. I'd modified a magic script and made it a weapon script - Doh!
Bingo! You're right. Thank you. I'd modified a magic script and made it a weapon script - Doh!
At first, I thought I knew what this thread was about, and the solution to the problem. But given the answers to it, I'm now confused.
My advice was to simply change the name of the variable &magic to something else. I had something similar, but different in BFTG. Sphinx had made the global variable called &map. I had script with the local variable, &map_number. Every time I would run that script, &map_number would always call &map instead. So, to fix the problem, I just changed the name of the local variable to something else. The script then worked fine.
My advice was to simply change the name of the variable &magic to something else. I had something similar, but different in BFTG. Sphinx had made the global variable called &map. I had script with the local variable, &map_number. Every time I would run that script, &map_number would always call &map instead. So, to fix the problem, I just changed the name of the local variable to something else. The script then worked fine.
: My advice was to simply change the name of the variable &magic to something else.
Yeah, but &magic_level, &magic_count, and &magic are all built-in global variables... you can't just change them and expect the game to know
Yeah, but &magic_level, &magic_count, and &magic are all built-in global variables... you can't just change them and expect the game to know

: At first, I thought I knew what this thread was about, and the solution to the problem. But given the answers to it, I'm now confused.
: My advice was to simply change the name of the variable &magic to something else. I had something similar, but different in BFTG. Sphinx had made the global variable called &map. I had script with the local variable, &map_number. Every time I would run that script, &map_number would always call &map instead. So, to fix the problem, I just changed the name of the local variable to something else. The script then worked fine.
The engine really messes up local variables with names like a glabal var with a suffix (e.g. local &goldkey will not work properly because of the global &gold). This is not the case if both vars are globals (not sure about both locals, though)
: My advice was to simply change the name of the variable &magic to something else. I had something similar, but different in BFTG. Sphinx had made the global variable called &map. I had script with the local variable, &map_number. Every time I would run that script, &map_number would always call &map instead. So, to fix the problem, I just changed the name of the local variable to something else. The script then worked fine.
The engine really messes up local variables with names like a glabal var with a suffix (e.g. local &goldkey will not work properly because of the global &gold). This is not the case if both vars are globals (not sure about both locals, though)