Page 1 of 1

Spell Status Issue

Posted: Thu Apr 25, 2019 5:55 am
by Ememjr
i have notice as well as others that spells on the hotbars dont always show like they should
ie
in queued state when should not be
dark when should be lit up etc
well this is apparently controlled by things like Unlockspell, lockspell, queue and unqueue

and those commands change the spell->status which is a bit map byte so the bit for queue appears to be bit 2 (value 4)
so if you have a status of 0 and want the spell to show queued you set status to 4
now here lies the problem

Code: Select all

void Player::ModifySpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast, int16 recast) {
	if (modify_recast) {
		spell->recast = recast;
		spell->recast_available = Timer::GetCurrentTime2()	+ (recast * 100);
	}

	if (modify_recast || spell->recast_available <= Timer::GetCurrentTime2() || value == 4)
		spell->status += value;
}
this modifie the status if the value is 4 it will ADD 4 to the current status, but wait theres more
if queuespell get called again it will add 4 more and make it status 8 which it should not be doing
should this not be doing something to set the bits adding or substacting a value

Re: Spell Status Issue

Posted: Thu Apr 25, 2019 2:38 pm
by tyrbo
This is another thing I addressed a long time ago.

I changed my code as follows:

The following functions were added for spell status.

Code: Select all

void Player::AddSpellStatus(SpellBookEntry* spell, sint16 value) {
  if (!(spell->status & value))
    spell->status += value;
}

void Player::RemoveSpellStatus(SpellBookEntry* spell, sint16 value) {
  if (spell->status & value)
    spell->status -= value;
}

Code: Select all

#define SPELL_STATUS_LEARNED 1
#define SPELL_STATUS_ENABLED 2
#define SPELL_STATUS_QUEUED 4
#define SPELL_STATUS_UNKNOWN4 8
#define SPELL_STATUS_UNKNOWN5 16
#define SPELL_STATUS_UNKNOWN6 32
#define SPELL_STATUS_READY 64
#define SPELL_STATUS_UNKNOWN7 128
and then we can add and remove status as necessary.

Re: Spell Status Issue

Posted: Thu Apr 25, 2019 3:07 pm
by Ememjr
thats basically the same thing i added, just didnt know what the 2 was

Re: Spell Status Issue

Posted: Thu Apr 25, 2019 6:25 pm
by tyrbo
Can't say I'm sure what the 1 and 2 are for. Just guessing when I set that up.