mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 14:37:44 +00:00
Add onTalk events for instances and some Sastasha work
This commit is contained in:
parent
1cddf71da3
commit
080f6ee77a
6 changed files with 93 additions and 5 deletions
|
@ -1,11 +1,15 @@
|
||||||
#include <ScriptObject.h>
|
#include <ScriptObject.h>
|
||||||
#include <Territory/InstanceContent.h>
|
#include <Territory/InstanceContent.h>
|
||||||
|
#include <Actor/EventObject.h>
|
||||||
|
|
||||||
using namespace Sapphire;
|
using namespace Sapphire;
|
||||||
|
|
||||||
class Sastasha :
|
class Sastasha :
|
||||||
public Sapphire::ScriptAPI::InstanceContentScript
|
public Sapphire::ScriptAPI::InstanceContentScript
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
uint8_t coralCount = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Sastasha() :
|
Sastasha() :
|
||||||
Sapphire::ScriptAPI::InstanceContentScript( 4 )
|
Sapphire::ScriptAPI::InstanceContentScript( 4 )
|
||||||
|
@ -14,9 +18,9 @@ public:
|
||||||
void onInit( InstanceContent& instance ) override
|
void onInit( InstanceContent& instance ) override
|
||||||
{
|
{
|
||||||
instance.registerEObj( "unknown_0", 2000211, 0, 4, { 367.827087f, 47.400051f, -226.694305f }, 4.714991f, 0.000432f );
|
instance.registerEObj( "unknown_0", 2000211, 0, 4, { 367.827087f, 47.400051f, -226.694305f }, 4.714991f, 0.000432f );
|
||||||
instance.registerEObj( "sgvf_w_lvd_b0250", 2001504, 4323996, 4, { 94.597588f, 26.865030f, -68.584061f }, 1.000000f, 0.000000f );
|
instance.registerEObj( "sgvf_w_lvd_b0250", 2001504, 4323996, 5, { 94.597588f, 26.865030f, -68.584061f }, 1.000000f, 0.000000f );
|
||||||
// States -> vf_bextwall_on (id: 3) vf_bextwall_of (id: 4)
|
// States -> vf_bextwall_on (id: 3) vf_bextwall_of (id: 4)
|
||||||
instance.registerEObj( "sgvf_w_lvd_b0249", 2001505, 4323997, 4, { 95.510597f, 26.620729f, -67.853653f }, 1.000000f, 0.000000f );
|
instance.registerEObj( "sgvf_w_lvd_b0249", 2001505, 4323997, 5, { 95.510597f, 26.620729f, -67.853653f }, 1.000000f, 0.000000f );
|
||||||
// States -> vf_line_on (id: 10) vf_line_of (id: 11)
|
// States -> vf_line_on (id: 10) vf_line_of (id: 11)
|
||||||
instance.registerEObj( "unknown_1", 2001506, 3653862, 4, { -9.239832f, 24.789940f, 35.778252f }, 0.991760f, 0.000048f );
|
instance.registerEObj( "unknown_1", 2001506, 3653862, 4, { -9.239832f, 24.789940f, 35.778252f }, 0.991760f, 0.000048f );
|
||||||
instance.registerEObj( "sgvf_w_lvd_b0094", 2001507, 4035750, 4, { -2.841087f, 23.114571f, 38.090420f }, 0.991760f, 0.000048f );
|
instance.registerEObj( "sgvf_w_lvd_b0094", 2001507, 4035750, 4, { -2.841087f, 23.114571f, 38.090420f }, 0.991760f, 0.000048f );
|
||||||
|
@ -33,7 +37,7 @@ public:
|
||||||
instance.registerEObj( "Bluecoralformation", 2000213, 3668215, 4, { 75.869797f, 35.101421f, -32.537209f }, 0.930753f, 0.000240f );
|
instance.registerEObj( "Bluecoralformation", 2000213, 3668215, 4, { 75.869797f, 35.101421f, -32.537209f }, 0.930753f, 0.000240f );
|
||||||
instance.registerEObj( "Redcoralformation", 2000214, 3668214, 4, { 88.769371f, 31.135691f, -40.869640f }, 0.930753f, 0.000240f );
|
instance.registerEObj( "Redcoralformation", 2000214, 3668214, 4, { 88.769371f, 31.135691f, -40.869640f }, 0.930753f, 0.000240f );
|
||||||
instance.registerEObj( "Greencoralformation", 2000215, 3668216, 4, { 64.988159f, 33.672821f, -56.690559f }, 0.991789f, 0.000048f );
|
instance.registerEObj( "Greencoralformation", 2000215, 3668216, 4, { 64.988159f, 33.672821f, -56.690559f }, 0.991789f, 0.000048f );
|
||||||
instance.registerEObj( "Inconspicuousswitch", 2000216, 3653858, 4, { 62.907951f, 33.969521f, -31.172279f }, 1.000000f, -1.396264f );
|
instance.registerEObj( "Inconspicuousswitch", 2000216, 3653858, 5, { 62.907951f, 33.969521f, -31.172279f }, 1.000000f, -1.396264f );
|
||||||
instance.registerEObj( "Hiddendoor", 2000217, 3653517, 4, { 59.000000f, 32.000000f, -35.000000f }, 1.000000f, -2.007129f );
|
instance.registerEObj( "Hiddendoor", 2000217, 3653517, 4, { 59.000000f, 32.000000f, -35.000000f }, 1.000000f, -2.007129f );
|
||||||
instance.registerEObj( "Giantclam", 2000222, 4208408, 4, { 181.170303f, 32.104599f, -128.069000f }, 0.991789f, -0.862350f );
|
instance.registerEObj( "Giantclam", 2000222, 4208408, 4, { 181.170303f, 32.104599f, -128.069000f }, 0.991789f, -0.862350f );
|
||||||
// States -> vf_kai_off (id: 4) vf_kai_on (id: 5) vf_kai_pop (id: 6) close_open (id: 7) open_close (id: 8)
|
// States -> vf_kai_off (id: 4) vf_kai_on (id: 5) vf_kai_pop (id: 6) close_open (id: 7) open_close (id: 8)
|
||||||
|
@ -72,6 +76,42 @@ public:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onTalk( InstanceContent& instance, Entity::Player& player, Entity::EventObject& eobj, uint32_t eventId ) override
|
||||||
|
{
|
||||||
|
if( eobj.getName() == "Bluecoralformation" || eobj.getName() == "Redcoralformation" || eobj.getName() == "Greencoralformation" )
|
||||||
|
{
|
||||||
|
eventMgr().eventActionStart( player, getId(), 15,
|
||||||
|
[ & ]( Entity::Player& player, uint32_t eventId, uint64_t additional )
|
||||||
|
{
|
||||||
|
eobj.setState( 1 );
|
||||||
|
coralCount += 1;
|
||||||
|
|
||||||
|
if( coralCount == 3 )
|
||||||
|
{
|
||||||
|
// TODO: summon boss, do this after boss is defeated
|
||||||
|
instance.getEObjByName( "Inconspicuousswitch" )->setState( 0 );
|
||||||
|
instance.setVar( 0, 1 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO: spawn adds
|
||||||
|
}
|
||||||
|
},
|
||||||
|
nullptr, getId() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( eobj.getName() == "Inconspicuousswitch" )
|
||||||
|
{
|
||||||
|
eventMgr().eventActionStart( player, getId(), 15,
|
||||||
|
[ & ]( Entity::Player& player, uint32_t eventId, uint64_t additional )
|
||||||
|
{
|
||||||
|
instance.getEObjByName( "Hiddendoor" )->setState( 1 );
|
||||||
|
eobj.setState( 1 );
|
||||||
|
},
|
||||||
|
nullptr, getId() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void onEnterTerritory( InstanceContent& instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
|
void onEnterTerritory( InstanceContent& instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
|
||||||
uint16_t param2 ) override
|
uint16_t param2 ) override
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,6 +19,16 @@ EOBJ_INIT
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onTalk( InstanceContent& instance, Entity::Player& player, Entity::EventObject& eobj, uint32_t eventId ) override
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void onTalk( InstanceContent& instance, Entity::Player& player, uint32_t eventId, uint64_t actorId ) override
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void onEnterTerritory( InstanceContent& instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
|
void onEnterTerritory( InstanceContent& instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
|
||||||
uint16_t param2 ) override
|
uint16_t param2 ) override
|
||||||
{
|
{
|
||||||
|
|
|
@ -222,6 +222,16 @@ namespace Sapphire::ScriptAPI
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceContentScript::onTalk( Sapphire::InstanceContent& instance, Sapphire::Entity::Player& player, Sapphire::Entity::EventObject& eobj,
|
||||||
|
uint32_t eventId )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void InstanceContentScript::onTalk( Sapphire::InstanceContent& instance, Sapphire::Entity::Player& player, uint32_t eventId,
|
||||||
|
uint64_t actorId )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void InstanceContentScript::onUpdate( InstanceContent& instance, uint64_t tickCount )
|
void InstanceContentScript::onUpdate( InstanceContent& instance, uint64_t tickCount )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,6 +331,10 @@ namespace Sapphire::ScriptAPI
|
||||||
|
|
||||||
virtual void onInit( Sapphire::InstanceContent& instance );
|
virtual void onInit( Sapphire::InstanceContent& instance );
|
||||||
|
|
||||||
|
virtual void onTalk( Sapphire::InstanceContent& instance, Sapphire::Entity::Player& player, Sapphire::Entity::EventObject& eobj, uint32_t eventId );
|
||||||
|
|
||||||
|
virtual void onTalk( Sapphire::InstanceContent& instance, Sapphire::Entity::Player& player, uint32_t eventId, uint64_t actorId );
|
||||||
|
|
||||||
virtual void onUpdate( Sapphire::InstanceContent& instance, uint64_t tickCount );
|
virtual void onUpdate( Sapphire::InstanceContent& instance, uint64_t tickCount );
|
||||||
|
|
||||||
virtual void onEnterTerritory( Sapphire::InstanceContent& instance, Sapphire::Entity::Player& player, uint32_t eventId,
|
virtual void onEnterTerritory( Sapphire::InstanceContent& instance, Sapphire::Entity::Player& player, uint32_t eventId,
|
||||||
|
|
|
@ -216,6 +216,16 @@ bool Sapphire::Scripting::ScriptMgr::onTalk( Entity::Player& player, uint64_t ac
|
||||||
script->onTalk( eventId, player, *eobj );
|
script->onTalk( eventId, player, *eobj );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( auto instance = zone->getAsInstanceContent() )
|
||||||
|
{
|
||||||
|
auto instanceScript = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::InstanceContentScript >( instance->getDirectorId() );
|
||||||
|
if( instanceScript )
|
||||||
|
{
|
||||||
|
instanceScript->onTalk( *instance, player, *eobj, eventId );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for a direct eventid match first, otherwise default to base type
|
// check for a direct eventid match first, otherwise default to base type
|
||||||
|
@ -234,6 +244,17 @@ bool Sapphire::Scripting::ScriptMgr::onTalk( Entity::Player& player, uint64_t ac
|
||||||
script->onTalk( eventId, player, actorId );
|
script->onTalk( eventId, player, actorId );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check for instance script
|
||||||
|
if( auto instance = zone->getAsInstanceContent() )
|
||||||
|
{
|
||||||
|
auto instanceScript = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::InstanceContentScript >( instance->getDirectorId() );
|
||||||
|
if( instanceScript )
|
||||||
|
{
|
||||||
|
instanceScript->onTalk( *instance, player, eventId, actorId );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sapphire::Scripting::ScriptMgr::onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 )
|
bool Sapphire::Scripting::ScriptMgr::onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 )
|
||||||
|
|
|
@ -500,7 +500,7 @@ void Sapphire::InstanceContent::onTalk( Sapphire::Entity::Player& player, uint32
|
||||||
{
|
{
|
||||||
// todo: handle exit (and maybe shortcut?) behaviour here
|
// todo: handle exit (and maybe shortcut?) behaviour here
|
||||||
|
|
||||||
auto it = m_eventIdToObjectMap.find( eventId );
|
/*auto it = m_eventIdToObjectMap.find( eventId );
|
||||||
if( it == m_eventIdToObjectMap.end() )
|
if( it == m_eventIdToObjectMap.end() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -508,7 +508,10 @@ void Sapphire::InstanceContent::onTalk( Sapphire::Entity::Player& player, uint32
|
||||||
onTalk( player, it->second, getAsInstanceContent(), actorId );
|
onTalk( player, it->second, getAsInstanceContent(), actorId );
|
||||||
else
|
else
|
||||||
PlayerMgr::sendDebug( player, "No onTalk handler found for interactable eobj with EObjID#{0}, eventId#{1}",
|
PlayerMgr::sendDebug( player, "No onTalk handler found for interactable eobj with EObjID#{0}, eventId#{1}",
|
||||||
it->second->getObjectId(), eventId );
|
it->second->getObjectId(), eventId );*/
|
||||||
|
|
||||||
|
auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref();
|
||||||
|
scriptMgr.onTalk( player, actorId, eventId );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Reference in a new issue