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,7 +2149,8 @@ void SpellProcess::GetSpellTargets(LuaSpell* luaspell)
|
|||||||
luaspell->initial_target = target->GetID();
|
luaspell->initial_target = target->GetID();
|
||||||
luaspell->initial_target_char_id = (target && target->IsPlayer()) ? ((Player*)target)->GetCharacterID() : 0;
|
luaspell->initial_target_char_id = (target && target->IsPlayer()) ? ((Player*)target)->GetCharacterID() : 0;
|
||||||
AddLuaSpellTarget(luaspell, target->GetID());
|
AddLuaSpellTarget(luaspell, target->GetID());
|
||||||
GetPlayerGroupTargets((Player*)target, caster, luaspell);
|
if(target_type == SPELL_TARGET_OTHER_GROUP_AE)
|
||||||
|
GetPlayerGroupTargets((Player*)target, caster, luaspell);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (secondary_target && target->IsPlayer() && ((Entity*)caster)->AttackAllowed((Entity*)secondary_target))
|
else if (secondary_target && target->IsPlayer() && ((Entity*)caster)->AttackAllowed((Entity*)secondary_target))
|
||||||
@ -2158,7 +2159,12 @@ void SpellProcess::GetSpellTargets(LuaSpell* luaspell)
|
|||||||
luaspell->initial_target = secondary_target->GetID();
|
luaspell->initial_target = secondary_target->GetID();
|
||||||
luaspell->initial_target_char_id = (secondary_target && secondary_target->IsPlayer()) ? ((Player*)secondary_target)->GetCharacterID() : 0;
|
luaspell->initial_target_char_id = (secondary_target && secondary_target->IsPlayer()) ? ((Player*)secondary_target)->GetCharacterID() : 0;
|
||||||
AddLuaSpellTarget(luaspell, secondary_target->GetID());
|
AddLuaSpellTarget(luaspell, secondary_target->GetID());
|
||||||
GetPlayerGroupTargets((Player*)secondary_target, caster, luaspell);
|
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
|
} // 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;
|
luaspell->initial_target_char_id = (target && target->IsPlayer()) ? ((Player*)target)->GetCharacterID() : 0;
|
||||||
AddLuaSpellTarget(luaspell, target->GetID());
|
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)
|
else if (data->friendly_spell)
|
||||||
{
|
{
|
||||||
// caster is an Entity
|
// caster is an Entity
|
||||||
if (luaspell->caster->IsEntity())
|
if (caster->IsPlayer())
|
||||||
{
|
{
|
||||||
// entity caster is in a player group
|
// entity caster is in a player group
|
||||||
if (((Entity*)caster)->GetGroupMemberInfo())
|
if (((Entity*)caster)->GetGroupMemberInfo())
|
||||||
@ -2339,7 +2349,7 @@ void SpellProcess::GetSpellTargets(LuaSpell* luaspell)
|
|||||||
}
|
}
|
||||||
else if (caster->IsNPC()) // caster is NOT a player
|
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();
|
vector<Spawn*>* group = ((NPC*)caster)->GetSpawnGroup();
|
||||||
if (group)
|
if (group)
|
||||||
{
|
{
|
||||||
@ -2349,7 +2359,7 @@ void SpellProcess::GetSpellTargets(LuaSpell* luaspell)
|
|||||||
{
|
{
|
||||||
Spawn* group_member = *itr;
|
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);
|
AddLuaSpellTarget(luaspell, group_member->GetID(), false);
|
||||||
if (((Entity*)group_member)->HasPet()){
|
if (((Entity*)group_member)->HasPet()){
|
||||||
Entity* pet = ((Entity*)group_member)->GetPet();
|
Entity* pet = ((Entity*)group_member)->GetPet();
|
||||||
@ -2366,7 +2376,7 @@ void SpellProcess::GetSpellTargets(LuaSpell* luaspell)
|
|||||||
AddSelfAndPet(luaspell, caster);
|
AddSelfAndPet(luaspell, caster);
|
||||||
|
|
||||||
safe_delete(group);
|
safe_delete(group);
|
||||||
} // end is player
|
} // end is npc
|
||||||
} // end is friendly
|
} // end is friendly
|
||||||
} // end is Group AE
|
} // end is Group AE
|
||||||
|
|
||||||
@ -3046,6 +3056,40 @@ bool SpellProcess::AddLuaSpellTarget(LuaSpell* lua_spell, int32 id, bool lock_sp
|
|||||||
return ret;
|
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) {
|
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 caster = in_caster ? std::string(in_caster->GetName()) : "Unknown";
|
||||||
std::string target = in_target ? std::string(in_target->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);
|
static void AddSelfAndPetToCharTargets(LuaSpell* spell, Spawn* caster, bool onlyPet=false);
|
||||||
void DeleteActiveSpell(LuaSpell* spell, bool skipRemoveCurrent = false);
|
void DeleteActiveSpell(LuaSpell* spell, bool skipRemoveCurrent = false);
|
||||||
static bool AddLuaSpellTarget(LuaSpell* lua_spell, int32 id, bool lock_spell_targets = true);
|
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;
|
mutable std::shared_mutex MSpellProcess;
|
||||||
|
|
||||||
static void ReplaceEffectTokens(std::string& message, Spawn* in_caster, Spawn* in_target);
|
static void ReplaceEffectTokens(std::string& message, Spawn* in_caster, Spawn* in_target);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user