I have noticed that when casting buffs that are target type 42 with TGB enabled when I have members of my own group targeted was resulting in a "Target not in range" message. If I turn off TGB it goes away. I dug into the targeting logic in spells.cpp and I noticed it was trying to set the target to my target and not use me as the target. It is my guess that somewhere in the EMU, it is not allowing me to target a group member and cast a Group v2 spell. So I wrote a quick function for Client::IsInMyGroup(Client* client) and added it to group.cpp
Code:
bool Client::IsInMyGroup(Client* client)
{
if(!(this->HasGroup()))
return false;
Group* g = this->GetGroup();
for(int i = 0; i < g->GroupCount(); i++)
{
if(g->members[i]->CastToClient() == client)
return true;
}
return false;
}
I then changed the targeting logic so that if the caster is a client, TGB is on, the spell can use TGB, the target is a client, and (finally) the target is in my group, it will use the caster as the target of the spell and you no longer get an error message.
Code:
case ST_GroupTeleport:
case ST_Group:
{
if(IsClient() && CastToClient()->TGB() && IsTGBCompatibleSpell(spell_id)) {
if( (!target) ||
(target->IsNPC() && !(target->GetOwner() && target->GetOwner()->IsClient())) ||
(target->IsCorpse()) ||
(target->IsClient() && this->CastToClient()->IsInMyGroup(target->CastToClient()))) // added by squevis667
spell_target = this;
else
spell_target = target;
} else {
spell_target = this;
}
CastAction = GroupSpell;
break;
}
I guess the other option is to dig down into whatever logic is throwing the message to begin with (you should be able to cast a spell with TGB on a group member without an error), so this is more of a quick fix and does not really address the root cause.