forked from mirror/openmw-tes3mp
[General] Implement jail time as a death penalty
This commit is contained in:
parent
71313c5aa6
commit
60574ae667
7 changed files with 73 additions and 2 deletions
|
@ -7,6 +7,14 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
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
|
void DeathFunctions::Resurrect(unsigned short pid, unsigned int type) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
|
|
|
@ -4,11 +4,15 @@
|
||||||
#include "../Types.hpp"
|
#include "../Types.hpp"
|
||||||
|
|
||||||
#define DEATHAPI \
|
#define DEATHAPI \
|
||||||
{"Resurrect", DeathFunctions::Resurrect}
|
{"SetDeathPenaltyJailDays", DeathFunctions::SetDeathPenaltyJailDays},\
|
||||||
|
\
|
||||||
|
{"Resurrect", DeathFunctions::Resurrect}
|
||||||
|
|
||||||
class DeathFunctions
|
class DeathFunctions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static void SetDeathPenaltyJailDays(unsigned short pid, int days) noexcept;
|
||||||
|
|
||||||
static void Resurrect(unsigned short pid, unsigned int type) noexcept;
|
static void Resurrect(unsigned short pid, unsigned int type) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,17 @@
|
||||||
#include <MyGUI_ScrollBar.h>
|
#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 <components/misc/rng.hpp>
|
||||||
|
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
@ -59,7 +71,18 @@ namespace MWGui
|
||||||
if (mFadeTimeRemaining <= 0)
|
if (mFadeTimeRemaining <= 0)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWMechanics::getPlayer();
|
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);
|
setVisible(true);
|
||||||
mTimeAdvancer.run(100);
|
mTimeAdvancer.run(100);
|
||||||
|
@ -104,6 +127,29 @@ namespace MWGui
|
||||||
else
|
else
|
||||||
message = gmst.find("sNotifyMessage43")->getString();
|
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;
|
std::stringstream dayStr;
|
||||||
dayStr << mDays;
|
dayStr << mDays;
|
||||||
if (message.find("%d") != std::string::npos)
|
if (message.find("%d") != std::string::npos)
|
||||||
|
|
|
@ -51,6 +51,7 @@ LocalPlayer::LocalPlayer()
|
||||||
difficulty = 0;
|
difficulty = 0;
|
||||||
|
|
||||||
ignorePosPacket = false;
|
ignorePosPacket = false;
|
||||||
|
ignoreJailTeleportation = false;
|
||||||
|
|
||||||
attack.shouldSend = false;
|
attack.shouldSend = false;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#ifndef OPENMW_PROCESSORPLAYERRESURRECT_HPP
|
#ifndef OPENMW_PROCESSORPLAYERRESURRECT_HPP
|
||||||
#define OPENMW_PROCESSORPLAYERRESURRECT_HPP
|
#define OPENMW_PROCESSORPLAYERRESURRECT_HPP
|
||||||
|
|
||||||
|
#include "apps/openmw/mwbase/environment.hpp"
|
||||||
|
#include "apps/openmw/mwgui/windowmanagerimp.hpp"
|
||||||
|
|
||||||
#include "../PlayerProcessor.hpp"
|
#include "../PlayerProcessor.hpp"
|
||||||
#include "apps/openmw/mwmp/Main.hpp"
|
#include "apps/openmw/mwmp/Main.hpp"
|
||||||
|
@ -59,6 +61,13 @@ namespace mwmp
|
||||||
static_cast<LocalPlayer*>(player)->updateStatsDynamic(true);
|
static_cast<LocalPlayer*>(player)->updateStatsDynamic(true);
|
||||||
Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(player);
|
Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(player);
|
||||||
Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_STATS_DYNAMIC)->Send(serverAddr);
|
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)
|
else if (player != 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -242,6 +242,8 @@ namespace mwmp
|
||||||
bool isChangingRegion;
|
bool isChangingRegion;
|
||||||
|
|
||||||
std::string deathReason;
|
std::string deathReason;
|
||||||
|
int deathPenaltyJailDays;
|
||||||
|
bool ignoreJailTeleportation;
|
||||||
|
|
||||||
unsigned int resurrectType;
|
unsigned int resurrectType;
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,4 +14,5 @@ void PacketPlayerResurrect::Packet(RakNet::BitStream *bs, bool send)
|
||||||
PlayerPacket::Packet(bs, send);
|
PlayerPacket::Packet(bs, send);
|
||||||
|
|
||||||
RW(player->resurrectType, send);
|
RW(player->resurrectType, send);
|
||||||
|
RW(player->deathPenaltyJailDays, send);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue