mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
Many fixes to regressions in perl and cleaning up the final interface
This commit is contained in:
-356
@@ -4672,362 +4672,6 @@ bool Client::SpellGlobalCheck(uint16 Spell_ID, uint16 Char_ID) {
|
||||
return false; // Default is false
|
||||
}
|
||||
|
||||
//this is one nasty function... FindType and FindSpell are rather complex operations...
|
||||
/*void Mob::CheckBuffs() {
|
||||
if (!IsCasting()) {
|
||||
|
||||
//try to summon a pet if we havent yet
|
||||
CheckPet();
|
||||
|
||||
uint8 newtype[15] = { SE_ArmorClass, SE_STR, SE_DEX, SE_AGI, SE_WIS,
|
||||
SE_INT, SE_CHA, SE_AttackSpeed, SE_MovementSpeed,
|
||||
SE_DamageShield, SE_ResistFire, SE_ResistCold,
|
||||
SE_ResistMagic, SE_ResistPoison, SE_ResistDisease };
|
||||
for (int h=0; h<15; h++) {
|
||||
if (!this->FindType(newtype[h])) {
|
||||
uint16 buffid = FindSpell(this->class_, this->level,
|
||||
newtype[h], SPELLTYPE_SELF, 0,
|
||||
GetMana());
|
||||
if (buffid != 0) {
|
||||
this->CastSpell(buffid, this->GetID());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Mob::CheckPet() {
|
||||
if(HasPet())
|
||||
return;
|
||||
uint16 buffid = 0;
|
||||
if ((GetClass() == NECROMANCER || GetClass() == MAGICIAN)) {
|
||||
if (this->GetClass() == MAGICIAN) {
|
||||
buffid = FindSpell(class_, level,
|
||||
SE_SummonPet, SPELLTYPE_OTHER, 0,
|
||||
GetMana());
|
||||
} else if (GetClass() == NECROMANCER) {
|
||||
buffid = FindSpell(class_, level,
|
||||
SE_NecPet, SPELLTYPE_OTHER, 0,
|
||||
GetMana());
|
||||
}
|
||||
if (buffid != 0) {
|
||||
CastSpell(buffid, GetID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint16 Mob::FindSpell(uint16 classp, uint16 level, int type,
|
||||
FindSpellType spelltype, float distance,
|
||||
int32 mana_avail) {
|
||||
int i,j;
|
||||
|
||||
int bestvalue = -1;
|
||||
int bestid = 0;
|
||||
|
||||
if (classp < 1)
|
||||
return 0;
|
||||
if (level < 1)
|
||||
return 0;
|
||||
classp = GetEQArrayEQClass(classp);
|
||||
|
||||
// purpose: find a suited spell for a class and level and type
|
||||
// the if's are here to filter out anything which isnt normal.
|
||||
// its possible that we miss some valid spells, but who cares.
|
||||
|
||||
for (i = 0; i < SPDAT_RECORDS; i++) {
|
||||
if(!IsValidSpell(i))
|
||||
continue;
|
||||
// Filter all spells that should never be used
|
||||
if (spells[i].effectid[0] == SE_NegateIfCombat)
|
||||
continue;
|
||||
if (spells[i].targettype == ST_Group)
|
||||
continue;
|
||||
if (i == 2632) // fix for obsolete BST pet summon spell
|
||||
continue;
|
||||
if (i == 1576) // fix for torpor
|
||||
continue;
|
||||
if (spells[i].cast_time < 11)
|
||||
continue;
|
||||
if (spells[i].mana == 0)
|
||||
continue;
|
||||
|
||||
// now for closer checks
|
||||
if (spelltype == SPELLTYPE_SELF) {
|
||||
if ( i == 357) // fix for dark empathy
|
||||
continue;
|
||||
// check buffs 12 would be max, but 90% of all effects are in the first 4 slots
|
||||
for (j = 0; j < 5; j++) {
|
||||
// fix for pets
|
||||
if ( spells[i].effectid[j] == SE_Illusion &&
|
||||
type != SE_Illusion) // only let illusions thru if explicitly requested
|
||||
continue;
|
||||
if (spells[i].effectid[j] == type &&
|
||||
spells[i].goodEffect != 0 &&
|
||||
spells[i].classes[classp] <= level &&
|
||||
spells[i].classes[classp] <= 65 &&
|
||||
(spells[i].recast_time < 10000 ||
|
||||
type == SE_SummonPet ||
|
||||
type == SE_SummonBSTPet) && // fix for druid pets
|
||||
(type == SE_AbsorbMagicAtt || type == SE_Rune ||
|
||||
type == SE_NecPet || type == SE_SummonPet ||
|
||||
spells[i].components[0] == -1 ) &&
|
||||
spells[i].targettype != ST_Undead && // for necro mend series
|
||||
spells[i].targettype != ST_Group && // fix for group spells
|
||||
spells[i].targettype != ST_Pet && // fix for beastlords casting pet heals on self
|
||||
spells[i].targettype != ST_Summoned && // fix for vs. summoned spells on normal npcs
|
||||
spells[i].targettype != ST_AETarget && // dont let em cast AEtarget spells
|
||||
spells[i].mana <= mana_avail &&
|
||||
spells[i].range >= distance) {
|
||||
int32 spellvalue;
|
||||
|
||||
// lets assume pet is always better if higher, so no formula needed
|
||||
if (type == SE_NecPet ||
|
||||
type == SE_SummonPet ||
|
||||
type == SE_SummonBSTPet) {
|
||||
spellvalue = spells[i].classes[classp];
|
||||
} else {
|
||||
spellvalue = CalcSpellEffectValue_formula(spells[i].formula[j],
|
||||
spells[i].base[j],
|
||||
spells[i].max[j],
|
||||
level, i);
|
||||
}
|
||||
|
||||
if (abs(spellvalue) > bestvalue) {
|
||||
bestvalue = abs(spellvalue);
|
||||
bestid = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (spelltype == SPELLTYPE_OFFENSIVE) {
|
||||
// check offensive spells
|
||||
for (j = 0; j < 5; j++) {
|
||||
if (spells[i].effectid[j] == SE_Illusion &&
|
||||
type != SE_Illusion) // only let illusions thru if explicitly requested
|
||||
continue;
|
||||
if (spells[i].effectid[j] == type &&
|
||||
spells[i].goodEffect == 0 &&
|
||||
spells[i].classes[classp] <= level &&
|
||||
spells[i].classes[classp] <= 65 &&
|
||||
spells[i].recast_time < 10000 &&
|
||||
spells[i].components[0] == -1 &&
|
||||
spells[i].mana <= mana_avail &&
|
||||
spells[i].targettype != ST_Undead && // thats for the necro mend series
|
||||
spells[i].targettype != ST_Group && // fix for group spells
|
||||
spells[i].targettype != ST_Pet && // fix for beastlords casting pet heals on self
|
||||
spells[i].targettype != ST_Summoned && // fix for vs. summoned spells on normal npcs
|
||||
spells[i].targettype != ST_AETarget && // dont let em cast AEtarget spells
|
||||
spells[i].range >= distance) {
|
||||
int32 spellvalue = CalcSpellEffectValue_formula(spells[i].formula[j],
|
||||
spells[i].base[j],
|
||||
spells[i].max[j],
|
||||
level, i);
|
||||
if ( abs(spellvalue) > bestvalue ) {
|
||||
bestvalue = abs(spellvalue);
|
||||
bestid = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (spelltype == SPELLTYPE_OTHER) {
|
||||
if ( i == 357) // fix for dark empathy
|
||||
continue;
|
||||
// healing and such
|
||||
for (j = 0; j < 5; j++) {
|
||||
if (spells[i].effectid[j] == SE_Illusion &&
|
||||
type != SE_Illusion) // only let illusions thru if explicitly requested
|
||||
continue;
|
||||
if (spells[i].effectid[j] == type &&
|
||||
spells[i].targettype != ST_Self &&
|
||||
spells[i].goodEffect != 0 &&
|
||||
spells[i].classes[classp] <= level &&
|
||||
spells[i].classes[classp] <= 65 &&
|
||||
spells[i].recast_time < 10000 &&
|
||||
spells[i].components[0] == -1 &&
|
||||
spells[i].targettype != ST_Undead && // thats for the necro mend series
|
||||
spells[i].targettype != ST_Group && // fix for group spells
|
||||
spells[i].targettype != ST_Pet && // fix for beastlords casting pet heals on self
|
||||
spells[i].targettype != ST_Summoned && // fix for vs. summoned spells on normal npcs
|
||||
spells[i].targettype != ST_AETarget && // dont let em cast AEtarget spells
|
||||
spells[i].mana <= mana_avail &&
|
||||
spells[i].range >= distance) {
|
||||
int32 spellvalue = CalcSpellEffectValue_formula(spells[i].formula[j],
|
||||
spells[i].base[j],
|
||||
spells[i].max[j],
|
||||
level, i);
|
||||
if ( abs(spellvalue) > bestvalue ) {
|
||||
bestvalue = abs(spellvalue);
|
||||
bestid = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // for i
|
||||
|
||||
// g_LogFile.write("for combination [class %02d][level %02d][SE_type %02d][type %02d] i selected the spell: %s",
|
||||
// classp, level, (uint16)type, uint16(spelltype), spells[bestid].name);
|
||||
return bestid;
|
||||
}
|
||||
|
||||
#if 0
|
||||
uint16 Mob::FindSpell(uint16 classp, uint16 level, uint8 type, uint8 spelltype) {
|
||||
if (this->casting_spell_id != 0)
|
||||
return 0;
|
||||
|
||||
if (spelltype == 2) // for future use
|
||||
spelltype = 0;
|
||||
|
||||
//int count=0;
|
||||
uint16 bestsofar = 0;
|
||||
uint16 bestspellid = 0;
|
||||
for (int i = 0; i < SPDAT_RECORDS; i++) {
|
||||
if ((IsLifetapSpell(i) && spelltype == 1) || (spells[i].targettype != ST_Group && spells[i].targettype != ST_Undead && spells[i].targettype != ST_Summoned && spells[i].targettype != ST_Pet && strstr(spells[i].name,"Summoning") == nullptr)) {
|
||||
int Canuse = CanUseSpell(i, classp, level);
|
||||
if (Canuse != 0) {
|
||||
for (int z=0; z < 12; z++) {
|
||||
int spfo = CalcSpellValue(spells[i].formula[z], spells[i].base[z], spells[i].max[z], this->GetLevel());
|
||||
if (spells[i].effectid[z] == SE_ArmorClass && type == SE_ArmorClass && !FindBuff(i)) {
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
if (spells[i].effectid[z] == SE_TotalHP && type == SE_TotalHP && !FindBuff(i)) {
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
if (spells[i].effectid[z] == SE_STR && type == SE_STR && !FindBuff(i)) {
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
if (spells[i].effectid[z] == SE_DEX && type == SE_DEX && !FindBuff(i)) {
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (spells[i].effectid[z] == SE_AGI && type == SE_AGI && !FindBuff(i)) {
|
||||
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (spells[i].effectid[z] == SE_WIS && type == SE_WIS && !FindBuff(i)) {
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (spells[i].effectid[z] == SE_INT && type == SE_INT && !FindBuff(i)) {
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
if (spells[i].effectid[z] == SE_CHA && type == SE_CHA && !FindBuff(i)) {
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (spells[i].effectid[z] == SE_MovementSpeed && type == SE_MovementSpeed && !FindBuff(i)) {
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (spells[i].effectid[z] == SE_AttackSpeed && type == SE_AttackSpeed && !FindBuff(i)) {
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
if (spells[i].effectid[z] == SE_ResistFire && type == SE_ResistFire && !FindBuff(i)) {
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
if (spells[i].effectid[z] == SE_ResistCold && type == SE_ResistCold && !FindBuff(i)) {
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
if (spells[i].effectid[z] == SE_ResistMagic && type == SE_ResistMagic && !FindBuff(i)) {
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
if (spells[i].effectid[z] == SE_ResistDisease && type == SE_ResistDisease && !FindBuff(i)) {
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
|
||||
}
|
||||
}
|
||||
if (spells[i].effectid[z] == SE_ResistPoison && type == SE_ResistPoison && !FindBuff(i)) {
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
if (spells[i].effectid[z] == SE_DamageShield && type == SE_DamageShield && !FindBuff(i)) {
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
if (spells[i].effectid[z] == SE_CurrentHPOnce && type == SE_CurrentHPOnce && !FindBuff(i)) {
|
||||
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
if (spells[i].effectid[z] == SE_SummonPet && type == SE_SummonPet && !FindBuff(i)) {
|
||||
if (Canuse > bestsofar) {
|
||||
bestsofar = Canuse;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
if (spells[i].effectid[z] == SE_NecPet && type == SE_NecPet && !FindBuff(i)) {
|
||||
if (Canuse > bestsofar) {
|
||||
bestsofar = Canuse;
|
||||
bestspellid = i;
|
||||
}
|
||||
}
|
||||
if (spells[i].effectid[z] == SE_CurrentHP && type == SE_CurrentHP && !FindBuff(i)) {
|
||||
if (spfo < 0 && (spells[i].buffduration + spfo) < bestsofar && spelltype == 1) {
|
||||
bestsofar = ((spells[i].buffduration * -1) + spfo);
|
||||
bestspellid = i;
|
||||
}
|
||||
if ((spfo + spells[i].buffduration) > bestsofar && spfo > 0 && spelltype == 0) {
|
||||
bestsofar = spfo + spells[i].buffduration;
|
||||
bestspellid = i;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bestspellid;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
// TODO get rid of this
|
||||
int16 Mob::GetBuffSlotFromType(uint16 type) {
|
||||
uint32 buff_count = GetMaxTotalSlots();
|
||||
|
||||
Reference in New Issue
Block a user