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

Map actions as pointers; Prototype AoE healing;

This commit is contained in:
Maru 2017-09-18 19:07:41 -03:00
parent d12db28951
commit f5f8acb774
7 changed files with 81 additions and 31 deletions

View file

@ -0,0 +1,18 @@
// Skill Name: Medica
// Skill ID: 124
class skillDef_124Def
{
def skillDef_124Def()
{
}
def onFinish( player, target )
{
player.handleScriptSkill( STD_HEAL, 124, 300, 0, player );
}
};
GLOBAL skillDef_124 = skillDef_124Def();

View file

@ -315,8 +315,7 @@ bool Core::Data::ExdData::loadActionInfo()
for( auto row : rows )
{
auto& fields = row.second;
ActionInfo info{ 0 };
auto info = boost::make_shared< ActionInfo >();
uint32_t id = row.first;
if( id == 0 )
@ -350,7 +349,7 @@ bool Core::Data::ExdData::loadActionInfo()
uint16_t recast_time = getField< uint16_t >( fields, 37 ); // 37
int8_t model = getField< int8_t >( fields, 39 ); // 39: Action model
uint8_t aspect = getField< uint8_t >( fields, 40 ); // 40: Action aspect
uint8_t aspect = getField< uint8_t >( fields, 40 ); // 40: Action aspect
uint8_t typeshift = 0x6;
uint8_t mask = 1 << typeshift;
@ -360,36 +359,36 @@ bool Core::Data::ExdData::loadActionInfo()
info.id = id;
info.name = name;
info.category = category;
info->id = id;
info->name = name;
info->category = category;
info.class_job = class_job;
info.unlock_level = unlock_level;
info.range = range;
info.can_target_self = can_target_self;
info.can_target_party = can_target_party;
info.can_target_friendly = can_target_friendly;
info.can_target_enemy = can_target_enemy;
info->class_job = class_job;
info->unlock_level = unlock_level;
info->range = range;
info->can_target_self = can_target_self;
info->can_target_party = can_target_party;
info->can_target_friendly = can_target_friendly;
info->can_target_enemy = can_target_enemy;
info.can_target_ko = can_target_ko;
info->can_target_ko = can_target_ko;
info.is_aoe = is_aoe;
info->is_aoe = is_aoe;
info.aoe_type = aoe_type;
info.radius = radius;
info->aoe_type = aoe_type;
info->radius = radius;
info.points_type = points_type;
info.points_cost = points_cost;
info->points_type = points_type;
info->points_cost = points_cost;
info.is_instant = is_instant;
info.cast_time = cast_time * 100;
info.recast_time = recast_time * 100;
info->is_instant = is_instant;
info->cast_time = cast_time * 100;
info->recast_time = recast_time * 100;
info.model = model;
info.aspect = aspect;
info->model = model;
info->aspect = aspect;
m_actionInfoMap[id] = info;
m_actionInfoMap.emplace( std::make_pair( info->id, info ) );
}
@ -464,6 +463,22 @@ boost::shared_ptr< Core::Data::AetheryteInfo >
}
boost::shared_ptr< Core::Data::ActionInfo >
Core::Data::ExdData::getActionInfo( uint32_t actionId )
{
try
{
return m_actionInfoMap[actionId];
}
catch ( ... )
{
return nullptr;
}
return nullptr;
}
boost::shared_ptr< Core::Data::CustomTalkInfo >
Core::Data::ExdData::getCustomTalkInfo( uint32_t customTalkId )
{

View file

@ -299,7 +299,7 @@ namespace Core {
std::map<uint8_t, ClassJobInfo> m_classJobInfoMap;
std::map<uint32_t, ParamGrowthInfo> m_paramGrowthInfoMap;
std::map<uint16_t, EventActionInfo> m_EventActionInfoMap;
std::map<uint16_t, ActionInfo> m_actionInfoMap;
std::map<uint16_t, boost::shared_ptr< ActionInfo > > m_actionInfoMap;
std::map<uint16_t, StatusEffectInfo> m_statusEffectInfoMap;
std::map<uint32_t, boost::shared_ptr< AetheryteInfo > > m_aetheryteInfoMap;
std::map<uint32_t, TribeInfo > m_tribeInfoMap;
@ -317,6 +317,7 @@ namespace Core {
boost::shared_ptr< OpeningInfo > getOpeningInfo( uint32_t openingId );
boost::shared_ptr< CustomTalkInfo > getCustomTalkInfo( uint32_t customTalkId );
boost::shared_ptr< AetheryteInfo > getAetheryteInfo( uint32_t aetheryteId );
boost::shared_ptr< ActionInfo > getActionInfo( uint32_t actionId );
boost::shared_ptr< PlaceNameInfo > getPlaceNameInfo( uint32_t placeNameId );
boost::shared_ptr< ItemInfo > getItemInfo( uint32_t catalogId );
boost::shared_ptr< RaceInfo > getRaceInfo( uint32_t raceId );

View file

@ -31,7 +31,7 @@ Core::Action::ActionCast::ActionCast( Entity::ActorPtr pActor, Entity::ActorPtr
m_startTime = 0;
m_id = actionId;
m_handleActionType = HandleActionType::Spell;
m_castTime = g_exdData.m_actionInfoMap[actionId].cast_time; // TODO: Add security checks.
m_castTime = g_exdData.getActionInfo( actionId )->cast_time; // TODO: Add security checks.
m_pSource = pActor;
m_pTarget = pTarget;
m_bInterrupt = false;

View file

@ -26,7 +26,7 @@ Core::Action::ActionTeleport::ActionTeleport( Entity::ActorPtr pActor, uint16_t
m_startTime = 0;
m_id = 5;
m_handleActionType = HandleActionType::Teleport;
m_castTime = g_exdData.m_actionInfoMap[5].cast_time; // TODO: Add security checks.
m_castTime = g_exdData.getActionInfo(5)->cast_time; // TODO: Add security checks.
m_pSource = pActor;
m_bInterrupt = false;
m_targetAetheryte = targetZone;

View file

@ -980,10 +980,11 @@ const uint8_t * Core::Entity::Player::getStateFlags() const
bool Core::Entity::Player::actionHasCastTime( uint32_t actionId ) //TODO: Add logic for special cases
{
if( g_exdData.m_actionInfoMap[actionId].is_instant )
auto actionInfoPtr = g_exdData.getActionInfo( actionId );
if( actionInfoPtr->is_instant )
return false;
if( g_exdData.m_actionInfoMap[actionId].cast_time == 0 )
if( actionInfoPtr->cast_time == 0 )
return false;
return true;
@ -1517,6 +1518,9 @@ void Core::Entity::Player::handleScriptSkill( uint32_t type, uint32_t actionId,
{
sendDebug( std::to_string( pTarget.getId() ) );
sendDebug( "Handle script skill type: " + std::to_string( type ) );
auto actionInfoPtr = g_exdData.getActionInfo( actionId );
switch( type )
{
@ -1574,6 +1578,18 @@ void Core::Entity::Player::handleScriptSkill( uint32_t type, uint32_t actionId,
if ( !pTarget.isAlive() )
break;
// todo: on AoE, send effect to heal all affected actors instead of just the caster
// this includes: calculating heal for every single actor. meaning we'd need to two-step the base heal from actor, and the value received
if ( actionInfoPtr->is_aoe )
{
for ( auto pCurAct : m_inRangePlayers )
{
assert( pCurAct );
pCurAct->heal( calculatedHeal );
}
}
pTarget.heal( calculatedHeal );
break;
}

View file

@ -52,7 +52,7 @@ void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inP
std::string actionIdStr = boost::str( boost::format( "%|04X|" ) % action );
pPlayer->sendDebug( "---------------------------------------" );
pPlayer->sendDebug( "ActionHandler ( " + actionIdStr + " | " +
g_exdData.m_actionInfoMap[action].name +
g_exdData.getActionInfo( action )->name +
" | " + std::to_string( targetId ) + " )" );
pPlayer->queuePacket( ActorControlPacket142( pPlayer->getId(), ActorControlType::ActionStart, 0x01, action ) );