mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 14:37:44 +00:00
Chai bindings for status effects, Sprint script
This commit is contained in:
parent
e38c0aa1f7
commit
0a62578590
5 changed files with 35 additions and 2 deletions
18
bin/scripts/chai/skill/skillDef_3.chai
Normal file
18
bin/scripts/chai/skill/skillDef_3.chai
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// Skill Name: Sprint
|
||||||
|
// Skill ID: 3
|
||||||
|
|
||||||
|
class skillDef_3Def
|
||||||
|
{
|
||||||
|
def skillDef_3Def()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
def onFinish( player, target )
|
||||||
|
{
|
||||||
|
player.addStatusEffectById(50, 20000);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
GLOBAL skillDef_3 = skillDef_3Def();
|
|
@ -14,6 +14,7 @@
|
||||||
#include "UpdateHpMpTpPacket.h"
|
#include "UpdateHpMpTpPacket.h"
|
||||||
|
|
||||||
#include "StatusEffectContainer.h"
|
#include "StatusEffectContainer.h"
|
||||||
|
#include "StatusEffect.h"
|
||||||
#include "ServerZone.h"
|
#include "ServerZone.h"
|
||||||
#include "Session.h"
|
#include "Session.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
|
@ -603,3 +604,10 @@ void Core::Entity::Actor::addStatusEffect( StatusEffect::StatusEffectPtr pEffect
|
||||||
m_pStatusEffectContainer->addStatusEffect( pEffect );
|
m_pStatusEffectContainer->addStatusEffect( pEffect );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! \param StatusEffectPtr to be applied to the actor */
|
||||||
|
void Core::Entity::Actor::addStatusEffectById( int32_t id, int32_t duration )
|
||||||
|
{
|
||||||
|
StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, shared_from_this(), shared_from_this(), duration, 3000 ) );
|
||||||
|
addStatusEffect( effect );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -289,6 +289,9 @@ public:
|
||||||
// add a status effect
|
// add a status effect
|
||||||
void addStatusEffect( StatusEffect::StatusEffectPtr pEffect );
|
void addStatusEffect( StatusEffect::StatusEffectPtr pEffect );
|
||||||
|
|
||||||
|
// add a status effect by id
|
||||||
|
void addStatusEffectById( int32_t id, int32_t duration );
|
||||||
|
|
||||||
// TODO: Why did i even declare them publicly here?!
|
// TODO: Why did i even declare them publicly here?!
|
||||||
std::set< ActorPtr > m_inRangeActors;
|
std::set< ActorPtr > m_inRangeActors;
|
||||||
std::set< PlayerPtr > m_inRangePlayers;
|
std::set< PlayerPtr > m_inRangePlayers;
|
||||||
|
|
|
@ -385,8 +385,8 @@ bool Core::Scripting::ScriptManager::onCastFinish( Entity::PlayerPtr pPlayer, En
|
||||||
std::string objName = "skillDef_" + std::to_string( actionId );
|
std::string objName = "skillDef_" + std::to_string( actionId );
|
||||||
|
|
||||||
pPlayer->sendDebug( "Calling: " + objName + "." + eventName );
|
pPlayer->sendDebug( "Calling: " + objName + "." + eventName );
|
||||||
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Player& ) > >( eventName );
|
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Player&, Entity::Actor& ) > >( eventName );
|
||||||
fn( obj, *pPlayer );
|
fn( obj, *pPlayer, *pTarget );
|
||||||
}
|
}
|
||||||
catch( std::exception& e )
|
catch( std::exception& e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "EventHelper.h"
|
#include "EventHelper.h"
|
||||||
|
|
||||||
#include "ServerNoticePacket.h"
|
#include "ServerNoticePacket.h"
|
||||||
|
#include "StatusEffect.h"
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
@ -32,6 +33,8 @@ int Core::Scripting::ScriptManager::init()
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::getTp ), "getTp" );
|
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::getTp ), "getTp" );
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::getLevel ), "getLevel" );
|
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::getLevel ), "getLevel" );
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::getTargetId ), "getTargetId" );
|
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::getTargetId ), "getTargetId" );
|
||||||
|
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffect ), "addStatusEffect" );
|
||||||
|
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffectById ), "addStatusEffectById" );
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::forceZoneing ), "setZone" );
|
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::forceZoneing ), "setZone" );
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getClassAsInt ), "getClass" );
|
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getClassAsInt ), "getClass" );
|
||||||
|
@ -152,6 +155,7 @@ int Core::Scripting::ScriptManager::init()
|
||||||
m_pChaiHandler->add( chaiscript::user_type< Entity::Actor >(), "Actor" );
|
m_pChaiHandler->add( chaiscript::user_type< Entity::Actor >(), "Actor" );
|
||||||
m_pChaiHandler->add( chaiscript::user_type< Entity::Player >(), "Player" );
|
m_pChaiHandler->add( chaiscript::user_type< Entity::Player >(), "Player" );
|
||||||
m_pChaiHandler->add( chaiscript::user_type< Entity::BattleNpc >(), "BattleNpc" );
|
m_pChaiHandler->add( chaiscript::user_type< Entity::BattleNpc >(), "BattleNpc" );
|
||||||
|
m_pChaiHandler->add( chaiscript::user_type< StatusEffect::StatusEffect >(), "StatusEffect" );
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::user_type< Zone >(), "Zone" );
|
m_pChaiHandler->add( chaiscript::user_type< Zone >(), "Zone" );
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Zone::getName ), "getName" );
|
m_pChaiHandler->add( chaiscript::fun( &Zone::getName ), "getName" );
|
||||||
|
|
Loading…
Add table
Reference in a new issue