[General] Implement jail time as a death penalty

0.6.1
David Cernat 8 years ago
parent 71313c5aa6
commit 60574ae667

@ -7,6 +7,14 @@
#include <iostream>
using namespace std;
void DeathFunctions::SetDeathPenaltyJailDays(unsigned short pid, int days) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
player->deathPenaltyJailDays = days;
}
void DeathFunctions::Resurrect(unsigned short pid, unsigned int type) noexcept
{
Player *player;

@ -4,11 +4,15 @@
#include "../Types.hpp"
#define DEATHAPI \
{"Resurrect", DeathFunctions::Resurrect}
{"SetDeathPenaltyJailDays", DeathFunctions::SetDeathPenaltyJailDays},\
\
{"Resurrect", DeathFunctions::Resurrect}
class DeathFunctions
{
public:
static void SetDeathPenaltyJailDays(unsigned short pid, int days) noexcept;
static void Resurrect(unsigned short pid, unsigned int type) noexcept;
};

@ -1,5 +1,17 @@
#include <MyGUI_ScrollBar.h>
/*
Start of tes3mp addition
Include additional headers for multiplayer purposes
*/
#include "../mwmp/Main.hpp"
#include "../mwmp/LocalPlayer.hpp"
#include <regex>
/*
End of tes3mp addition
*/
#include <components/misc/rng.hpp>
#include "../mwbase/windowmanager.hpp"
@ -59,7 +71,18 @@ namespace MWGui
if (mFadeTimeRemaining <= 0)
{
MWWorld::Ptr player = MWMechanics::getPlayer();
MWBase::Environment::get().getWorld()->teleportToClosestMarker(player, "prisonmarker");
/*
Start of tes3mp change (minor)
If the jail code is being used from elsewhere to lower skills, don't
teleport the player to the nearest prison
*/
if (!mwmp::Main::get().getLocalPlayer()->ignoreJailTeleportation)
MWBase::Environment::get().getWorld()->teleportToClosestMarker(player, "prisonmarker");
/*
End of tes3mp change (minor)
*/
setVisible(true);
mTimeAdvancer.run(100);
@ -104,6 +127,29 @@ namespace MWGui
else
message = gmst.find("sNotifyMessage43")->getString();
/*
Start of tes3mp addition
If the jail code is being used from elsewhere to lower skills, reset the
corresponding boolean and use more ambiguous wording for the message displayed
*/
if (mwmp::Main::get().getLocalPlayer()->ignoreJailTeleportation)
{
mwmp::Main::get().getLocalPlayer()->ignoreJailTeleportation = false;
const std::string stringToReplace = "been released";
const std::string stringToReplace2 = "in prison";
if (message.find(stringToReplace) != std::string::npos)
message.replace(message.find(stringToReplace), stringToReplace.size(), "recovered");
if (message.find(stringToReplace2) != std::string::npos)
message.replace(message.find(stringToReplace2), stringToReplace2.size(), "incapacitated");
}
/*
End of tes3mp addition
*/
std::stringstream dayStr;
dayStr << mDays;
if (message.find("%d") != std::string::npos)

@ -51,6 +51,7 @@ LocalPlayer::LocalPlayer()
difficulty = 0;
ignorePosPacket = false;
ignoreJailTeleportation = false;
attack.shouldSend = false;

@ -5,6 +5,8 @@
#ifndef OPENMW_PROCESSORPLAYERRESURRECT_HPP
#define OPENMW_PROCESSORPLAYERRESURRECT_HPP
#include "apps/openmw/mwbase/environment.hpp"
#include "apps/openmw/mwgui/windowmanagerimp.hpp"
#include "../PlayerProcessor.hpp"
#include "apps/openmw/mwmp/Main.hpp"
@ -59,6 +61,13 @@ namespace mwmp
static_cast<LocalPlayer*>(player)->updateStatsDynamic(true);
Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(player);
Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_STATS_DYNAMIC)->Send(serverAddr);
// Apply death penalties
if (player->deathPenaltyJailDays > 0)
{
player->ignoreJailTeleportation = true;
MWBase::Environment::get().getWindowManager()->goToJail(player->deathPenaltyJailDays);
}
}
else if (player != 0)
{

@ -242,6 +242,8 @@ namespace mwmp
bool isChangingRegion;
std::string deathReason;
int deathPenaltyJailDays;
bool ignoreJailTeleportation;
unsigned int resurrectType;
};

@ -14,4 +14,5 @@ void PacketPlayerResurrect::Packet(RakNet::BitStream *bs, bool send)
PlayerPacket::Packet(bs, send);
RW(player->resurrectType, send);
RW(player->deathPenaltyJailDays, send);
}

Loading…
Cancel
Save