Issues with Counters and Dar

A forum for reporting bugs NOT related to custom plugins.

Moderator: MacroQuest Developers

plure
orc pawn
orc pawn
Posts: 16
Joined: Tue Mar 15, 2016 8:24 am

Issues with Counters and Dar

Post by plure » Fri May 11, 2018 12:16 am

${Me.Counters}, ${Me.Buff[blah].Counters}, ${Me.Buff[blah].Dar} and ${Me.Dar} reports 0, when they should give some value. I'm not super knowledge about SlotData, but after some testing with a limited number of cases (4) it appears that we need to change:

Code: Select all

pChar2->Buff[k].SlotData[i];
to

Code: Select all

pChar2->Buff[k].SlotData[i+1];
Obviously 4 cases don't make enough data but hopefully this helps. There was an additional error in ${Me.Dar} that needs to be corrected (it was only checking detrimental and group beneficial buffs).

Original: ${Me.Dar}

Code: Select all

	case Dar://returns combined number of spell and damage "absorbment"
		Dest.DWord = 0;//should probably split these into spell vs melee
		Dest.Type = pIntType;
		if (PCHARINFO2 pChar2 = GetCharInfo2()) {
			for (unsigned long k = 0; k < NUM_LONG_BUFFS; k++) {
				if (PSPELL pSpell = GetSpellByID(pChar2->Buff[k].SpellID)) {
					if (pSpell->SpellType != 1) {
						LONG slots = GetSpellNumEffects(pSpell);
						for (LONG i = 0; i < slots; i++) {
							LONG attrib = GetSpellAttrib(pSpell, i);
							if (attrib == 55 /*Absorb Damage*/ || attrib == 78 /*SpellShield*/
								|| attrib == 161 /*Mitigate Spell Damage*/ || attrib == 162 /*Mitigate Melee Damage*/
								|| attrib == 450 /*DoT Guard*/ || attrib == 451 /*Melee Threshold Guard*/
								|| attrib == 452 /*Spell Threshold Guard*/) {
								Dest.DWord += pChar2->Buff[k].SlotData[i];
							}
						}
					}
				}
			}
		}
		return true;
New: ${Me.Dar}

Code: Select all

	case Dar://returns combined number of spell and damage "absorbment"
		Dest.DWord = 0;//should probably split these into spell vs melee
		Dest.Type = pIntType;
		if (PCHARINFO2 pChar2 = GetCharInfo2()) {
			for (unsigned long k = 0; k < NUM_LONG_BUFFS; k++) {
				if (PSPELL pSpell = GetSpellByID(pChar2->Buff[k].SpellID)) {
					if (pSpell->SpellType != 0) {
						LONG slots = GetSpellNumEffects(pSpell);
						for (LONG i = 0; i < slots; i++) {
							LONG attrib = GetSpellAttrib(pSpell, i);
							if (attrib == 55 /*Absorb Damage*/ || attrib == 78 /*SpellShield*/
								|| attrib == 161 /*Mitigate Spell Damage*/ || attrib == 162 /*Mitigate Melee Damage*/
								|| attrib == 450 /*DoT Guard*/ || attrib == 451 /*Melee Threshold Guard*/
								|| attrib == 452 /*Spell Threshold Guard*/) {
								Dest.DWord += pChar2->Buff[k].SlotData[i+1];
							}
						}
					}
				}
			}
		}
		return true;
Original: ${Me.Counters}

Code: Select all

	case Counters://this case adds all resist Counters and returns that, why is this useful?
		Dest.DWord = 0;//should we split these into 4? one for each debuff?
		Dest.Type = pIntType;
		if (PCHARINFO2 pChar2 = GetCharInfo2()) {
			for (unsigned long k = 0; k < NUM_LONG_BUFFS; k++) {
				if (PSPELL pSpell = GetSpellByID(pChar2->Buff[k].SpellID)) {
					if (pSpell->SpellType == 0) {
						LONG slots = GetSpellNumEffects(pSpell);
						for (LONG i = 0; i < slots; i++) {
							LONG attrib = GetSpellAttrib(pSpell, i);
							if (attrib == 35 /*Disease Counter*/ || attrib == 36 /*Poison*/ || attrib == 116 /*Curse*/ || attrib == 369/*Corruption*/) {
								Dest.DWord += pChar2->Buff[k].SlotData[i];
							}
						}
					}
				}
			}
		}
		return true;
New: ${Me.Counters}

