[General] Implement resurrection at nearest shrine or temple

0.6.1
David Cernat 8 years ago
parent a358dc6af8
commit b3b73c5cd2

@ -78,10 +78,10 @@ set(SERVER
Script/Functions/Actors.cpp Script/Functions/World.cpp Script/Functions/Miscellaneous.cpp
Script/Functions/Cells.cpp Script/Functions/CharClass.cpp Script/Functions/Chat.cpp
Script/Functions/Dialogue.cpp Script/Functions/Factions.cpp Script/Functions/GUI.cpp
Script/Functions/Items.cpp Script/Functions/Positions.cpp Script/Functions/Quests.cpp
Script/Functions/Settings.cpp Script/Functions/Spells.cpp Script/Functions/Stats.cpp
Script/Functions/Timer.cpp
Script/Functions/Death.cpp Script/Functions/Dialogue.cpp Script/Functions/Factions.cpp
Script/Functions/GUI.cpp Script/Functions/Items.cpp Script/Functions/Positions.cpp
Script/Functions/Quests.cpp Script/Functions/Settings.cpp Script/Functions/Spells.cpp
Script/Functions/Stats.cpp Script/Functions/Timer.cpp
ProcessorInitializer.cpp PlayerProcessor.cpp ActorProcessor.cpp WorldProcessor.cpp

@ -0,0 +1,26 @@
#include "Death.hpp"
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <components/openmw-mp/Log.hpp>
#include <iostream>
using namespace std;
void DeathFunctions::SetResurrectType(unsigned short pid, unsigned int type)
{
Player *player;
GET_PLAYER(pid, player,);
player->resurrectType = type;
}
void DeathFunctions::SendResurrect(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_RESURRECT)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_RESURRECT)->Send(false);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_RESURRECT)->Send(true);
}

@ -0,0 +1,19 @@
#ifndef OPENMW_DEATHAPI_HPP
#define OPENMW_DEATHAPI_HPP
#include "../Types.hpp"
#define DEATHAPI \
{"SetResurrectType", DeathFunctions::SetResurrectType},\
\
{"SendResurrect", DeathFunctions::SendResurrect}
class DeathFunctions
{
public:
static void SetResurrectType(unsigned short pid, unsigned int type);
static void SendResurrect(unsigned short pid) noexcept;
};
#endif //OPENMW_DEATHAPI_HPP

@ -504,13 +504,6 @@ void StatsFunctions::SetCharGenStage(unsigned short pid, int start, int end) noe
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CHARGEN)->Send(false);
}
void StatsFunctions::Resurrect(unsigned short pid)
{
Player *player;
GET_PLAYER(pid, player,);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_RESURRECT)->RequestData(player->guid);
}
void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept
{
Player *player;

@ -74,7 +74,6 @@
{"SetBounty", StatsFunctions::SetBounty},\
{"SetCharGenStage", StatsFunctions::SetCharGenStage},\
\
{"Resurrect", StatsFunctions::Resurrect},\
{"SendBaseInfo", StatsFunctions::SendBaseInfo},\
\
{"SendStatsDynamic", StatsFunctions::SendStatsDynamic},\
@ -152,7 +151,6 @@ public:
static void SetBounty(unsigned short pid, int value) noexcept;
static void SetCharGenStage(unsigned short pid, int start, int end) noexcept;
static void Resurrect(unsigned short pid);
static void SendBaseInfo(unsigned short pid) noexcept;
static void SendStatsDynamic(unsigned short pid) noexcept;

@ -8,6 +8,7 @@
#include <Script/Functions/Actors.hpp>
#include <Script/Functions/Cells.hpp>
#include <Script/Functions/CharClass.hpp>
#include <Script/Functions/Death.hpp>
#include <Script/Functions/Dialogue.hpp>
#include <Script/Functions/Factions.hpp>
#include <Script/Functions/GUI.hpp>
@ -110,6 +111,7 @@ public:
ITEMAPI,
QUESTAPI,
FACTIONAPI,
DEATHAPI,
DIALOGUEAPI,
SPELLAPI,
GUIAPI,

@ -15,7 +15,6 @@ namespace mwmp
ProcessorPlayerResurrect()
{
BPP_INIT(ID_PLAYER_RESURRECT)
avoidReading = true;
}
void Do(PlayerPacket &packet, Player &player) override

@ -18,7 +18,6 @@ namespace mwmp
ProcessorPlayerResurrect()
{
BPP_INIT(ID_PLAYER_RESURRECT)
avoidReading = true;
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
@ -27,9 +26,15 @@ namespace mwmp
if (isLocal())
{
LOG_APPEND(Log::LOG_INFO, "- Packet was about me");
LOG_APPEND(Log::LOG_INFO, "- Packet was about me with resurrectType of %i", player->resurrectType);
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
if (player->resurrectType == mwmp::RESURRECT_TYPE::IMPERIAL_SHRINE)
MWBase::Environment::get().getWorld()->teleportToClosestMarker(playerPtr, "divinemarker");
else if (player->resurrectType == mwmp::RESURRECT_TYPE::TRIBUNAL_TEMPLE)
MWBase::Environment::get().getWorld()->teleportToClosestMarker(playerPtr, "templemarker");
playerPtr.getClass().getCreatureStats(playerPtr).resurrect();
// The player could have died from a hand-to-hand attack, so reset their fatigue

@ -128,6 +128,13 @@ namespace mwmp
unsigned int count;
};
enum RESURRECT_TYPE
{
REGULAR = 0,
IMPERIAL_SHRINE,
TRIBUNAL_TEMPLE
};
class BasePlayer
{
public:
@ -214,6 +221,8 @@ namespace mwmp
bool isChangingRegion;
std::string deathReason;
unsigned int resurrectType;
};
}

@ -0,0 +1,18 @@
#include "PacketPlayerResurrect.hpp"
#include <components/openmw-mp/NetworkMessages.hpp>
#include <components/openmw-mp/Log.hpp>
using namespace mwmp;
PacketPlayerResurrect::PacketPlayerResurrect(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_PLAYER_RESURRECT;
}
void PacketPlayerResurrect::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
RW(player->creatureStats.mDead, send);
RW(player->resurrectType, send);
}

@ -1,30 +1,17 @@
//
// Created by koncord on 13.01.16.
//
#ifndef OPENMW_PACKETPLAYERRESURRECT_HPP
#define OPENMW_PACKETPLAYERRESURRECT_HPP
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
namespace mwmp
{
class PacketPlayerResurrect: public PlayerPacket
class PacketPlayerResurrect : public PlayerPacket
{
public:
PacketPlayerResurrect(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_PLAYER_RESURRECT;
}
void Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
RW(player->creatureStats.mDead, send);
}
PacketPlayerResurrect(RakNet::RakPeerInterface *peer);
virtual void Packet(RakNet::BitStream *bs, bool send);
};
}
#endif //OPENMW_PACKETPLAYERRESURRECT_HPP

Loading…
Cancel
Save