mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-02 08:57:44 +00:00
Added a onPlayerDeath function, to be reworked when battlescripts arrive
This commit is contained in:
parent
4d64ece25a
commit
bd1753423e
8 changed files with 51 additions and 1 deletions
|
@ -96,6 +96,9 @@ namespace Sapphire::Network::ActorControl
|
||||||
FateReqFailMsg = 0x76,
|
FateReqFailMsg = 0x76,
|
||||||
DutyQuestScreenMsg = 0x7B,
|
DutyQuestScreenMsg = 0x7B,
|
||||||
|
|
||||||
|
SetContentClearFlag = 0x82,
|
||||||
|
SetContentOpenFlag = 0x83,
|
||||||
|
|
||||||
ItemObtainIcon = 0x84,
|
ItemObtainIcon = 0x84,
|
||||||
FateItemFailMsg = 0x85,
|
FateItemFailMsg = 0x85,
|
||||||
ItemFailMsg = 0x86,
|
ItemFailMsg = 0x86,
|
||||||
|
|
|
@ -1005,7 +1005,10 @@ void Player::unsetStateFlag( Common::PlayerStateFlag flag )
|
||||||
void Player::update( uint64_t tickCount )
|
void Player::update( uint64_t tickCount )
|
||||||
{
|
{
|
||||||
if( m_hp <= 0 && m_status != ActorStatus::Dead )
|
if( m_hp <= 0 && m_status != ActorStatus::Dead )
|
||||||
|
{
|
||||||
die();
|
die();
|
||||||
|
Service< World::Manager::PlayerMgr >::ref().onDeath( *this );
|
||||||
|
}
|
||||||
|
|
||||||
if( !isAlive() )
|
if( !isAlive() )
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -270,7 +270,11 @@ void PlayerMgr::onLogin( Entity::Player &player )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerMgr::onDeath( Entity::Player &player )
|
||||||
|
{
|
||||||
|
auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref();
|
||||||
|
scriptMgr.onPlayerDeath( player );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////// Helper ///////////
|
////////// Helper ///////////
|
||||||
|
|
|
@ -44,6 +44,8 @@ class PlayerMgr
|
||||||
|
|
||||||
void onLogin( Sapphire::Entity::Player& player );
|
void onLogin( Sapphire::Entity::Player& player );
|
||||||
|
|
||||||
|
void onDeath( Sapphire::Entity::Player& player );
|
||||||
|
|
||||||
//////////// Helpers
|
//////////// Helpers
|
||||||
|
|
||||||
static void sendServerNotice( Sapphire::Entity::Player& player, const std::string& message );
|
static void sendServerNotice( Sapphire::Entity::Player& player, const std::string& message );
|
||||||
|
|
|
@ -182,6 +182,10 @@ namespace Sapphire::ScriptAPI
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QuestScript::onPlayerDeath( World::Quest& quest, Sapphire::Entity::Player& player )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
EventObjectScript::EventObjectScript( uint32_t eobjId ) :
|
EventObjectScript::EventObjectScript( uint32_t eobjId ) :
|
||||||
|
|
|
@ -254,6 +254,8 @@ namespace Sapphire::ScriptAPI
|
||||||
|
|
||||||
virtual void onOutsideRange( World::Quest& quest, Sapphire::Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
|
virtual void onOutsideRange( World::Quest& quest, Sapphire::Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
|
||||||
|
|
||||||
|
virtual void onPlayerDeath( World::Quest& quest, Sapphire::Entity::Player& player );
|
||||||
|
|
||||||
virtual void onEventHandlerTradeReturn( Sapphire::Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param,
|
virtual void onEventHandlerTradeReturn( Sapphire::Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param,
|
||||||
uint32_t catalogId );
|
uint32_t catalogId );
|
||||||
|
|
||||||
|
|
|
@ -491,6 +491,36 @@ bool Sapphire::Scripting::ScriptMgr::onBNpcKill( Entity::Player& player, Entity:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Sapphire::Scripting::ScriptMgr::onPlayerDeath( Entity::Player& player )
|
||||||
|
{
|
||||||
|
auto& eventMgr = Common::Service< World::Manager::EventMgr >::ref();
|
||||||
|
|
||||||
|
// loop through all active quests and try to call available onPlayerDeath callbacks
|
||||||
|
for( size_t i = 0; i < 30; i++ )
|
||||||
|
{
|
||||||
|
auto quest = player.getQuestByIndex( static_cast< uint16_t >( i ) );
|
||||||
|
if( quest.getId() == 0 )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
uint32_t questId = quest.getId() | Event::EventHandler::EventHandlerType::Quest << 16;
|
||||||
|
|
||||||
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestScript >( questId );
|
||||||
|
if( script )
|
||||||
|
{
|
||||||
|
std::string objName = eventMgr.getEventName( questId );
|
||||||
|
|
||||||
|
PlayerMgr::sendDebug( player, "Calling: {0}.onPlayerDeath name: {1}", objName, player.getName() );
|
||||||
|
|
||||||
|
World::Quest preQ = quest;
|
||||||
|
script->onPlayerDeath( quest, player );
|
||||||
|
if( quest != preQ )
|
||||||
|
player.updateQuest( quest );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Sapphire::Scripting::ScriptMgr::onEObjHit( Sapphire::Entity::Player& player, uint64_t actorId, uint32_t actionId )
|
bool Sapphire::Scripting::ScriptMgr::onEObjHit( Sapphire::Entity::Player& player, uint64_t actorId, uint32_t actionId )
|
||||||
{
|
{
|
||||||
auto& eventMgr = Common::Service< World::Manager::EventMgr >::ref();
|
auto& eventMgr = Common::Service< World::Manager::EventMgr >::ref();
|
||||||
|
|
|
@ -70,6 +70,8 @@ namespace Sapphire::Scripting
|
||||||
|
|
||||||
bool onBNpcKill( Entity::Player& player, Entity::BNpc& bnpc );
|
bool onBNpcKill( Entity::Player& player, Entity::BNpc& bnpc );
|
||||||
|
|
||||||
|
bool onPlayerDeath( Entity::Player& player );
|
||||||
|
|
||||||
void onTriggerOwnerDeaggro( Entity::Player& player, Entity::BNpc& bnpc );
|
void onTriggerOwnerDeaggro( Entity::Player& player, Entity::BNpc& bnpc );
|
||||||
|
|
||||||
bool onEObjHit( Entity::Player& player, uint64_t actorId, uint32_t actionId );
|
bool onEObjHit( Entity::Player& player, uint64_t actorId, uint32_t actionId );
|
||||||
|
|
Loading…
Add table
Reference in a new issue