Example #1
0
void SetBlueSpell(CCharEntity* PChar, CBlueSpell* PSpell, uint8 slotIndex, bool addingSpell) {

	//sanity check
	if (slotIndex < 20) {
		if (PSpell != NULL && PSpell->getID() > 0x200)
        {
			if (addingSpell) 
            {
                if (!IsSpellSet(PChar, PSpell) && HasEnoughSetPoints(PChar, PSpell, slotIndex))
                {
				    // Blue spells in SetBlueSpells must be 0x200 ofsetted so it's 1 byte per spell.
                    if (PChar->m_SetBlueSpells[slotIndex] != 0)
                    {
                        CBlueSpell* POldSpell = (CBlueSpell*)spell::GetSpell(PChar->m_SetBlueSpells[slotIndex] + 0x200);
                        PChar->delModifiers(&POldSpell->modList);
                    }
				    PChar->m_SetBlueSpells[slotIndex] = PSpell->getID() - 0x200;
				    PChar->addModifiers(&PSpell->modList);
                }
			}
			else
            {
				PChar->m_SetBlueSpells[slotIndex] = 0x00;
				PChar->delModifiers(&PSpell->modList);
			}
            SaveSetSpells(PChar);
		}
	}
}
Example #2
0
void ValidateBlueSpells(CCharEntity* PChar)
{
    CheckSpellLevels(PChar);

    uint8 maxSetPoints = GetTotalBlueMagicPoints(PChar);
    uint8 currentPoints = 0;

    for (int slot = 0; slot < 20; slot++)
    {
        if (PChar->m_SetBlueSpells[slot] != 0)
        {
            CBlueSpell* PSpell = (CBlueSpell*)spell::GetSpell(PChar->m_SetBlueSpells[slot] + 0x200);
            if (currentPoints + PSpell->getSetPoints() > maxSetPoints)
            {
                SetBlueSpell(PChar, PSpell, slot, false);
            }
            else
            {
                currentPoints += PSpell->getSetPoints();
            }
        }
    }

    CompactSpells(PChar);

    uint8 maxSlots = GetTotalSlots(PChar);

    for (int slot = maxSlots; slot < 20; slot++)
    {
        if (PChar->m_SetBlueSpells[slot] != 0)
        {
            SetBlueSpell(PChar, (CBlueSpell*)spell::GetSpell(PChar->m_SetBlueSpells[slot] + 0x200), slot, false);
        }
    }

    SaveSetSpells(PChar);
    PChar->status = STATUS_UPDATE;
    charutils::BuildingCharTraitsTable(PChar);
	PChar->pushPacket(new CCharJobExtraPacket(PChar, true));
	PChar->pushPacket(new CCharJobExtraPacket(PChar, false));
	PChar->pushPacket(new CCharStatsPacket(PChar));
	charutils::CalculateStats(PChar);
	PChar->UpdateHealth();
	PChar->pushPacket(new CCharHealthPacket(PChar));
}
Example #3
0
void UnequipAllBlueSpells(CCharEntity* PChar)
{
    for (int slot = 0; slot < 20; slot++)
    {
        if (PChar->m_SetBlueSpells[slot] != 0)
        {
            CBlueSpell* PSpell = (CBlueSpell*)spell::GetSpell(static_cast<SpellID>(PChar->m_SetBlueSpells[slot] + 0x200));
            PChar->m_SetBlueSpells[slot] = 0;
            PChar->delModifiers(&PSpell->modList);
        }
    }
    charutils::BuildingCharTraitsTable(PChar);
	PChar->pushPacket(new CCharJobExtraPacket(PChar, true));
	PChar->pushPacket(new CCharJobExtraPacket(PChar, false));
	PChar->pushPacket(new CCharStatsPacket(PChar));
	charutils::CalculateStats(PChar);
	PChar->UpdateHealth();
    SaveSetSpells(PChar);
    PChar->updatemask |= UPDATE_HP;
}
Example #4
0
void ValidateBlueSpells(CCharEntity* PChar)
{
    CheckSpellLevels(PChar);

    uint8 maxSetPoints = GetTotalBlueMagicPoints(PChar);
    uint8 currentPoints = 0;

    for (int slot = 0; slot < 20; slot++)
    {
        if (PChar->m_SetBlueSpells[slot] != 0)
        {
            CBlueSpell* PSpell = (CBlueSpell*)spell::GetSpell(static_cast<SpellID>(PChar->m_SetBlueSpells[slot] + 0x200));
            if (currentPoints + PSpell->getSetPoints() > maxSetPoints)
            {
                SetBlueSpell(PChar, PSpell, slot, false);
            }
            else
            {
                currentPoints += PSpell->getSetPoints();
            }
        }
    }

    CompactSpells(PChar);

    uint8 maxSlots = GetTotalSlots(PChar);

    for (int slot = maxSlots; slot < 20; slot++)
    {
        if (PChar->m_SetBlueSpells[slot] != 0)
        {
            SetBlueSpell(PChar, (CBlueSpell*)spell::GetSpell(static_cast<SpellID>(PChar->m_SetBlueSpells[slot] + 0x200)), slot, false);
        }
    }

    SaveSetSpells(PChar);
}