mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 22:57:45 +00:00
correctly register eobjs on startup/build and handle the interaction
This commit is contained in:
parent
ebbe861e79
commit
0a5b71a320
13 changed files with 104 additions and 8 deletions
|
@ -2909,6 +2909,10 @@ Sapphire::Data::HousingFurniture::HousingFurniture( uint32_t row_id, Sapphire::D
|
|||
Sapphire::Data::HousingMapMarkerInfo::HousingMapMarkerInfo( uint32_t row_id, uint32_t subRow, Sapphire::Data::ExdDataGenerated* exdData )
|
||||
{
|
||||
auto row = exdData->m_HousingMapMarkerInfoDat.get_row( row_id, subRow );
|
||||
x = exdData->getField< float >( row, 0 );
|
||||
y = exdData->getField< float >( row, 1 );
|
||||
z = exdData->getField< float >( row, 2 );
|
||||
plotNumberDistance = exdData->getField< float >( row, 3 );
|
||||
map = exdData->getField< uint16_t >( row, 4 );
|
||||
}
|
||||
|
||||
|
|
|
@ -3048,6 +3048,10 @@ struct HousingFurniture
|
|||
struct HousingMapMarkerInfo
|
||||
{
|
||||
uint16_t map;
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float plotNumberDistance;
|
||||
|
||||
HousingMapMarkerInfo( uint32_t row_id, uint32_t subRow, Sapphire::Data::ExdDataGenerated* exdData );
|
||||
};
|
||||
|
|
|
@ -1794,7 +1794,7 @@ struct FFXIVIpcObjectSpawn :
|
|||
int16_t unknown24b;
|
||||
uint16_t unknown28a;
|
||||
int16_t unknown28c;
|
||||
uint32_t unknown2C;
|
||||
uint32_t housingLink;
|
||||
Common::FFXIVARR_POSITION3 position;
|
||||
int16_t unknown3C;
|
||||
int16_t unknown3E;
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#include <ScriptObject.h>
|
||||
#include <Actor/Player.h>
|
||||
|
||||
#include "Zone/HousingZone.h"
|
||||
#include "Actor/EventObject.h"
|
||||
|
||||
using namespace Sapphire;
|
||||
|
||||
class HousingEstateEntranceWarpTaxi :
|
||||
public Sapphire::ScriptAPI::EventScript
|
||||
{
|
||||
public:
|
||||
HousingEstateEntranceWarpTaxi() :
|
||||
Sapphire::ScriptAPI::EventScript( 0x0002004c )
|
||||
{
|
||||
}
|
||||
|
||||
void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override
|
||||
{
|
||||
auto zone = std::dynamic_pointer_cast< HousingZone >( player.getCurrentZone() );
|
||||
if( !zone )
|
||||
return;
|
||||
|
||||
auto eobj = zone->getEObj( actorId );
|
||||
if( !eobj )
|
||||
return;
|
||||
|
||||
player.sendDebug( "Found plot entrance for plot: " + std::to_string( eobj->getHousingLink() >> 8 ) );
|
||||
|
||||
player.playScene( getId(), 0, 0, []( Entity::Player& player, const Event::SceneResult& result )
|
||||
{
|
||||
if( result.param2 != 1 )
|
||||
return;
|
||||
|
||||
// param2 == 1, zone into instance
|
||||
} );
|
||||
}
|
||||
};
|
|
@ -29,7 +29,8 @@ Sapphire::Entity::EventObject::EventObject( uint32_t actorId, uint32_t objectId,
|
|||
m_gimmickId( gimmickId ),
|
||||
m_state( initialState ),
|
||||
m_objectId( objectId ),
|
||||
m_name( givenName )
|
||||
m_name( givenName ),
|
||||
m_housingLink( 0 )
|
||||
{
|
||||
m_id = actorId;
|
||||
m_pos.x = pos.x;
|
||||
|
@ -96,6 +97,16 @@ void Sapphire::Entity::EventObject::setAnimationFlag( uint32_t flag, uint32_t an
|
|||
}
|
||||
}
|
||||
|
||||
void Sapphire::Entity::EventObject::setHousingLink( uint32_t housingLink )
|
||||
{
|
||||
m_housingLink = housingLink;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::EventObject::getHousingLink() const
|
||||
{
|
||||
return m_housingLink;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::EventObject::setParentInstance( Sapphire::InstanceContentPtr instance )
|
||||
{
|
||||
m_parentInstance = instance;
|
||||
|
@ -125,6 +136,7 @@ void Sapphire::Entity::EventObject::spawn( Sapphire::Entity::PlayerPtr pTarget )
|
|||
eobjStatePacket->data().position = getPos();
|
||||
eobjStatePacket->data().scale = getScale();
|
||||
eobjStatePacket->data().actorId = getId();
|
||||
eobjStatePacket->data().housingLink = getHousingLink();
|
||||
eobjStatePacket->data().rotation = Math::Util::floatToUInt16Rot( getRot() );
|
||||
pTarget->queuePacket( eobjStatePacket );
|
||||
}
|
||||
|
|
|
@ -45,7 +45,12 @@ namespace Sapphire::Entity
|
|||
|
||||
void setAnimationFlag( uint32_t flag, uint32_t animationFlag );
|
||||
|
||||
void setHousingLink( uint32_t housingLink );
|
||||
|
||||
uint32_t getHousingLink() const;
|
||||
|
||||
protected:
|
||||
uint32_t m_housingLink;
|
||||
uint32_t m_gimmickId;
|
||||
uint32_t m_objectId;
|
||||
uint8_t m_state;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <cstring>
|
||||
|
||||
#include "Actor/Player.h"
|
||||
#include "Actor/EventObject.h"
|
||||
|
||||
#include "TerritoryMgr.h"
|
||||
#include "Zone.h"
|
||||
|
@ -321,6 +322,9 @@ void Sapphire::HousingMgr::buildPresetEstate( Entity::Player& player, uint8_t pl
|
|||
|
||||
player.setLandFlags( LandFlagsSlot::Private, EstateBuilt, pLand->getLandId(), pLand->getWardNum(), pLand->getTerritoryTypeId() );
|
||||
player.sendLandFlagsSlot( LandFlagsSlot::Private );
|
||||
|
||||
auto eobj = hZone->registerEObj( "entrance", 2002737, 0, 4, pLand->getMapMarkerPosition(), 1.f, 0.f );
|
||||
eobj->setHousingLink( plotNum << 8 );
|
||||
}
|
||||
|
||||
void Sapphire::HousingMgr::requestEstateRename( Entity::Player& player, uint16_t territoryTypeId, uint16_t worldId, uint8_t wardId, uint8_t plotId )
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "Actor/Player.h"
|
||||
#include "Actor/Actor.h"
|
||||
#include "Actor/EventObject.h"
|
||||
#include "Land.h"
|
||||
#include "House.h"
|
||||
|
||||
|
@ -62,8 +63,14 @@ bool Sapphire::HousingZone::init()
|
|||
uint32_t landId;
|
||||
for( landId = 0; landId < 60; landId++ )
|
||||
{
|
||||
auto pObject = make_Land( m_territoryTypeId, getWardNum(), landId, m_landSetId, info );
|
||||
m_landPtrMap[ landId ] = pObject;
|
||||
auto pLand = make_Land( m_territoryTypeId, getWardNum(), landId, m_landSetId, info );
|
||||
m_landPtrMap[ landId ] = pLand;
|
||||
|
||||
if( auto house = pLand->getHouse() )
|
||||
{
|
||||
auto eobj = registerEObj( "entrance", 2002737, 0, 4, pLand->getMapMarkerPosition(), 1.f, 0.f );
|
||||
eobj->setHousingLink( landId << 8 );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -134,7 +141,6 @@ void Sapphire::HousingZone::sendLandSet( Entity::Player& player )
|
|||
|
||||
landData.plotSize = pLand->getSize();
|
||||
landData.houseState = pLand->getState();
|
||||
landData.flags = 1;
|
||||
landData.iconAddIcon = pLand->getSharing();
|
||||
landData.fcId = pLand->getFcId();
|
||||
landData.fcIcon = pLand->getFcIcon();
|
||||
|
@ -142,6 +148,8 @@ void Sapphire::HousingZone::sendLandSet( Entity::Player& player )
|
|||
|
||||
if( auto house = pLand->getHouse() )
|
||||
{
|
||||
landData.flags = 1;
|
||||
|
||||
auto& parts = house->getHouseParts();
|
||||
|
||||
for( auto i = 0; i != parts.size(); i++ )
|
||||
|
@ -169,7 +177,6 @@ void Sapphire::HousingZone::sendLandUpdate( uint8_t landId )
|
|||
|
||||
landData.plotSize = pLand->getSize();
|
||||
landData.houseState = pLand->getState();
|
||||
landData.flags = 1;
|
||||
landData.iconAddIcon = pLand->getSharing();
|
||||
landData.fcId = pLand->getFcId();
|
||||
landData.fcIcon = pLand->getFcIcon();
|
||||
|
@ -178,6 +185,8 @@ void Sapphire::HousingZone::sendLandUpdate( uint8_t landId )
|
|||
|
||||
if( auto house = pLand->getHouse() )
|
||||
{
|
||||
landData.flags = 1;
|
||||
|
||||
auto& parts = house->getHouseParts();
|
||||
|
||||
for( auto i = 0; i != parts.size(); i++ )
|
||||
|
@ -221,4 +230,4 @@ Sapphire::LandPtr Sapphire::HousingZone::getLand( uint8_t id )
|
|||
return nullptr;
|
||||
|
||||
return it->second;
|
||||
}
|
||||
}
|
|
@ -42,6 +42,8 @@ namespace Sapphire
|
|||
void sendLandUpdate( uint8_t landId );
|
||||
bool isPlayerSubInstance( Entity::Player& player );
|
||||
|
||||
bool onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId );
|
||||
|
||||
/* returns current ward number for this zone */
|
||||
uint8_t getWardNum() const;
|
||||
|
||||
|
|
|
@ -88,6 +88,16 @@ void Sapphire::Land::load()
|
|||
m_pHouse = make_House( houseId, m_landSetId, m_landId, m_wardNum, m_territoryTypeId );
|
||||
|
||||
}
|
||||
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto info = pExdData->get< Sapphire::Data::HousingMapMarkerInfo >( getTerritoryTypeId(), getLandId() );
|
||||
if( info )
|
||||
{
|
||||
m_mapMarkerPosition.x = info->x;
|
||||
m_mapMarkerPosition.y = info->y;
|
||||
m_mapMarkerPosition.z = info->z;
|
||||
}
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
@ -169,6 +179,11 @@ Sapphire::HousePtr Sapphire::Land::getHouse() const
|
|||
return m_pHouse;
|
||||
}
|
||||
|
||||
FFXIVARR_POSITION3 Sapphire::Land::getMapMarkerPosition()
|
||||
{
|
||||
return m_mapMarkerPosition;
|
||||
}
|
||||
|
||||
Sapphire::Common::LandType Sapphire::Land::getLandType() const
|
||||
{
|
||||
return m_type;
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace Sapphire
|
|||
uint16_t getTerritoryTypeId() const;
|
||||
Common::LandType getLandType() const;
|
||||
Sapphire::HousePtr getHouse() const;
|
||||
Common::FFXIVARR_POSITION3 getMapMarkerPosition();
|
||||
|
||||
//Free Comapny
|
||||
void setFreeCompany( uint32_t id, uint32_t icon, uint32_t color );
|
||||
|
@ -78,6 +79,8 @@ namespace Sapphire
|
|||
uint32_t m_fcIcon;
|
||||
uint32_t m_fcIconColor;
|
||||
|
||||
Common::FFXIVARR_POSITION3 m_mapMarkerPosition;
|
||||
|
||||
uint32_t m_ownerPlayerId;
|
||||
Sapphire::Data::HousingLandSetPtr m_landInfo;
|
||||
|
||||
|
|
|
@ -727,7 +727,7 @@ void Sapphire::Zone::registerEObj( Entity::EventObjectPtr object )
|
|||
|
||||
onRegisterEObj( object );
|
||||
|
||||
pLog->debug( "Registered instance eobj: " + std::to_string( object->getId() ) );
|
||||
//pLog->debug( "Registered instance eobj: " + std::to_string( object->getId() ) );
|
||||
}
|
||||
|
||||
Sapphire::Entity::EventObjectPtr Sapphire::Zone::getEObj( uint32_t objId )
|
||||
|
|
Loading…
Add table
Reference in a new issue