1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 22:57:45 +00:00

Merge pull request #15 from amibu01/master

.travis.yml test and start of skill scripting
This commit is contained in:
SapphireMordred 2017-08-09 16:38:24 +02:00 committed by GitHub
commit 2d0c3070da
7 changed files with 65 additions and 5 deletions

28
.travis.yml Normal file
View file

@ -0,0 +1,28 @@
language: c++
sudo: enabled
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq libboost-all-dev:i368 libmysqlclient-dev:i368
compiler:
- gcc
install:
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
- mkdir ${DEPS_DIR} && cd ${DEPS_DIR}
- |
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
CMAKE_URL="http://www.cmake.org/files/v3.3/cmake-3.3.2-Linux-x86_64.tar.gz"
mkdir cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
fi
# Go to the Root directory
- cd ..
# Build steps
script:
- mkdir build
- cd build
- ${DEPS_DIR}/cmake/bin/cmake .. && make

View file

@ -9,6 +9,7 @@
#include "ActorControlPacket142.h" #include "ActorControlPacket142.h"
#include "ActorControlPacket143.h" #include "ActorControlPacket143.h"
#include "Player.h" #include "Player.h"
#include "ScriptManager.h"
using namespace Core::Common; using namespace Core::Common;
using namespace Core::Network; using namespace Core::Network;
@ -17,6 +18,7 @@ using namespace Core::Network::Packets::Server;
extern Core::Data::ExdData g_exdData; extern Core::Data::ExdData g_exdData;
extern Core::Logger g_log; extern Core::Logger g_log;
extern Core::Scripting::ScriptManager g_scriptMgr;
Core::Action::ActionCast::ActionCast() Core::Action::ActionCast::ActionCast()
{ {
@ -89,6 +91,8 @@ void Core::Action::ActionCast::onFinish()
pPlayer->sendToInRangeSet( effectPacket, true ); pPlayer->sendToInRangeSet( effectPacket, true );
m_pTarget->takeDamage( 30 ); m_pTarget->takeDamage( 30 );
g_scriptMgr.onCastFinish( pPlayer, m_pTarget, m_id );
} }
void Core::Action::ActionCast::onInterrupt() void Core::Action::ActionCast::onInterrupt()

View file

@ -62,9 +62,14 @@ bool Core::Entity::Actor::isMob() const
} }
/*! \return list of actors currently in range */ /*! \return list of actors currently in range */
std::set< Core::Entity::ActorPtr > Core::Entity::Actor::getInRangeActors() const std::set< Core::Entity::ActorPtr > Core::Entity::Actor::getInRangeActors( bool includeSelf )
{ {
return m_inRangeActors; auto tempInRange = m_inRangeActors;
if( includeSelf )
tempInRange.insert( shared_from_this() );
return tempInRange;
} }
/*! \return current stance of the actors */ /*! \return current stance of the actors */

View file

@ -181,7 +181,7 @@ public:
bool isMob() const; bool isMob() const;
std::set< ActorPtr > getInRangeActors() const; std::set< ActorPtr > getInRangeActors( bool includeSelf = false );
bool face( const Common::FFXIVARR_POSITION3& p ); bool face( const Common::FFXIVARR_POSITION3& p );

View file

@ -62,7 +62,7 @@ void Core::Network::GameConnection::skillHandler( Core::Network::Packets::GamePa
{ {
std::string actionIdStr = boost::str( boost::format( "%|04X|" ) % action ); std::string actionIdStr = boost::str( boost::format( "%|04X|" ) % action );
pPlayer->sendDebug( "---------------------------------------" ); pPlayer->sendDebug( "---------------------------------------" );
pPlayer->sendDebug( "ActionHandler ( " + actionIdStr + " | " + g_exdData.m_actionInfoMap[action].name + " )" ); pPlayer->sendDebug( "ActionHandler ( " + actionIdStr + " | " + g_exdData.m_actionInfoMap[action].name + " | " + std::to_string( targetId ) + " )" );
if( action == 5 ) if( action == 5 )
{ {
@ -76,7 +76,7 @@ void Core::Network::GameConnection::skillHandler( Core::Network::Packets::GamePa
{ {
Core::Entity::ActorPtr targetActor; Core::Entity::ActorPtr targetActor;
auto inRange = pPlayer->getInRangeActors(); auto inRange = pPlayer->getInRangeActors( true );
for( auto actor : inRange ) for( auto actor : inRange )
{ {
if( actor->getId() == targetId ) if( actor->getId() == targetId )

View file

@ -375,6 +375,27 @@ bool Core::Scripting::ScriptManager::onMobKill( Entity::PlayerPtr pPlayer, uint1
return true; return true;
} }
bool Core::Scripting::ScriptManager::onCastFinish( Entity::PlayerPtr pPlayer, Entity::ActorPtr pTarget, uint32_t actionId )
{
std::string eventName = "onFinish";
try
{
auto obj = m_pChaiHandler->eval( "skillDef_" + std::to_string( actionId ) );
std::string objName = "skillDef_" + std::to_string( actionId );
pPlayer->sendDebug( "Calling: " + objName + "." + eventName );
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Player& ) > >( eventName );
fn( obj, *pPlayer );
}
catch( std::exception& e )
{
pPlayer->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();

View file

@ -50,6 +50,8 @@ namespace Core
bool onMobKill( Entity::PlayerPtr pPlayer, uint16_t nameId ); bool onMobKill( Entity::PlayerPtr pPlayer, uint16_t nameId );
bool onCastFinish( Entity::PlayerPtr pPlayer, Entity::ActorPtr pTarget, uint32_t actionId );
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 );