[Client] When players die, make guards willing to arrest them again

pull/311/head
David Cernat 7 years ago
parent f5e23d5fc6
commit ccb15cc09e

@ -129,7 +129,7 @@ namespace MWGui
Disable increases for Security and Sneak when using ignoreJailSkillIncreases Disable increases for Security and Sneak when using ignoreJailSkillIncreases
*/ */
if (mwmp::Main::get().getLocalPlayer()->ignoreJailSkillIncreases) if (mwmp::Main::get().getLocalPlayer()->ignoreJailSkillIncreases)
value.setBase(value.getBase() - 1); value.setBase(std::max(0, value.getBase()-1));
else if (skill == ESM::Skill::Security || skill == ESM::Skill::Sneak) else if (skill == ESM::Skill::Security || skill == ESM::Skill::Sneak)
/* /*
End of tes3mp change (minor) End of tes3mp change (minor)

@ -1065,7 +1065,18 @@ namespace MWMechanics
&& MWBase::Environment::get().getMechanicsManager()->awarenessCheck(player, ptr)) && MWBase::Environment::get().getMechanicsManager()->awarenessCheck(player, ptr))
{ {
static const int iCrimeThresholdMultiplier = esmStore.get<ESM::GameSetting>().find("iCrimeThresholdMultiplier")->getInt(); static const int iCrimeThresholdMultiplier = esmStore.get<ESM::GameSetting>().find("iCrimeThresholdMultiplier")->getInt();
if (player.getClass().getNpcStats(player).getBounty() >= cutoff * iCrimeThresholdMultiplier)
/*
Start of tes3mp change (major)
Only attack players based on their high bounty if they haven't died since the last
time an attempt was made to arrest them
*/
if (player.getClass().getNpcStats(player).getBounty() >= cutoff * iCrimeThresholdMultiplier
&& !mwmp::Main::get().getLocalPlayer()->diedSinceArrestAttempt)
/*
End of tes3mp change (major)
*/
{ {
MWBase::Environment::get().getMechanicsManager()->startCombat(ptr, player); MWBase::Environment::get().getMechanicsManager()->startCombat(ptr, player);
creatureStats.setHitAttemptActorId(player.getClass().getCreatureStats(player).getActorId()); // Stops the guard from quitting combat if player is unreachable creatureStats.setHitAttemptActorId(player.getClass().getCreatureStats(player).getActorId()); // Stops the guard from quitting combat if player is unreachable
@ -1096,6 +1107,24 @@ namespace MWMechanics
// Update witness crime id // Update witness crime id
npcStats.setCrimeId(-1); npcStats.setCrimeId(-1);
} }
/*
Start of tes3mp addition
If the player has died, stop combat with them as though they had
paid their bounty
*/
else if (mwmp::Main::get().getLocalPlayer()->diedSinceArrestAttempt)
{
if (creatureStats.getAiSequence().isInCombat(player))
{
creatureStats.getAiSequence().stopCombat();
creatureStats.setAttacked(false);
creatureStats.setAlarmed(false);
}
}
/*
End of tes3mp addition
*/
} }
} }
} }

@ -13,7 +13,10 @@
Include additional headers for multiplayer purposes Include additional headers for multiplayer purposes
*/ */
#include <components/openmw-mp/Log.hpp>
#include "../mwgui/windowmanagerimp.hpp" #include "../mwgui/windowmanagerimp.hpp"
#include "../mwmp/Main.hpp"
#include "../mwmp/LocalPlayer.hpp"
/* /*
End of tes3mp addition End of tes3mp addition
*/ */
@ -81,6 +84,18 @@ bool AiPursue::execute (const MWWorld::Ptr& actor, CharacterController& characte
if (pathTo(actor, dest, duration, 100)) { if (pathTo(actor, dest, duration, 100)) {
target.getClass().activate(target,actor).get()->execute(actor); //Arrest player when reached target.getClass().activate(target,actor).get()->execute(actor); //Arrest player when reached
/*
Start of tes3mp addition
Record that the player has not died since the last attempt to arrest them
*/
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "After being pursued by %s, diedSinceArrestAttempt is now false", actor.getCellRef().getRefId().c_str());
mwmp::Main::get().getLocalPlayer()->diedSinceArrestAttempt = false;
/*
End of tes3mp addition
*/
return true; return true;
} }

@ -61,6 +61,8 @@ LocalPlayer::LocalPlayer()
jailProgressText = ""; jailProgressText = "";
jailEndText = ""; jailEndText = "";
diedSinceArrestAttempt = false;
} }
LocalPlayer::~LocalPlayer() LocalPlayer::~LocalPlayer()

@ -52,6 +52,12 @@ namespace mwmp
// readied but be unable to use it unless we clear it here // readied but be unable to use it unless we clear it here
playerPtr.getClass().getNpcStats(playerPtr).setDrawState(MWMechanics::DrawState_Nothing); playerPtr.getClass().getNpcStats(playerPtr).setDrawState(MWMechanics::DrawState_Nothing);
// Record that the player has died since the last attempt was made to arrest them,
// used to make guards lenient enough to attempt an arrest again
player->diedSinceArrestAttempt = true;
LOG_APPEND(Log::LOG_INFO, "- diedSinceArrestAttempt is now true");
packet.setPlayer(player); packet.setPlayer(player);
packet.Send(serverAddr); packet.Send(serverAddr);

@ -263,6 +263,8 @@ namespace mwmp
std::string jailEndText; std::string jailEndText;
unsigned int resurrectType; unsigned int resurrectType;
bool diedSinceArrestAttempt;
}; };
} }

Loading…
Cancel
Save