Fixed target type 9 (AE other groups) like Shout getting implied or proper targets
- (Enemy) Players targetting NPCs and their spawn groups - (Friendly) NPCs targetting NPCs and their own spawn groups
This commit is contained in:
parent
bc925887ad
commit
398a4ef1f4
@ -2149,6 +2149,7 @@ void SpellProcess::GetSpellTargets(LuaSpell* luaspell)
|
||||
luaspell->initial_target = target->GetID();
|
||||
luaspell->initial_target_char_id = (target && target->IsPlayer()) ? ((Player*)target)->GetCharacterID() : 0;
|
||||
AddLuaSpellTarget(luaspell, target->GetID());
|
||||
if(target_type == SPELL_TARGET_OTHER_GROUP_AE)
|
||||
GetPlayerGroupTargets((Player*)target, caster, luaspell);
|
||||
|
||||
}
|
||||
@ -2158,8 +2159,13 @@ void SpellProcess::GetSpellTargets(LuaSpell* luaspell)
|
||||
luaspell->initial_target = secondary_target->GetID();
|
||||
luaspell->initial_target_char_id = (secondary_target && secondary_target->IsPlayer()) ? ((Player*)secondary_target)->GetCharacterID() : 0;
|
||||
AddLuaSpellTarget(luaspell, secondary_target->GetID());
|
||||
if(target_type == SPELL_TARGET_OTHER_GROUP_AE)
|
||||
GetPlayerGroupTargets((Player*)secondary_target, caster, luaspell);
|
||||
}
|
||||
else if(target->IsNPC() && ((Entity*)caster)->AttackAllowed((Entity*)target)) {
|
||||
// caster is NPC and potentially in a spawn group with other NPCs
|
||||
AddNPCGroupOrSelfTarget(luaspell, target);
|
||||
}
|
||||
}
|
||||
} // end friendly spell check
|
||||
}
|
||||
@ -2180,6 +2186,10 @@ void SpellProcess::GetSpellTargets(LuaSpell* luaspell)
|
||||
luaspell->initial_target_char_id = (target && target->IsPlayer()) ? ((Player*)target)->GetCharacterID() : 0;
|
||||
AddLuaSpellTarget(luaspell, target->GetID());
|
||||
}
|
||||
else if(target->IsNPC() && ((Entity*)caster)->AttackAllowed((Entity*)target)) {
|
||||
// caster is NPC and potentially in a spawn group with other NPCs
|
||||
AddNPCGroupOrSelfTarget(luaspell, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2280,7 +2290,7 @@ void SpellProcess::GetSpellTargets(LuaSpell* luaspell)
|
||||
else if (data->friendly_spell)
|
||||
{
|
||||
// caster is an Entity
|
||||
if (luaspell->caster->IsEntity())
|
||||
if (caster->IsPlayer())
|
||||
{
|
||||
// entity caster is in a player group
|
||||
if (((Entity*)caster)->GetGroupMemberInfo())
|
||||
@ -2339,7 +2349,7 @@ void SpellProcess::GetSpellTargets(LuaSpell* luaspell)
|
||||
}
|
||||
else if (caster->IsNPC()) // caster is NOT a player
|
||||
{
|
||||
// caster is NPC and in a spawn group with other NPCs
|
||||
// caster is NPC and in a spawn group with other NPCs check FRIENDLY
|
||||
vector<Spawn*>* group = ((NPC*)caster)->GetSpawnGroup();
|
||||
if (group)
|
||||
{
|
||||
@ -2349,7 +2359,7 @@ void SpellProcess::GetSpellTargets(LuaSpell* luaspell)
|
||||
{
|
||||
Spawn* group_member = *itr;
|
||||
|
||||
if (group_member->IsNPC() && group_member->Alive() && ((Entity*)caster)->AttackAllowed(((Entity*)group_member))){
|
||||
if (group_member->IsNPC() && group_member->Alive()){
|
||||
AddLuaSpellTarget(luaspell, group_member->GetID(), false);
|
||||
if (((Entity*)group_member)->HasPet()){
|
||||
Entity* pet = ((Entity*)group_member)->GetPet();
|
||||
@ -2366,7 +2376,7 @@ void SpellProcess::GetSpellTargets(LuaSpell* luaspell)
|
||||
AddSelfAndPet(luaspell, caster);
|
||||
|
||||
safe_delete(group);
|
||||
} // end is player
|
||||
} // end is npc
|
||||
} // end is friendly
|
||||
} // end is Group AE
|
||||
|
||||
@ -3046,6 +3056,40 @@ bool SpellProcess::AddLuaSpellTarget(LuaSpell* lua_spell, int32 id, bool lock_sp
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SpellProcess::AddNPCGroupOrSelfTarget(LuaSpell* luaspell, Spawn* target) {
|
||||
if(!target->IsNPC())
|
||||
return;
|
||||
|
||||
int8 target_type = luaspell->spell->GetSpellData()->target_type;
|
||||
Spawn* caster = luaspell->caster;
|
||||
vector<Spawn*>* group = ((NPC*)target)->GetSpawnGroup();
|
||||
if (target_type == SPELL_TARGET_OTHER_GROUP_AE && group)
|
||||
{
|
||||
vector<Spawn*>::iterator itr;
|
||||
|
||||
for (itr = group->begin(); itr != group->end(); itr++)
|
||||
{
|
||||
Spawn* group_member = *itr;
|
||||
|
||||
if (group_member->IsNPC() && group_member->Alive() && ((Entity*)caster)->AttackAllowed(((Entity*)group_member))){
|
||||
AddLuaSpellTarget(luaspell, group_member->GetID(), false);
|
||||
if (((Entity*)group_member)->HasPet()){
|
||||
Entity* pet = ((Entity*)group_member)->GetPet();
|
||||
if (pet)
|
||||
AddLuaSpellTarget(luaspell, pet->GetID(), false);
|
||||
pet = ((Entity*)group_member)->GetCharmedPet();
|
||||
if (pet)
|
||||
AddLuaSpellTarget(luaspell, pet->GetID(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
AddLuaSpellTarget(luaspell, target->GetID());
|
||||
|
||||
safe_delete(group);
|
||||
}
|
||||
|
||||
void SpellProcess::ReplaceEffectTokens(std::string& message, Spawn* in_caster, Spawn* in_target) {
|
||||
std::string caster = in_caster ? std::string(in_caster->GetName()) : "Unknown";
|
||||
std::string target = in_target ? std::string(in_target->GetName()) : "Unknown";
|
||||
|
@ -400,6 +400,7 @@ public:
|
||||
static void AddSelfAndPetToCharTargets(LuaSpell* spell, Spawn* caster, bool onlyPet=false);
|
||||
void DeleteActiveSpell(LuaSpell* spell, bool skipRemoveCurrent = false);
|
||||
static bool AddLuaSpellTarget(LuaSpell* lua_spell, int32 id, bool lock_spell_targets = true);
|
||||
static void AddNPCGroupOrSelfTarget(LuaSpell* luaspell, Spawn* target);
|
||||
mutable std::shared_mutex MSpellProcess;
|
||||
|
||||
static void ReplaceEffectTokens(std::string& message, Spawn* in_caster, Spawn* in_target);
|
||||
|
Loading…
x
Reference in New Issue
Block a user