From f5f8acb77456524deb8d1cc8c73af3e3e45a94c8 Mon Sep 17 00:00:00 2001 From: Maru Date: Mon, 18 Sep 2017 19:07:41 -0300 Subject: [PATCH] Map actions as pointers; Prototype AoE healing; --- scripts/chai/skill/cnj/skillDef_124.chai | 18 +++++ src/servers/Server_Common/Exd/ExdData.cpp | 65 ++++++++++++------- src/servers/Server_Common/Exd/ExdData.h | 3 +- src/servers/Server_Zone/Action/ActionCast.cpp | 2 +- .../Server_Zone/Action/ActionTeleport.cpp | 2 +- src/servers/Server_Zone/Actor/Player.cpp | 20 +++++- .../Network/Handlers/SkillHandler.cpp | 2 +- 7 files changed, 81 insertions(+), 31 deletions(-) create mode 100644 scripts/chai/skill/cnj/skillDef_124.chai diff --git a/scripts/chai/skill/cnj/skillDef_124.chai b/scripts/chai/skill/cnj/skillDef_124.chai new file mode 100644 index 00000000..325dd3d9 --- /dev/null +++ b/scripts/chai/skill/cnj/skillDef_124.chai @@ -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(); diff --git a/src/servers/Server_Common/Exd/ExdData.cpp b/src/servers/Server_Common/Exd/ExdData.cpp index 5f9f22c5..0c5fd98f 100644 --- a/src/servers/Server_Common/Exd/ExdData.cpp +++ b/src/servers/Server_Common/Exd/ExdData.cpp @@ -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 ) { diff --git a/src/servers/Server_Common/Exd/ExdData.h b/src/servers/Server_Common/Exd/ExdData.h index f0c5793f..a6376550 100644 --- a/src/servers/Server_Common/Exd/ExdData.h +++ b/src/servers/Server_Common/Exd/ExdData.h @@ -299,7 +299,7 @@ namespace Core { std::map m_classJobInfoMap; std::map m_paramGrowthInfoMap; std::map m_EventActionInfoMap; - std::map m_actionInfoMap; + std::map > m_actionInfoMap; std::map m_statusEffectInfoMap; std::map > m_aetheryteInfoMap; std::map 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 ); diff --git a/src/servers/Server_Zone/Action/ActionCast.cpp b/src/servers/Server_Zone/Action/ActionCast.cpp index ef138cdd..16d07d8b 100644 --- a/src/servers/Server_Zone/Action/ActionCast.cpp +++ b/src/servers/Server_Zone/Action/ActionCast.cpp @@ -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; diff --git a/src/servers/Server_Zone/Action/ActionTeleport.cpp b/src/servers/Server_Zone/Action/ActionTeleport.cpp index 06207db0..22705d71 100644 --- a/src/servers/Server_Zone/Action/ActionTeleport.cpp +++ b/src/servers/Server_Zone/Action/ActionTeleport.cpp @@ -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; diff --git a/src/servers/Server_Zone/Actor/Player.cpp b/src/servers/Server_Zone/Actor/Player.cpp index dc5bbf41..4d229f07 100644 --- a/src/servers/Server_Zone/Actor/Player.cpp +++ b/src/servers/Server_Zone/Actor/Player.cpp @@ -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; } diff --git a/src/servers/Server_Zone/Network/Handlers/SkillHandler.cpp b/src/servers/Server_Zone/Network/Handlers/SkillHandler.cpp index d08b6db0..457aa855 100644 --- a/src/servers/Server_Zone/Network/Handlers/SkillHandler.cpp +++ b/src/servers/Server_Zone/Network/Handlers/SkillHandler.cpp @@ -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 ) );