mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
[Spells] Update to Charm target restriction code (#1666)
* charm target restrictions * fixed * Update spells.cpp * Update spells.cpp * Update spells.cpp only send spell bar when we have to, avoid potential exploit. * logs
This commit is contained in:
parent
5874deeffc
commit
8c95323728
@ -846,6 +846,7 @@ public:
|
||||
inline void SetSpellPowerDistanceMod(int16 value) { SpellPowerDistanceMod = value; };
|
||||
int32 GetSpellStat(uint32 spell_id, const char *identifier, uint8 slot = 0);
|
||||
bool HarmonySpellLevelCheck(int32 spell_id, Mob* target = nullptr);
|
||||
bool PassCharmTargetRestriction(Mob *target);
|
||||
bool CanFocusUseRandomEffectivenessByType(focusType type);
|
||||
int GetFocusRandomEffectivenessValue(int focus_base, int focus_base2, bool best_focus = 0);
|
||||
int GetHealRate() const { return itembonuses.HealRate + spellbonuses.HealRate + aabonuses.HealRate; }
|
||||
|
||||
@ -732,27 +732,6 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
|
||||
break;
|
||||
}
|
||||
|
||||
if (IsClient() && caster->IsClient()) {
|
||||
caster->Message(Chat::White, "Unable to cast charm on a fellow player.");
|
||||
BuffFadeByEffect(SE_Charm);
|
||||
break;
|
||||
}
|
||||
else if (IsCorpse()) {
|
||||
caster->Message(Chat::White, "Unable to cast charm on a corpse.");
|
||||
BuffFadeByEffect(SE_Charm);
|
||||
break;
|
||||
}
|
||||
else if (caster->GetPet() != nullptr && caster->IsClient()) {
|
||||
caster->Message(Chat::White, "You cannot charm something when you already have a pet.");
|
||||
BuffFadeByEffect(SE_Charm);
|
||||
break;
|
||||
}
|
||||
else if (GetOwner()) {
|
||||
caster->Message(Chat::White, "You cannot charm someone else's pet!");
|
||||
BuffFadeByEffect(SE_Charm);
|
||||
break;
|
||||
}
|
||||
|
||||
if (IsNPC()) {
|
||||
CastToNPC()->SaveGuardSpotCharm();
|
||||
}
|
||||
@ -8439,6 +8418,35 @@ bool Mob::HarmonySpellLevelCheck(int32 spell_id, Mob *target)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Mob::PassCharmTargetRestriction(Mob *target) {
|
||||
|
||||
//Level restriction check should not go here.
|
||||
if (!target) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target->IsClient() && IsClient()) {
|
||||
MessageString(Chat::Red, CANNOT_AFFECT_PC);
|
||||
LogSpells("Spell casting canceled: Can not cast charm on a client.");
|
||||
return false;
|
||||
}
|
||||
else if (target->IsCorpse()) {
|
||||
LogSpells("Spell casting canceled: Can not cast charm on a corpse.");
|
||||
return false;
|
||||
}
|
||||
else if (GetPet() && IsClient()) {
|
||||
MessageString(Chat::Red, ONLY_ONE_PET);
|
||||
LogSpells("Spell casting canceled: Can not cast charm if you have a pet.");
|
||||
return false;
|
||||
}
|
||||
else if (target->GetOwner()) {
|
||||
MessageString(Chat::Red, CANNOT_CHARM);
|
||||
LogSpells("Spell casting canceled: Can not cast charm on a pet.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Mob::CanFocusUseRandomEffectivenessByType(focusType type)
|
||||
{
|
||||
switch (type) {
|
||||
|
||||
@ -229,6 +229,21 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsEffectInSpell(spell_id, SE_Charm) && !PassCharmTargetRestriction(entity_list.GetMobID(target_id))) {
|
||||
bool can_send_spellbar_enable = true;
|
||||
if ((item_slot != -1 && cast_time == 0) || aa_id) {
|
||||
can_send_spellbar_enable = false;
|
||||
}
|
||||
|
||||
if (can_send_spellbar_enable) {
|
||||
SendSpellBarEnable(spell_id);
|
||||
}
|
||||
if (casting_spell_id && IsNPC()) {
|
||||
CastToNPC()->AI_Event_SpellCastFinished(false, static_cast<uint16>(casting_spell_slot));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (HasActiveSong() && IsBardSong(spell_id)) {
|
||||
LogSpells("Casting a new song while singing a song. Killing old song [{}]", bardsong);
|
||||
//Note: this does NOT tell the client
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user