1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-04 17:57:47 +00:00

More skill scripting

This commit is contained in:
amibu 2017-08-14 17:10:19 +02:00
parent 166e61d6f3
commit b267533908
11 changed files with 135 additions and 17 deletions

View file

@ -224,3 +224,10 @@ GLOBAL CURRENCY_MGP = 0X0B
GLOBAL CURRENCY_TOMESTONELAW = 0X0C GLOBAL CURRENCY_TOMESTONELAW = 0X0C
GLOBAL CURRENCY_TOMESTONEESO = 0X0D GLOBAL CURRENCY_TOMESTONEESO = 0X0D
GLOBAL CURRENCY_TOMESTONELORE = 0X0E GLOBAL CURRENCY_TOMESTONELORE = 0X0E
////////////////////////////////////////////////////////////
// Skill handle types
////////////////////////////////////////////////////////////
GLOBAL STD_DAMAGE = 0X00
GLOBAL STD_HEAL = 0X01
GLOBAL STD_DOT = 0X02

View file

@ -0,0 +1,18 @@
// Skill Name: Sprint
// Skill ID: 3
class skillDef_120Def
{
def skillDef_120Def()
{
}
def onFinish( player, target )
{
player.handleScriptSkill( STD_HEAL, 120, 1000, 0, target );
}
};
GLOBAL skillDef_120 = skillDef_120Def();

View file

@ -0,0 +1,18 @@
// Skill Name: Sprint
// Skill ID: 3
class skillDef_127Def
{
def skillDef_127Def()
{
}
def onFinish( player, target )
{
player.handleScriptSkill( STD_DAMAGE, 127, 1000, 0, target );
}
};
GLOBAL skillDef_127 = skillDef_127Def();

View file

@ -545,6 +545,13 @@ namespace Core {
}; };
enum HandleSkillType : uint8_t
{
StdDamage,
StdHeal,
StdDot,
};
enum struct PlayerStateFlag : uint8_t enum struct PlayerStateFlag : uint8_t
{ {
NoCombat, NoCombat,

View file

@ -410,7 +410,7 @@ struct FFXIVIpcUpdateHpMpTp : FFXIVIpcBasePacket<UpdateHpMpTp>
/** /**
* Structural representation of the packet sent by the server * Structural representation of the packet sent by the server
* to update HP / MP / TP * for battle actions
*/ */
struct effectEntry struct effectEntry
{ {

View file

@ -75,22 +75,7 @@ void Core::Action::ActionCast::onFinish()
pPlayer->unsetStateFlag( PlayerStateFlag::Casting ); pPlayer->unsetStateFlag( PlayerStateFlag::Casting );
pPlayer->sendStateFlags(); pPlayer->sendStateFlags();
GamePacketNew< FFXIVIpcEffect > effectPacket( pPlayer->getId() );
effectPacket.data().targetId = m_pTarget->getId();
effectPacket.data().actionAnimationId = m_id;
effectPacket.data().unknown_2 = 0;
// effectPacket.data().unknown_3 = 1;
effectPacket.data().actionTextId = m_id;
effectPacket.data().numEffects = 1;
effectPacket.data().rotation = Math::Util::floatToUInt16Rot( pPlayer->getRotation() );
effectPacket.data().effectTarget = m_pTarget->getId();
effectPacket.data().effects[0].param1 = 30;
effectPacket.data().effects[0].unknown_1 = 3;
effectPacket.data().effects[0].unknown_2 = 1;
effectPacket.data().effects[0].unknown_3 = 7;
pPlayer->sendToInRangeSet( effectPacket, true );
m_pTarget->takeDamage( 30 );
g_scriptMgr.onCastFinish( pPlayer, m_pTarget, m_id ); g_scriptMgr.onCastFinish( pPlayer, m_pTarget, m_id );
} }

View file

@ -337,6 +337,25 @@ void Core::Entity::Actor::takeDamage( uint32_t damage )
sendStatusUpdate( false ); sendStatusUpdate( false );
} }
/*!
Let an actor get healed and perform necessary steps
according to resulting hp, propagates new hp value to players
in range
\param amount of hp to be healed
*/
void Core::Entity::Actor::heal( uint32_t amount )
{
if( ( m_hp + amount ) > getMaxHp() )
{
m_hp = getMaxHp();
}
else
m_hp += amount;
sendStatusUpdate( false );
}
/*! /*!
Send an HpMpTp update to players in range ( and potentially to self ) Send an HpMpTp update to players in range ( and potentially to self )
TODO: poor naming, should be changed. Status is not HP. Also should be virtual TODO: poor naming, should be changed. Status is not HP. Also should be virtual

View file

@ -245,6 +245,7 @@ public:
virtual uint8_t getLevel() const; virtual uint8_t getLevel() const;
virtual void sendStatusUpdate( bool toSelf = true ); virtual void sendStatusUpdate( bool toSelf = true );
virtual void takeDamage( uint32_t damage ); virtual void takeDamage( uint32_t damage );
virtual void heal( uint32_t amount );
virtual bool checkAction(); virtual bool checkAction();
virtual void update( int64_t currTime ) {}; virtual void update( int64_t currTime ) {};

View file

@ -1499,3 +1499,62 @@ void Core::Entity::Player::autoAttack( ActorPtr pTarget )
pTarget->takeDamage(damage); pTarget->takeDamage(damage);
} }
void Core::Entity::Player::handleScriptSkill( uint32_t type, uint32_t actionId, uint64_t param1, uint64_t param2, Entity::Actor& pTarget )
{
sendDebug( std::to_string( pTarget.getId() ) );
sendDebug( "Handle script skill type: " + std::to_string( type ) );
switch( type )
{
case Core::Common::HandleSkillType::StdDamage:
{
sendDebug( "STD_DAMAGE" );
GamePacketNew< FFXIVIpcEffect > effectPacket( getId() );
effectPacket.data().targetId = pTarget.getId();
effectPacket.data().actionAnimationId = actionId;
effectPacket.data().unknown_2 = 0;
// effectPacket.data().unknown_3 = 1;
effectPacket.data().actionTextId = actionId;
effectPacket.data().numEffects = 1;
effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() );
effectPacket.data().effectTarget = pTarget.getId();
effectPacket.data().effects[0].param1 = param1;
effectPacket.data().effects[0].unknown_1 = 3;
effectPacket.data().effects[0].unknown_2 = 1;
effectPacket.data().effects[0].unknown_3 = 7;
sendToInRangeSet( effectPacket, true );
pTarget.takeDamage( param1 );
break;
}
case Core::Common::HandleSkillType::StdHeal:
{
sendDebug( "STD_HEAL" );
GamePacketNew< FFXIVIpcEffect > effectPacket( getId() );
effectPacket.data().targetId = pTarget.getId();
effectPacket.data().actionAnimationId = actionId;
effectPacket.data().unknown_2 = 0;
// effectPacket.data().unknown_3 = 1;
effectPacket.data().actionTextId = actionId;
effectPacket.data().numEffects = 1;
effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() );
effectPacket.data().effectTarget = pTarget.getId();
effectPacket.data().effects[0].param1 = param1;
effectPacket.data().effects[0].unknown_1 = 4;
effectPacket.data().effects[0].unknown_2 = 1;
effectPacket.data().effects[0].unknown_3 = 7;
sendToInRangeSet( effectPacket, true );
pTarget.heal( param1 );
break;
}
default:
break;
}
}

View file

@ -482,6 +482,8 @@ public:
void setAutoattack( bool mode ); void setAutoattack( bool mode );
bool isAutoattackOn() const; bool isAutoattackOn() const;
void handleScriptSkill( uint32_t type, uint32_t actionId, uint64_t param1, uint64_t param2, Entity::Actor& target );
private: private:
uint32_t m_lastWrite; uint32_t m_lastWrite;
uint32_t m_lastPing; uint32_t m_lastPing;

View file

@ -35,6 +35,7 @@ int Core::Scripting::ScriptManager::init()
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::addStatusEffect ), "addStatusEffect" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffectById ), "addStatusEffectById" ); m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffectById ), "addStatusEffectById" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::takeDamage ), "takeDamage" );
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" );
@ -65,6 +66,7 @@ int Core::Scripting::ScriptManager::init()
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestSeq ), "questGetSeq" ); m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestSeq ), "questGetSeq" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::hasQuest ), "hasQuest" ); m_pChaiHandler->add( chaiscript::fun( &Entity::Player::hasQuest ), "hasQuest" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getZoneId ), "getZoneId" ); m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getZoneId ), "getZoneId" );
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::handleScriptSkill ), "handleScriptSkill" );
m_pChaiHandler->add( chaiscript::fun( &Core::Event::mapEventActorToRealActor ), "mapActor" ); m_pChaiHandler->add( chaiscript::fun( &Core::Event::mapEventActorToRealActor ), "mapActor" );