mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-28 21:06:41 +00:00
[Client] Implement PlayerTeam packet, part 2
When determining actors siding with someone, also check the team members of DedicatedPlayers, not just those of the LocalPlayer. Don't set players as each other's hitAttemptActor if they are team members. Don't run startCombat() for DedicatedPlayers who get attacked.
This commit is contained in:
parent
3a52f7dcf5
commit
c4950f1beb
6 changed files with 71 additions and 10 deletions
|
@ -433,20 +433,25 @@ namespace MWClass
|
||||||
|
|
||||||
Instead of only checking whether an attacker is the LocalPlayer, also
|
Instead of only checking whether an attacker is the LocalPlayer, also
|
||||||
check if they are a DedicatedPlayer
|
check if they are a DedicatedPlayer
|
||||||
|
|
||||||
|
Additionally, if the two players are on each other's team, don't track
|
||||||
|
their hits
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// First handle the attacked actor
|
// First handle the attacked actor
|
||||||
if ((stats.getHitAttemptActorId() == -1)
|
if ((stats.getHitAttemptActorId() == -1)
|
||||||
&& (statsAttacker.getAiSequence().isInCombat(ptr)
|
&& (statsAttacker.getAiSequence().isInCombat(ptr)
|
||||||
|| attacker == MWMechanics::getPlayer()
|
|| attacker == MWMechanics::getPlayer()
|
||||||
|| mwmp::PlayerList::isDedicatedPlayer(attacker)))
|
|| mwmp::PlayerList::isDedicatedPlayer(attacker))
|
||||||
|
&& !MechanicsHelper::isTeamMember(attacker, ptr))
|
||||||
stats.setHitAttemptActorId(statsAttacker.getActorId());
|
stats.setHitAttemptActorId(statsAttacker.getActorId());
|
||||||
|
|
||||||
// Next handle the attacking actor
|
// Next handle the attacking actor
|
||||||
if ((statsAttacker.getHitAttemptActorId() == -1)
|
if ((statsAttacker.getHitAttemptActorId() == -1)
|
||||||
&& (statsAttacker.getAiSequence().isInCombat(ptr)
|
&& (statsAttacker.getAiSequence().isInCombat(ptr)
|
||||||
|| attacker == MWMechanics::getPlayer()
|
|| attacker == MWMechanics::getPlayer()
|
||||||
|| mwmp::PlayerList::isDedicatedPlayer(attacker)))
|
|| mwmp::PlayerList::isDedicatedPlayer(attacker))
|
||||||
|
&& !MechanicsHelper::isTeamMember(ptr, attacker))
|
||||||
statsAttacker.setHitAttemptActorId(stats.getActorId());
|
statsAttacker.setHitAttemptActorId(stats.getActorId());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -768,20 +768,25 @@ namespace MWClass
|
||||||
|
|
||||||
Instead of only checking whether an attacker is the LocalPlayer, also
|
Instead of only checking whether an attacker is the LocalPlayer, also
|
||||||
check if they are a DedicatedPlayer
|
check if they are a DedicatedPlayer
|
||||||
|
|
||||||
|
Additionally, if the two players are on each other's team, don't track
|
||||||
|
their hits
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// First handle the attacked actor
|
// First handle the attacked actor
|
||||||
if ((stats.getHitAttemptActorId() == -1)
|
if ((stats.getHitAttemptActorId() == -1)
|
||||||
&& (statsAttacker.getAiSequence().isInCombat(ptr)
|
&& (statsAttacker.getAiSequence().isInCombat(ptr)
|
||||||
|| attacker == MWMechanics::getPlayer()
|
|| attacker == MWMechanics::getPlayer()
|
||||||
|| mwmp::PlayerList::isDedicatedPlayer(attacker)))
|
|| mwmp::PlayerList::isDedicatedPlayer(attacker))
|
||||||
|
&& !MechanicsHelper::isTeamMember(attacker, ptr))
|
||||||
stats.setHitAttemptActorId(statsAttacker.getActorId());
|
stats.setHitAttemptActorId(statsAttacker.getActorId());
|
||||||
|
|
||||||
// Next handle the attacking actor
|
// Next handle the attacking actor
|
||||||
if ((statsAttacker.getHitAttemptActorId() == -1)
|
if ((statsAttacker.getHitAttemptActorId() == -1)
|
||||||
&& (statsAttacker.getAiSequence().isInCombat(ptr)
|
&& (statsAttacker.getAiSequence().isInCombat(ptr)
|
||||||
|| attacker == MWMechanics::getPlayer()
|
|| attacker == MWMechanics::getPlayer()
|
||||||
|| mwmp::PlayerList::isDedicatedPlayer(attacker)))
|
|| mwmp::PlayerList::isDedicatedPlayer(attacker))
|
||||||
|
&& !MechanicsHelper::isTeamMember(ptr, attacker))
|
||||||
statsAttacker.setHitAttemptActorId(stats.getActorId());
|
statsAttacker.setHitAttemptActorId(stats.getActorId());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -2363,8 +2363,11 @@ namespace MWMechanics
|
||||||
/*
|
/*
|
||||||
Start of tes3mp addition
|
Start of tes3mp addition
|
||||||
|
|
||||||
If we're checking a player and the iteratedActor is another player belonging to this one's teamMembers,
|
If we're checking the LocalPlayer and the iteratedActor is a DedicatedPlayer belonging to this one's teamMembers,
|
||||||
include the iteratedActor in the actors siding with the player
|
include the iteratedActor in the actors siding with the player
|
||||||
|
|
||||||
|
Alternatively, if we're checking a DedicatedPlayer and the iteratedActor is a LocalPlayer or DedicatedPlayer
|
||||||
|
belonging to their team members, include the iteratedActor in the actors siding with them
|
||||||
*/
|
*/
|
||||||
if (actor == getPlayer() && mwmp::PlayerList::isDedicatedPlayer(iteratedActor))
|
if (actor == getPlayer() && mwmp::PlayerList::isDedicatedPlayer(iteratedActor))
|
||||||
{
|
{
|
||||||
|
@ -2373,6 +2376,19 @@ namespace MWMechanics
|
||||||
list.push_back(iteratedActor);
|
list.push_back(iteratedActor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (mwmp::PlayerList::isDedicatedPlayer(actor))
|
||||||
|
{
|
||||||
|
if (iteratedActor == getPlayer() &&
|
||||||
|
Utils::vectorContains(mwmp::PlayerList::getPlayer(actor)->teamMembers, mwmp::Main::get().getLocalPlayer()->guid))
|
||||||
|
{
|
||||||
|
list.push_back(iteratedActor);
|
||||||
|
}
|
||||||
|
else if (mwmp::PlayerList::isDedicatedPlayer(iteratedActor) &&
|
||||||
|
Utils::vectorContains(mwmp::PlayerList::getPlayer(actor)->teamMembers, mwmp::PlayerList::getPlayer(iteratedActor)->guid))
|
||||||
|
{
|
||||||
|
list.push_back(iteratedActor);
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1577,6 +1577,18 @@ namespace MWMechanics
|
||||||
if (target == player || !attacker.getClass().isActor())
|
if (target == player || !attacker.getClass().isActor())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp change (major)
|
||||||
|
|
||||||
|
Don't set DedicatedPlayers as being in combat with the attacker, to prevent
|
||||||
|
AI actors from deciding to reciprocate by also starting combat
|
||||||
|
*/
|
||||||
|
if (mwmp::PlayerList::isDedicatedPlayer(target))
|
||||||
|
return false;
|
||||||
|
/*
|
||||||
|
End of tes3mp change (major)
|
||||||
|
*/
|
||||||
|
|
||||||
MWMechanics::CreatureStats& statsTarget = target.getClass().getCreatureStats(target);
|
MWMechanics::CreatureStats& statsTarget = target.getClass().getCreatureStats(target);
|
||||||
/*
|
/*
|
||||||
Start of tes3mp change (major)
|
Start of tes3mp change (major)
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace MechanicsHelper
|
||||||
// Note: This is not supposed to also check if playerWithTeam is on playerChecked's
|
// Note: This is not supposed to also check if playerWithTeam is on playerChecked's
|
||||||
// team, because it should technically be possible to be allied to someone
|
// team, because it should technically be possible to be allied to someone
|
||||||
// who isn't mutually allied to you
|
// who isn't mutually allied to you
|
||||||
bool isTeamMember(const MWWorld::Ptr& playedChecked, const MWWorld::Ptr& playerWithTeam);
|
bool isTeamMember(const MWWorld::Ptr& playerChecked, const MWWorld::Ptr& playerWithTeam);
|
||||||
|
|
||||||
bool getSpellSuccess(std::string spellId, const MWWorld::Ptr& caster);
|
bool getSpellSuccess(std::string spellId, const MWWorld::Ptr& caster);
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,11 @@ namespace mwmp
|
||||||
|
|
||||||
virtual void Do(PlayerPacket &packet, BasePlayer *player)
|
virtual void Do(PlayerPacket &packet, BasePlayer *player)
|
||||||
{
|
{
|
||||||
|
mwmp::LocalPlayer *localPlayer = mwmp::Main::get().getLocalPlayer();
|
||||||
|
|
||||||
if (isLocal())
|
if (isLocal())
|
||||||
{
|
{
|
||||||
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received ID_PLAYER_TEAM about LocalPlayer from server");
|
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received ID_PLAYER_TEAM about LocalPlayer %s from server", localPlayer->npc.mName.c_str());
|
||||||
|
|
||||||
mwmp::LocalPlayer *localPlayer = mwmp::Main::get().getLocalPlayer();
|
|
||||||
|
|
||||||
for (std::vector<RakNet::RakNetGUID>::iterator iter = localPlayer->teamMembers.begin(); iter != localPlayer->teamMembers.end(); )
|
for (std::vector<RakNet::RakNetGUID>::iterator iter = localPlayer->teamMembers.begin(); iter != localPlayer->teamMembers.end(); )
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,30 @@ namespace mwmp
|
||||||
|
|
||||||
if (dedicatedPlayer)
|
if (dedicatedPlayer)
|
||||||
{
|
{
|
||||||
LOG_APPEND(TimedLog::LOG_INFO, "- Adding %s to our team members", dedicatedPlayer->npc.mName.c_str());
|
LOG_APPEND(TimedLog::LOG_INFO, "- Adding DedicatedPlayer %s to our team members", dedicatedPlayer->npc.mName.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (player != 0)
|
||||||
|
{
|
||||||
|
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received ID_PLAYER_TEAM about DedicatedPlayer %s from server", player->npc.mName.c_str());
|
||||||
|
|
||||||
|
for (std::vector<RakNet::RakNetGUID>::iterator iter = player->teamMembers.begin(); iter != player->teamMembers.end(); )
|
||||||
|
{
|
||||||
|
if (*iter == localPlayer->guid)
|
||||||
|
{
|
||||||
|
LOG_APPEND(TimedLog::LOG_INFO, "- Adding LocalPlayer %s to their team members", localPlayer->npc.mName.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DedicatedPlayer *otherDedicatedPlayer = PlayerList::getPlayer(*iter);
|
||||||
|
|
||||||
|
if (otherDedicatedPlayer)
|
||||||
|
{
|
||||||
|
LOG_APPEND(TimedLog::LOG_INFO, "- Adding DedicatedPlayer %s to their team members", otherDedicatedPlayer->npc.mName.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++iter;
|
++iter;
|
||||||
|
|
Loading…
Reference in a new issue