1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 22:37:45 +00:00

Merge pull request #357 from NotAdam/develop

new effect packet + base gilshop implementation
This commit is contained in:
Mordred 2018-07-22 23:37:09 +02:00 committed by GitHub
commit b64c56faa1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 528 additions and 280 deletions

View file

@ -409,6 +409,7 @@ namespace Common {
TpLoss = 12,
TpGain = 13,
GpGain = 14,
Knockback = 33,
Mount = 38
};
@ -422,6 +423,13 @@ namespace Common {
CritDirectHitDamage = 3
};
enum ActionEffectDisplayType : uint8_t
{
HideActionName = 0,
ShowActionName = 1,
ShowItemName = 2,
};
enum class ActionCollisionType : uint8_t
{
None,

View file

@ -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
@ -136,6 +140,7 @@ namespace Packets {
UpdateInventorySlot = 0x0198, // updated 4.3
EventPlay = 0x01A6, // updated 4.3
EventOpenGilShop = 0x01AD, // updated 4.3
DirectorPlayScene = 0x01AA, // updated 4.3
EventStart = 0x01AF, // updated 4.3
@ -224,8 +229,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

View file

@ -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 param4;
};
struct FFXIVIpcEnterTerritoryHandler : FFXIVIpcBasePacket< EnterTeriEventHandler >

View file

@ -299,47 +299,77 @@ struct FFXIVIpcUpdateHpMpTp : FFXIVIpcBasePacket<UpdateHpMpTp>
* Structural representation of the packet sent by the server
* for battle actions
*/
struct effectEntry
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;
};
struct EffectHeader
{
uint64_t animationTargetId; // who the animation targets
uint32_t actionId; // what the casting player casts, shown in battle log/ui
uint32_t globalEffectCounter; // seems to only increment on retail?
float animationLockTime; // maybe? doesn't seem to do anything
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
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?
Common::ActionEffectDisplayType effectDisplayType;
uint8_t unknown20; // is read by handler, runs code which gets the LODWORD of animationLockTime (wtf?)
uint8_t effectCount; // ignores effects if 0, otherwise parses all of them
uint32_t padding_22[2];
};
struct FFXIVIpcEffect : FFXIVIpcBasePacket<Effect>
{
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;
EffectHeader header;
uint8_t unknown_9;
uint8_t numEffects;
EffectEntry effects[8];
uint16_t unknown_10;
uint32_t unknown_11;
uint16_t unknown_12;
uint16_t padding_6A[3];
effectEntry effects[8];
uint32_t effectTargetId; // who the effect targets
uint32_t effectFlags; // nonzero = effects do nothing, no battle log, no ui text - only shows animations
uint32_t unknown_13;
uint16_t unknown_14;
uint32_t effectTargetId;
uint64_t unknown_15;
uint32_t padding_78;
};
template< int size >
struct FFXIVIpcAoeEffect
{
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;
};
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
@ -1063,6 +1093,17 @@ struct FFXIVIpcEventFinish : FFXIVIpcBasePacket<EventFinish>
/* 000C */ uint32_t padding1;
};
struct FFXIVIpcEventOpenGilShop : FFXIVIpcBasePacket<EventOpenGilShop>
{
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

View file

@ -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 )

View file

@ -0,0 +1,19 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
class CmnDefHousingSignboard : public EventScript
{
public:
CmnDefHousingSignboard() : EventScript( 721031 )
{}
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 );
}
};

View file

@ -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

View file

@ -0,0 +1,19 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
class CmnDefMarketBoardGridania : public EventScript
{
public:
CmnDefMarketBoardGridania() : EventScript( 0xB0027 )
{}
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 );
}
};

View file

@ -0,0 +1,19 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
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 );
}
};

View file

@ -0,0 +1,19 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
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 );
}
};

View file

@ -0,0 +1,48 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
class GilShop : public EventScript
{
public:
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 )
{
// buy
if( result.param2 == 1 )
{
}
// sell
else if( result.param2 == 2 )
{
}
player.sendDebug( "got tradeQuantity: " + std::to_string( result.param4 ) );
player.playGilShop( result.eventId, SCENE_FLAGS, shopInteractionCallback );
return;
}
// exit
player.playScene( result.eventId, 255, SCENE_FLAGS );
}
static void shopCallback( Entity::Player& player, const Event::SceneResult& result )
{
player.playGilShop( result.eventId, SCENE_FLAGS, shopInteractionCallback );
}
};

View file

@ -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

View file

@ -3,6 +3,7 @@
#include <Util/UtilMath.h>
#include <Logging/Logger.h>
#include <Network/CommonActorControl.h>
#include <sapphire_zone/Network/PacketWrappers/EffectPacket.h>
#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< FFXIVIpcEffect >( getId() );
auto effectPacket = boost::make_shared< Server::EffectPacket >( getId(), pPlayer->getId(), 4 );
effectPacket->setRotation( Math::Util::floatToUInt16Rot( pPlayer->getRot() ) );
effectPacket->data().targetId = 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().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 );

View file

@ -2,6 +2,8 @@
#include <Exd/ExdDataGenerated.h>
#include <Logging/Logger.h>
#include <Network/CommonActorControl.h>
#include <sapphire_zone/Network/PacketWrappers/EffectPacket.h>
#include <Util/UtilMath.h>
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
@ -84,20 +86,12 @@ void Core::Action::ActionTeleport::onFinish()
pPlayer->setZoningType( ZoneingType::Teleport );
auto effectPacket = makeZonePacket< FFXIVIpcEffect >( getId() );
effectPacket->data().targetId = pPlayer->getId();
effectPacket->data().actionAnimationId = 5;
//effectPacket.data().unknown_3 = 1;
effectPacket->data().actionTextId = 5;
effectPacket->data().unknown_5 = 1;
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()

View file

@ -7,6 +7,7 @@
#include "Network/PacketWrappers/ActorControlPacket142.h"
#include "Network/PacketWrappers/ActorControlPacket143.h"
#include "Network/PacketWrappers/EffectPacket.h"
#include "Actor/Player.h"
@ -69,15 +70,9 @@ void Core::Action::EventItemAction::onFinish()
try
{
auto effectPacket = makeZonePacket< FFXIVIpcEffect >( m_pSource->getId() );
effectPacket->data().targetId = 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().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 );

View file

@ -4,6 +4,7 @@
#include <Exd/ExdDataGenerated.h>
#include <utility>
#include <Network/CommonActorControl.h>
#include <sapphire_zone/Network/PacketWrappers/EffectPacket.h>
#include "Forwards.h"
#include "Action/Action.h"
@ -399,24 +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< FFXIVIpcEffect >( getId() );
ipcEffect->data().targetId = pTarget->getId();
ipcEffect->data().actionAnimationId = 0x366;
ipcEffect->data().unknown_2 = variation;
// effectPacket->data().unknown_3 = 1;
ipcEffect->data().actionTextId = 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;
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 );
}
@ -443,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< FFXIVIpcEffect >( getId() );
effectPacket->data().targetId = 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().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 )
@ -460,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 )
{
@ -487,8 +478,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().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 );
@ -518,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 )
{
@ -540,8 +533,7 @@ void Core::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionId, u
for( auto pHitActor : actorsCollided )
{
effectPacket->data().targetId = target.getId();
effectPacket->data().effectTargetId = pHitActor->getId();
effectPacket->setTargetActor( pHitActor->getId() );
sendToInRangeSet( effectPacket, true );
pHitActor->getAsChara()->heal( calculatedHeal );

View file

@ -7,6 +7,7 @@
#include <Exd/ExdDataGenerated.h>
#include <Network/PacketContainer.h>
#include <Network/CommonActorControl.h>
#include <Network/PacketWrappers/EffectPacket.h>
#include "Session.h"
#include "Player.h"
@ -1418,43 +1419,32 @@ 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();
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().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() ) );
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< FFXIVIpcEffect >( getId() );
effectPacket->data().targetId = 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().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 );
}
pTarget->takeDamage( damage );

View file

@ -58,6 +58,9 @@ public:
/*! play a subevent */
void playScene( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam2, uint32_t eventParam3 );
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 );
/*! play a subevent */

View file

@ -133,6 +133,27 @@ void Core::Entity::Player::playScene( uint32_t eventId, uint32_t scene,
playScene( eventId, scene, flags, eventParam2, eventParam3, 0, eventCallback );
}
void Core::Entity::Player::playGilShop( uint32_t eventId, uint32_t flags,
Event::EventHandler::SceneReturnCallback eventCallback )
{
auto pEvent = bootstrapSceneEvent( eventId, flags );
if( !pEvent )
return;
pEvent->setPlayedScene( true );
pEvent->setEventReturnCallback( eventCallback );
pEvent->setSceneChainCallback( nullptr );
auto openGilShopPacket = makeZonePacket< Server::FFXIVIpcEventOpenGilShop >( getId() );
openGilShopPacket->data().eventId = eventId;
openGilShopPacket->data().sceneFlags = flags;
openGilShopPacket->data().actorId = getId();
openGilShopPacket->data().scene = 10;
queuePacket( openGilShopPacket );
}
Core::Event::EventHandlerPtr Core::Entity::Player::bootstrapSceneEvent( uint32_t eventId, uint32_t flags )
{
if( flags & 0x02 )

View file

@ -12,6 +12,7 @@ namespace Core {
uint16_t param1;
uint16_t param2;
uint16_t param3;
uint16_t param4;
};
class EventHandler

View file

@ -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& param4 = packet.data().param4;
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.param4 = param4;
eventCallback( player, result );
}
// we might have a scene chain callback instead so check for that too

View file

@ -0,0 +1,65 @@
#ifndef SAPPHIRE_EFFECTPACKET_H
#define SAPPHIRE_EFFECTPACKET_H
#include <Network/GamePacketNew.h>
#include <Network/PacketDef/Zone/ServerZoneDef.h>
#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.header.actionId = actionId;
m_data.header.actionAnimationId = static_cast< uint16_t >( actionId );
m_data.header.animationTargetId = targetId;
m_data.effectTargetId = targetId;
m_data.header.effectDisplayType = Common::ActionEffectDisplayType::ShowActionName;
}
void addEffect( const Server::EffectEntry& effect )
{
assert( m_data.header.effectCount <= 8 );
std::memcpy( &m_data.effects[m_data.header.effectCount++], &effect, sizeof( Server::EffectEntry ) );
}
void setAnimationId( uint16_t animationId )
{
m_data.header.actionAnimationId = animationId;
}
void setEffectFlags( uint32_t effectFlags )
{
m_data.effectFlags = effectFlags;
}
void setRotation( uint16_t rotation )
{
m_data.header.rotation = rotation;
}
void setTargetActor( const uint32_t targetId )
{
m_data.header.animationTargetId = targetId;
m_data.effectTargetId = targetId;
FFXIVPacketBase::setTargetActor( targetId );
}
};
}
}
}
}
#endif //SAPPHIRE_EFFECTPACKET_H

View file

@ -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 )
{
@ -182,6 +183,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 = 0x00040001;
}
auto script = m_nativeScriptMgr->getScript< EventScript >( scriptId );
if( !script )