mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 14:37:44 +00:00
Merge pull request #775 from Skyliegirl33/feature-impl
[3.x] Sastasha work, fix instance rotation and add custom vars to director
This commit is contained in:
commit
6bfbb689fb
5 changed files with 186 additions and 31 deletions
34
src/scripts/common/eobj/InstanceExit.cpp
Normal file
34
src/scripts/common/eobj/InstanceExit.cpp
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#include <ScriptObject.h>
|
||||||
|
#include <Actor/Player.h>
|
||||||
|
#include <Service.h>
|
||||||
|
|
||||||
|
#include "Actor/EventObject.h"
|
||||||
|
#include "Territory/HousingZone.h"
|
||||||
|
#include "Manager/TerritoryMgr.h"
|
||||||
|
#include "Manager/PlayerMgr.h"
|
||||||
|
#include "Territory/Land.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace Sapphire;
|
||||||
|
using namespace Sapphire::World::Manager;
|
||||||
|
|
||||||
|
class InstanceExit :
|
||||||
|
public Sapphire::ScriptAPI::EventObjectScript
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InstanceExit() :
|
||||||
|
Sapphire::ScriptAPI::EventObjectScript( 2000139 )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void onTalk( uint32_t eventId, Entity::Player& player, Entity::EventObject& eobj ) override
|
||||||
|
{
|
||||||
|
eventMgr().playScene( player, eventId, 1, 0, [this, eobj]( Entity::Player& player, const Event::SceneResult& result )
|
||||||
|
{
|
||||||
|
if( result.getResult( 0 ) != 1 )
|
||||||
|
player.exitInstance();
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
EXPOSE_SCRIPT( InstanceExit );
|
|
@ -2,6 +2,8 @@
|
||||||
#include <Territory/InstanceContent.h>
|
#include <Territory/InstanceContent.h>
|
||||||
#include <Manager/RNGMgr.h>
|
#include <Manager/RNGMgr.h>
|
||||||
#include <Actor/EventObject.h>
|
#include <Actor/EventObject.h>
|
||||||
|
#include <Actor/Player.h>
|
||||||
|
#include <Actor/BNpc.h>
|
||||||
|
|
||||||
using namespace Sapphire;
|
using namespace Sapphire;
|
||||||
|
|
||||||
|
@ -16,7 +18,23 @@ private:
|
||||||
Green = 2000215
|
Green = 2000215
|
||||||
};
|
};
|
||||||
|
|
||||||
Corals coral;
|
enum Variables : uint8_t
|
||||||
|
{
|
||||||
|
Coral,
|
||||||
|
ObtainedKey
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Sequence : uint8_t
|
||||||
|
{
|
||||||
|
Seq1 = 1,
|
||||||
|
Seq2 = 3,
|
||||||
|
Seq3 = 7,
|
||||||
|
Seq4 = 15,
|
||||||
|
SeqFinish = 31
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr auto EventActionTouch = 24;
|
||||||
|
static constexpr auto EventActionShort = 15;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Sastasha() :
|
Sastasha() :
|
||||||
|
@ -27,9 +45,9 @@ public:
|
||||||
{
|
{
|
||||||
// Random coral
|
// Random coral
|
||||||
auto& RNGMgr = Common::Service< World::Manager::RNGMgr >::ref();
|
auto& RNGMgr = Common::Service< World::Manager::RNGMgr >::ref();
|
||||||
coral = static_cast< Corals >( RNGMgr.getRandGenerator< float >( Corals::Blue, Corals::Green ).next() );
|
instance.setCustomVar( Coral, static_cast< uint64_t >( RNGMgr.getRandGenerator< float >( Corals::Blue, Corals::Green ).next() ) );
|
||||||
|
|
||||||
switch( coral )
|
switch( instance.getCustomVar( Coral ) )
|
||||||
{
|
{
|
||||||
case Corals::Blue:
|
case Corals::Blue:
|
||||||
instance.registerEObj( "Bloodymemo", 2000212, 0, 4, { 320.812988f, 47.862450f, -130.776306f }, 0.600000f, -0.898762f );
|
instance.registerEObj( "Bloodymemo", 2000212, 0, 4, { 320.812988f, 47.862450f, -130.776306f }, 0.600000f, -0.898762f );
|
||||||
|
@ -43,14 +61,16 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
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, 1, { 94.597588f, 26.865030f, -68.584061f }, 1.000000f, 0.000000f );
|
// TODO: this should be spawned when entering the boss arena (1)
|
||||||
|
instance.registerEObj( "sgvf_w_lvd_b0250", 2001504, 4323996, 4, { 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, 1, { 95.510597f, 26.620729f, -67.853653f }, 1.000000f, 0.000000f );
|
instance.registerEObj( "sgvf_w_lvd_b0249", 2001505, 4323997, 4, { 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 );
|
// TODO: this should be spawned when entering the boss arena (2)
|
||||||
|
//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 );
|
||||||
// States -> vf_line_on (id: 12) vf_line_of (id: 13)
|
// States -> vf_line_on (id: 12) vf_line_of (id: 13)
|
||||||
instance.registerEObj( "unknown_2", 2001539, 3653864, 4, { -158.560898f, 8.099012f, 214.344803f }, 0.991760f, 0.000048f );
|
//instance.registerEObj( "unknown_2", 2001539, 3653864, 4, { -158.560898f, 8.099012f, 214.344803f }, 0.991760f, 0.000048f );
|
||||||
instance.registerEObj( "sgvf_w_lvd_b0094_1", 2001540, 4056793, 4, { -163.598602f, 8.026373f, 214.030106f }, 0.991760f, 0.000048f );
|
instance.registerEObj( "sgvf_w_lvd_b0094_1", 2001540, 4056793, 4, { -163.598602f, 8.026373f, 214.030106f }, 0.991760f, 0.000048f );
|
||||||
// States -> vf_line_on (id: 12) vf_line_of (id: 13)
|
// States -> vf_line_on (id: 12) vf_line_of (id: 13)
|
||||||
instance.registerEObj( "sgpl_s1d1_bosswall", 2001508, 4236989, 4, { -303.983612f, 5.576412f, 276.214111f }, 1.000000f, 0.000000f );
|
instance.registerEObj( "sgpl_s1d1_bosswall", 2001508, 4236989, 4, { -303.983612f, 5.576412f, 276.214111f }, 1.000000f, 0.000000f );
|
||||||
|
@ -62,7 +82,6 @@ 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, 3, { 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)
|
||||||
|
@ -90,7 +109,6 @@ public:
|
||||||
instance.registerEObj( "Unnaturalripples_1", 2000406, 3992452, 4, { -302.037598f, 6.500000f, 336.047302f }, 1.000000f, 0.000000f );
|
instance.registerEObj( "Unnaturalripples_1", 2000406, 3992452, 4, { -302.037598f, 6.500000f, 336.047302f }, 1.000000f, 0.000000f );
|
||||||
instance.registerEObj( "Unnaturalripples_2", 2000407, 3992449, 4, { -338.036499f, 6.500000f, 300.206512f }, 0.991789f, 0.000048f );
|
instance.registerEObj( "Unnaturalripples_2", 2000407, 3992449, 4, { -338.036499f, 6.500000f, 300.206512f }, 0.991789f, 0.000048f );
|
||||||
instance.registerEObj( "Unnaturalripples_3", 2000408, 3992453, 4, { -337.929596f, 6.500000f, 335.975311f }, 1.000000f, 0.000000f );
|
instance.registerEObj( "Unnaturalripples_3", 2000408, 3992453, 4, { -337.929596f, 6.500000f, 335.975311f }, 1.000000f, 0.000000f );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onUpdate( InstanceContent& instance, uint64_t tickCount ) override
|
void onUpdate( InstanceContent& instance, uint64_t tickCount ) override
|
||||||
|
@ -107,16 +125,21 @@ public:
|
||||||
|
|
||||||
if( eobj.getName() == "Bluecoralformation" || eobj.getName() == "Redcoralformation" || eobj.getName() == "Greencoralformation" )
|
if( eobj.getName() == "Bluecoralformation" || eobj.getName() == "Redcoralformation" || eobj.getName() == "Greencoralformation" )
|
||||||
{
|
{
|
||||||
eventMgr().eventActionStart( player, getId(), 15,
|
eventMgr().playScene( player, eventId, 1, HIDE_HOTBAR, { 1 },
|
||||||
|
[ & ]( Entity::Player& player, const Event::SceneResult& result )
|
||||||
|
{
|
||||||
|
if( result.getResult( 0 ) == 0 )
|
||||||
|
{
|
||||||
|
eventMgr().eventActionStart( player, getId(), EventActionTouch,
|
||||||
[ & ]( Entity::Player& player, uint32_t eventId, uint64_t additional )
|
[ & ]( Entity::Player& player, uint32_t eventId, uint64_t additional )
|
||||||
{
|
{
|
||||||
eobj.setState( 1 );
|
eobj.setState( 1 );
|
||||||
|
|
||||||
if( eobj.getObjectId() == coral )
|
if( eobj.getObjectId() == instance.getCustomVar( Coral ) )
|
||||||
{
|
{
|
||||||
// TODO: summon boss, do this after boss is defeated
|
// TODO: summon boss, do this after boss is defeated
|
||||||
instance.getEObjByName( "Inconspicuousswitch" )->setState( 0 );
|
instance.registerEObj( "Inconspicuousswitch", 2000216, 3653858, 4, { 62.907951f, 33.969521f, -31.172279f }, 1.000000f, -1.396264f );
|
||||||
instance.setVar( 0, 1 );
|
instance.setVar( 0, Seq1 );
|
||||||
Logger::debug( "correct coral!" );
|
Logger::debug( "correct coral!" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -127,14 +150,56 @@ public:
|
||||||
},
|
},
|
||||||
nullptr, getId() );
|
nullptr, getId() );
|
||||||
}
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open the door and progress duty
|
||||||
if( eobj.getName() == "Inconspicuousswitch" )
|
if( eobj.getName() == "Inconspicuousswitch" )
|
||||||
{
|
{
|
||||||
eventMgr().eventActionStart( player, getId(), 15,
|
eventMgr().eventActionStart( player, getId(), EventActionTouch,
|
||||||
[ & ]( Entity::Player& player, uint32_t eventId, uint64_t additional )
|
[ & ]( Entity::Player& player, uint32_t eventId, uint64_t additional )
|
||||||
{
|
{
|
||||||
instance.getEObjByName( "Hiddendoor" )->setState( 1 );
|
instance.getEObjByName( "Hiddendoor" )->setState( 1 );
|
||||||
eobj.setState( 1 );
|
eobj.setState( 1 );
|
||||||
|
instance.setVar( 0, Seq2 );
|
||||||
|
},
|
||||||
|
nullptr, getId() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: set Seq3 and SeqFinish
|
||||||
|
|
||||||
|
// Pick up key and progress duty
|
||||||
|
if( eobj.getName() == "Captainsquarterskey" )
|
||||||
|
{
|
||||||
|
eventMgr().eventActionStart( player, getId(), EventActionShort,
|
||||||
|
[ & ]( Entity::Player& player, uint32_t eventId, uint64_t additional )
|
||||||
|
{
|
||||||
|
eobj.setState( 1 );
|
||||||
|
instance.setVar( 0, Seq4 );
|
||||||
|
},
|
||||||
|
nullptr, getId() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pick up 2nd key and set variable
|
||||||
|
if( eobj.getName() == "WaveriderGatekey" )
|
||||||
|
{
|
||||||
|
eventMgr().eventActionStart( player, getId(), EventActionShort,
|
||||||
|
[ & ]( Entity::Player& player, uint32_t eventId, uint64_t additional )
|
||||||
|
{
|
||||||
|
eobj.setState( 1 );
|
||||||
|
instance.setCustomVar( ObtainedKey, true );
|
||||||
|
},
|
||||||
|
nullptr, getId() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open the door if the right key has been obtained
|
||||||
|
if( ( eobj.getName() == "Captainsquarters" && instance.getDirectorVar( 0 ) == Seq4 ) ||
|
||||||
|
( eobj.getName() == "WaveriderGate" && instance.getCustomVar( ObtainedKey ) ) )
|
||||||
|
{
|
||||||
|
eventMgr().eventActionStart( player, getId(), EventActionTouch,
|
||||||
|
[ & ]( Entity::Player& player, uint32_t eventId, uint64_t additional )
|
||||||
|
{
|
||||||
|
eobj.setState( 1 );
|
||||||
},
|
},
|
||||||
nullptr, getId() );
|
nullptr, getId() );
|
||||||
}
|
}
|
||||||
|
@ -146,6 +211,29 @@ public:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onLeaveTerritory( InstanceContent& instance, Entity::Player& player ) override
|
||||||
|
{
|
||||||
|
// TODO: Set seq properly once bosses work
|
||||||
|
if( instance.getDirectorVar( 0 ) == Seq4 )
|
||||||
|
instance.setVar( 0, SeqFinish );
|
||||||
|
|
||||||
|
if( instance.getDirectorVar( 0 ) != SeqFinish )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( auto quest = player.getQuest( 66211 ) )
|
||||||
|
if( quest->getSeq() == 3 )
|
||||||
|
{
|
||||||
|
quest->setSeq( 255 );
|
||||||
|
player.updateQuest( quest.value() );
|
||||||
|
}
|
||||||
|
else if( auto quest = player.getQuest( 65781 ) )
|
||||||
|
if( quest->getSeq() == 3 )
|
||||||
|
{
|
||||||
|
quest->setSeq( 255 );
|
||||||
|
player.updateQuest( quest.value() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPOSE_SCRIPT( Sastasha );
|
EXPOSE_SCRIPT( Sastasha );
|
|
@ -121,3 +121,16 @@ uint8_t Sapphire::Event::Director::getDirectorVar( uint8_t index, bool shiftLeft
|
||||||
{
|
{
|
||||||
return getDirectorVar( index ) & ( shiftLeft ? 0xF0 : 0x0F );
|
return getDirectorVar( index ) & ( shiftLeft ? 0xF0 : 0x0F );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sapphire::Event::Director::setCustomVar( uint32_t index, uint64_t value )
|
||||||
|
{
|
||||||
|
m_customVarMap[ index ] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Sapphire::Event::Director::getCustomVar( uint32_t index )
|
||||||
|
{
|
||||||
|
auto it = m_customVarMap.find( index );
|
||||||
|
if( it != m_customVarMap.end() )
|
||||||
|
return it->second;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -100,6 +100,13 @@ namespace Sapphire::Event
|
||||||
*/
|
*/
|
||||||
void setDirectorVar( uint8_t index, uint8_t valueLeft, uint8_t valueRight );
|
void setDirectorVar( uint8_t index, uint8_t valueLeft, uint8_t valueRight );
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Sets a value of a custom var
|
||||||
|
* @param index of var to set
|
||||||
|
* @param value to set
|
||||||
|
*/
|
||||||
|
void setCustomVar( uint32_t index, uint64_t value );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Gets a value of a director var
|
* @brief Gets a value of a director var
|
||||||
* @param index of var to get
|
* @param index of var to get
|
||||||
|
@ -114,6 +121,13 @@ namespace Sapphire::Event
|
||||||
* @return 4 bits of selected index
|
* @return 4 bits of selected index
|
||||||
*/
|
*/
|
||||||
uint8_t getDirectorVar( uint8_t index, bool shiftLeft );
|
uint8_t getDirectorVar( uint8_t index, bool shiftLeft );
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Gets a value of a custom var
|
||||||
|
* @param index of var to get
|
||||||
|
* @return custom var
|
||||||
|
*/
|
||||||
|
uint64_t getCustomVar( uint32_t index );
|
||||||
private:
|
private:
|
||||||
/*! Id of the content of the director */
|
/*! Id of the content of the director */
|
||||||
uint16_t m_contextId;
|
uint16_t m_contextId;
|
||||||
|
@ -131,6 +145,9 @@ namespace Sapphire::Event
|
||||||
|
|
||||||
/*! type of the director */
|
/*! type of the director */
|
||||||
DirectorType m_type;
|
DirectorType m_type;
|
||||||
|
|
||||||
|
/*! custom vars */
|
||||||
|
std::unordered_map< uint32_t, uint64_t > m_customVarMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -469,12 +469,15 @@ void Sapphire::InstanceContent::onBeforePlayerZoneIn( Sapphire::Entity::Player&
|
||||||
|
|
||||||
if( m_pEntranceEObj != nullptr )
|
if( m_pEntranceEObj != nullptr )
|
||||||
{
|
{
|
||||||
|
if( rect )
|
||||||
|
player.setRot( Util::eulerToDirection( { rect->header.transform.rotation.x, rect->header.transform.rotation.y, rect->header.transform.rotation.z } ) );
|
||||||
|
else
|
||||||
player.setRot( PI );
|
player.setRot( PI );
|
||||||
player.setPos( m_pEntranceEObj->getPos() );
|
player.setPos( m_pEntranceEObj->getPos() );
|
||||||
}
|
}
|
||||||
else if( rect )
|
else if( rect )
|
||||||
{
|
{
|
||||||
player.setRot( PI );
|
player.setRot( Util::eulerToDirection( { rect->header.transform.rotation.x, rect->header.transform.rotation.y, rect->header.transform.rotation.z } ) );
|
||||||
player.setPos( { rect->header.transform.translation.x, rect->header.transform.translation.y, rect->header.transform.translation.z } );
|
player.setPos( { rect->header.transform.translation.x, rect->header.transform.translation.y, rect->header.transform.translation.z } );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue