mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 06:47:45 +00:00
DoTs/HoTs, fixed status effects for players
This commit is contained in:
parent
adaf0bceba
commit
c92d907295
13 changed files with 121 additions and 14 deletions
18
bin/scripts/chai/skill/skillDef_121.chai
Normal file
18
bin/scripts/chai/skill/skillDef_121.chai
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Skill Name: Sprint
|
||||
// Skill ID: 3
|
||||
|
||||
class skillDef_121Def
|
||||
{
|
||||
def skillDef_121Def()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
def onFinish( player, target )
|
||||
{
|
||||
target.addStatusEffectById(143, 20000, 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
GLOBAL skillDef_121 = skillDef_121Def();
|
19
bin/scripts/chai/status/statusDef_143.chai
Normal file
19
bin/scripts/chai/status/statusDef_143.chai
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Status Name: Wind
|
||||
// Status ID: 143
|
||||
|
||||
class statusDef_143Def
|
||||
{
|
||||
def statusDef_143Def()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
def onTick( actor, effect )
|
||||
{
|
||||
print("tick");
|
||||
effect.registerTickEffect( 1, 30 );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
GLOBAL statusDef_143 = statusDef_143Def();
|
|
@ -702,6 +702,7 @@ namespace Core {
|
|||
StatusEffectGain = 0x14,
|
||||
StatusEffectLose = 0x15,
|
||||
|
||||
HPFloatingText = 0x17,
|
||||
UpdateRestedExp = 0x018,
|
||||
Unk2 = 0x19,
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "MoveActorPacket.h"
|
||||
#include "ActorControlPacket142.h"
|
||||
#include "ActorControlPacket143.h"
|
||||
#include "StatusEffectContainer.h"
|
||||
|
||||
using namespace Core::Common;
|
||||
using namespace Core::Network::Packets;
|
||||
|
@ -84,6 +85,10 @@ Core::Entity::BattleNpc::BattleNpc( uint32_t modelId, uint32_t nameid, const Com
|
|||
|
||||
}
|
||||
|
||||
void Core::Entity::BattleNpc::initStatusEffectContainer()
|
||||
{
|
||||
m_pStatusEffectContainer = StatusEffect::StatusEffectContainerPtr( new StatusEffect::StatusEffectContainer( shared_from_this() ) );
|
||||
}
|
||||
|
||||
// spawn this player for pTarget
|
||||
void Core::Entity::BattleNpc::spawn( Core::Entity::PlayerPtr pTarget )
|
||||
|
@ -482,7 +487,7 @@ void Core::Entity::BattleNpc::update( int64_t currTime )
|
|||
return;
|
||||
}
|
||||
|
||||
//m_pStatusEffectContainer->update();
|
||||
m_pStatusEffectContainer->update();
|
||||
float distance = Math::Util::distance( m_pos.x, m_pos.y, m_pos.z,
|
||||
m_posOrigin.x, m_posOrigin.y, m_posOrigin.z );
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ public:
|
|||
// const Common::FFXIVARR_POSITION3& spawnPos,
|
||||
// uint32_t type = 2, uint32_t behaviour = 1, uint32_t mobType = 0 );
|
||||
|
||||
void initStatusEffectContainer();
|
||||
|
||||
// send spawn packets to pTarget
|
||||
void spawn( PlayerPtr pTarget ) override;
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ namespace Core
|
|||
{
|
||||
|
||||
entry->setCurrentZone( m_pZone );
|
||||
entry->getAsBattleNpc()->initStatusEffectContainer();
|
||||
m_pZone->pushActor( entry );
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "Event.h"
|
||||
#include "EventHelper.h"
|
||||
#include "ScriptManager.h"
|
||||
#include "StatusEffect.h"
|
||||
|
||||
#include "ServerNoticePacket.h"
|
||||
|
||||
|
@ -405,34 +406,40 @@ bool Core::Scripting::ScriptManager::onStatusReceive( Entity::ActorPtr pActor, u
|
|||
auto obj = m_pChaiHandler->eval( "statusDef_" + std::to_string( effectId ) );
|
||||
std::string objName = "statusDef_" + std::to_string( effectId );
|
||||
|
||||
pActor->getAsPlayer()->sendDebug( "Calling: " + objName + "." + eventName );
|
||||
if( pActor->isPlayer() )
|
||||
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() );
|
||||
if( pActor->isPlayer() )
|
||||
pActor->getAsPlayer()->sendUrgent( e.what() );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Core::Scripting::ScriptManager::onStatusTick( Entity::ActorPtr pActor, uint32_t effectId )
|
||||
bool Core::Scripting::ScriptManager::onStatusTick( Entity::ActorPtr pActor, Core::StatusEffect::StatusEffect& effect )
|
||||
{
|
||||
std::string eventName = "onTick";
|
||||
|
||||
try
|
||||
{
|
||||
auto obj = m_pChaiHandler->eval( "statusDef_" + std::to_string( effectId ) );
|
||||
std::string objName = "statusDef_" + std::to_string( effectId );
|
||||
auto obj = m_pChaiHandler->eval( "statusDef_" + std::to_string( effect.getId() ) );
|
||||
std::string objName = "statusDef_" + std::to_string( effect.getId() );
|
||||
|
||||
pActor->getAsPlayer()->sendDebug( "Calling: " + objName + "." + eventName );
|
||||
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Actor& ) > >( eventName );
|
||||
fn( obj, *pActor );
|
||||
if( pActor->isPlayer() )
|
||||
pActor->getAsPlayer()->sendDebug( "Calling: " + objName + "." + eventName );
|
||||
|
||||
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Actor&, Core::StatusEffect::StatusEffect& ) > >( eventName );
|
||||
fn( obj, *pActor, effect );
|
||||
}
|
||||
catch( std::exception& e )
|
||||
{
|
||||
pActor->getAsPlayer()->sendUrgent( e.what() );
|
||||
if( pActor->isPlayer() )
|
||||
pActor->getAsPlayer()->sendUrgent( e.what() );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -447,13 +454,16 @@ bool Core::Scripting::ScriptManager::onStatusTimeOut( Entity::ActorPtr pActor, u
|
|||
auto obj = m_pChaiHandler->eval( "statusDef_" + std::to_string( effectId ) );
|
||||
std::string objName = "statusDef_" + std::to_string( effectId );
|
||||
|
||||
pActor->getAsPlayer()->sendDebug( "Calling: " + objName + "." + eventName );
|
||||
if( pActor->isPlayer() )
|
||||
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() );
|
||||
if( pActor->isPlayer() )
|
||||
pActor->getAsPlayer()->sendUrgent( e.what() );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace Core
|
|||
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 onStatusTick( Entity::ActorPtr pActor, Core::StatusEffect::StatusEffect& effect );
|
||||
bool onStatusTimeOut( Entity::ActorPtr pActor, uint32_t effectId );
|
||||
|
||||
bool onZoneInit( ZonePtr pZone );
|
||||
|
|
|
@ -160,6 +160,8 @@ int Core::Scripting::ScriptManager::init()
|
|||
m_pChaiHandler->add( chaiscript::user_type< Entity::BattleNpc >(), "BattleNpc" );
|
||||
m_pChaiHandler->add( chaiscript::user_type< StatusEffect::StatusEffect >(), "StatusEffect" );
|
||||
|
||||
m_pChaiHandler->add( chaiscript::fun( &StatusEffect::StatusEffect::registerTickEffect ), "registerTickEffect" );
|
||||
|
||||
m_pChaiHandler->add( chaiscript::user_type< Zone >(), "Zone" );
|
||||
m_pChaiHandler->add( chaiscript::fun( &Zone::getName ), "getName" );
|
||||
|
||||
|
|
|
@ -50,11 +50,22 @@ Core::StatusEffect::StatusEffect::~StatusEffect()
|
|||
{
|
||||
}
|
||||
|
||||
void Core::StatusEffect::StatusEffect::registerTickEffect( uint8_t type, uint32_t param )
|
||||
{
|
||||
m_currTickEffect = std::make_pair( type, param );
|
||||
}
|
||||
|
||||
std::pair< uint8_t, uint32_t> Core::StatusEffect::StatusEffect::getTickEffect()
|
||||
{
|
||||
auto thisTick = m_currTickEffect;
|
||||
m_currTickEffect = std::make_pair( 0, 0 );
|
||||
return thisTick;
|
||||
}
|
||||
|
||||
void Core::StatusEffect::StatusEffect::onTick()
|
||||
{
|
||||
m_lastTick = Util::getTimeMs();
|
||||
g_scriptMgr.onStatusTick( m_targetActor, m_id );
|
||||
g_scriptMgr.onStatusTick( m_targetActor, *this );
|
||||
}
|
||||
|
||||
uint32_t Core::StatusEffect::StatusEffect::getSrcActorId() const
|
||||
|
|
|
@ -33,6 +33,8 @@ public:
|
|||
uint16_t getParam() const;
|
||||
void setLastTick( uint64_t lastTick );
|
||||
void setParam( uint16_t param );
|
||||
void registerTickEffect( uint8_t type, uint32_t param );
|
||||
std::pair< uint8_t, uint32_t> getTickEffect();
|
||||
const std::string& getName() const;
|
||||
|
||||
private:
|
||||
|
@ -45,6 +47,7 @@ private:
|
|||
uint64_t m_lastTick;
|
||||
uint16_t m_param;
|
||||
std::string m_name;
|
||||
std::pair< uint8_t, uint32_t> m_currTickEffect;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -125,6 +125,9 @@ void Core::StatusEffect::StatusEffectContainer::update()
|
|||
{
|
||||
uint64_t currentTimeMs = Util::getTimeMs();
|
||||
|
||||
uint64_t thisTickDmg = 0;
|
||||
uint64_t thisTickHeal = 0;
|
||||
|
||||
for( auto effectIt : m_effectMap )
|
||||
{
|
||||
uint8_t effectIndex = effectIt.first;
|
||||
|
@ -147,7 +150,38 @@ void Core::StatusEffect::StatusEffectContainer::update()
|
|||
{
|
||||
effect->setLastTick( currentTimeMs );
|
||||
effect->onTick();
|
||||
|
||||
auto thisEffect = effect->getTickEffect();
|
||||
|
||||
switch( thisEffect.first )
|
||||
{
|
||||
|
||||
case 1:
|
||||
{
|
||||
thisTickDmg += thisEffect.second;
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
thisTickHeal += thisEffect.second;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( thisTickDmg != 0 )
|
||||
{
|
||||
m_pOwner->takeDamage( thisTickDmg );
|
||||
m_pOwner->sendToInRangeSet( ActorControlPacket142( m_pOwner->getId(), HPFloatingText, 0, 3, thisTickDmg ) );
|
||||
}
|
||||
|
||||
if( thisTickHeal != 0 )
|
||||
{
|
||||
m_pOwner->heal( thisTickDmg );
|
||||
m_pOwner->sendToInRangeSet( ActorControlPacket142( m_pOwner->getId(), HPFloatingText, 0, 4, thisTickHeal ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ private:
|
|||
std::queue< uint8_t > m_freeEffectSlotQueue;
|
||||
|
||||
std::vector< StatusEffectPtr > m_effectList;
|
||||
std::vector< std::pair< uint8_t, uint32_t> > m_tickEffectList;
|
||||
std::map< uint8_t, StatusEffectPtr > m_effectMap;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue