From 3131d36ea612e3d08a8d63827b1279c747da8c68 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sat, 21 Jul 2018 15:39:58 +1000 Subject: [PATCH 01/13] update effect struct, knockback effect type --- src/common/Common.h | 1 + .../Network/PacketDef/Zone/ServerZoneDef.h | 49 +++++++++++-------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/common/Common.h b/src/common/Common.h index d826fe96..7a72418b 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -409,6 +409,7 @@ namespace Common { TpLoss = 12, TpGain = 13, GpGain = 14, + Knockback = 33, Mount = 38 }; diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index ddbd4b00..2bc4e0ce 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -304,7 +304,7 @@ struct effectEntry Common::ActionEffectType effectType; Common::ActionHitSeverityType hitSeverity; uint8_t param; - int8_t bonusPercent; + int8_t bonusPercent; // shows an additional percentage in the battle log, will not change the damage number sent & shown uint8_t valueMultiplier; // This multiplies whatever value is in the 'value' param by 10. Possibly a workaround for big numbers uint8_t flags; int16_t value; @@ -312,32 +312,41 @@ struct effectEntry struct FFXIVIpcEffect : FFXIVIpcBasePacket { - uint32_t targetId; - uint32_t unknown_1; - uint32_t actionAnimationId; - uint32_t unknown_2; - uint32_t unknown_5; - uint32_t unknown_6; - uint16_t unknown_7; - uint16_t rotation; - uint16_t actionTextId; - uint16_t unknown_8; + uint64_t animationTargetId; // who the animation targets + uint32_t actionId; // what the casting player casts, shown in battle log/ui - uint8_t unknown_9; - uint8_t numEffects; + uint32_t globalEffectCounter; // seems to only increment on retail? + float animationLockTime; // maybe? doesn't seem to do anything - uint16_t unknown_10; - uint32_t unknown_11; - uint16_t unknown_12; + uint32_t someTargetId; // always 00 00 00 E0, 0x0E000000 is the internal def for INVALID TARGET ID + + uint16_t hiddenAnimation; // if 0, always shows animation, otherwise hides it. counts up by 1 for each animation skipped on a caster + + int16_t rotation; + + uint16_t actionAnimationId; // the animation that is played by the casting character + uint8_t unknown1E; // can be 0,1,2 - maybe other values? - doesn't do anything? + + /* effectDisplayType + * 0 = only show damage/heal amount + * 1 = show damage/heal amount + name + * 2 = show damage/heal amount + name but name is from item.exd, name id is actionId + */ + uint8_t effectDisplayType; + + uint8_t unknown20; // is read by handler, runs code which gets the LODWORD of animationLockTime (wtf?) + uint8_t numEffects; // ignores effects if 0, otherwise parses all of them + + uint32_t padding_22[2]; effectEntry effects[8]; - uint32_t unknown_13; - uint16_t unknown_14; + uint16_t padding_6A[3]; - uint32_t effectTargetId; + uint32_t effectTargetId; // who the effect targets + uint32_t effectFlags; // nonzero = effects do nothing, no battle log, no ui text - only shows animations - uint64_t unknown_15; + uint32_t padding_78; }; From 9d7896043c8ad32495e107474dbb7b53d7f457f8 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sat, 21 Jul 2018 15:54:37 +1000 Subject: [PATCH 02/13] fix builds with new effect packet --- .../sapphire_zone/Action/ActionMount.cpp | 6 +++--- .../sapphire_zone/Action/ActionTeleport.cpp | 7 +++---- .../sapphire_zone/Action/EventItemAction.cpp | 8 +++---- src/servers/sapphire_zone/Actor/Chara.cpp | 21 ++++++++----------- src/servers/sapphire_zone/Actor/Player.cpp | 12 +++++------ 5 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/servers/sapphire_zone/Action/ActionMount.cpp b/src/servers/sapphire_zone/Action/ActionMount.cpp index ea06c069..912e0c84 100644 --- a/src/servers/sapphire_zone/Action/ActionMount.cpp +++ b/src/servers/sapphire_zone/Action/ActionMount.cpp @@ -73,13 +73,13 @@ void Core::Action::ActionMount::onFinish() pPlayer->unsetStateFlag( PlayerStateFlag::Casting ); - auto effectPacket = makeZonePacket< FFXIVIpcEffect >( getId() ); + auto effectPacket = makeZonePacket< Server::FFXIVIpcEffect >( getId() ); - effectPacket->data().targetId = pPlayer->getId(); + effectPacket->data().animationTargetId = pPlayer->getId(); effectPacket->data().actionAnimationId = m_id; // Affects displaying action name next to number in floating text //effectPacket->data().unknown_62 = 13; - effectPacket->data().actionTextId = 4; + effectPacket->data().actionAnimationId = 4; effectPacket->data().numEffects = 1; effectPacket->data().rotation = Math::Util::floatToUInt16Rot( pPlayer->getRot() ); //effectPacket->data().effectTarget = INVALID_GAME_OBJECT_ID; diff --git a/src/servers/sapphire_zone/Action/ActionTeleport.cpp b/src/servers/sapphire_zone/Action/ActionTeleport.cpp index 277aec5b..81a204c4 100644 --- a/src/servers/sapphire_zone/Action/ActionTeleport.cpp +++ b/src/servers/sapphire_zone/Action/ActionTeleport.cpp @@ -84,12 +84,11 @@ void Core::Action::ActionTeleport::onFinish() pPlayer->setZoningType( ZoneingType::Teleport ); - auto effectPacket = makeZonePacket< FFXIVIpcEffect >( getId() ); - effectPacket->data().targetId = pPlayer->getId(); + auto effectPacket = makeZonePacket< Server::FFXIVIpcEffect >( getId() ); + effectPacket->data().animationTargetId = pPlayer->getId(); effectPacket->data().actionAnimationId = 5; //effectPacket.data().unknown_3 = 1; - effectPacket->data().actionTextId = 5; - effectPacket->data().unknown_5 = 1; + effectPacket->data().actionAnimationId = 5; effectPacket->data().numEffects = 1; effectPacket->data().rotation = static_cast< uint16_t >( 0x8000 * ( ( pPlayer->getRot() + 3.1415926 ) ) / 3.1415926 ); effectPacket->data().effectTargetId = pPlayer->getId(); diff --git a/src/servers/sapphire_zone/Action/EventItemAction.cpp b/src/servers/sapphire_zone/Action/EventItemAction.cpp index a6c68208..8fa6323d 100644 --- a/src/servers/sapphire_zone/Action/EventItemAction.cpp +++ b/src/servers/sapphire_zone/Action/EventItemAction.cpp @@ -69,12 +69,10 @@ void Core::Action::EventItemAction::onFinish() try { - auto effectPacket = makeZonePacket< FFXIVIpcEffect >( m_pSource->getId() ); - effectPacket->data().targetId = static_cast< uint32_t >( m_additional ); + auto effectPacket = makeZonePacket< Server::FFXIVIpcEffect >( m_pSource->getId() ); + effectPacket->data().animationTargetId = static_cast< uint32_t >( m_additional ); effectPacket->data().actionAnimationId = 1; -// effectPacket.data().unknown_3 = 3; - effectPacket->data().actionTextId = m_id; - effectPacket->data().unknown_5 = 2; + effectPacket->data().actionId = m_id; effectPacket->data().numEffects = 1; effectPacket->data().rotation = Math::Util::floatToUInt16Rot( m_pSource->getRot() ); effectPacket->data().effectTargetId = static_cast< uint32_t >( m_additional ); diff --git a/src/servers/sapphire_zone/Actor/Chara.cpp b/src/servers/sapphire_zone/Actor/Chara.cpp index 7ebcf50a..a2e6be7d 100644 --- a/src/servers/sapphire_zone/Actor/Chara.cpp +++ b/src/servers/sapphire_zone/Actor/Chara.cpp @@ -399,19 +399,16 @@ void Core::Entity::Chara::autoAttack( CharaPtr pTarget ) uint16_t damage = static_cast< uint16_t >( 10 + rand() % 12 ); uint32_t variation = static_cast< uint32_t >( 0 + rand() % 4 ); - auto ipcEffect = makeZonePacket< FFXIVIpcEffect >( getId() ); - ipcEffect->data().targetId = pTarget->getId(); + auto ipcEffect = makeZonePacket< Server::FFXIVIpcEffect >( getId() ); + ipcEffect->data().animationTargetId = pTarget->getId(); ipcEffect->data().actionAnimationId = 0x366; - ipcEffect->data().unknown_2 = variation; -// effectPacket->data().unknown_3 = 1; - ipcEffect->data().actionTextId = 0x366; + ipcEffect->data().actionId = 0x366; ipcEffect->data().numEffects = 1; ipcEffect->data().rotation = Math::Util::floatToUInt16Rot( getRot() ); ipcEffect->data().effectTargetId = pTarget->getId(); ipcEffect->data().effects[0].value = damage; ipcEffect->data().effects[0].effectType = ActionEffectType::Damage; ipcEffect->data().effects[0].hitSeverity = static_cast< ActionHitSeverityType >( variation ); - //ipcEffect->data().effects[0].unknown_3 = 7; sendToInRangeSet( ipcEffect ); @@ -444,12 +441,12 @@ void Core::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionId, u // Prepare packet. This is seemingly common for all packets in the action handler. - auto effectPacket = makeZonePacket< FFXIVIpcEffect >( getId() ); - effectPacket->data().targetId = target.getId(); + auto effectPacket = makeZonePacket< Server::FFXIVIpcEffect >( getId() ); + effectPacket->data().animationTargetId = target.getId(); effectPacket->data().actionAnimationId = actionId; //effectPacket->data().unknown_62 = 1; // Affects displaying action name next to number in floating text - effectPacket->data().unknown_2 = 1; // This seems to have an effect on the "double-cast finish" animation - effectPacket->data().actionTextId = actionId; + //effectPacket->data().globalEffectCounter = 1; // This seems to have an effect on the "double-cast finish" animation + effectPacket->data().actionId = actionId; effectPacket->data().numEffects = 1; effectPacket->data().rotation = Math::Util::floatToUInt16Rot( getRot() ); effectPacket->data().effectTargetId = target.getId(); @@ -487,7 +484,7 @@ void Core::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionId, u for( const auto& pHitActor : actorsCollided ) { - effectPacket->data().targetId = pHitActor->getId(); + effectPacket->data().animationTargetId = pHitActor->getId(); effectPacket->data().effectTargetId = pHitActor->getId(); // todo: send to range of what? ourselves? when mob script hits this is going to be lacking @@ -540,7 +537,7 @@ void Core::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionId, u for( auto pHitActor : actorsCollided ) { - effectPacket->data().targetId = target.getId(); + effectPacket->data().animationTargetId = target.getId(); effectPacket->data().effectTargetId = pHitActor->getId(); sendToInRangeSet( effectPacket, true ); diff --git a/src/servers/sapphire_zone/Actor/Player.cpp b/src/servers/sapphire_zone/Actor/Player.cpp index 27cf2775..80356f77 100644 --- a/src/servers/sapphire_zone/Actor/Player.cpp +++ b/src/servers/sapphire_zone/Actor/Player.cpp @@ -1418,14 +1418,14 @@ void Core::Entity::Player::autoAttack( CharaPtr pTarget ) if( getClass() == ClassJob::Machinist || getClass() == ClassJob::Bard || getClass() == ClassJob::Archer ) { - auto effectPacket = makeZonePacket< FFXIVIpcEffect >( getId() ); - effectPacket->data().targetId = pTarget->getId(); + auto effectPacket = makeZonePacket< Server::FFXIVIpcEffect >( getId() ); + effectPacket->data().animationTargetId = pTarget->getId(); effectPacket->data().actionAnimationId = 8; // effectPacket.data().unknown_2 = variation; effectPacket->data().numEffects = 1; //effectPacket->data().unknown_61 = 1; //effectPacket->data().unknown_62 = 1; - effectPacket->data().actionTextId = 8; + effectPacket->data().actionId = 8; effectPacket->data().rotation = Math::Util::floatToUInt16Rot( getRot() ); effectPacket->data().effectTargetId = pTarget->getId(); //effectPacket->data().effectTarget = pTarget->getId(); @@ -1439,14 +1439,14 @@ void Core::Entity::Player::autoAttack( CharaPtr pTarget ) else { - auto effectPacket = makeZonePacket< FFXIVIpcEffect >( getId() ); - effectPacket->data().targetId = pTarget->getId(); + auto effectPacket = makeZonePacket< Server::FFXIVIpcEffect >( getId() ); + effectPacket->data().animationTargetId = pTarget->getId(); effectPacket->data().actionAnimationId = 7; // effectPacket.data().unknown_2 = variation; effectPacket->data().numEffects = 1; //effectPacket->data().unknown_61 = 1; //effectPacket->data().unknown_62 = 1; - effectPacket->data().actionTextId = 7; + effectPacket->data().actionId = 7; effectPacket->data().rotation = Math::Util::floatToUInt16Rot( getRot() ); effectPacket->data().effectTargetId = pTarget->getId(); effectPacket->data().effects[0].value = damage; From c84beee30a2002c324b604208435eb8addb7350e Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sat, 21 Jul 2018 23:32:10 +1000 Subject: [PATCH 03/13] replace old inline generation of effects packet with a wrapper --- src/common/Common.h | 7 ++ .../Network/PacketDef/Zone/ServerZoneDef.h | 15 ++--- .../sapphire_zone/Action/ActionMount.cpp | 21 +++--- .../sapphire_zone/Action/ActionTeleport.cpp | 17 ++--- .../sapphire_zone/Action/EventItemAction.cpp | 11 ++-- src/servers/sapphire_zone/Actor/Chara.cpp | 61 ++++++++--------- src/servers/sapphire_zone/Actor/Player.cpp | 54 +++++++-------- .../Network/PacketWrappers/EffectPacket.h | 65 +++++++++++++++++++ 8 files changed, 146 insertions(+), 105 deletions(-) create mode 100644 src/servers/sapphire_zone/Network/PacketWrappers/EffectPacket.h diff --git a/src/common/Common.h b/src/common/Common.h index 7a72418b..39fbc393 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -423,6 +423,13 @@ namespace Common { CritDirectHitDamage = 3 }; + enum ActionEffectDisplayType : uint8_t + { + HideActionName = 0, + ShowActionName = 1, + ShowItemName = 2, + }; + enum class ActionCollisionType : uint8_t { None, diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index 2bc4e0ce..3787e1c2 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -299,7 +299,7 @@ struct FFXIVIpcUpdateHpMpTp : FFXIVIpcBasePacket * Structural representation of the packet sent by the server * for battle actions */ -struct effectEntry +struct EffectEntry { Common::ActionEffectType effectType; Common::ActionHitSeverityType hitSeverity; @@ -322,24 +322,19 @@ struct FFXIVIpcEffect : FFXIVIpcBasePacket uint16_t hiddenAnimation; // if 0, always shows animation, otherwise hides it. counts up by 1 for each animation skipped on a caster - int16_t rotation; + uint16_t rotation; uint16_t actionAnimationId; // the animation that is played by the casting character uint8_t unknown1E; // can be 0,1,2 - maybe other values? - doesn't do anything? - /* effectDisplayType - * 0 = only show damage/heal amount - * 1 = show damage/heal amount + name - * 2 = show damage/heal amount + name but name is from item.exd, name id is actionId - */ - uint8_t effectDisplayType; + Common::ActionEffectDisplayType effectDisplayType; uint8_t unknown20; // is read by handler, runs code which gets the LODWORD of animationLockTime (wtf?) - uint8_t numEffects; // ignores effects if 0, otherwise parses all of them + uint8_t effectCount; // ignores effects if 0, otherwise parses all of them uint32_t padding_22[2]; - effectEntry effects[8]; + EffectEntry effects[8]; uint16_t padding_6A[3]; diff --git a/src/servers/sapphire_zone/Action/ActionMount.cpp b/src/servers/sapphire_zone/Action/ActionMount.cpp index 912e0c84..2b1ec0da 100644 --- a/src/servers/sapphire_zone/Action/ActionMount.cpp +++ b/src/servers/sapphire_zone/Action/ActionMount.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket143.h" @@ -73,19 +74,15 @@ void Core::Action::ActionMount::onFinish() pPlayer->unsetStateFlag( PlayerStateFlag::Casting ); - auto effectPacket = makeZonePacket< Server::FFXIVIpcEffect >( getId() ); + auto effectPacket = boost::make_shared< Server::EffectPacket >( getId(), pPlayer->getId(), 4 ); + effectPacket->setRotation( Math::Util::floatToUInt16Rot( pPlayer->getRot() ) ); - effectPacket->data().animationTargetId = pPlayer->getId(); - effectPacket->data().actionAnimationId = m_id; - // Affects displaying action name next to number in floating text - //effectPacket->data().unknown_62 = 13; - effectPacket->data().actionAnimationId = 4; - effectPacket->data().numEffects = 1; - effectPacket->data().rotation = Math::Util::floatToUInt16Rot( pPlayer->getRot() ); - //effectPacket->data().effectTarget = INVALID_GAME_OBJECT_ID; - effectPacket->data().effects[0].effectType = ActionEffectType::Mount; - effectPacket->data().effects[0].hitSeverity = ActionHitSeverityType::CritDamage; - effectPacket->data().effects[0].value = m_id; + Server::EffectEntry effectEntry{}; + effectEntry.effectType = ActionEffectType::Mount; + effectEntry.hitSeverity = ActionHitSeverityType::CritDamage; + effectEntry.value = m_id; + + effectPacket->addEffect( effectEntry ); pPlayer->sendToInRangeSet( effectPacket, true ); diff --git a/src/servers/sapphire_zone/Action/ActionTeleport.cpp b/src/servers/sapphire_zone/Action/ActionTeleport.cpp index 81a204c4..257bc27d 100644 --- a/src/servers/sapphire_zone/Action/ActionTeleport.cpp +++ b/src/servers/sapphire_zone/Action/ActionTeleport.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include "Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket143.h" @@ -84,19 +86,12 @@ void Core::Action::ActionTeleport::onFinish() pPlayer->setZoningType( ZoneingType::Teleport ); - auto effectPacket = makeZonePacket< Server::FFXIVIpcEffect >( getId() ); - effectPacket->data().animationTargetId = pPlayer->getId(); - effectPacket->data().actionAnimationId = 5; - //effectPacket.data().unknown_3 = 1; - effectPacket->data().actionAnimationId = 5; - effectPacket->data().numEffects = 1; - effectPacket->data().rotation = static_cast< uint16_t >( 0x8000 * ( ( pPlayer->getRot() + 3.1415926 ) ) / 3.1415926 ); - effectPacket->data().effectTargetId = pPlayer->getId(); + auto effectPacket = boost::make_shared< Server::EffectPacket >( getId(), pPlayer->getId(), 5 ); + effectPacket->setRotation( Math::Util::floatToUInt16Rot( pPlayer->getRot() ) ); + + pPlayer->sendToInRangeSet( effectPacket, true ); - pPlayer->teleport( m_targetAetheryte ); - - } void Core::Action::ActionTeleport::onInterrupt() diff --git a/src/servers/sapphire_zone/Action/EventItemAction.cpp b/src/servers/sapphire_zone/Action/EventItemAction.cpp index 8fa6323d..f1ac74e3 100644 --- a/src/servers/sapphire_zone/Action/EventItemAction.cpp +++ b/src/servers/sapphire_zone/Action/EventItemAction.cpp @@ -7,6 +7,7 @@ #include "Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket143.h" +#include "Network/PacketWrappers/EffectPacket.h" #include "Actor/Player.h" @@ -69,13 +70,9 @@ void Core::Action::EventItemAction::onFinish() try { - auto effectPacket = makeZonePacket< Server::FFXIVIpcEffect >( m_pSource->getId() ); - effectPacket->data().animationTargetId = static_cast< uint32_t >( m_additional ); - effectPacket->data().actionAnimationId = 1; - effectPacket->data().actionId = m_id; - effectPacket->data().numEffects = 1; - effectPacket->data().rotation = Math::Util::floatToUInt16Rot( m_pSource->getRot() ); - effectPacket->data().effectTargetId = static_cast< uint32_t >( m_additional ); + auto effectPacket = boost::make_shared< Server::EffectPacket >( m_pSource->getId(), m_additional, m_id ); + effectPacket->setAnimationId( 1 ); + effectPacket->setRotation( Math::Util::floatToUInt16Rot( m_pSource->getRot() ) ); m_pSource->getAsPlayer()->unsetStateFlag( Common::PlayerStateFlag::Casting ); m_pSource->sendToInRangeSet( effectPacket, true ); diff --git a/src/servers/sapphire_zone/Actor/Chara.cpp b/src/servers/sapphire_zone/Actor/Chara.cpp index a2e6be7d..b0b22153 100644 --- a/src/servers/sapphire_zone/Actor/Chara.cpp +++ b/src/servers/sapphire_zone/Actor/Chara.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "Forwards.h" #include "Action/Action.h" @@ -399,21 +400,20 @@ void Core::Entity::Chara::autoAttack( CharaPtr pTarget ) uint16_t damage = static_cast< uint16_t >( 10 + rand() % 12 ); uint32_t variation = static_cast< uint32_t >( 0 + rand() % 4 ); - auto ipcEffect = makeZonePacket< Server::FFXIVIpcEffect >( getId() ); - ipcEffect->data().animationTargetId = pTarget->getId(); - ipcEffect->data().actionAnimationId = 0x366; - ipcEffect->data().actionId = 0x366; - ipcEffect->data().numEffects = 1; - ipcEffect->data().rotation = Math::Util::floatToUInt16Rot( getRot() ); - ipcEffect->data().effectTargetId = pTarget->getId(); - ipcEffect->data().effects[0].value = damage; - ipcEffect->data().effects[0].effectType = ActionEffectType::Damage; - ipcEffect->data().effects[0].hitSeverity = static_cast< ActionHitSeverityType >( variation ); + auto effectPacket = boost::make_shared< Server::EffectPacket >( getId(), pTarget->getId(), 0x336 ); + effectPacket->setRotation( Math::Util::floatToUInt16Rot( getRot() ) ); - sendToInRangeSet( ipcEffect ); + Server::EffectEntry effectEntry{ }; + effectEntry.value = damage; + effectEntry.effectType = ActionEffectType::Damage; + effectEntry.hitSeverity = static_cast< ActionHitSeverityType >( variation ); + + effectPacket->addEffect( effectEntry ); + + sendToInRangeSet( effectPacket ); if( isPlayer() ) - getAsPlayer()->queuePacket( ipcEffect ); + getAsPlayer()->queuePacket( effectPacket ); pTarget->takeDamage( damage ); } @@ -440,16 +440,8 @@ void Core::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionId, u // Todo: Effect packet generator. 90% of this is basically setting params and it's basically unreadable. // Prepare packet. This is seemingly common for all packets in the action handler. - - auto effectPacket = makeZonePacket< Server::FFXIVIpcEffect >( getId() ); - effectPacket->data().animationTargetId = target.getId(); - effectPacket->data().actionAnimationId = actionId; - //effectPacket->data().unknown_62 = 1; // Affects displaying action name next to number in floating text - //effectPacket->data().globalEffectCounter = 1; // This seems to have an effect on the "double-cast finish" animation - effectPacket->data().actionId = actionId; - effectPacket->data().numEffects = 1; - effectPacket->data().rotation = Math::Util::floatToUInt16Rot( getRot() ); - effectPacket->data().effectTargetId = target.getId(); + auto effectPacket = boost::make_shared< Server::EffectPacket >( getId(), target.getId(), actionId ); + effectPacket->setRotation( Math::Util::floatToUInt16Rot( getRot() ) ); // Todo: for each actor, calculate how much damage the calculated value should deal to them - 2-step damage calc. we only have 1-step switch( type ) @@ -457,10 +449,12 @@ void Core::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionId, u case ActionEffectType::Damage: { - effectPacket->data().effects[0].value = static_cast< uint16_t >( param1 ); - effectPacket->data().effects[0].effectType = ActionEffectType::Damage; - effectPacket->data().effects[0].hitSeverity = ActionHitSeverityType::NormalDamage; - //effectPacket->data().effects[0].unknown_3 = 7; + Server::EffectEntry effectEntry{}; + effectEntry.value = static_cast< uint16_t >( param1 ); + effectEntry.effectType = ActionEffectType::Damage; + effectEntry.hitSeverity = ActionHitSeverityType::NormalDamage; + + effectPacket->addEffect( effectEntry ); if( actionInfoPtr->castType == 1 && actionInfoPtr->effectRange != 0 || actionInfoPtr->castType != 1 ) { @@ -484,8 +478,7 @@ void Core::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionId, u for( const auto& pHitActor : actorsCollided ) { - effectPacket->data().animationTargetId = pHitActor->getId(); - effectPacket->data().effectTargetId = pHitActor->getId(); + effectPacket->setTargetActor( pHitActor->getId() ); // todo: send to range of what? ourselves? when mob script hits this is going to be lacking sendToInRangeSet( effectPacket, true ); @@ -515,9 +508,12 @@ void Core::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionId, u { uint32_t calculatedHeal = Math::CalcBattle::calculateHealValue( getAsPlayer(), static_cast< uint32_t >( param1 ) ); - effectPacket->data().effects[0].value = calculatedHeal; - effectPacket->data().effects[0].effectType = ActionEffectType::Heal; - effectPacket->data().effects[0].hitSeverity = ActionHitSeverityType::NormalHeal; + Server::EffectEntry effectEntry{}; + effectEntry.value = calculatedHeal; + effectEntry.effectType = ActionEffectType::Heal; + effectEntry.hitSeverity = ActionHitSeverityType::NormalHeal; + + effectPacket->addEffect( effectEntry ); if( actionInfoPtr->castType == 1 && actionInfoPtr->effectRange != 0 || actionInfoPtr->castType != 1 ) { @@ -537,8 +533,7 @@ void Core::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionId, u for( auto pHitActor : actorsCollided ) { - effectPacket->data().animationTargetId = target.getId(); - effectPacket->data().effectTargetId = pHitActor->getId(); + effectPacket->setTargetActor( pHitActor->getId() ); sendToInRangeSet( effectPacket, true ); pHitActor->getAsChara()->heal( calculatedHeal ); diff --git a/src/servers/sapphire_zone/Actor/Player.cpp b/src/servers/sapphire_zone/Actor/Player.cpp index 80356f77..0d1dccb3 100644 --- a/src/servers/sapphire_zone/Actor/Player.cpp +++ b/src/servers/sapphire_zone/Actor/Player.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "Session.h" #include "Player.h" @@ -1418,46 +1419,35 @@ void Core::Entity::Player::autoAttack( CharaPtr pTarget ) if( getClass() == ClassJob::Machinist || getClass() == ClassJob::Bard || getClass() == ClassJob::Archer ) { - auto effectPacket = makeZonePacket< Server::FFXIVIpcEffect >( getId() ); - effectPacket->data().animationTargetId = pTarget->getId(); - effectPacket->data().actionAnimationId = 8; - // effectPacket.data().unknown_2 = variation; - effectPacket->data().numEffects = 1; - //effectPacket->data().unknown_61 = 1; - //effectPacket->data().unknown_62 = 1; - effectPacket->data().actionId = 8; - effectPacket->data().rotation = Math::Util::floatToUInt16Rot( getRot() ); - effectPacket->data().effectTargetId = pTarget->getId(); - //effectPacket->data().effectTarget = pTarget->getId(); - effectPacket->data().effects[0].value = damage; - effectPacket->data().effects[0].effectType = Common::ActionEffectType::Damage; - effectPacket->data().effects[0].hitSeverity = Common::ActionHitSeverityType::NormalDamage; - //effectPacket->data().effects[0].unknown_3 = 7; + auto effectPacket = boost::make_shared< Server::EffectPacket >( getId(), pTarget->getId(), 8 ); + effectPacket->setRotation( Math::Util::floatToUInt16Rot( getRot() ) ); - sendToInRangeSet(effectPacket, true); + Server::EffectEntry entry; + entry.value = damage; + entry.effectType = Common::ActionEffectType::Damage; + entry.hitSeverity = Common::ActionHitSeverityType::NormalDamage; + + effectPacket->addEffect( entry ); + + sendToInRangeSet( effectPacket, true ); } else { + auto effectPacket = boost::make_shared< Server::EffectPacket >( getId(), pTarget->getId(), 7 ); + effectPacket->setRotation( Math::Util::floatToUInt16Rot( getRot() ) ); - auto effectPacket = makeZonePacket< Server::FFXIVIpcEffect >( getId() ); - effectPacket->data().animationTargetId = pTarget->getId(); - effectPacket->data().actionAnimationId = 7; - // effectPacket.data().unknown_2 = variation; - effectPacket->data().numEffects = 1; - //effectPacket->data().unknown_61 = 1; - //effectPacket->data().unknown_62 = 1; - effectPacket->data().actionId = 7; - effectPacket->data().rotation = Math::Util::floatToUInt16Rot( getRot() ); - effectPacket->data().effectTargetId = pTarget->getId(); - effectPacket->data().effects[0].value = damage; - effectPacket->data().effects[0].effectType = Common::ActionEffectType::Damage; - effectPacket->data().effects[0].hitSeverity = Common::ActionHitSeverityType::NormalDamage; - //effectPacket->data().effects[0].unknown_3 = 71; + Server::EffectEntry entry; + entry.value = damage; + entry.effectType = Common::ActionEffectType::Damage; + entry.hitSeverity = Common::ActionHitSeverityType::NormalDamage; + + effectPacket->addEffect( entry ); + + sendToInRangeSet( effectPacket, true ); - sendToInRangeSet(effectPacket, true); } - pTarget->takeDamage(damage); + pTarget->takeDamage( damage ); } diff --git a/src/servers/sapphire_zone/Network/PacketWrappers/EffectPacket.h b/src/servers/sapphire_zone/Network/PacketWrappers/EffectPacket.h new file mode 100644 index 00000000..afafdffc --- /dev/null +++ b/src/servers/sapphire_zone/Network/PacketWrappers/EffectPacket.h @@ -0,0 +1,65 @@ +#ifndef SAPPHIRE_EFFECTPACKET_H +#define SAPPHIRE_EFFECTPACKET_H + +#include +#include +#include "Forwards.h" + +namespace Core { +namespace Network { +namespace Packets { +namespace Server { + +class EffectPacket : + public ZoneChannelPacket< FFXIVIpcEffect > +{ +public: + EffectPacket( uint64_t sourceId, uint32_t targetId, uint32_t actionId ) : + ZoneChannelPacket< FFXIVIpcEffect >( sourceId, targetId ) + { + m_data.actionId = actionId; + m_data.actionAnimationId = static_cast< uint16_t >( actionId ); + + m_data.animationTargetId = targetId; + m_data.effectTargetId = targetId; + + m_data.effectDisplayType = Common::ActionEffectDisplayType::ShowActionName; + } + + void addEffect( const Server::EffectEntry& effect ) + { + assert( m_data.effectCount <= 8 ); + + std::memcpy( &m_data.effects[m_data.effectCount++], &effect, sizeof( Server::EffectEntry ) ); + } + + void setAnimationId( const uint16_t animationId ) + { + m_data.actionAnimationId = animationId; + } + + void setEffectFlags( const uint32_t effectFlags ) + { + m_data.effectFlags = effectFlags; + } + + void setRotation( const uint16_t rotation ) + { + m_data.rotation = rotation; + } + + void setTargetActor( const uint32_t targetId ) + { + m_data.animationTargetId = targetId; + m_data.effectTargetId = targetId; + + FFXIVPacketBase::setTargetActor( targetId ); + } +}; + +} +} +} +} + +#endif //SAPPHIRE_EFFECTPACKET_H From 2665e55a17bf33a6d73fd8c2f9592dc198204864 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sat, 21 Jul 2018 23:48:14 +1000 Subject: [PATCH 04/13] aoeeffect8/16/24/32 packet defs/opcodes --- src/common/Network/PacketDef/Ipcs.h | 4 ++ .../Network/PacketDef/Zone/ServerZoneDef.h | 40 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/common/Network/PacketDef/Ipcs.h b/src/common/Network/PacketDef/Ipcs.h index d8010c37..4de2bb9d 100644 --- a/src/common/Network/PacketDef/Ipcs.h +++ b/src/common/Network/PacketDef/Ipcs.h @@ -97,6 +97,10 @@ namespace Packets { StatusEffectList = 0x014E, // updated 4.3 Effect = 0x0151, // updated 4.3 + AoeEffect8 = 0x0154, // updated 4.3 + AoeEffect16 = 0x0155, // updated 4.3 + AoeEffect24 = 0x0156, // updated 4.3 + AoeEffect32 = 0x0157, // updated 4.3 PersistantEffect = 0x0158, // updated 4.3 GCAffiliation = 0xCCFC, // OUTDATED diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index 3787e1c2..e1f875c9 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -344,6 +344,46 @@ struct FFXIVIpcEffect : FFXIVIpcBasePacket uint32_t padding_78; }; +template< int size > +struct FFXIVIpcAoeEffect +{ + uint64_t animationTargetId; + uint32_t actionId; + + uint32_t globalEffectCounter; + float animationLockTime; + + uint32_t someTargetId; + + uint16_t hiddenAnimation; + + uint16_t rotation; + + uint16_t actionAnimationId; + uint8_t unknown1E; + + Common::ActionEffectDisplayType effectDisplayType; + + uint8_t unknown20; + uint8_t effectCount; + + uint32_t padding_22[2]; + + EffectEntry effects[size]; + + uint16_t padding_6A[3]; + + uint32_t effectTargetId[size]; + uint32_t effectFlags; + + uint32_t padding_78; +}; + +struct FFXIVIpcAoeEffect8 : FFXIVIpcBasePacket< AoeEffect8 >, FFXIVIpcAoeEffect< 8 > {}; +struct FFXIVIpcAoeEffect16 : FFXIVIpcBasePacket< AoeEffect16 >, FFXIVIpcAoeEffect< 16 > {}; +struct FFXIVIpcAoeEffect24 : FFXIVIpcBasePacket< AoeEffect24 >, FFXIVIpcAoeEffect< 24 > {}; +struct FFXIVIpcAoeEffect32 : FFXIVIpcBasePacket< AoeEffect32 >, FFXIVIpcAoeEffect< 32 > {}; + /** * Structural representation of the packet sent by the server From 68b08de1ded9e197d6418a4e47e92de435d6e20b Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sun, 22 Jul 2018 16:54:01 +1000 Subject: [PATCH 05/13] housing placard script, gridania mb script, opcodes --- src/common/Network/PacketDef/Ipcs.h | 3 +++ .../Scripts/common/CmnDefHousingSignboard.cpp | 19 +++++++++++++++++++ .../common/CmnDefMarketBoardGridania.cpp | 19 +++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 src/servers/Scripts/common/CmnDefHousingSignboard.cpp create mode 100644 src/servers/Scripts/common/CmnDefMarketBoardGridania.cpp diff --git a/src/common/Network/PacketDef/Ipcs.h b/src/common/Network/PacketDef/Ipcs.h index 4de2bb9d..1acc4dbd 100644 --- a/src/common/Network/PacketDef/Ipcs.h +++ b/src/common/Network/PacketDef/Ipcs.h @@ -228,8 +228,11 @@ namespace Packets { LinkshellListHandler = 0x00F4, // updated 4.3 + SearchMarketboard = 0x0103, // updated 4.3 + FcInfoReqHandler = 0x011A, // updated 4.2 + ReqMarketWishList = 0x012C, // updated 4.3 ReqJoinNoviceNetwork = 0x0129, // updated 4.2 diff --git a/src/servers/Scripts/common/CmnDefHousingSignboard.cpp b/src/servers/Scripts/common/CmnDefHousingSignboard.cpp new file mode 100644 index 00000000..bb922cbd --- /dev/null +++ b/src/servers/Scripts/common/CmnDefHousingSignboard.cpp @@ -0,0 +1,19 @@ +#include +#include + +class CmnDefHousingSignboard : public EventScript +{ +public: + CmnDefHousingSignboard() : EventScript( 721031 ) + {} + + void Scene00000( Entity::Player& player ) + { + player.playScene( getId(), 0, 0x2000, 0, 1 ); + } + + void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override + { + Scene00000( player ); + } +}; \ No newline at end of file diff --git a/src/servers/Scripts/common/CmnDefMarketBoardGridania.cpp b/src/servers/Scripts/common/CmnDefMarketBoardGridania.cpp new file mode 100644 index 00000000..3f0eec55 --- /dev/null +++ b/src/servers/Scripts/common/CmnDefMarketBoardGridania.cpp @@ -0,0 +1,19 @@ +#include +#include + +class CmnDefMarketBoardGridania : public EventScript +{ +public: + CmnDefMarketBoardGridania() : EventScript( 0xB0027 ) + {} + + void Scene00000( Entity::Player& player ) + { + player.playScene( getId(), 0, 0x2000, 0, 1 ); + } + + void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override + { + Scene00000( player ); + } +}; \ No newline at end of file From 893ebd3454d4182347462f8724d724363ed5787b Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sun, 22 Jul 2018 16:54:23 +1000 Subject: [PATCH 06/13] move common effect struct members into a shared struct for single target/aoe --- .../Network/PacketDef/Zone/ServerZoneDef.h | 30 +++++-------------- .../Network/PacketWrappers/EffectPacket.h | 18 +++++------ 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index e1f875c9..98eeda5c 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -310,7 +310,7 @@ struct EffectEntry int16_t value; }; -struct FFXIVIpcEffect : FFXIVIpcBasePacket +struct EffectHeader { uint64_t animationTargetId; // who the animation targets uint32_t actionId; // what the casting player casts, shown in battle log/ui @@ -333,6 +333,11 @@ struct FFXIVIpcEffect : FFXIVIpcBasePacket uint8_t effectCount; // ignores effects if 0, otherwise parses all of them uint32_t padding_22[2]; +}; + +struct FFXIVIpcEffect : FFXIVIpcBasePacket +{ + EffectHeader header; EffectEntry effects[8]; @@ -347,33 +352,14 @@ struct FFXIVIpcEffect : FFXIVIpcBasePacket template< int size > struct FFXIVIpcAoeEffect { - uint64_t animationTargetId; - uint32_t actionId; - - uint32_t globalEffectCounter; - float animationLockTime; - - uint32_t someTargetId; - - uint16_t hiddenAnimation; - - uint16_t rotation; - - uint16_t actionAnimationId; - uint8_t unknown1E; - - Common::ActionEffectDisplayType effectDisplayType; - - uint8_t unknown20; - uint8_t effectCount; - - uint32_t padding_22[2]; + EffectHeader header; EffectEntry effects[size]; uint16_t padding_6A[3]; uint32_t effectTargetId[size]; + Common::FFXIVARR_POSITION3 position; uint32_t effectFlags; uint32_t padding_78; diff --git a/src/servers/sapphire_zone/Network/PacketWrappers/EffectPacket.h b/src/servers/sapphire_zone/Network/PacketWrappers/EffectPacket.h index afafdffc..548aa83c 100644 --- a/src/servers/sapphire_zone/Network/PacketWrappers/EffectPacket.h +++ b/src/servers/sapphire_zone/Network/PacketWrappers/EffectPacket.h @@ -17,25 +17,25 @@ public: EffectPacket( uint64_t sourceId, uint32_t targetId, uint32_t actionId ) : ZoneChannelPacket< FFXIVIpcEffect >( sourceId, targetId ) { - m_data.actionId = actionId; - m_data.actionAnimationId = static_cast< uint16_t >( actionId ); + m_data.header.actionId = actionId; + m_data.header.actionAnimationId = static_cast< uint16_t >( actionId ); - m_data.animationTargetId = targetId; + m_data.header.animationTargetId = targetId; m_data.effectTargetId = targetId; - m_data.effectDisplayType = Common::ActionEffectDisplayType::ShowActionName; + m_data.header.effectDisplayType = Common::ActionEffectDisplayType::ShowActionName; } void addEffect( const Server::EffectEntry& effect ) { - assert( m_data.effectCount <= 8 ); + assert( m_data.header.effectCount <= 8 ); - std::memcpy( &m_data.effects[m_data.effectCount++], &effect, sizeof( Server::EffectEntry ) ); + std::memcpy( &m_data.effects[m_data.header.effectCount++], &effect, sizeof( Server::EffectEntry ) ); } void setAnimationId( const uint16_t animationId ) { - m_data.actionAnimationId = animationId; + m_data.header.actionAnimationId = animationId; } void setEffectFlags( const uint32_t effectFlags ) @@ -45,12 +45,12 @@ public: void setRotation( const uint16_t rotation ) { - m_data.rotation = rotation; + m_data.header.rotation = rotation; } void setTargetActor( const uint32_t targetId ) { - m_data.animationTargetId = targetId; + m_data.header.animationTargetId = targetId; m_data.effectTargetId = targetId; FFXIVPacketBase::setTargetActor( targetId ); From 394988fbb0b7648575b93fdbfcbe7cdd97ce2a1b Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sun, 22 Jul 2018 17:02:09 +1000 Subject: [PATCH 07/13] scripts cleanup, npc repair script and hunt board --- .../Scripts/common/CmnDefCutSceneReplay.cpp | 2 +- .../Scripts/common/CmnDefHousingSignboard.cpp | 2 +- src/servers/Scripts/common/CmnDefInnBed.cpp | 2 +- .../common/CmnDefMarketBoardGridania.cpp | 2 +- .../Scripts/common/CmnDefNpcRepair.cpp | 19 +++++++++++++++++++ .../Scripts/common/ComDefMobHuntBoard.cpp | 19 +++++++++++++++++++ .../Scripts/common/HouFurOrchestrion.cpp | 2 +- 7 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 src/servers/Scripts/common/CmnDefNpcRepair.cpp create mode 100644 src/servers/Scripts/common/ComDefMobHuntBoard.cpp diff --git a/src/servers/Scripts/common/CmnDefCutSceneReplay.cpp b/src/servers/Scripts/common/CmnDefCutSceneReplay.cpp index fdd742e1..137c5a02 100644 --- a/src/servers/Scripts/common/CmnDefCutSceneReplay.cpp +++ b/src/servers/Scripts/common/CmnDefCutSceneReplay.cpp @@ -17,7 +17,7 @@ public: } }; - player.playScene( getId(), 0, 0x2000, 0, 1, callback ); + player.playScene( getId(), 0, HIDE_HOTBAR, 0, 1, callback ); } void Scene00001( Entity::Player& player, uint16_t returnScene ) diff --git a/src/servers/Scripts/common/CmnDefHousingSignboard.cpp b/src/servers/Scripts/common/CmnDefHousingSignboard.cpp index bb922cbd..cced1ec6 100644 --- a/src/servers/Scripts/common/CmnDefHousingSignboard.cpp +++ b/src/servers/Scripts/common/CmnDefHousingSignboard.cpp @@ -9,7 +9,7 @@ public: void Scene00000( Entity::Player& player ) { - player.playScene( getId(), 0, 0x2000, 0, 1 ); + player.playScene( getId(), 0, HIDE_HOTBAR, 0, 1 ); } void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override diff --git a/src/servers/Scripts/common/CmnDefInnBed.cpp b/src/servers/Scripts/common/CmnDefInnBed.cpp index 2b524502..8c09c3c3 100644 --- a/src/servers/Scripts/common/CmnDefInnBed.cpp +++ b/src/servers/Scripts/common/CmnDefInnBed.cpp @@ -16,7 +16,7 @@ public: Scene00001( player, result.param2 ); }; - player.playScene( getId(), 0, 0x2000, 0, 1, callback ); + player.playScene( getId(), 0, HIDE_HOTBAR, 0, 1, callback ); } // lay down diff --git a/src/servers/Scripts/common/CmnDefMarketBoardGridania.cpp b/src/servers/Scripts/common/CmnDefMarketBoardGridania.cpp index 3f0eec55..292bdaa9 100644 --- a/src/servers/Scripts/common/CmnDefMarketBoardGridania.cpp +++ b/src/servers/Scripts/common/CmnDefMarketBoardGridania.cpp @@ -9,7 +9,7 @@ public: void Scene00000( Entity::Player& player ) { - player.playScene( getId(), 0, 0x2000, 0, 1 ); + player.playScene( getId(), 0, HIDE_HOTBAR, 0, 1 ); } void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override diff --git a/src/servers/Scripts/common/CmnDefNpcRepair.cpp b/src/servers/Scripts/common/CmnDefNpcRepair.cpp new file mode 100644 index 00000000..18be6f72 --- /dev/null +++ b/src/servers/Scripts/common/CmnDefNpcRepair.cpp @@ -0,0 +1,19 @@ +#include +#include + +class CmnDefNpcRepair : public EventScript +{ +public: + CmnDefNpcRepair() : EventScript( 0xB0013 ) + {} + + void Scene00000( Entity::Player& player ) + { + player.playScene( getId(), 0, HIDE_HOTBAR, 0, 1 ); + } + + void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override + { + Scene00000( player ); + } +}; \ No newline at end of file diff --git a/src/servers/Scripts/common/ComDefMobHuntBoard.cpp b/src/servers/Scripts/common/ComDefMobHuntBoard.cpp new file mode 100644 index 00000000..1c0281a5 --- /dev/null +++ b/src/servers/Scripts/common/ComDefMobHuntBoard.cpp @@ -0,0 +1,19 @@ +#include +#include + +class ComDefMobHuntBoard : public EventScript +{ +public: + ComDefMobHuntBoard() : EventScript( 0xB00CA ) + {} + + void Scene00000( Entity::Player& player ) + { + player.playScene( getId(), 0, HIDE_HOTBAR, 0, 1 ); + } + + void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override + { + Scene00000( player ); + } +}; \ No newline at end of file diff --git a/src/servers/Scripts/common/HouFurOrchestrion.cpp b/src/servers/Scripts/common/HouFurOrchestrion.cpp index 7ceeea71..514f86a9 100644 --- a/src/servers/Scripts/common/HouFurOrchestrion.cpp +++ b/src/servers/Scripts/common/HouFurOrchestrion.cpp @@ -9,7 +9,7 @@ public: void Scene00000( Entity::Player& player ) { - player.playScene( getId(), 0, 0x2000, 0, 1 ); + player.playScene( getId(), 0, HIDE_HOTBAR, 0, 1 ); } void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override From d68fa6d19256ab46c670b649500074f5b9d98370 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sun, 22 Jul 2018 19:10:52 +1000 Subject: [PATCH 08/13] remove const constraint --- .../sapphire_zone/Network/PacketWrappers/EffectPacket.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/servers/sapphire_zone/Network/PacketWrappers/EffectPacket.h b/src/servers/sapphire_zone/Network/PacketWrappers/EffectPacket.h index 548aa83c..8e45fc23 100644 --- a/src/servers/sapphire_zone/Network/PacketWrappers/EffectPacket.h +++ b/src/servers/sapphire_zone/Network/PacketWrappers/EffectPacket.h @@ -33,17 +33,17 @@ public: std::memcpy( &m_data.effects[m_data.header.effectCount++], &effect, sizeof( Server::EffectEntry ) ); } - void setAnimationId( const uint16_t animationId ) + void setAnimationId( uint16_t animationId ) { m_data.header.actionAnimationId = animationId; } - void setEffectFlags( const uint32_t effectFlags ) + void setEffectFlags( uint32_t effectFlags ) { m_data.effectFlags = effectFlags; } - void setRotation( const uint16_t rotation ) + void setRotation( uint16_t rotation ) { m_data.header.rotation = rotation; } From bf726c2a48cc816cb4a969b050e6f7d1c20497a2 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sun, 22 Jul 2018 22:05:09 +1000 Subject: [PATCH 09/13] consistent indentation --- src/common/Network/PacketDef/Ipcs.h | 317 ++++++++++++++-------------- 1 file changed, 159 insertions(+), 158 deletions(-) diff --git a/src/common/Network/PacketDef/Ipcs.h b/src/common/Network/PacketDef/Ipcs.h index 1acc4dbd..662c2fba 100644 --- a/src/common/Network/PacketDef/Ipcs.h +++ b/src/common/Network/PacketDef/Ipcs.h @@ -14,13 +14,13 @@ namespace Packets { */ enum ServerLobbyIpcType : uint16_t { - LobbyError = 0x0002, - LobbyServiceAccountList = 0x000C, - LobbyCharList = 0x000D, - LobbyCharCreate = 0x000E, - LobbyEnterWorld = 0x000F, - LobbyServerList = 0x0015, - LobbyRetainerList = 0x0017, + LobbyError = 0x0002, + LobbyServiceAccountList = 0x000C, + LobbyCharList = 0x000D, + LobbyCharCreate = 0x000E, + LobbyEnterWorld = 0x000F, + LobbyServerList = 0x0015, + LobbyRetainerList = 0x0017, }; @@ -29,12 +29,12 @@ namespace Packets { */ enum ClientLobbyIpcType : uint16_t { - ReqCharList = 0x0003, - ReqEnterWorld = 0x0004, - ReqServiceAccountList = 0x0005, + ReqCharList = 0x0003, + ReqEnterWorld = 0x0004, + ReqServiceAccountList = 0x0005, - ReqCharDelete = 0x000A, - ReqCharCreate = 0x000B, + ReqCharDelete = 0x000A, + ReqCharCreate = 0x000B, }; //////////////////////////////////////////////////////////////////////////////// @@ -46,149 +46,150 @@ namespace Packets { { // static opcode ( the ones that rarely, if ever, change ) - Ping = 0x0065, - Init = 0x0066, + Ping = 0x0065, + Init = 0x0066, - ActorFreeSpawn = 0x0191, - InitZone = 0x019A, + ActorFreeSpawn = 0x0191, + InitZone = 0x019A, - AddStatusEffect = 0x0141, - ActorControl142 = 0x0142, - ActorControl143 = 0x0143, - ActorControl144 = 0x0144, - UpdateHpMpTp = 0x0145, + AddStatusEffect = 0x0141, + ActorControl142 = 0x0142, + ActorControl143 = 0x0143, + ActorControl144 = 0x0144, + UpdateHpMpTp = 0x0145, /////////////////////////////////////////////////// - ChatBanned = 0x006B, - Logout = 0x0077, // updated 4.3 - CFNotify = 0x0078, - CFMemberStatus = 0x0079, - CFDutyInfo = 0x007A, - CFPlayerInNeed = 0x007F, + ChatBanned = 0x006B, + Logout = 0x0077, // updated 4.3 + CFNotify = 0x0078, + CFMemberStatus = 0x0079, + CFDutyInfo = 0x007A, + CFPlayerInNeed = 0x007F, - SocialRequestError = 0x00AD, + SocialRequestError = 0x00AD, - CFRegistered = 0x00B8, // updated 4.1 - SocialRequestResponse = 0x00BB, // updated 4.1 - CancelAllianceForming = 0x00C6, // updated 4.2 + CFRegistered = 0x00B8, // updated 4.1 + SocialRequestResponse = 0x00BB, // updated 4.1 + CancelAllianceForming = 0x00C6, // updated 4.2 - Playtime = 0x00F5, // updated 4.3 - Chat = 0x00F7, // updated 4.3 - SocialList = 0x00FD, // updated 4.3 + Playtime = 0x00F5, // updated 4.3 + Chat = 0x00F7, // updated 4.3 + SocialList = 0x00FD, // updated 4.3 - UpdateSearchInfo = 0x0100, // updated 4.3 - InitSearchInfo = 0x0101, // updated 4.3 + UpdateSearchInfo = 0x0100, // updated 4.3 + InitSearchInfo = 0x0101, // updated 4.3 - ServerNotice = 0x0106, // updated 4.3 - SetOnlineStatus = 0x0107, // updated 4.3 + ServerNotice = 0x0106, // updated 4.3 + SetOnlineStatus = 0x0107, // updated 4.3 - CountdownInitiate = 0x0111, // updated 4.3 - CountdownCancel = 0x0112, // updated 4.3 + CountdownInitiate = 0x0111, // updated 4.3 + CountdownCancel = 0x0112, // updated 4.3 - BlackList = 0x0115, // updated 4.3 + BlackList = 0x0115, // updated 4.3 - LogMessage = 0x00D0, + LogMessage = 0x00D0, - LinkshellList = 0x011C, // updated 4.3 - CharaFreeCompanyTag = 0x013B, // updated 4.3 - FreeCompanyBoardMsg = 0x013C, // updated 4.3 - FreeCompanyInfo = 0x013D, // updated 4.3 + LinkshellList = 0x011C, // updated 4.3 + CharaFreeCompanyTag = 0x013B, // updated 4.3 + FreeCompanyBoardMsg = 0x013C, // updated 4.3 + FreeCompanyInfo = 0x013D, // updated 4.3 - StatusEffectList = 0x014E, // updated 4.3 - Effect = 0x0151, // updated 4.3 - AoeEffect8 = 0x0154, // updated 4.3 - AoeEffect16 = 0x0155, // updated 4.3 - AoeEffect24 = 0x0156, // updated 4.3 - AoeEffect32 = 0x0157, // updated 4.3 - PersistantEffect = 0x0158, // updated 4.3 + StatusEffectList = 0x014E, // updated 4.3 + Effect = 0x0151, // updated 4.3 + AoeEffect8 = 0x0154, // updated 4.3 + AoeEffect16 = 0x0155, // updated 4.3 + AoeEffect24 = 0x0156, // updated 4.3 + AoeEffect32 = 0x0157, // updated 4.3 + PersistantEffect = 0x0158, // updated 4.3 - GCAffiliation = 0xCCFC, // OUTDATED + GCAffiliation = 0xCCFC, // OUTDATED - PlayerSpawn = 0x0172, // updated 4.3 - NpcSpawn = 0x0173, // updated 4.3 - ActorMove = 0x0174, // updated 4.3 - ActorSetPos = 0x0176, // updated 4.3 + PlayerSpawn = 0x0172, // updated 4.3 + NpcSpawn = 0x0173, // updated 4.3 + ActorMove = 0x0174, // updated 4.3 + ActorSetPos = 0x0176, // updated 4.3 - ActorCast = 0x0178, // updated 4.3 + ActorCast = 0x0178, // updated 4.3 - PartyList = 0x017A, // updated 4.3 - HateList = 0x017B, // updated 4.3 + PartyList = 0x017A, // updated 4.3 + HateList = 0x017B, // updated 4.3 - ObjectSpawn = 0x017D, // updated 4.3 - ObjectDespawn = 0x017E, // updated 4.3 + ObjectSpawn = 0x017D, // updated 4.3 + ObjectDespawn = 0x017E, // updated 4.3 - SetLevelSync = 0x017F, // updated 4.3 - SilentSetClassJob = 0x0180, // updated 4.3 - seems to be the case, not sure if it's actually used for anything + SetLevelSync = 0x017F, // updated 4.3 + SilentSetClassJob = 0x0180, // updated 4.3 - seems to be the case, not sure if it's actually used for anything - InitUI = 0x0181, // updated 4.3 - PlayerStats = 0x0182, // updated 4.3 - ActorOwner = 0x0183, // updated 4.3 ? - PlayerStateFlags = 0x0184, // updated 4.3 - PlayerClassInfo = 0x0185, // updated 4.3 - ModelEquip = 0x0186, // updated 4.3 + InitUI = 0x0181, // updated 4.3 + PlayerStats = 0x0182, // updated 4.3 + ActorOwner = 0x0183, // updated 4.3 ? + PlayerStateFlags = 0x0184, // updated 4.3 + PlayerClassInfo = 0x0185, // updated 4.3 + ModelEquip = 0x0186, // updated 4.3 - UpdateClassInfo = 0x018A, // updated 4.3 + UpdateClassInfo = 0x018A, // updated 4.3 - ItemInfo = 0x0190, // updated 4.3 - ContainerInfo = 0x0192, // updated 4.3 - InventoryTransactionFinish = 0x0193, // updated 4.3 - InventoryTransaction = 0x0194, // updated 4.3 - InventoryActionAck = 0x0197, // updated 4.3 - CurrencyCrystalInfo = 0xFFFF, // updated 4.3 - wrong opcode + ItemInfo = 0x0190, // updated 4.3 + ContainerInfo = 0x0192, // updated 4.3 + InventoryTransactionFinish = 0x0193, // updated 4.3 + InventoryTransaction = 0x0194, // updated 4.3 + InventoryActionAck = 0x0197, // updated 4.3 + CurrencyCrystalInfo = 0xFFFF, // updated 4.3 - wrong opcode - UpdateInventorySlot = 0x0198, // updated 4.3 + UpdateInventorySlot = 0x0198, // updated 4.3 - EventPlay = 0x01A6, // updated 4.3 - DirectorPlayScene = 0x01AA, // updated 4.3 + EventPlay = 0x01A6, // updated 4.3 + EventOpenGilShop = 0x01AD, // updated 4.3 + DirectorPlayScene = 0x01AA, // updated 4.3 - EventStart = 0x01AF, // updated 4.3 - EventFinish = 0x01B0, // updated 4.3 + EventStart = 0x01AF, // updated 4.3 + EventFinish = 0x01B0, // updated 4.3 - EventLinkshell = 0x1169, + EventLinkshell = 0x1169, - QuestActiveList = 0x01C3, // updated 4.3 - QuestUpdate = 0x01C4, // updated 4.3 - QuestCompleteList = 0x01C5, // updated 4.3 + QuestActiveList = 0x01C3, // updated 4.3 + QuestUpdate = 0x01C4, // updated 4.3 + QuestCompleteList = 0x01C5, // updated 4.3 - QuestFinish = 0x01C6, // updated 4.3 - MSQTrackerComplete = 0x01C7, // updated 4.3 - MSQTrackerProgress = 0x01C8, // updated 4.3 + QuestFinish = 0x01C6, // updated 4.3 + MSQTrackerComplete = 0x01C7, // updated 4.3 + MSQTrackerProgress = 0x01C8, // updated 4.3 - QuestMessage = 0x01CE, // updated 4.3 + QuestMessage = 0x01CE, // updated 4.3 - QuestTracker = 0x01D3, // updated 4.3 + QuestTracker = 0x01D3, // updated 4.3 - Mount = 0x01E3, // updated 4.3 + Mount = 0x01E3, // updated 4.3 - DirectorVars = 0x01E5, // updated 4.3 + DirectorVars = 0x01E5, // updated 4.3 - CFAvailableContents = 0x01FD, // updated 4.2 + CFAvailableContents = 0x01FD, // updated 4.2 - WeatherChange = 0x0200, // updated 4.3 - PlayerTitleList = 0x0201, // updated 4.3 - Discovery = 0x0202, // updated 4.3 + WeatherChange = 0x0200, // updated 4.3 + PlayerTitleList = 0x0201, // updated 4.3 + Discovery = 0x0202, // updated 4.3 - EorzeaTimeOffset = 0x0204, // updated 4.3 + EorzeaTimeOffset = 0x0204, // updated 4.3 - EquipDisplayFlags = 0x0210, // updated 4.3 + EquipDisplayFlags = 0x0210, // updated 4.3 - WardInfo = 0x0224, // updated 4.3 - WardHousingPermission = 0x022D, // updated 4.3 - WardYardInfo = 0x022F, // updated 4.3 + WardInfo = 0x0224, // updated 4.3 + WardHousingPermission = 0x022D, // updated 4.3 + WardYardInfo = 0x022F, // updated 4.3 - DuelChallenge = 0x0277, // 4.2; this is responsible for opening the ui - PerformNote = 0x0286, // updated 4.3 + DuelChallenge = 0x0277, // 4.2; this is responsible for opening the ui + PerformNote = 0x0286, // updated 4.3 - PrepareZoning = 0x0291, // updated 4.3 - ActorGauge = 0x0292, // updated 4.3 + PrepareZoning = 0x0291, // updated 4.3 + ActorGauge = 0x0292, // updated 4.3 // Unknown IPC types that still need to be sent // TODO: figure all these out properly - IPCTYPE_UNK_320 = 0x024C, // updated 4.3 - IPCTYPE_UNK_322 = 0x024E, // updated 4.3 + IPCTYPE_UNK_320 = 0x024C, // updated 4.3 + IPCTYPE_UNK_322 = 0x024E, // updated 4.3 }; @@ -198,78 +199,78 @@ namespace Packets { enum ClientZoneIpcType : uint16_t { - PingHandler = 0x0065, // unchanged 4.3 - InitHandler = 0x0066, // unchanged 4.3 + PingHandler = 0x0065, // unchanged 4.3 + InitHandler = 0x0066, // unchanged 4.3 - FinishLoadingHandler = 0x0069, // unchanged 4.3 + FinishLoadingHandler = 0x0069, // unchanged 4.3 - CFCommenceHandler = 0x006F, + CFCommenceHandler = 0x006F, - CFRegisterDuty = 0x0071, - CFRegisterRoulette = 0x0072, - PlayTimeHandler = 0x0073, // unchanged 4.3 - LogoutHandler = 0x0074, // unchanged 4.3 + CFRegisterDuty = 0x0071, + CFRegisterRoulette = 0x0072, + PlayTimeHandler = 0x0073, // unchanged 4.3 + LogoutHandler = 0x0074, // unchanged 4.3 - CFDutyInfoHandler = 0x0078, // updated 4.2 + CFDutyInfoHandler = 0x0078, // updated 4.2 - SocialReqSendHandler = 0x00AE, // updated 4.1 - CreateCrossWorldLS = 0x00AF, // updated 4.3 + SocialReqSendHandler = 0x00AE, // updated 4.1 + CreateCrossWorldLS = 0x00AF, // updated 4.3 - ChatHandler = 0x00D3, // updated 4.3 + ChatHandler = 0x00D3, // updated 4.3 - SocialListHandler = 0x00DB, // updated 4.3 - ReqSearchInfoHandler = 0x00E0, // updated 4.3 - SetSearchInfoHandler = 0x00DE, // updated 4.3 + SocialListHandler = 0x00DB, // updated 4.3 + ReqSearchInfoHandler = 0x00E0, // updated 4.3 + SetSearchInfoHandler = 0x00DE, // updated 4.3 - BlackListHandler = 0x00EC, // updated 4.3 - PlayerSearchHandler = 0x00E2, // updated 4.2 + BlackListHandler = 0x00EC, // updated 4.3 + PlayerSearchHandler = 0x00E2, // updated 4.2 - LinkshellListHandler = 0x00F4, // updated 4.3 + LinkshellListHandler = 0x00F4, // updated 4.3 - SearchMarketboard = 0x0103, // updated 4.3 + SearchMarketboard = 0x0103, // updated 4.3 - FcInfoReqHandler = 0x011A, // updated 4.2 + FcInfoReqHandler = 0x011A, // updated 4.2 - ReqMarketWishList = 0x012C, // updated 4.3 + ReqMarketWishList = 0x012C, // updated 4.3 - ReqJoinNoviceNetwork = 0x0129, // updated 4.2 + ReqJoinNoviceNetwork = 0x0129, // updated 4.2 - ReqCountdownInitiate = 0x0138, // updated 4.3 - ReqCountdownCancel = 0x0139, // updated 4.3 - ClearWaymarks = 0x013A, // updated 4.3 + ReqCountdownInitiate = 0x0138, // updated 4.3 + ReqCountdownCancel = 0x0139, // updated 4.3 + ClearWaymarks = 0x013A, // updated 4.3 - ZoneLineHandler = 0x013C, // updated 4.3 - ClientTrigger = 0x013D, // updated 4.3 - DiscoveryHandler = 0x013E, // updated 4.3 + ZoneLineHandler = 0x013C, // updated 4.3 + ClientTrigger = 0x013D, // updated 4.3 + DiscoveryHandler = 0x013E, // updated 4.3 - AddWaymark = 0x013F, // updated 4.3 + AddWaymark = 0x013F, // updated 4.3 - SkillHandler = 0x0140, // updated 4.3 - GMCommand1 = 0x0141, // updated 4.3 - GMCommand2 = 0x0142, // updated 4.3 + SkillHandler = 0x0140, // updated 4.3 + GMCommand1 = 0x0141, // updated 4.3 + GMCommand2 = 0x0142, // updated 4.3 - UpdatePositionHandler = 0x0144, // updated 4.3 - UpdatePositionInstance = 0x0183, // updated 4.3 + UpdatePositionHandler = 0x0144, // updated 4.3 + UpdatePositionInstance = 0x0183, // updated 4.3 - InventoryModifyHandler = 0x014B, // updated 4.3 + InventoryModifyHandler = 0x014B, // updated 4.3 - TalkEventHandler = 0x0154, // updated 4.3 - EmoteEventHandler = 0x0155, // updated 4.3 - WithinRangeEventHandler = 0x0156, // updated 4.3 - OutOfRangeEventHandler = 0x0157, // updated 4.3 - EnterTeriEventHandler = 0x0158, // updated 4.3 + TalkEventHandler = 0x0154, // updated 4.3 + EmoteEventHandler = 0x0155, // updated 4.3 + WithinRangeEventHandler = 0x0156, // updated 4.3 + OutOfRangeEventHandler = 0x0157, // updated 4.3 + EnterTeriEventHandler = 0x0158, // updated 4.3 - ReturnEventHandler = 0x015D, // updated 4.3 - TradeReturnEventHandler = 0x015E, // updated 4.3 + ReturnEventHandler = 0x015D, // updated 4.3 + TradeReturnEventHandler = 0x015E, // updated 4.3 - LinkshellEventHandler = 0x0150, // updated 4.1 ?? - LinkshellEventHandler1 = 0x0151, // updated 4.1 ?? + LinkshellEventHandler = 0x0150, // updated 4.1 ?? + LinkshellEventHandler1 = 0x0151, // updated 4.1 ?? - PerformNoteHandler = 0x029B, // updated 4.3 + PerformNoteHandler = 0x029B, // updated 4.3 - ReqEquipDisplayFlagsChange = 0x0178, // updated 4.3 + ReqEquipDisplayFlagsChange = 0x0178, // updated 4.3 }; @@ -281,8 +282,8 @@ namespace Packets { */ enum ServerChatIpcType : uint16_t { - Tell = 0x0064, // updated for sb - TellErrNotFound = 0x0066, + Tell = 0x0064, // updated for sb + TellErrNotFound = 0x0066, }; /** @@ -290,7 +291,7 @@ namespace Packets { */ enum ClientChatIpcType : uint16_t { - TellReq = 0x0064, + TellReq = 0x0064, }; From 18a1ab79d6a2831ddc9314d247b7e7ee260e90f0 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sun, 22 Jul 2018 22:11:03 +1000 Subject: [PATCH 10/13] extremely broken gilshop implementation --- .../Network/PacketDef/Zone/ServerZoneDef.h | 11 ++++++++++ src/servers/Scripts/common/GilShop.cpp | 19 ++++++++++++++++++ src/servers/sapphire_zone/Actor/Player.h | 2 ++ .../sapphire_zone/Actor/PlayerEvent.cpp | 20 +++++++++++++++++++ .../sapphire_zone/Script/ScriptMgr.cpp | 4 ++++ 5 files changed, 56 insertions(+) create mode 100644 src/servers/Scripts/common/GilShop.cpp diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index 98eeda5c..6524d7fc 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -1093,6 +1093,17 @@ struct FFXIVIpcEventFinish : FFXIVIpcBasePacket /* 000C */ uint32_t padding1; }; +struct FFXIVIpcEventOpenGilShop : FFXIVIpcBasePacket +{ + uint64_t actorId; + uint32_t eventId; + uint16_t scene; + uint16_t padding; + uint32_t sceneFlags; + + uint32_t unknown_wtf[0x101]; +}; + /** * Structural representation of the packet sent by the server diff --git a/src/servers/Scripts/common/GilShop.cpp b/src/servers/Scripts/common/GilShop.cpp new file mode 100644 index 00000000..c72256fe --- /dev/null +++ b/src/servers/Scripts/common/GilShop.cpp @@ -0,0 +1,19 @@ +#include +#include + +class GilShop : public EventScript +{ +public: + GilShop() : EventScript( 0x00041 ) + {} + + void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override + { + auto callback = [actorId]( Entity::Player& player, const Event::SceneResult& result ) + { + player.playGilShop( actorId, result.eventId, HIDE_HOTBAR | NO_DEFAULT_CAMERA ); + }; + + player.playScene( eventId, 0, HIDE_HOTBAR | NO_DEFAULT_CAMERA, 0, 2, callback ); + } +}; \ No newline at end of file diff --git a/src/servers/sapphire_zone/Actor/Player.h b/src/servers/sapphire_zone/Actor/Player.h index 33dc78f5..276610c2 100644 --- a/src/servers/sapphire_zone/Actor/Player.h +++ b/src/servers/sapphire_zone/Actor/Player.h @@ -58,6 +58,8 @@ public: /*! play a subevent */ void playScene( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam2, uint32_t eventParam3 ); + void playGilShop( uint64_t actorId, uint32_t eventId, uint32_t flags ); + void directorPlayScene( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam3, uint32_t eventParam4, uint32_t eventParam5 = 0 ); /*! play a subevent */ diff --git a/src/servers/sapphire_zone/Actor/PlayerEvent.cpp b/src/servers/sapphire_zone/Actor/PlayerEvent.cpp index 243474e0..1d877b10 100644 --- a/src/servers/sapphire_zone/Actor/PlayerEvent.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerEvent.cpp @@ -133,6 +133,26 @@ void Core::Entity::Player::playScene( uint32_t eventId, uint32_t scene, playScene( eventId, scene, flags, eventParam2, eventParam3, 0, eventCallback ); } +void Core::Entity::Player::playGilShop( uint64_t actorId, uint32_t eventId, uint32_t flags ) +{ + auto pEvent = getEvent( eventId ); + if( !pEvent ) + { + auto pLog = g_fw.get< Logger >(); + pLog->error( "Could not find event " + std::to_string( eventId ) + ", event has not been started!" ); + return; + } + + auto openGilShopPacket = makeZonePacket< Server::FFXIVIpcEventOpenGilShop >( getId() ); + openGilShopPacket->data().eventId = eventId; + openGilShopPacket->data().sceneFlags = flags; + openGilShopPacket->data().actorId = actorId; + + openGilShopPacket->data().scene = 10; + + queuePacket( openGilShopPacket ); +} + Core::Event::EventHandlerPtr Core::Entity::Player::bootstrapSceneEvent( uint32_t eventId, uint32_t flags ) { if( flags & 0x02 ) diff --git a/src/servers/sapphire_zone/Script/ScriptMgr.cpp b/src/servers/sapphire_zone/Script/ScriptMgr.cpp index 78424df8..fe87b6a4 100644 --- a/src/servers/sapphire_zone/Script/ScriptMgr.cpp +++ b/src/servers/sapphire_zone/Script/ScriptMgr.cpp @@ -182,6 +182,10 @@ bool Core::Scripting::ScriptMgr::onTalk( Entity::Player& player, uint64_t actorI if( !aetherInfo->isAetheryte ) scriptId = EVENTSCRIPT_AETHERNET_ID; } + else if( eventType == Event::EventHandler::EventHandlerType::Shop ) + { + scriptId = 0x00041; + } auto script = m_nativeScriptMgr->getScript< EventScript >( scriptId ); if( !script ) From 9ab7d5c68a001c757c8de6a50251112e1dd4ed59 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sun, 22 Jul 2018 23:20:12 +1000 Subject: [PATCH 11/13] somewhat working gilshops --- .../Network/PacketDef/Zone/ClientZoneDef.h | 2 ++ src/servers/Scripts/common/GilShop.cpp | 32 +++++++++++++++---- src/servers/sapphire_zone/Actor/Player.h | 3 +- .../sapphire_zone/Actor/PlayerEvent.cpp | 13 ++++---- .../sapphire_zone/Event/EventHandler.h | 1 + .../Network/Handlers/EventHandlers.cpp | 2 ++ 6 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/common/Network/PacketDef/Zone/ClientZoneDef.h b/src/common/Network/PacketDef/Zone/ClientZoneDef.h index 6963493b..8ebca6f9 100644 --- a/src/common/Network/PacketDef/Zone/ClientZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ClientZoneDef.h @@ -65,6 +65,8 @@ struct FFXIVIpcEventHandlerReturn : FFXIVIpcBasePacket< ReturnEventHandler > /* 0008 */ uint16_t param2; /* 000A */ char pad_000A[2]; /* 000C */ uint16_t param3; + /* 000E */ char pad_000E[2]; + /* 0010 */ uint16_t tradeQuantity; }; struct FFXIVIpcEnterTerritoryHandler : FFXIVIpcBasePacket< EnterTeriEventHandler > diff --git a/src/servers/Scripts/common/GilShop.cpp b/src/servers/Scripts/common/GilShop.cpp index c72256fe..bcf67844 100644 --- a/src/servers/Scripts/common/GilShop.cpp +++ b/src/servers/Scripts/common/GilShop.cpp @@ -7,13 +7,33 @@ public: GilShop() : EventScript( 0x00041 ) {} + constexpr static auto SCENE_FLAGS = HIDE_HOTBAR | NO_DEFAULT_CAMERA; + + static void shopInteractionCallback( Entity::Player& player, const Event::SceneResult& result ) + { + // item purchase + if( result.param1 == 768 ) + { + //player.playGilShop( result.eventId, HIDE_HOTBAR | NO_DEFAULT_CAMERA, shopInteractionCallback ); + + player.sendDebug("got tradeQuantity: " + std::to_string( result.tradeQuantity ) ); + player.playScene( result.eventId, 10, SCENE_FLAGS, 0, 0, shopInteractionCallback ); + return; + } + + // exit + player.playScene( result.eventId, 255, SCENE_FLAGS ); + } + + static void shopCallback( Entity::Player& player, const Event::SceneResult& result ) + { + //player.playGilShop( result.eventId, HIDE_HOTBAR | NO_DEFAULT_CAMERA, shopInteractionCallback ); + + player.playScene( result.eventId, 10, SCENE_FLAGS, 0, 0, shopInteractionCallback ); + } + void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override { - auto callback = [actorId]( Entity::Player& player, const Event::SceneResult& result ) - { - player.playGilShop( actorId, result.eventId, HIDE_HOTBAR | NO_DEFAULT_CAMERA ); - }; - - player.playScene( eventId, 0, HIDE_HOTBAR | NO_DEFAULT_CAMERA, 0, 2, callback ); + player.playScene( eventId, 0, SCENE_FLAGS, 0, 2, shopCallback ); } }; \ No newline at end of file diff --git a/src/servers/sapphire_zone/Actor/Player.h b/src/servers/sapphire_zone/Actor/Player.h index 276610c2..1ea9aec1 100644 --- a/src/servers/sapphire_zone/Actor/Player.h +++ b/src/servers/sapphire_zone/Actor/Player.h @@ -58,7 +58,8 @@ public: /*! play a subevent */ void playScene( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam2, uint32_t eventParam3 ); - void playGilShop( uint64_t actorId, uint32_t eventId, uint32_t flags ); + void playGilShop( uint32_t eventId, uint32_t flags, + Event::EventHandler::SceneReturnCallback eventCallback ); void directorPlayScene( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam3, uint32_t eventParam4, uint32_t eventParam5 = 0 ); diff --git a/src/servers/sapphire_zone/Actor/PlayerEvent.cpp b/src/servers/sapphire_zone/Actor/PlayerEvent.cpp index 1d877b10..d8cbf1f7 100644 --- a/src/servers/sapphire_zone/Actor/PlayerEvent.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerEvent.cpp @@ -133,20 +133,19 @@ void Core::Entity::Player::playScene( uint32_t eventId, uint32_t scene, playScene( eventId, scene, flags, eventParam2, eventParam3, 0, eventCallback ); } -void Core::Entity::Player::playGilShop( uint64_t actorId, uint32_t eventId, uint32_t flags ) +void Core::Entity::Player::playGilShop( uint32_t eventId, uint32_t flags, + Event::EventHandler::SceneReturnCallback eventCallback ) { - auto pEvent = getEvent( eventId ); + auto pEvent = bootstrapSceneEvent( eventId, flags ); if( !pEvent ) - { - auto pLog = g_fw.get< Logger >(); - pLog->error( "Could not find event " + std::to_string( eventId ) + ", event has not been started!" ); return; - } + + pEvent->setEventReturnCallback( eventCallback ); auto openGilShopPacket = makeZonePacket< Server::FFXIVIpcEventOpenGilShop >( getId() ); openGilShopPacket->data().eventId = eventId; openGilShopPacket->data().sceneFlags = flags; - openGilShopPacket->data().actorId = actorId; + openGilShopPacket->data().actorId = getId(); openGilShopPacket->data().scene = 10; diff --git a/src/servers/sapphire_zone/Event/EventHandler.h b/src/servers/sapphire_zone/Event/EventHandler.h index 87a29c8d..c6e94105 100644 --- a/src/servers/sapphire_zone/Event/EventHandler.h +++ b/src/servers/sapphire_zone/Event/EventHandler.h @@ -12,6 +12,7 @@ namespace Core { uint16_t param1; uint16_t param2; uint16_t param3; + uint16_t tradeQuantity; }; class EventHandler diff --git a/src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp b/src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp index 801ab2b7..27a165bd 100644 --- a/src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp @@ -203,6 +203,7 @@ void Core::Network::GameConnection::eventHandlerReturn( const Packets::FFXIVARR_ const auto& param1 = packet.data().param1; const auto& param2 = packet.data().param2; const auto& param3 = packet.data().param3; + const auto& tradeQuantity = packet.data().tradeQuantity; std::string eventName = Event::getEventName( eventId ); @@ -228,6 +229,7 @@ void Core::Network::GameConnection::eventHandlerReturn( const Packets::FFXIVARR_ result.param1 = param1; result.param2 = param2; result.param3 = param3; + result.tradeQuantity = tradeQuantity; eventCallback( player, result ); } // we might have a scene chain callback instead so check for that too From b8871519fef83cbadf984642e408d160441f9247 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sun, 22 Jul 2018 23:32:16 +1000 Subject: [PATCH 12/13] minor refactoring --- src/common/Network/PacketDef/Zone/ClientZoneDef.h | 2 +- src/servers/Scripts/common/GilShop.cpp | 2 +- src/servers/sapphire_zone/Event/EventHandler.h | 2 +- src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/Network/PacketDef/Zone/ClientZoneDef.h b/src/common/Network/PacketDef/Zone/ClientZoneDef.h index 8ebca6f9..3b77195f 100644 --- a/src/common/Network/PacketDef/Zone/ClientZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ClientZoneDef.h @@ -66,7 +66,7 @@ struct FFXIVIpcEventHandlerReturn : FFXIVIpcBasePacket< ReturnEventHandler > /* 000A */ char pad_000A[2]; /* 000C */ uint16_t param3; /* 000E */ char pad_000E[2]; - /* 0010 */ uint16_t tradeQuantity; + /* 0010 */ uint16_t param4; }; struct FFXIVIpcEnterTerritoryHandler : FFXIVIpcBasePacket< EnterTeriEventHandler > diff --git a/src/servers/Scripts/common/GilShop.cpp b/src/servers/Scripts/common/GilShop.cpp index bcf67844..f496074d 100644 --- a/src/servers/Scripts/common/GilShop.cpp +++ b/src/servers/Scripts/common/GilShop.cpp @@ -16,7 +16,7 @@ public: { //player.playGilShop( result.eventId, HIDE_HOTBAR | NO_DEFAULT_CAMERA, shopInteractionCallback ); - player.sendDebug("got tradeQuantity: " + std::to_string( result.tradeQuantity ) ); + player.sendDebug("got tradeQuantity: " + std::to_string( result.param4 ) ); player.playScene( result.eventId, 10, SCENE_FLAGS, 0, 0, shopInteractionCallback ); return; } diff --git a/src/servers/sapphire_zone/Event/EventHandler.h b/src/servers/sapphire_zone/Event/EventHandler.h index c6e94105..8821d6c5 100644 --- a/src/servers/sapphire_zone/Event/EventHandler.h +++ b/src/servers/sapphire_zone/Event/EventHandler.h @@ -12,7 +12,7 @@ namespace Core { uint16_t param1; uint16_t param2; uint16_t param3; - uint16_t tradeQuantity; + uint16_t param4; }; class EventHandler diff --git a/src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp b/src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp index 27a165bd..69d2dd57 100644 --- a/src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/EventHandlers.cpp @@ -203,7 +203,7 @@ void Core::Network::GameConnection::eventHandlerReturn( const Packets::FFXIVARR_ const auto& param1 = packet.data().param1; const auto& param2 = packet.data().param2; const auto& param3 = packet.data().param3; - const auto& tradeQuantity = packet.data().tradeQuantity; + const auto& param4 = packet.data().param4; std::string eventName = Event::getEventName( eventId ); @@ -229,7 +229,7 @@ void Core::Network::GameConnection::eventHandlerReturn( const Packets::FFXIVARR_ result.param1 = param1; result.param2 = param2; result.param3 = param3; - result.tradeQuantity = tradeQuantity; + result.param4 = param4; eventCallback( player, result ); } // we might have a scene chain callback instead so check for that too From 5ac4573bd317a19e05eeb4391a388d3e7eb8d4f9 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Mon, 23 Jul 2018 00:05:44 +1000 Subject: [PATCH 13/13] gilshops now work using the proper packet --- src/servers/Scripts/common/GilShop.cpp | 33 ++++++++++++------- .../sapphire_zone/Actor/PlayerEvent.cpp | 2 ++ .../sapphire_zone/Script/ScriptMgr.cpp | 3 +- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/servers/Scripts/common/GilShop.cpp b/src/servers/Scripts/common/GilShop.cpp index f496074d..8ff007f4 100644 --- a/src/servers/Scripts/common/GilShop.cpp +++ b/src/servers/Scripts/common/GilShop.cpp @@ -4,20 +4,36 @@ class GilShop : public EventScript { public: - GilShop() : EventScript( 0x00041 ) + GilShop() : EventScript( 0x00040001 ) {} constexpr static auto SCENE_FLAGS = HIDE_HOTBAR | NO_DEFAULT_CAMERA; + void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override + { + player.playScene( eventId, 0, SCENE_FLAGS, 0, 2, shopCallback ); + } + +private: static void shopInteractionCallback( Entity::Player& player, const Event::SceneResult& result ) { // item purchase if( result.param1 == 768 ) { - //player.playGilShop( result.eventId, HIDE_HOTBAR | NO_DEFAULT_CAMERA, shopInteractionCallback ); + // buy + if( result.param2 == 1 ) + { - player.sendDebug("got tradeQuantity: " + std::to_string( result.param4 ) ); - player.playScene( result.eventId, 10, SCENE_FLAGS, 0, 0, shopInteractionCallback ); + } + + // sell + else if( result.param2 == 2 ) + { + + } + + player.sendDebug( "got tradeQuantity: " + std::to_string( result.param4 ) ); + player.playGilShop( result.eventId, SCENE_FLAGS, shopInteractionCallback ); return; } @@ -27,13 +43,6 @@ public: static void shopCallback( Entity::Player& player, const Event::SceneResult& result ) { - //player.playGilShop( result.eventId, HIDE_HOTBAR | NO_DEFAULT_CAMERA, shopInteractionCallback ); - - player.playScene( result.eventId, 10, SCENE_FLAGS, 0, 0, shopInteractionCallback ); - } - - void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override - { - player.playScene( eventId, 0, SCENE_FLAGS, 0, 2, shopCallback ); + player.playGilShop( result.eventId, SCENE_FLAGS, shopInteractionCallback ); } }; \ No newline at end of file diff --git a/src/servers/sapphire_zone/Actor/PlayerEvent.cpp b/src/servers/sapphire_zone/Actor/PlayerEvent.cpp index d8cbf1f7..61d7e06c 100644 --- a/src/servers/sapphire_zone/Actor/PlayerEvent.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerEvent.cpp @@ -140,7 +140,9 @@ void Core::Entity::Player::playGilShop( uint32_t eventId, uint32_t flags, if( !pEvent ) return; + pEvent->setPlayedScene( true ); pEvent->setEventReturnCallback( eventCallback ); + pEvent->setSceneChainCallback( nullptr ); auto openGilShopPacket = makeZonePacket< Server::FFXIVIpcEventOpenGilShop >( getId() ); openGilShopPacket->data().eventId = eventId; diff --git a/src/servers/sapphire_zone/Script/ScriptMgr.cpp b/src/servers/sapphire_zone/Script/ScriptMgr.cpp index fe87b6a4..f9ca9890 100644 --- a/src/servers/sapphire_zone/Script/ScriptMgr.cpp +++ b/src/servers/sapphire_zone/Script/ScriptMgr.cpp @@ -174,6 +174,7 @@ bool Core::Scripting::ScriptMgr::onTalk( Entity::Player& player, uint64_t actorI uint16_t eventType = eventId >> 16; uint32_t scriptId = eventId; + // todo: replace this shit with something more flexible allowing for handlers for an entire type without a bunch of if statements // aethernet/aetherytes need to be handled separately if( eventType == Event::EventHandler::EventHandlerType::Aetheryte ) { @@ -184,7 +185,7 @@ bool Core::Scripting::ScriptMgr::onTalk( Entity::Player& player, uint64_t actorI } else if( eventType == Event::EventHandler::EventHandlerType::Shop ) { - scriptId = 0x00041; + scriptId = 0x00040001; } auto script = m_nativeScriptMgr->getScript< EventScript >( scriptId );