mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 15:17:46 +00:00
ugly prototype of arenascript;
This commit is contained in:
parent
52dfd3a2f6
commit
fc46e5792e
6 changed files with 149 additions and 3 deletions
|
@ -46,7 +46,7 @@ foreach(_scriptDir ${children})
|
|||
MODULE
|
||||
${SCRIPT_BUILD_FILES}
|
||||
"${SCRIPT_INCLUDE_FILES}"
|
||||
"${_scriptDir}/ScriptLoader.cpp" )
|
||||
"${_scriptDir}/ScriptLoader.cpp" "arena/IfritNormal.cpp")
|
||||
|
||||
target_link_libraries( "script_${_name}" world )
|
||||
|
||||
|
|
71
src/scripts/arena/IfritNormal.cpp
Normal file
71
src/scripts/arena/IfritNormal.cpp
Normal file
|
@ -0,0 +1,71 @@
|
|||
#include <ScriptObject.h>
|
||||
#include <Territory/InstanceContent.h>
|
||||
#include <Actor/GameObject.h>
|
||||
#include <Actor/BNpc.h>
|
||||
|
||||
using namespace Sapphire;
|
||||
|
||||
class IfritNormal : public Sapphire::ScriptAPI::InstanceArenaScript
|
||||
{
|
||||
public:
|
||||
IfritNormal() : Sapphire::ScriptAPI::InstanceArenaScript( 20001 )
|
||||
{ }
|
||||
|
||||
void onInit( InstanceContent& instance ) override
|
||||
{
|
||||
auto boss = instance.createBNpcFromLayoutId( 4126276, 13884, Common::BNpcType::Enemy );
|
||||
boss->setFlag( Entity::NoDeaggro );
|
||||
|
||||
//instance.sendForward();
|
||||
}
|
||||
|
||||
void onUpdate( InstanceContent& instance, uint64_t tickCount ) override
|
||||
{
|
||||
auto boss = instance.getActiveBNpcByLayoutId( 4126276 );
|
||||
|
||||
if( boss; boss->hateListGetHighestValue() != 0 )
|
||||
{
|
||||
if( instance.getDirectorVar( 0 ) == 0 )
|
||||
onBattleStart( instance );
|
||||
|
||||
boss->setRot( boss->getRot() + 0.5f );
|
||||
boss->setPos( boss->getPos() );
|
||||
|
||||
boss->sendPositionUpdate();
|
||||
|
||||
playerMgr().sendDebug( *boss->hateListGetHighest()->getAsPlayer(), std::to_string( boss->getRot() ) );
|
||||
|
||||
if( boss->getRot() >= 4.f && instance.getDirectorVar( 0 ) == 1 )
|
||||
{
|
||||
instance.setDirectorVar( 0, 0 );
|
||||
boss->hateListGetHighest()->die();
|
||||
boss->hateListClear();
|
||||
onReset( instance );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void onReset( InstanceContent& instance ) override
|
||||
{
|
||||
auto boss = instance.getActiveBNpcByLayoutId( 4126276 );
|
||||
instance.removeActor( boss );
|
||||
|
||||
onInit( instance );
|
||||
}
|
||||
|
||||
void onBattleStart( InstanceContent& instance ) override
|
||||
{
|
||||
auto boss = instance.getActiveBNpcByLayoutId( 4126276 );
|
||||
|
||||
instance.setDirectorVar( 0, 1 );
|
||||
|
||||
auto pPlayer = boss->hateListGetHighest()->getAsPlayer();
|
||||
|
||||
instance.sendEventLogMessage( *pPlayer, instance, 4847, { 0, 0 } );
|
||||
instance.sendEventLogMessage( *pPlayer, instance, 170, { 0, boss->getId() } );
|
||||
}
|
||||
};
|
||||
|
||||
EXPOSE_SCRIPT( IfritNormal );
|
|
@ -291,5 +291,27 @@ namespace Sapphire::ScriptAPI
|
|||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
InstanceArenaScript::InstanceArenaScript( uint32_t instanceContentId ) : ScriptObject( uint32_t{ 0x8003 } << 16 | instanceContentId, typeid( InstanceArenaScript ).hash_code() )
|
||||
{
|
||||
}
|
||||
|
||||
void InstanceArenaScript::onInit( InstanceContent& instance )
|
||||
{
|
||||
}
|
||||
|
||||
void InstanceArenaScript::onUpdate( InstanceContent& instance, uint64_t tickCount )
|
||||
{
|
||||
}
|
||||
|
||||
void InstanceArenaScript::onReset( InstanceContent& instance )
|
||||
{
|
||||
}
|
||||
|
||||
void InstanceArenaScript::onBattleStart( InstanceContent& instance )
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -375,7 +375,7 @@ namespace Sapphire::ScriptAPI
|
|||
};
|
||||
|
||||
/*!
|
||||
* @brief The base class for any scripts that implement behaviour related to instance content zones
|
||||
* @brief The base class for any scripts that implement behaviour related to quest battles
|
||||
*/
|
||||
class QuestBattleScript : public ScriptObject
|
||||
{
|
||||
|
@ -406,6 +406,48 @@ namespace Sapphire::ScriptAPI
|
|||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief The base class for any scripts that implement behaviour related to a generic arena
|
||||
*/
|
||||
class ArenaScript : public ScriptObject
|
||||
{
|
||||
public:
|
||||
explicit ArenaScript( uint32_t battleId );
|
||||
|
||||
virtual void onInit( Sapphire::Territory& instance );
|
||||
|
||||
virtual void onUpdate( Sapphire::Territory& instance, uint64_t tickCount );
|
||||
|
||||
virtual void onReset( Sapphire::Territory& instance );
|
||||
|
||||
World::Manager::PlayerMgr& playerMgr()
|
||||
{
|
||||
return Common::Service< World::Manager::PlayerMgr >::ref();
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief The base class for any scripts that implement behaviour related to an instance arena
|
||||
*/
|
||||
class InstanceArenaScript : public ScriptObject
|
||||
{
|
||||
public:
|
||||
explicit InstanceArenaScript( uint32_t instanceContentId );
|
||||
|
||||
virtual void onInit( Sapphire::InstanceContent& instance );
|
||||
|
||||
virtual void onUpdate( Sapphire::InstanceContent& instance, uint64_t tickCount );
|
||||
|
||||
virtual void onReset( Sapphire::InstanceContent& instance );
|
||||
|
||||
virtual void onBattleStart( Sapphire::InstanceContent& instance );
|
||||
|
||||
World::Manager::PlayerMgr& playerMgr()
|
||||
{
|
||||
return Common::Service< World::Manager::PlayerMgr >::ref();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -241,7 +241,7 @@ Sapphire::ScriptAPI::ScriptObject** Sapphire::Scripting::ScriptLoader::getScript
|
|||
}
|
||||
else
|
||||
{
|
||||
Logger::warn( "did not find a win32initLinkshell export on a windows script target - the server will likely crash!" );
|
||||
Logger::warn( "did not find a win32initWarp export on a windows script target - the server will likely crash!" );
|
||||
}
|
||||
#else
|
||||
auto func = reinterpret_cast< getScripts >( dlsym( handle, "getScripts" ) );
|
||||
|
|
|
@ -680,10 +680,17 @@ bool Sapphire::Scripting::ScriptMgr::onZoneInit( const Territory& zone )
|
|||
|
||||
bool Sapphire::Scripting::ScriptMgr::onInstanceInit( InstanceContent& instance )
|
||||
{
|
||||
auto instId = instance.getDirectorId();
|
||||
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::InstanceContentScript >( instance.getDirectorId() );
|
||||
|
||||
if( script )
|
||||
{
|
||||
script->onInit( instance );
|
||||
|
||||
auto arenaScript = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::InstanceArenaScript >( instance.getDirectorId() );
|
||||
if( arenaScript )
|
||||
arenaScript->onInit( instance );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -697,6 +704,10 @@ bool Sapphire::Scripting::ScriptMgr::onInstanceUpdate( InstanceContent& instance
|
|||
if( script )
|
||||
{
|
||||
script->onUpdate( instance, tickCount );
|
||||
|
||||
auto arenaScript = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::InstanceArenaScript >( instance.getDirectorId() );
|
||||
if( arenaScript )
|
||||
arenaScript->onUpdate( instance, tickCount );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue