mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 22:37:45 +00:00
Merge pull request #25 from amibu01/master
Sprint fix, Return implemented
This commit is contained in:
commit
3db37945f4
14 changed files with 122 additions and 8 deletions
|
@ -10,7 +10,7 @@ class skillDef_3Def
|
||||||
|
|
||||||
def onFinish( player, target )
|
def onFinish( player, target )
|
||||||
{
|
{
|
||||||
player.addStatusEffectById(50, 20000);
|
player.addStatusEffectById(50, 20000, 3791585310);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
18
bin/scripts/chai/skill/skillDef_6.chai
Normal file
18
bin/scripts/chai/skill/skillDef_6.chai
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// Skill Name: Sprint
|
||||||
|
// Skill ID: 3
|
||||||
|
|
||||||
|
class skillDef_6Def
|
||||||
|
{
|
||||||
|
def skillDef_6Def()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
def onFinish( player, target )
|
||||||
|
{
|
||||||
|
player.returnToHomepoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
GLOBAL skillDef_6 = skillDef_6Def();
|
|
@ -605,9 +605,10 @@ void Core::Entity::Actor::addStatusEffect( StatusEffect::StatusEffectPtr pEffect
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \param StatusEffectPtr to be applied to the actor */
|
/*! \param StatusEffectPtr to be applied to the actor */
|
||||||
void Core::Entity::Actor::addStatusEffectById( int32_t id, int32_t duration )
|
void Core::Entity::Actor::addStatusEffectById( int32_t id, int32_t duration, uint32_t power )
|
||||||
{
|
{
|
||||||
StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, shared_from_this(), shared_from_this(), duration, 3000 ) );
|
StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, shared_from_this(), shared_from_this(), duration, 3000 ) );
|
||||||
|
effect->setPower( power );
|
||||||
addStatusEffect( effect );
|
addStatusEffect( effect );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -290,7 +290,7 @@ public:
|
||||||
void addStatusEffect( StatusEffect::StatusEffectPtr pEffect );
|
void addStatusEffect( StatusEffect::StatusEffectPtr pEffect );
|
||||||
|
|
||||||
// add a status effect by id
|
// add a status effect by id
|
||||||
void addStatusEffectById( int32_t id, int32_t duration );
|
void addStatusEffectById( int32_t id, int32_t duration, uint32_t power = 0 );
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
|
@ -84,7 +84,7 @@ void Core::GameCommandHandler::execCommand( char * data, Core::Entity::PlayerPtr
|
||||||
|
|
||||||
if( it == m_commandMap.end() )
|
if( it == m_commandMap.end() )
|
||||||
// no command found, do something... or not
|
// no command found, do something... or not
|
||||||
g_log.error( "[" + std::to_string( pPlayer->getId() ) + "] " + "Command not found" );
|
pPlayer->sendUrgent( "Command not found." );
|
||||||
// TODO Notify the client of the failed command
|
// TODO Notify the client of the failed command
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -249,8 +249,6 @@ void Core::GameCommandHandler::set( char * data, Core::Entity::PlayerPtr pPlayer
|
||||||
|
|
||||||
sscanf( params.c_str(), "%d", &id );
|
sscanf( params.c_str(), "%d", &id );
|
||||||
|
|
||||||
g_log.debug( std::to_string( pPlayer->getLevelForClass( static_cast<Core::Common::ClassJob> ( id ) ) ) );
|
|
||||||
|
|
||||||
if( pPlayer->getLevelForClass( static_cast<Core::Common::ClassJob> ( id ) ) == 0 )
|
if( pPlayer->getLevelForClass( static_cast<Core::Common::ClassJob> ( id ) ) == 0 )
|
||||||
{
|
{
|
||||||
pPlayer->setLevelForClass( 1, static_cast<Core::Common::ClassJob> ( id ) );
|
pPlayer->setLevelForClass( 1, static_cast<Core::Common::ClassJob> ( id ) );
|
||||||
|
|
|
@ -842,8 +842,7 @@ void Core::Network::GameConnection::actionHandler( Core::Network::Packets::GameP
|
||||||
}
|
}
|
||||||
case 0xC8: // return dead
|
case 0xC8: // return dead
|
||||||
{
|
{
|
||||||
pPlayer->setZoningType( Common::ZoneingType::Return );
|
pPlayer->returnToHomepoint();
|
||||||
pPlayer->teleport( pPlayer->getHomepoint(), 3 );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0xC9: // Finish zoning
|
case 0xC9: // Finish zoning
|
||||||
|
|
|
@ -341,6 +341,12 @@ void Core::Entity::Player::forceZoneing( uint32_t zoneId )
|
||||||
//performZoning( zoneId, Common::ZoneingType::None, getPos() );
|
//performZoning( zoneId, Common::ZoneingType::None, getPos() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::Entity::Player::returnToHomepoint()
|
||||||
|
{
|
||||||
|
setZoningType( Common::ZoneingType::Return );
|
||||||
|
teleport( getHomepoint(), 3 );
|
||||||
|
}
|
||||||
|
|
||||||
void Core::Entity::Player::setZone( uint32_t zoneId )
|
void Core::Entity::Player::setZone( uint32_t zoneId )
|
||||||
{
|
{
|
||||||
auto pPlayer = getAsPlayer();
|
auto pPlayer = getAsPlayer();
|
||||||
|
|
|
@ -302,6 +302,8 @@ public:
|
||||||
void setZone( uint32_t zoneId );
|
void setZone( uint32_t zoneId );
|
||||||
|
|
||||||
void forceZoneing( uint32_t zoneId );
|
void forceZoneing( uint32_t zoneId );
|
||||||
|
/*! return player to preset homepoint */
|
||||||
|
void returnToHomepoint();
|
||||||
/*! change position, sends update too */
|
/*! change position, sends update too */
|
||||||
void changePosition( float x, float y, float z, float o );
|
void changePosition( float x, float y, float z, float o );
|
||||||
/*! return the contentId */
|
/*! return the contentId */
|
||||||
|
|
|
@ -396,6 +396,69 @@ bool Core::Scripting::ScriptManager::onCastFinish( Entity::PlayerPtr pPlayer, En
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Core::Scripting::ScriptManager::onStatusReceive( Entity::ActorPtr pActor, uint32_t effectId )
|
||||||
|
{
|
||||||
|
std::string eventName = "onReceive";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auto obj = m_pChaiHandler->eval( "statusDef_" + std::to_string( effectId ) );
|
||||||
|
std::string objName = "statusDef_" + std::to_string( effectId );
|
||||||
|
|
||||||
|
pActor->getAsPlayer()->sendDebug( "Calling: " + objName + "." + eventName );
|
||||||
|
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Actor&) > >( eventName );
|
||||||
|
fn( obj, *pActor );
|
||||||
|
}
|
||||||
|
catch( std::exception& e )
|
||||||
|
{
|
||||||
|
pActor->getAsPlayer()->sendUrgent( e.what() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Core::Scripting::ScriptManager::onStatusTick( Entity::ActorPtr pActor, uint32_t effectId )
|
||||||
|
{
|
||||||
|
std::string eventName = "onTick";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auto obj = m_pChaiHandler->eval( "statusDef_" + std::to_string( effectId ) );
|
||||||
|
std::string objName = "statusDef_" + std::to_string( effectId );
|
||||||
|
|
||||||
|
pActor->getAsPlayer()->sendDebug( "Calling: " + objName + "." + eventName );
|
||||||
|
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Actor& ) > >( eventName );
|
||||||
|
fn( obj, *pActor );
|
||||||
|
}
|
||||||
|
catch( std::exception& e )
|
||||||
|
{
|
||||||
|
pActor->getAsPlayer()->sendUrgent( e.what() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Core::Scripting::ScriptManager::onStatusTimeOut( Entity::ActorPtr pActor, uint32_t effectId )
|
||||||
|
{
|
||||||
|
std::string eventName = "onTimeOut";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auto obj = m_pChaiHandler->eval( "statusDef_" + std::to_string( effectId ) );
|
||||||
|
std::string objName = "statusDef_" + std::to_string( effectId );
|
||||||
|
|
||||||
|
pActor->getAsPlayer()->sendDebug( "Calling: " + objName + "." + eventName );
|
||||||
|
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Actor& ) > >( eventName );
|
||||||
|
fn( obj, *pActor );
|
||||||
|
}
|
||||||
|
catch( std::exception& e )
|
||||||
|
{
|
||||||
|
pActor->getAsPlayer()->sendUrgent( e.what() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Core::Scripting::ScriptManager::onZoneInit( ZonePtr pZone )
|
bool Core::Scripting::ScriptManager::onZoneInit( ZonePtr pZone )
|
||||||
{
|
{
|
||||||
std::string eventName = "onZoneInit_" + pZone->getInternalName();
|
std::string eventName = "onZoneInit_" + pZone->getInternalName();
|
||||||
|
|
|
@ -52,6 +52,10 @@ namespace Core
|
||||||
|
|
||||||
bool onCastFinish( Entity::PlayerPtr pPlayer, Entity::ActorPtr pTarget, uint32_t actionId );
|
bool onCastFinish( Entity::PlayerPtr pPlayer, Entity::ActorPtr pTarget, uint32_t actionId );
|
||||||
|
|
||||||
|
bool onStatusReceive( Entity::ActorPtr pActor, uint32_t effectId );
|
||||||
|
bool onStatusTick( Entity::ActorPtr pActor, uint32_t effectId );
|
||||||
|
bool onStatusTimeOut( Entity::ActorPtr pActor, uint32_t effectId );
|
||||||
|
|
||||||
bool onZoneInit( ZonePtr pZone );
|
bool onZoneInit( ZonePtr pZone );
|
||||||
|
|
||||||
bool onEventHandlerReturn( Entity::PlayerPtr pPlayer, uint32_t eventId, uint16_t subEvent, uint16_t param1, uint16_t param2, uint16_t param3 );
|
bool onEventHandlerReturn( Entity::PlayerPtr pPlayer, uint32_t eventId, uint16_t subEvent, uint16_t param1, uint16_t param2, uint16_t param3 );
|
||||||
|
|
|
@ -48,6 +48,7 @@ int Core::Scripting::ScriptManager::init()
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::learnAction ), "learnAction" );
|
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::learnAction ), "learnAction" );
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getHomepoint ), "getHomepoint" );
|
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getHomepoint ), "getHomepoint" );
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setHomepoint ), "setHomepoint" );
|
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setHomepoint ), "setHomepoint" );
|
||||||
|
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::returnToHomepoint ), "returnToHomepoint" );
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::teleport ), "teleport" );
|
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::teleport ), "teleport" );
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::prepareZoning ), "prepareZoning" );
|
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::prepareZoning ), "prepareZoning" );
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "Actor.h"
|
#include "Actor.h"
|
||||||
|
|
||||||
#include "StatusEffect.h"
|
#include "StatusEffect.h"
|
||||||
|
#include "ScriptManager.h"
|
||||||
|
|
||||||
extern Core::Logger g_log;
|
extern Core::Logger g_log;
|
||||||
extern Core::Data::ExdData g_exdData;
|
extern Core::Data::ExdData g_exdData;
|
||||||
|
@ -17,6 +18,8 @@ extern Core::Data::ExdData g_exdData;
|
||||||
using namespace Core::Common;
|
using namespace Core::Common;
|
||||||
using namespace Core::Network::Packets;
|
using namespace Core::Network::Packets;
|
||||||
using namespace Core::Network::Packets::Server;
|
using namespace Core::Network::Packets::Server;
|
||||||
|
extern Core::Scripting::ScriptManager g_scriptMgr;
|
||||||
|
|
||||||
|
|
||||||
Core::StatusEffect::StatusEffect::StatusEffect( uint32_t id, Entity::ActorPtr sourceActor, Entity::ActorPtr targetActor,
|
Core::StatusEffect::StatusEffect::StatusEffect( uint32_t id, Entity::ActorPtr sourceActor, Entity::ActorPtr targetActor,
|
||||||
uint32_t duration, uint32_t tickRate )
|
uint32_t duration, uint32_t tickRate )
|
||||||
|
@ -51,6 +54,7 @@ Core::StatusEffect::StatusEffect::~StatusEffect()
|
||||||
void Core::StatusEffect::StatusEffect::onTick()
|
void Core::StatusEffect::StatusEffect::onTick()
|
||||||
{
|
{
|
||||||
m_lastTick = Util::getTimeMs();
|
m_lastTick = Util::getTimeMs();
|
||||||
|
g_scriptMgr.onStatusTick( m_targetActor, m_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Core::StatusEffect::StatusEffect::getSrcActorId() const
|
uint32_t Core::StatusEffect::StatusEffect::getSrcActorId() const
|
||||||
|
@ -63,6 +67,11 @@ uint32_t Core::StatusEffect::StatusEffect::getTargetActorId() const
|
||||||
return m_targetActor->getId();
|
return m_targetActor->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Core::StatusEffect::StatusEffect::getPower() const
|
||||||
|
{
|
||||||
|
return m_power;
|
||||||
|
}
|
||||||
|
|
||||||
void Core::StatusEffect::StatusEffect::applyStatus()
|
void Core::StatusEffect::StatusEffect::applyStatus()
|
||||||
{
|
{
|
||||||
m_startTime = Util::getTimeMs();
|
m_startTime = Util::getTimeMs();
|
||||||
|
@ -86,11 +95,13 @@ void Core::StatusEffect::StatusEffect::applyStatus()
|
||||||
//m_sourceActor->sendToInRangeSet( effectPacket, true );
|
//m_sourceActor->sendToInRangeSet( effectPacket, true );
|
||||||
|
|
||||||
g_log.debug( "StatusEffect applied: " + m_name );
|
g_log.debug( "StatusEffect applied: " + m_name );
|
||||||
|
g_scriptMgr.onStatusReceive( m_targetActor, m_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::StatusEffect::StatusEffect::removeStatus()
|
void Core::StatusEffect::StatusEffect::removeStatus()
|
||||||
{
|
{
|
||||||
g_log.debug( "StatusEffect removed: " + m_name );
|
g_log.debug( "StatusEffect removed: " + m_name );
|
||||||
|
g_scriptMgr.onStatusTimeOut( m_targetActor, m_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Core::StatusEffect::StatusEffect::getId() const
|
uint32_t Core::StatusEffect::StatusEffect::getId() const
|
||||||
|
@ -123,6 +134,12 @@ void Core::StatusEffect::StatusEffect::setLastTick( uint64_t lastTick )
|
||||||
m_lastTick = lastTick;
|
m_lastTick = lastTick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::StatusEffect::StatusEffect::setPower( uint32_t power )
|
||||||
|
{
|
||||||
|
m_power = power;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::string& Core::StatusEffect::StatusEffect::getName() const
|
const std::string& Core::StatusEffect::StatusEffect::getName() const
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
|
|
|
@ -30,7 +30,9 @@ public:
|
||||||
uint32_t getTargetActorId() const;
|
uint32_t getTargetActorId() const;
|
||||||
uint64_t getLastTickMs() const;
|
uint64_t getLastTickMs() const;
|
||||||
uint64_t getStartTimeMs() const;
|
uint64_t getStartTimeMs() const;
|
||||||
|
uint32_t getPower() const;
|
||||||
void setLastTick( uint64_t lastTick );
|
void setLastTick( uint64_t lastTick );
|
||||||
|
void setPower( uint32_t power );
|
||||||
const std::string& getName() const;
|
const std::string& getName() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -41,6 +43,7 @@ private:
|
||||||
uint64_t m_startTime;
|
uint64_t m_startTime;
|
||||||
uint32_t m_tickRate;
|
uint32_t m_tickRate;
|
||||||
uint64_t m_lastTick;
|
uint64_t m_lastTick;
|
||||||
|
uint32_t m_power; //Figure out what this actually is supposed to be
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -68,6 +68,8 @@ void Core::StatusEffect::StatusEffectContainer::addStatusEffect( StatusEffectPtr
|
||||||
statusEffectAdd.data().max_hp = m_pOwner->getMaxHp();
|
statusEffectAdd.data().max_hp = m_pOwner->getMaxHp();
|
||||||
statusEffectAdd.data().max_mp = m_pOwner->getMaxMp();
|
statusEffectAdd.data().max_mp = m_pOwner->getMaxMp();
|
||||||
statusEffectAdd.data().max_something = 1;
|
statusEffectAdd.data().max_something = 1;
|
||||||
|
//statusEffectAdd.data().unknown2 = 28;
|
||||||
|
statusEffectAdd.data().power = pEffect->getPower();
|
||||||
|
|
||||||
bool sendToSelf = m_pOwner->isPlayer() ? true : false;
|
bool sendToSelf = m_pOwner->isPlayer() ? true : false;
|
||||||
m_pOwner->sendToInRangeSet( statusEffectAdd, sendToSelf );
|
m_pOwner->sendToInRangeSet( statusEffectAdd, sendToSelf );
|
||||||
|
|
Loading…
Add table
Reference in a new issue