Code: Select all

	case Counters://this case adds all resist Counters and returns that, why is this useful?
		Dest.DWord = 0;//should we split these into 4? one for each debuff?
		Dest.Type = pIntType;
		if (PCHARINFO2 pChar2 = GetCharInfo2()) {
			for (unsigned long k = 0; k < NUM_LONG_BUFFS; k++) {
				if (PSPELL pSpell = GetSpellByID(pChar2->Buff[k].SpellID)) {
					if (pSpell->SpellType == 0) {
						LONG slots = GetSpellNumEffects(pSpell);
						for (LONG i = 0; i < slots; i++) {
							LONG attrib = GetSpellAttrib(pSpell, i);
							if (attrib == 35 /*Disease Counter*/ || attrib == 36 /*Poison*/ || attrib == 116 /*Curse*/ || attrib == 369/*Corruption*/) {
								Dest.DWord += pChar2->Buff[k].SlotData[i+1];
							}
						}
					}
				}
			}
		}
		return true;
Original: ${Me.Buff[blah].Dar}

Code: Select all

	case Dar:
		if (PSPELL pSpell = GetSpellByID(pBuff->SpellID))
		{
			if (pSpell->SpellType != 0)
			{
				Dest.DWord = 0;
				Dest.Type = pIntType;
				LONG slots = GetSpellNumEffects(pSpell);
				for (LONG i = 0; i < slots; i++) {
					LONG attrib = GetSpellAttrib(pSpell, i);
					if (attrib == 55 || attrib == 78 || attrib == 161 || attrib == 162 || attrib == 450 || attrib == 451 || attrib == 452)
						Dest.DWord += pBuff->SlotData[i];
				}
				return true;
			}
		}
		return false;
New: ${Me.Buff[blah].Dar}

Code: Select all

	case Dar:
		if (PSPELL pSpell = GetSpellByID(pBuff->SpellID))
		{
			if (pSpell->SpellType != 0)
			{
				Dest.DWord = 0;
				Dest.Type = pIntType;
				LONG slots = GetSpellNumEffects(pSpell);
				for (LONG i = 0; i < slots; i++) {
					LONG attrib = GetSpellAttrib(pSpell, i);
					if (attrib == 55 || attrib == 78 || attrib == 161 || attrib == 162 || attrib == 450 || attrib == 451 || attrib == 452)
						Dest.DWord += pBuff->SlotData[i+1];
				}
				return true;
			}
		}
		return false;
Original: ${Me.Buff[blah].Counters}

Code: Select all

	case Counters:
		if (PSPELL pSpell = GetSpellByID(pBuff->SpellID))
		{
			if (pSpell->SpellType == 0) {
				Dest.DWord = 0;
				Dest.Type = pIntType;
				LONG slots = GetSpellNumEffects(pSpell);
				for (LONG i = 0; i < slots; i++) {
					LONG attrib = GetSpellAttrib(pSpell, i);
					if (attrib == 35 || attrib == 36 || attrib == 116 || attrib == 369)
						Dest.DWord += pBuff->SlotData[i];
				}
				return true;
			}
		}
		return false;
New: ${Me.Buff[blah].Counters}

Code: Select all

	case Counters:
		if (PSPELL pSpell = GetSpellByID(pBuff->SpellID))
		{
			if (pSpell->SpellType == 0) {
				Dest.DWord = 0;
				Dest.Type = pIntType;
				LONG slots = GetSpellNumEffects(pSpell);
				for (LONG i = 0; i < slots; i++) {
					LONG attrib = GetSpellAttrib(pSpell, i);
					if (attrib == 35 || attrib == 36 || attrib == 116 || attrib == 369)
						Dest.DWord += pBuff->SlotData[i+1];
				}
				return true;
			}
		}
		return false;

SwiftyMUSE
Developer
Developer
Posts: 1205
Joined: Tue Sep 23, 2003 10:52 pm

Re: Issues with Counters and Dar

Post by SwiftyMUSE » Fri May 11, 2018 12:59 pm

The way we are using slotdata is just wrong. It has nothing to do with the slot number so basing what we pull from there via slot (i) is just wrong.
PayPal: Donate to SwiftyMUSE
Bitcoin: 1LuQ6YcEAWxF3fm9yWMiro4K582je7364V
Krono: PM me

dont_know_at_all wrote:Gee, if only there was a way to correctly report a crash...

plure
orc pawn
orc pawn
Posts: 16
Joined: Tue Mar 15, 2016 8:24 am

Re: Issues with Counters and Dar

Post by plure » Fri May 11, 2018 2:36 pm

I don't have a solution then :cry:

SwiftyMUSE
Developer
Developer
Posts: 1205
Joined: Tue Sep 23, 2003 10:52 pm

Re: Issues with Counters and Dar

Post by SwiftyMUSE » Fri May 11, 2018 6:29 pm

plure wrote:
Fri May 11, 2018 2:36 pm
I don't have a solution then :cry:
That's why I'm looking at it...
PayPal: Donate to SwiftyMUSE
Bitcoin: 1LuQ6YcEAWxF3fm9yWMiro4K582je7364V
Krono: PM me

dont_know_at_all wrote:Gee, if only there was a way to correctly report a crash...