mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 06:27:45 +00:00
restructure how actionscripts work
This commit is contained in:
parent
2e9e127f56
commit
83f6bd247b
11 changed files with 126 additions and 50 deletions
|
@ -1,18 +0,0 @@
|
||||||
#include <Script/NativeScriptApi.h>
|
|
||||||
#include "../ScriptObject.h"
|
|
||||||
#include <Actor/Player.h>
|
|
||||||
|
|
||||||
class ActionReturn6 :
|
|
||||||
public Sapphire::ScriptAPI::ActionScript
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ActionReturn6() :
|
|
||||||
Sapphire::ScriptAPI::ActionScript( 6 )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void onCastFinish( Sapphire::Entity::Player& player, Sapphire::Entity::Chara& targetActor ) override
|
|
||||||
{
|
|
||||||
player.returnToHomepoint();
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1,17 +0,0 @@
|
||||||
#include <ScriptObject.h>
|
|
||||||
#include <Actor/Player.h>
|
|
||||||
|
|
||||||
class ActionSprint3 :
|
|
||||||
public Sapphire::ScriptAPI::ActionScript
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ActionSprint3() :
|
|
||||||
Sapphire::ScriptAPI::ActionScript( 3 )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void onCastFinish( Sapphire::Entity::Player& player, Sapphire::Entity::Chara& targetActor ) override
|
|
||||||
{
|
|
||||||
player.addStatusEffectByIdIfNotExist( 50, 20000, player, 30 );
|
|
||||||
}
|
|
||||||
};
|
|
21
src/scripts/action/common/ActionReturn6.cpp
Normal file
21
src/scripts/action/common/ActionReturn6.cpp
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#include <Script/NativeScriptApi.h>
|
||||||
|
#include <ScriptObject.h>
|
||||||
|
#include <Actor/Player.h>
|
||||||
|
|
||||||
|
class ActionReturn6 :
|
||||||
|
public Sapphire::ScriptAPI::ActionScript
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ActionReturn6() :
|
||||||
|
Sapphire::ScriptAPI::ActionScript( 6 )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void onCastFinish( Sapphire::Entity::Chara& sourceActor, Sapphire::Action::Action& currentAction ) override
|
||||||
|
{
|
||||||
|
if( !sourceActor.isPlayer() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
sourceActor.getAsPlayer()->returnToHomepoint();
|
||||||
|
}
|
||||||
|
};
|
20
src/scripts/action/common/ActionSprint3.cpp
Normal file
20
src/scripts/action/common/ActionSprint3.cpp
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#include <ScriptObject.h>
|
||||||
|
#include <Actor/Player.h>
|
||||||
|
|
||||||
|
class ActionSprint3 :
|
||||||
|
public Sapphire::ScriptAPI::ActionScript
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ActionSprint3() :
|
||||||
|
Sapphire::ScriptAPI::ActionScript( 3 )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void onCastFinish( Sapphire::Entity::Chara& sourceActor, Sapphire::Action::Action& currentAction ) override
|
||||||
|
{
|
||||||
|
if( !sourceActor.isPlayer() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
sourceActor.getAsPlayer()->addStatusEffectByIdIfNotExist( 50, 20000, sourceActor, 30 );
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,27 @@
|
||||||
|
#include <Script/NativeScriptApi.h>
|
||||||
|
#include <ScriptObject.h>
|
||||||
|
#include <Actor/Player.h>
|
||||||
|
|
||||||
|
class ActionHeavyShot97 :
|
||||||
|
public Sapphire::ScriptAPI::ActionScript
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ActionHeavyShot97() :
|
||||||
|
Sapphire::ScriptAPI::ActionScript( 97 )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void onCastFinish( Sapphire::Entity::Chara& source, Sapphire::Action::Action& currentAction ) override
|
||||||
|
{
|
||||||
|
if( auto player = source.getAsPlayer() )
|
||||||
|
player->sendDebug( "cast finished" );
|
||||||
|
}
|
||||||
|
|
||||||
|
void onCharaHit( Sapphire::Entity::Chara& sourceActor, Sapphire::Entity::Chara& hitActor,
|
||||||
|
Sapphire::Action::Action& currentAction ) override
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
|
@ -156,7 +156,7 @@ void Sapphire::Action::Action::onStart()
|
||||||
auto player = m_pSource->getAsPlayer();
|
auto player = m_pSource->getAsPlayer();
|
||||||
if( player )
|
if( player )
|
||||||
{
|
{
|
||||||
player->sendDebug( "onStart()" );
|
player->sendDebug( "onCastStart()" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( isCastedAction() )
|
if( isCastedAction() )
|
||||||
|
@ -197,7 +197,7 @@ void Sapphire::Action::Action::onInterrupt()
|
||||||
//player->unsetStateFlag( PlayerStateFlag::Occupied1 );
|
//player->unsetStateFlag( PlayerStateFlag::Occupied1 );
|
||||||
player->unsetStateFlag( PlayerStateFlag::Casting );
|
player->unsetStateFlag( PlayerStateFlag::Casting );
|
||||||
|
|
||||||
player->sendDebug( "onInterrupt()" );
|
player->sendDebug( "onCastInterrupt()" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( isCastedAction() )
|
if( isCastedAction() )
|
||||||
|
@ -234,12 +234,15 @@ void Sapphire::Action::Action::onFinish()
|
||||||
|
|
||||||
if( !hasResidentTarget() )
|
if( !hasResidentTarget() )
|
||||||
{
|
{
|
||||||
pScriptMgr->onCastFinish( *pPlayer, m_pTarget, m_id );
|
pScriptMgr->onCastFinish( *m_pSource, *this );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pScriptMgr->onEObjHit( *pPlayer, m_targetId );
|
pScriptMgr->onEObjHit( *pPlayer, m_targetId );
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: calculate final hit targets and call onCharaHit in action script
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::Action::Action::buildEffectPacket()
|
void Sapphire::Action::Action::buildEffectPacket()
|
||||||
|
|
|
@ -300,7 +300,7 @@ void Sapphire::Entity::Player::eventActionStart( uint32_t eventId,
|
||||||
//
|
//
|
||||||
// if( pEvent )
|
// if( pEvent )
|
||||||
// pEvent->setPlayedScene( true );
|
// pEvent->setPlayedScene( true );
|
||||||
// pEventAction->onStart();
|
// pEventAction->onCastStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ void Sapphire::Entity::Player::eventItemActionStart( uint32_t eventId,
|
||||||
//
|
//
|
||||||
// setCurrentAction( pEventItemAction );
|
// setCurrentAction( pEventItemAction );
|
||||||
//
|
//
|
||||||
// pEventItemAction->onStart();
|
// pEventItemAction->onCastStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -88,15 +88,20 @@ namespace Sapphire::ScriptAPI
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionScript::onStart( Entity::Chara& sourceActor, Entity::Chara& targetActor )
|
void ActionScript::onCastStart( Entity::Chara& sourceActor, Sapphire::Action::Action& currentAction )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionScript::onCastFinish( Entity::Player& player, Entity::Chara& targetActor )
|
void ActionScript::onCastFinish( Entity::Chara& sourceActor, Sapphire::Action::Action& currentAction )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionScript::onInterrupt( Entity::Chara& sourceActor/*, Sapphire::Entity::Chara targetActor*/ )
|
void ActionScript::onCastInterrupt( Entity::Chara& sourceActor, Sapphire::Action::Action& currentAction )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActionScript::onCharaHit( Sapphire::Entity::Chara& sourceActor, Sapphire::Entity::Chara& hitActor,
|
||||||
|
Sapphire::Action::Action& currentAction )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,11 +140,14 @@ namespace Sapphire::ScriptAPI
|
||||||
public:
|
public:
|
||||||
explicit ActionScript( uint32_t abilityId );
|
explicit ActionScript( uint32_t abilityId );
|
||||||
|
|
||||||
virtual void onStart( Sapphire::Entity::Chara& sourceActor, Sapphire::Entity::Chara& targetActor );
|
virtual void onCastStart( Sapphire::Entity::Chara& sourceActor, Sapphire::Action::Action& currentAction );
|
||||||
|
|
||||||
virtual void onCastFinish( Sapphire::Entity::Player& player, Sapphire::Entity::Chara& targetActor );
|
virtual void onCastFinish( Sapphire::Entity::Chara& sourceActor, Sapphire::Action::Action& currentAction );
|
||||||
|
|
||||||
virtual void onInterrupt( Sapphire::Entity::Chara& sourceActor/*, Sapphire::Entity::Chara targetActor*/ );
|
virtual void onCastInterrupt( Sapphire::Entity::Chara& sourceActor, Sapphire::Action::Action& currentAction );
|
||||||
|
|
||||||
|
virtual void onCharaHit( Sapphire::Entity::Chara& sourceActor, Sapphire::Entity::Chara& hitActor,
|
||||||
|
Sapphire::Action::Action& currentAction );
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "Actor/EventObject.h"
|
#include "Actor/EventObject.h"
|
||||||
#include "ServerMgr.h"
|
#include "ServerMgr.h"
|
||||||
#include "Event/EventHandler.h"
|
#include "Event/EventHandler.h"
|
||||||
|
#include "Action/Action.h"
|
||||||
|
|
||||||
#include "Manager/EventMgr.h"
|
#include "Manager/EventMgr.h"
|
||||||
|
|
||||||
|
@ -325,12 +326,40 @@ bool Sapphire::Scripting::ScriptMgr::onEObjHit( Sapphire::Entity::Player& player
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sapphire::Scripting::ScriptMgr::onCastFinish( Entity::Player& player, Entity::CharaPtr pTarget, uint32_t actionId )
|
bool Sapphire::Scripting::ScriptMgr::onCastFinish( Entity::Chara& sourceActor, Action::Action& currentAction )
|
||||||
{
|
{
|
||||||
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::ActionScript >( actionId );
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::ActionScript >( currentAction.getId() );
|
||||||
|
|
||||||
if( script )
|
if( script )
|
||||||
script->onCastFinish( player, *pTarget );
|
script->onCastFinish( sourceActor, currentAction );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Sapphire::Scripting::ScriptMgr::onCastInterrupt( Entity::Chara& sourceActor, Action::Action& currentAction )
|
||||||
|
{
|
||||||
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::ActionScript >( currentAction.getId() );
|
||||||
|
|
||||||
|
if( script )
|
||||||
|
script->onCastInterrupt( sourceActor, currentAction );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Sapphire::Scripting::ScriptMgr::onCastStart( Entity::Chara& sourceActor, Action::Action& currentAction )
|
||||||
|
{
|
||||||
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::ActionScript >( currentAction.getId() );
|
||||||
|
|
||||||
|
if( script )
|
||||||
|
script->onCastStart( sourceActor, currentAction );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Sapphire::Scripting::ScriptMgr::onCharaHit( Entity::Chara& sourceActor, Entity::Chara& hitActor,
|
||||||
|
Action::Action& currentAction )
|
||||||
|
{
|
||||||
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::ActionScript >( currentAction.getId() );
|
||||||
|
|
||||||
|
if( script )
|
||||||
|
script->onCharaHit( sourceActor, hitActor, currentAction );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,10 @@ namespace Sapphire::Scripting
|
||||||
|
|
||||||
bool onEObjHit( Entity::Player& player, uint64_t actorId );
|
bool onEObjHit( Entity::Player& player, uint64_t actorId );
|
||||||
|
|
||||||
bool onCastFinish( Entity::Player& pPlayer, Entity::CharaPtr pTarget, uint32_t actionId );
|
bool onCastStart( Entity::Chara& sourceActor, Action::Action& currentAction );
|
||||||
|
bool onCastInterrupt( Entity::Chara& sourceActor, Action::Action& currentAction );
|
||||||
|
bool onCastFinish( Entity::Chara& sourceActor, Action::Action& currentAction );
|
||||||
|
bool onCharaHit( Entity::Chara& sourceActor, Entity::Chara& hitActor, Action::Action& currentAction );
|
||||||
|
|
||||||
bool onStatusReceive( Entity::CharaPtr pActor, uint32_t effectId );
|
bool onStatusReceive( Entity::CharaPtr pActor, uint32_t effectId );
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue