2017-03-31 18:36:24 +00:00
|
|
|
//
|
|
|
|
// Created by koncord on 01.04.17.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef OPENMW_PROCESSORPLAYERATTRIBUTE_HPP
|
|
|
|
#define OPENMW_PROCESSORPLAYERATTRIBUTE_HPP
|
|
|
|
|
2017-07-03 17:13:10 +00:00
|
|
|
#include "../PlayerProcessor.hpp"
|
2017-03-31 18:36:24 +00:00
|
|
|
|
|
|
|
namespace mwmp
|
|
|
|
{
|
2017-12-09 02:20:55 +00:00
|
|
|
class ProcessorPlayerAttribute final: public PlayerProcessor
|
2017-03-31 18:36:24 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-03-05 07:19:09 +00:00
|
|
|
using OldAState = ESM::StatState<int>;
|
2017-03-31 18:36:24 +00:00
|
|
|
ProcessorPlayerAttribute()
|
|
|
|
{
|
|
|
|
BPP_INIT(ID_PLAYER_ATTRIBUTE)
|
2018-03-05 07:19:09 +00:00
|
|
|
|
|
|
|
Networking::get().getState().getState()->new_usertype<OldAState>("OldAState",
|
|
|
|
"base", &OldAState::mBase,
|
|
|
|
"current", &OldAState::mCurrent,
|
|
|
|
"mod", &OldAState::mMod,
|
|
|
|
"damage", &OldAState::mDamage);
|
|
|
|
}
|
|
|
|
|
2018-03-05 07:30:24 +00:00
|
|
|
void PreReading(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
|
2018-03-05 07:19:09 +00:00
|
|
|
{
|
|
|
|
if (!player->creatureStats.mDead)
|
|
|
|
std::copy(std::begin(player->creatureStats.mAttributes),
|
|
|
|
std::end(player->creatureStats.mAttributes),
|
|
|
|
oldValues.begin()
|
|
|
|
);
|
|
|
|
|
2017-03-31 18:36:24 +00:00
|
|
|
}
|
|
|
|
|
2017-12-07 23:32:39 +00:00
|
|
|
void Do(PlayerPacket &packet, const std::shared_ptr<Player> &player) override
|
2017-03-31 18:36:24 +00:00
|
|
|
{
|
2017-08-27 16:15:56 +00:00
|
|
|
if (!player->creatureStats.mDead)
|
2017-03-31 18:36:24 +00:00
|
|
|
{
|
|
|
|
//myPacket->Send(player, true);
|
2018-03-05 07:19:09 +00:00
|
|
|
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_PLAYER_ATTRIBUTE, true>(&oldValues, player.get());
|
2017-03-31 18:36:24 +00:00
|
|
|
|
2017-12-09 07:03:06 +00:00
|
|
|
player->sendToLoaded(packet);
|
2017-03-31 18:36:24 +00:00
|
|
|
}
|
|
|
|
}
|
2018-03-05 07:19:09 +00:00
|
|
|
private:
|
|
|
|
std::array<OldAState, ESM::Attribute::Length> oldValues;
|
2017-03-31 18:36:24 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //OPENMW_PROCESSORPLAYERATTRIBUTE_HPP
|