mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 14:57:44 +00:00
Merge pull request #56 from amibu01/master
Status Effect fixes, more skill scripting, fixing insta cast skills for real
This commit is contained in:
commit
7c9594ee7f
12 changed files with 83 additions and 11 deletions
18
bin/scripts/chai/skill/skillDef_119.chai
Normal file
18
bin/scripts/chai/skill/skillDef_119.chai
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Skill Name: Stone
|
||||
// Skill ID: 119
|
||||
|
||||
class skillDef_119Def
|
||||
{
|
||||
def skillDef_119Def()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
def onFinish( player, target )
|
||||
{
|
||||
player.handleScriptSkill( STD_DAMAGE, 119, 30, 0, target );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
GLOBAL skillDef_119 = skillDef_119Def();
|
|
@ -10,7 +10,8 @@ class skillDef_121Def
|
|||
|
||||
def onFinish( player, target )
|
||||
{
|
||||
target.addStatusEffectById(143, 20000, 0);
|
||||
player.handleScriptSkill( STD_DAMAGE, 121, 5, 0, target );
|
||||
target.addStatusEffectByIdIfNotExist(143, 20000, 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -345,13 +345,13 @@ bool Core::Data::ExdData::loadActionInfo()
|
|||
uint8_t points_type = getField< uint8_t >( fields, 30 );//28
|
||||
uint16_t points_cost = getField< uint16_t >( fields, 31 );//29
|
||||
|
||||
bool is_instant = getField< bool >( fields, 35 );
|
||||
uint32_t instantval = getField< bool >( fields, 35 );
|
||||
|
||||
uint8_t typeshift = 0x6;
|
||||
uint8_t mask = 1 << typeshift;
|
||||
is_instant &= mask;
|
||||
bool final = ( is_instant & mask ) == mask;
|
||||
is_instant = final;
|
||||
instantval &= mask;
|
||||
bool final = ( instantval & mask ) == mask;
|
||||
bool is_instant = final;
|
||||
|
||||
uint16_t cast_time = getField< uint16_t >( fields, 36 );
|
||||
uint16_t recast_time = getField< uint16_t >( fields, 37 );
|
||||
|
|
|
@ -70,13 +70,9 @@ void Core::Action::ActionCast::onFinish()
|
|||
auto pPlayer = m_pSource->getAsPlayer();
|
||||
pPlayer->sendDebug( "onFinish()" );
|
||||
|
||||
m_pTarget->onActionHostile( pPlayer->shared_from_this() );
|
||||
|
||||
pPlayer->unsetStateFlag( PlayerStateFlag::Casting );
|
||||
pPlayer->sendStateFlags();
|
||||
|
||||
|
||||
|
||||
g_scriptMgr.onCastFinish( pPlayer, m_pTarget, m_id );
|
||||
}
|
||||
|
||||
|
|
|
@ -631,3 +631,14 @@ void Core::Entity::Actor::addStatusEffectById( int32_t id, int32_t duration, uin
|
|||
addStatusEffect( effect );
|
||||
}
|
||||
|
||||
/*! \param StatusEffectPtr to be applied to the actor */
|
||||
void Core::Entity::Actor::addStatusEffectByIdIfNotExist( int32_t id, int32_t duration, uint16_t param )
|
||||
{
|
||||
if( !m_pStatusEffectContainer->hasStatusEffect( id ) )
|
||||
{
|
||||
StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, shared_from_this(), shared_from_this(), duration, 3000 ) );
|
||||
effect->setParam( param );
|
||||
addStatusEffect( effect );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -293,6 +293,9 @@ public:
|
|||
// add a status effect by id
|
||||
void addStatusEffectById( int32_t id, int32_t duration, uint16_t param = 0 );
|
||||
|
||||
// add a status effect by id if it doesn't exist
|
||||
void addStatusEffectByIdIfNotExist( int32_t id, int32_t duration, uint16_t param = 0 );
|
||||
|
||||
// TODO: Why did i even declare them publicly here?!
|
||||
std::set< ActorPtr > m_inRangeActors;
|
||||
std::set< PlayerPtr > m_inRangePlayers;
|
||||
|
|
|
@ -257,7 +257,27 @@ void Core::GameCommandHandler::set( char * data, Core::Entity::PlayerPtr pPlayer
|
|||
else
|
||||
pPlayer->setClassJob( static_cast<Core::Common::ClassJob> ( id ) );
|
||||
}
|
||||
else if( subCommand == "no" )
|
||||
{
|
||||
int32_t id;
|
||||
|
||||
sscanf( params.c_str(), "%d", &id );
|
||||
|
||||
|
||||
|
||||
uint8_t typeshift = 0x6;
|
||||
uint8_t mask = 1 << typeshift;
|
||||
id &= mask;
|
||||
bool final = ( id & mask ) == mask;
|
||||
pPlayer->sendDebug( std::to_string(final) );
|
||||
}
|
||||
else if( subCommand == "aaah" )
|
||||
{
|
||||
int32_t id;
|
||||
|
||||
sscanf( params.c_str(), "%d", &id );
|
||||
pPlayer->sendDebug( std::to_string( pPlayer->actionHasCastTime( id ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ void Core::Network::GameConnection::skillHandler( Core::Network::Packets::GamePa
|
|||
targetActor = pPlayer->lookupTargetById( targetId );
|
||||
}
|
||||
|
||||
if( pPlayer->actionHasCastTime( action ) )
|
||||
if( !pPlayer->actionHasCastTime( action ) )
|
||||
{
|
||||
g_scriptMgr.onCastFinish( pPlayer, targetActor, action );
|
||||
}
|
||||
|
|
|
@ -988,7 +988,13 @@ const uint8_t * Core::Entity::Player::getStateFlags() const
|
|||
|
||||
bool Core::Entity::Player::actionHasCastTime( uint32_t actionId ) //TODO: Add logic for special cases
|
||||
{
|
||||
return g_exdData.m_actionInfoMap[actionId].is_instant;
|
||||
if( g_exdData.m_actionInfoMap[actionId].is_instant )
|
||||
return false;
|
||||
|
||||
if( g_exdData.m_actionInfoMap[actionId].cast_time == 0 )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Core::Entity::Player::hasStateFlag( Core::Common::PlayerStateFlag flag ) const
|
||||
|
@ -1528,6 +1534,7 @@ void Core::Entity::Player::handleScriptSkill( uint32_t type, uint32_t actionId,
|
|||
sendToInRangeSet( effectPacket, true );
|
||||
|
||||
pTarget.takeDamage( param1 );
|
||||
pTarget.onActionHostile( shared_from_this() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -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::addStatusEffect ), "addStatusEffect" );
|
||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffectById ), "addStatusEffectById" );
|
||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffectByIdIfNotExist ), "addStatusEffectByIdIfNotExist" );
|
||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::takeDamage ), "takeDamage" );
|
||||
|
||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::forceZoneing ), "setZone" );
|
||||
|
|
|
@ -185,3 +185,16 @@ void Core::StatusEffect::StatusEffectContainer::update()
|
|||
m_pOwner->sendToInRangeSet( ActorControlPacket142( m_pOwner->getId(), HPFloatingText, 0, 4, thisTickHeal ) );
|
||||
}
|
||||
}
|
||||
|
||||
bool Core::StatusEffect::StatusEffectContainer::hasStatusEffect( uint32_t id )
|
||||
{
|
||||
for( auto effectIt : m_effectMap )
|
||||
{
|
||||
if( effectIt.second->getId() == id )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
|
@ -23,6 +23,8 @@ public:
|
|||
void removeStatusEffect( uint8_t effectSlotId );
|
||||
void update();
|
||||
|
||||
bool hasStatusEffect( uint32_t id );
|
||||
|
||||
int8_t getFreeSlot();
|
||||
void freeSlot( uint8_t slotId );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue