mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 14:37:44 +00:00
Merge pull request #174 from itsMaru/others
Reorganize math classes; Fix crash on spawning actor; Style;
This commit is contained in:
commit
4224f78242
10 changed files with 282 additions and 221 deletions
|
@ -2,12 +2,13 @@
|
|||
#include <src/servers/Server_Common/Util/UtilMath.h>
|
||||
#include <src/servers/Server_Common/Network/PacketContainer.h>
|
||||
#include <src/servers/Server_Common/Exd/ExdData.h>
|
||||
#include <src/servers/Server_Common/Network/GamePacket.h>
|
||||
|
||||
#include "src/servers/Server_Zone/Forwards.h"
|
||||
#include "src/servers/Server_Zone/Action/Action.h"
|
||||
#include "Actor.h"
|
||||
|
||||
#include "src/servers/Server_Zone/Zone/Zone.h"
|
||||
#include <src/servers/Server_Common/Network/GamePacket.h>
|
||||
|
||||
#include "src/servers/Server_Zone/Network/GameConnection.h"
|
||||
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket142.h"
|
||||
#include "src/servers/Server_Zone/Network/PacketWrappers/ActorControlPacket143.h"
|
||||
|
@ -19,7 +20,8 @@
|
|||
#include "src/servers/Server_Zone/Action/ActionCollision.h"
|
||||
#include "src/servers/Server_Zone/ServerZone.h"
|
||||
#include "src/servers/Server_Zone/Session.h"
|
||||
#include "CalcBattle.h"
|
||||
#include "src/servers/Server_Zone/Math/CalcBattle.h"
|
||||
#include "Actor.h"
|
||||
#include "Player.h"
|
||||
|
||||
extern Core::ServerZone g_serverZone;
|
||||
|
@ -738,7 +740,7 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint32_t actionId, u
|
|||
|
||||
case ActionEffectType::Heal:
|
||||
{
|
||||
uint32_t calculatedHeal = Data::CalcBattle::calculateHealValue( getAsPlayer(), static_cast< uint32_t >( param1 ) );
|
||||
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;
|
||||
|
|
|
@ -66,7 +66,7 @@ Core::Entity::BattleNpc::BattleNpc( uint32_t modelId, uint32_t nameid, const Com
|
|||
m_currentStance = Stance::Passive;
|
||||
|
||||
m_class = ClassJob::Gladiator;
|
||||
m_level = level > 0 ? level : 60;
|
||||
m_level = level > 0 ? level : 70;
|
||||
|
||||
m_modelId = modelId;
|
||||
m_nameId = nameid;
|
||||
|
@ -489,6 +489,8 @@ void Core::Entity::BattleNpc::update( int64_t currTime )
|
|||
return;
|
||||
}
|
||||
|
||||
if ( !m_pStatusEffectContainer )
|
||||
initStatusEffectContainer();
|
||||
m_pStatusEffectContainer->update();
|
||||
float distance = Math::Util::distance( m_pos.x, m_pos.y, m_pos.z,
|
||||
m_posOrigin.x, m_posOrigin.y, m_posOrigin.z );
|
||||
|
|
|
@ -41,7 +41,8 @@
|
|||
#include "src/servers/Server_Zone/Action/EventAction.h"
|
||||
#include "src/servers/Server_Zone/Action/EventItemAction.h"
|
||||
#include "src/servers/Server_Zone/Zone/ZonePosition.h"
|
||||
#include "src/servers/Server_Zone/Actor/CalcBattle.h"
|
||||
#include "src/servers/Server_Zone/Math/CalcStats.h"
|
||||
#include "src/servers/Server_Zone/Math/CalcBattle.h"
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
extern Core::Logger g_log;
|
||||
|
@ -226,7 +227,7 @@ void Core::Entity::Player::calculateStats()
|
|||
auto paramGrowthInfo = paramGrowthInfoIt->second;
|
||||
|
||||
// TODO: put formula somewhere else...
|
||||
float base = Data::CalcBattle::calculateBaseStat( getAsPlayer() );
|
||||
float base = Math::CalcStats::calculateBaseStat( getAsPlayer() );
|
||||
|
||||
m_baseStats.str = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_str ) / 100 ) + tribeInfo.mod_str );
|
||||
m_baseStats.dex = static_cast< uint32_t >( base * ( static_cast< float >( classInfo.mod_dex ) / 100 ) + tribeInfo.mod_dex );
|
||||
|
@ -242,9 +243,9 @@ void Core::Entity::Player::calculateStats()
|
|||
m_baseStats.attackPotMagic = paramGrowthInfo.base_secondary;
|
||||
m_baseStats.healingPotMagic = paramGrowthInfo.base_secondary;
|
||||
|
||||
m_baseStats.max_mp = Data::CalcBattle::calculateMaxMp( getAsPlayer() );
|
||||
m_baseStats.max_mp = Math::CalcStats::calculateMaxMp( getAsPlayer() );
|
||||
|
||||
m_baseStats.max_hp = Data::CalcBattle::calculateMaxHp( getAsPlayer() );
|
||||
m_baseStats.max_hp = Math::CalcStats::calculateMaxHp( getAsPlayer() );
|
||||
|
||||
if( m_mp > m_baseStats.max_mp )
|
||||
m_mp = m_baseStats.max_mp;
|
||||
|
|
|
@ -12,6 +12,7 @@ file(GLOB SERVER_PUBLIC_INCLUDE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
|||
Event/*.h
|
||||
Inventory/*.h
|
||||
Linkshell/*.h
|
||||
Math/*.h
|
||||
Network/*.h
|
||||
Network/Handlers/*.h
|
||||
Network/PacketWrappers/*.h
|
||||
|
@ -27,6 +28,7 @@ file(GLOB SERVER_SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
|||
Event/*.c*
|
||||
Inventory/*.c*
|
||||
Linkshell/*.c*
|
||||
Math/*.c*
|
||||
Network/*.c*
|
||||
Network/Handlers/*.c*
|
||||
Network/PacketWrappers/*.c*
|
||||
|
|
45
src/servers/Server_Zone/Math/CalcBattle.cpp
Normal file
45
src/servers/Server_Zone/Math/CalcBattle.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include <cmath>
|
||||
|
||||
#include <Server_Common/Exd/ExdData.h>
|
||||
#include <Server_Common/Common.h>
|
||||
#include <Server_Zone/Actor/Actor.h>
|
||||
#include <Server_Zone/Actor/Player.h>
|
||||
|
||||
#include "CalcBattle.h"
|
||||
|
||||
|
||||
using namespace Core::Math;
|
||||
using namespace Core::Entity;
|
||||
|
||||
extern Core::Data::ExdData g_exdData;
|
||||
|
||||
/*
|
||||
Class used for battle-related formulas and calculations.
|
||||
Big thanks to the Theoryjerks group!
|
||||
|
||||
NOTE:
|
||||
Formulas here shouldn't be considered final. It's possible that the formula it was based on is correct but
|
||||
wasn't implemented correctly here, or approximated things due to limited knowledge of how things work in retail.
|
||||
It's also possible that we're using formulas that were correct for previous patches, but not the current version.
|
||||
|
||||
TODO:
|
||||
|
||||
Damage outgoing calculations. This includes auto-attacks, etc.
|
||||
More formulas in general. Most of it was moved to another class, but work can be done in this area as well already.
|
||||
|
||||
*/
|
||||
|
||||
uint32_t CalcBattle::calculateHealValue( PlayerPtr pPlayer, uint32_t potency )
|
||||
{
|
||||
auto classInfoIt = g_exdData.m_classJobInfoMap.find( static_cast< uint8_t >( pPlayer->getClass() ) );
|
||||
auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() );
|
||||
|
||||
if ( classInfoIt == g_exdData.m_classJobInfoMap.end() ||
|
||||
paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end())
|
||||
return 0;
|
||||
|
||||
auto jobModVal = classInfoIt->second;
|
||||
|
||||
// consider 3% variation
|
||||
return potency / 10;
|
||||
}
|
24
src/servers/Server_Zone/Math/CalcBattle.h
Normal file
24
src/servers/Server_Zone/Math/CalcBattle.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef _CALCBATTLE_H
|
||||
#define _CALCBATTLE_H
|
||||
|
||||
#include <Server_Common/Common.h>
|
||||
#include <Server_Zone/Actor/Actor.h>
|
||||
|
||||
using namespace Core::Entity;
|
||||
|
||||
namespace Core {
|
||||
namespace Math {
|
||||
|
||||
class CalcBattle
|
||||
{
|
||||
public:
|
||||
static uint32_t calculateHealValue( PlayerPtr pPlayer, uint32_t potency );
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,11 +1,14 @@
|
|||
#include <src/servers/Server_Common/Exd/ExdData.h>
|
||||
|
||||
#include "CalcBattle.h"
|
||||
#include "Actor.h"
|
||||
#include "Player.h"
|
||||
#include <cmath>
|
||||
|
||||
using namespace Core::Data;
|
||||
#include <Server_Common/Exd/ExdData.h>
|
||||
#include <Server_Common/Common.h>
|
||||
#include <Server_Zone/Actor/Actor.h>
|
||||
#include <Server_Zone/Actor/Player.h>
|
||||
|
||||
#include "CalcStats.h"
|
||||
|
||||
|
||||
using namespace Core::Math;
|
||||
using namespace Core::Entity;
|
||||
|
||||
extern Core::Data::ExdData g_exdData;
|
||||
|
@ -22,15 +25,14 @@ extern Core::Data::ExdData g_exdData;
|
|||
TODO:
|
||||
|
||||
Base HP val modifier. I can only find values for levels 50~70.
|
||||
Attack power (and healing power). Needs more research on this.
|
||||
Damage outgoing calculations. This includes auto-attacks, etc.
|
||||
|
||||
Dereferencing the actor (Player right now) for stats seem meh, perhaps consider a structure purely for stats?
|
||||
Reduce repeated code (more specifically the data we pull from exd)
|
||||
*/
|
||||
|
||||
// 3 Versions. SB and HW are linear, ARR is polynomial.
|
||||
// Originally from Player.cpp, calculateStats().
|
||||
|
||||
float CalcBattle::calculateBaseStat( PlayerPtr pPlayer )
|
||||
float CalcStats::calculateBaseStat( PlayerPtr pPlayer )
|
||||
{
|
||||
float base = 0.0f;
|
||||
uint8_t level = pPlayer->getLevel();
|
||||
|
@ -53,10 +55,10 @@ float CalcBattle::calculateBaseStat( PlayerPtr pPlayer )
|
|||
// Leggerless' HP Formula
|
||||
// ROUNDDOWN(JobModHP * (BaseHP / 100)) + ROUNDDOWN(VitHPMod / 100 * (VIT - BaseDET))
|
||||
|
||||
uint32_t CalcBattle::calculateMaxHp( PlayerPtr pPlayer )
|
||||
uint32_t CalcStats::calculateMaxHp( PlayerPtr pPlayer )
|
||||
{
|
||||
// TODO: Replace ApproxBaseHP with something that can get us an accurate BaseHP.
|
||||
// Is there any way to pull BaseHP without having to manually use a pet for every level, and using the values from a table?
|
||||
// Is there any way to pull reliable BaseHP without having to manually use a pet for every level, and using the values from a table?
|
||||
// More info here: https://docs.google.com/spreadsheets/d/1de06KGT0cNRUvyiXNmjNgcNvzBCCQku7jte5QxEQRbs/edit?usp=sharing
|
||||
|
||||
auto classInfoIt = g_exdData.m_classJobInfoMap.find( static_cast< uint8_t >( pPlayer->getClass() ) );
|
||||
|
@ -91,7 +93,7 @@ uint32_t CalcBattle::calculateMaxHp( PlayerPtr pPlayer )
|
|||
// Leggerless' MP Formula
|
||||
// ROUNDDOWN(((ROUNDDOWN(((PIE - BaseDET) * PieMPMod/100),0) + BaseMP) * JobModMP / 100),0)
|
||||
|
||||
uint32_t CalcBattle::calculateMaxMp( PlayerPtr pPlayer )
|
||||
uint32_t CalcStats::calculateMaxMp( PlayerPtr pPlayer )
|
||||
{
|
||||
auto classInfoIt = g_exdData.m_classJobInfoMap.find( static_cast< uint8_t >( pPlayer->getClass() ) );
|
||||
auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() );
|
||||
|
@ -109,19 +111,4 @@ uint32_t CalcBattle::calculateMaxMp( PlayerPtr pPlayer )
|
|||
uint16_t result = static_cast< uint16_t >( floor( floor( piety - baseStat ) * ( pietyScalar / 100 ) + baseMp ) * jobModMp / 100 );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t CalcBattle::calculateHealValue( PlayerPtr pPlayer, uint32_t potency )
|
||||
{
|
||||
auto classInfoIt = g_exdData.m_classJobInfoMap.find( static_cast< uint8_t >( pPlayer->getClass() ) );
|
||||
auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() );
|
||||
|
||||
if ( classInfoIt == g_exdData.m_classJobInfoMap.end() ||
|
||||
paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end())
|
||||
return 0;
|
||||
|
||||
auto jobModVal = classInfoIt->second;
|
||||
|
||||
// consider 3% variation
|
||||
return potency / 10;
|
||||
}
|
|
@ -1,23 +1,20 @@
|
|||
#ifndef _CALCBATTLE_H
|
||||
#define _CALCBATTLE_H
|
||||
#ifndef _CALCSTATS_H
|
||||
#define _CALCSTATS_H
|
||||
|
||||
#include <src/servers/Server_Common/Common.h>
|
||||
|
||||
#include "Actor.h"
|
||||
#include <Server_Common/Common.h>
|
||||
#include <Server_Zone/Actor/Actor.h>
|
||||
|
||||
using namespace Core::Entity;
|
||||
|
||||
namespace Core {
|
||||
namespace Data {
|
||||
|
||||
class CalcBattle
|
||||
namespace Math {
|
||||
|
||||
class CalcStats
|
||||
{
|
||||
public:
|
||||
|
||||
static float calculateBaseStat( PlayerPtr pPlayer );
|
||||
static uint32_t calculateMaxMp( PlayerPtr pPlayer );
|
||||
static uint32_t calculateMaxHp( PlayerPtr pPlayer );
|
||||
static uint32_t calculateHealValue( PlayerPtr pPlayer, uint32_t potency );
|
||||
|
||||
private:
|
||||
|
|
@ -86,10 +86,12 @@ enum GmCommand
|
|||
GCRank = 0x0155,
|
||||
Aetheryte = 0x015E,
|
||||
Teri = 0x0258,
|
||||
Kick = 0x025C,
|
||||
TeriInfo = 0x025D,
|
||||
Jump = 0x025E,
|
||||
JumpNpc = 0x025F,
|
||||
};
|
||||
|
||||
void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPacket, Entity::PlayerPtr pPlayer )
|
||||
{
|
||||
if( pPlayer->getGmRank() <= 0 )
|
||||
|
@ -126,35 +128,85 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
|||
|
||||
switch( commandId )
|
||||
{
|
||||
case GmCommand::Kill:
|
||||
case GmCommand::Lv:
|
||||
{
|
||||
targetActor->takeDamage( 9999999 );
|
||||
pPlayer->sendNotice( "Killed " + std::to_string( targetActor->getId() ) );
|
||||
targetPlayer->setLevel( param1 );
|
||||
pPlayer->sendNotice( "Level for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
||||
break;
|
||||
}
|
||||
case GmCommand::QuestSequence:
|
||||
case GmCommand::Race:
|
||||
{
|
||||
targetPlayer->updateQuest( param1, param2 );
|
||||
targetPlayer->setLookAt( CharaLook::Race, param1 );
|
||||
pPlayer->sendNotice( "Race for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
||||
targetPlayer->spawn( targetPlayer );
|
||||
auto inRange = targetPlayer->getInRangeActors();
|
||||
for ( auto actor : inRange )
|
||||
{
|
||||
targetPlayer->despawn( actor->getAsPlayer() );
|
||||
targetPlayer->spawn( actor->getAsPlayer() );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GmCommand::QuestComplete:
|
||||
case GmCommand::Tribe:
|
||||
{
|
||||
targetPlayer->finishQuest( param1 );
|
||||
targetPlayer->setLookAt( CharaLook::Tribe, param1 );
|
||||
pPlayer->sendNotice( "Tribe for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
||||
targetPlayer->spawn( targetPlayer );
|
||||
auto inRange = targetPlayer->getInRangeActors();
|
||||
for ( auto actor : inRange )
|
||||
{
|
||||
targetPlayer->despawn( actor->getAsPlayer() );
|
||||
targetPlayer->spawn( actor->getAsPlayer() );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GmCommand::QuestAccept:
|
||||
case GmCommand::Sex:
|
||||
{
|
||||
targetPlayer->updateQuest( param1, 1 );
|
||||
targetPlayer->setLookAt( CharaLook::Gender, param1 );
|
||||
pPlayer->sendNotice( "Sex for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
||||
targetPlayer->spawn( targetPlayer );
|
||||
auto inRange = targetActor->getInRangeActors();
|
||||
for ( auto actor : inRange )
|
||||
{
|
||||
targetPlayer->despawn( actor->getAsPlayer() );
|
||||
targetPlayer->spawn( actor->getAsPlayer() );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GmCommand::QuestCancel:
|
||||
case GmCommand::Time:
|
||||
{
|
||||
targetPlayer->removeQuest( param1 );
|
||||
pPlayer->setEorzeaTimeOffset( param2 );
|
||||
pPlayer->sendNotice( "Eorzea time offset: " + std::to_string( param2 ) );
|
||||
break;
|
||||
}
|
||||
case GmCommand::QuestIncomplete:
|
||||
case GmCommand::Weather:
|
||||
{
|
||||
targetPlayer->unfinishQuest( param1 );
|
||||
targetPlayer->getCurrentZone()->setWeatherOverride( param1 );
|
||||
pPlayer->sendNotice( "Weather in Zone \"" + targetPlayer->getCurrentZone()->getName() + "\" of " +
|
||||
targetPlayer->getName() + " set in range." );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Call:
|
||||
{
|
||||
if ( targetPlayer->getZoneId() != pPlayer->getZoneId() )
|
||||
targetPlayer->setZone( pPlayer->getZoneId() );
|
||||
|
||||
targetPlayer->changePosition( pPlayer->getPos().x, pPlayer->getPos().y, pPlayer->getPos().z,
|
||||
pPlayer->getRotation() );
|
||||
pPlayer->sendNotice( "Calling " + targetPlayer->getName() );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Inspect:
|
||||
{
|
||||
pPlayer->sendNotice( "Name: " + targetPlayer->getName() +
|
||||
"\nGil: " + std::to_string( targetPlayer->getCurrency( 1 ) ) +
|
||||
"\nZone: " + targetPlayer->getCurrentZone()->getName() +
|
||||
"(" + std::to_string( targetPlayer->getZoneId() ) + ")" +
|
||||
"\nClass: " + std::to_string( static_cast< uint8_t >( targetPlayer->getClass() ) ) +
|
||||
"\nLevel: " + std::to_string( targetPlayer->getLevel() ) +
|
||||
"\nExp: " + std::to_string( targetPlayer->getExp() ) +
|
||||
"\nSearchMessage: " + targetPlayer->getSearchMessage() +
|
||||
"\nPlayTime: " + std::to_string( targetPlayer->getPlayTime() ) );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Speed:
|
||||
|
@ -163,16 +215,30 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
|||
pPlayer->sendNotice( "Speed for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Gil:
|
||||
case GmCommand::Kill:
|
||||
{
|
||||
targetPlayer->addCurrency( 1, param1 );
|
||||
pPlayer->sendNotice( "Added " + std::to_string( param1 ) + " Gil for " + targetPlayer->getName() );
|
||||
targetActor->takeDamage( 9999999 );
|
||||
pPlayer->sendNotice( "Killed " + std::to_string( targetActor->getId() ) );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Lv:
|
||||
case GmCommand::Icon:
|
||||
{
|
||||
targetPlayer->setLevel( param1 );
|
||||
pPlayer->sendNotice( "Level for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
||||
targetPlayer->setOnlineStatusMask( param1 );
|
||||
|
||||
GamePacketNew< FFXIVIpcSetOnlineStatus, ServerZoneIpcType > statusPacket( targetPlayer->getId() );
|
||||
statusPacket.data().onlineStatusFlags = param1;
|
||||
queueOutPacket( statusPacket );
|
||||
|
||||
GamePacketNew< FFXIVIpcSetSearchInfo, ServerZoneIpcType > searchInfoPacket( targetPlayer->getId() );
|
||||
searchInfoPacket.data().onlineStatusFlags = param1;
|
||||
searchInfoPacket.data().selectRegion = targetPlayer->getSearchSelectRegion();
|
||||
strcpy( searchInfoPacket.data().searchMessage, targetPlayer->getSearchMessage() );
|
||||
targetPlayer->queuePacket( searchInfoPacket );
|
||||
|
||||
targetPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), SetStatusIcon,
|
||||
static_cast< uint8_t >( pPlayer->getOnlineStatus() ) ),
|
||||
true );
|
||||
pPlayer->sendNotice( "Icon for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Hp:
|
||||
|
@ -199,43 +265,37 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
|||
pPlayer->sendNotice( std::to_string( param1 ) + " Exp was added to " + targetPlayer->getName() );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Sex:
|
||||
case GmCommand::Inv:
|
||||
{
|
||||
targetPlayer->setLookAt( CharaLook::Gender, param1 );
|
||||
pPlayer->sendNotice( "Sex for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
||||
targetPlayer->spawn( targetPlayer );
|
||||
auto inRange = targetActor->getInRangeActors();
|
||||
for( auto actor : inRange )
|
||||
{
|
||||
targetPlayer->despawn( actor->getAsPlayer() );
|
||||
targetPlayer->spawn( actor->getAsPlayer() );
|
||||
}
|
||||
if ( targetActor->getInvincibilityType() == Common::InvincibilityType::InvincibilityRefill )
|
||||
targetActor->setInvincibilityType( Common::InvincibilityType::InvincibilityNone );
|
||||
else
|
||||
targetActor->setInvincibilityType( Common::InvincibilityType::InvincibilityRefill );
|
||||
|
||||
pPlayer->sendNotice( "Invincibility for " + targetPlayer->getName() +
|
||||
" was switched." );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Race:
|
||||
case GmCommand::Orchestrion:
|
||||
{
|
||||
targetPlayer->setLookAt( CharaLook::Race, param1 );
|
||||
pPlayer->sendNotice( "Race for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
||||
targetPlayer->spawn( targetPlayer );
|
||||
auto inRange = targetPlayer->getInRangeActors();
|
||||
for( auto actor : inRange )
|
||||
if ( param1 == 1 )
|
||||
{
|
||||
targetPlayer->despawn( actor->getAsPlayer() );
|
||||
targetPlayer->spawn( actor->getAsPlayer() );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GmCommand::Tribe:
|
||||
{
|
||||
targetPlayer->setLookAt( CharaLook::Tribe, param1 );
|
||||
pPlayer->sendNotice( "Tribe for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
||||
targetPlayer->spawn( targetPlayer );
|
||||
auto inRange = targetPlayer->getInRangeActors();
|
||||
for( auto actor : inRange )
|
||||
{
|
||||
targetPlayer->despawn( actor->getAsPlayer() );
|
||||
targetPlayer->spawn( actor->getAsPlayer() );
|
||||
if ( param2 == 0 )
|
||||
{
|
||||
for ( uint8_t i = 0; i < 255; i++ )
|
||||
targetActor->getAsPlayer()->learnSong( i, 0 );
|
||||
|
||||
pPlayer->sendNotice( "All Songs for " + targetPlayer->getName() +
|
||||
" were turned on." );
|
||||
}
|
||||
else
|
||||
{
|
||||
targetActor->getAsPlayer()->learnSong( param2, 0 );
|
||||
pPlayer->sendNotice( "Song " + std::to_string( param2 ) + " for " + targetPlayer->getName() +
|
||||
" was turned on." );
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case GmCommand::Item:
|
||||
|
@ -255,61 +315,17 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
|||
pPlayer->sendUrgent( "Item " + std::to_string( param1 ) + " not found..." );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Time:
|
||||
case GmCommand::Gil:
|
||||
{
|
||||
pPlayer->setEorzeaTimeOffset( param2 );
|
||||
pPlayer->sendNotice( "Eorzea time offset: " + std::to_string( param2 ) );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Weather:
|
||||
{
|
||||
targetPlayer->getCurrentZone()->setWeatherOverride( param1 );
|
||||
pPlayer->sendNotice( "Weather in Zone \"" + targetPlayer->getCurrentZone()->getName() + "\" of " +
|
||||
targetPlayer->getName() + " set in range." );
|
||||
break;
|
||||
}
|
||||
case GmCommand::TeriInfo:
|
||||
{
|
||||
pPlayer->sendNotice( "ZoneId: " + std::to_string( pPlayer->getZoneId() ) + "\nName: " +
|
||||
pPlayer->getCurrentZone()->getName() + "\nInternalName: " +
|
||||
pPlayer->getCurrentZone()->getInternalName() + "\nPopCount: " +
|
||||
std::to_string( pPlayer->getCurrentZone()->getPopCount() ) +
|
||||
"\nCurrentWeather:" + std::to_string( pPlayer->getCurrentZone()->getCurrentWeather() ) +
|
||||
"\nNextWeather:" + std::to_string( pPlayer->getCurrentZone()->getNextWeather() ) );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Teri:
|
||||
{
|
||||
auto zoneInfo = g_zoneMgr.getZone( param1 );
|
||||
if ( !zoneInfo )
|
||||
{
|
||||
pPlayer->sendUrgent( "Invalid zone " + std::to_string( param1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPlayer->setPosition( targetPlayer->getPos() );
|
||||
targetPlayer->performZoning( param1, targetPlayer->getPos(), 0 );
|
||||
pPlayer->sendNotice( targetPlayer->getName() + " was warped to zone " + std::to_string( param1 ) + " (" + zoneInfo->getName( ) + ")" );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GmCommand::Jump:
|
||||
{
|
||||
|
||||
auto inRange = pPlayer->getInRangeActors();
|
||||
for( auto actor : inRange )
|
||||
{
|
||||
pPlayer->changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z,
|
||||
targetActor->getRotation() );
|
||||
}
|
||||
pPlayer->sendNotice( "Jumping to " + targetPlayer->getName() + " in range." );
|
||||
targetPlayer->addCurrency( 1, param1 );
|
||||
pPlayer->sendNotice( "Added " + std::to_string( param1 ) + " Gil for " + targetPlayer->getName() );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Collect:
|
||||
{
|
||||
uint32_t gil = targetPlayer->getCurrency( 1 );
|
||||
|
||||
if( gil < param1 )
|
||||
if ( gil < param1 )
|
||||
{
|
||||
pPlayer->sendUrgent( "Player does not have enough Gil(" + std::to_string( gil ) + ")" );
|
||||
}
|
||||
|
@ -322,24 +338,29 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
|||
}
|
||||
break;
|
||||
}
|
||||
case GmCommand::Icon:
|
||||
case GmCommand::QuestAccept:
|
||||
{
|
||||
targetPlayer->setOnlineStatusMask( param1 );
|
||||
|
||||
GamePacketNew< FFXIVIpcSetOnlineStatus, ServerZoneIpcType > statusPacket( targetPlayer->getId() );
|
||||
statusPacket.data().onlineStatusFlags = param1;
|
||||
queueOutPacket( statusPacket );
|
||||
|
||||
GamePacketNew< FFXIVIpcSetSearchInfo, ServerZoneIpcType > searchInfoPacket( targetPlayer->getId() );
|
||||
searchInfoPacket.data().onlineStatusFlags = param1;
|
||||
searchInfoPacket.data().selectRegion = targetPlayer->getSearchSelectRegion();
|
||||
strcpy( searchInfoPacket.data().searchMessage, targetPlayer->getSearchMessage() );
|
||||
targetPlayer->queuePacket( searchInfoPacket );
|
||||
|
||||
targetPlayer->sendToInRangeSet( ActorControlPacket142( pPlayer->getId(), SetStatusIcon,
|
||||
static_cast< uint8_t >( pPlayer->getOnlineStatus() ) ),
|
||||
true );
|
||||
pPlayer->sendNotice( "Icon for " + targetPlayer->getName() + " was set to " + std::to_string( param1 ) );
|
||||
targetPlayer->updateQuest( param1, 1 );
|
||||
break;
|
||||
}
|
||||
case GmCommand::QuestCancel:
|
||||
{
|
||||
targetPlayer->removeQuest( param1 );
|
||||
break;
|
||||
}
|
||||
case GmCommand::QuestComplete:
|
||||
{
|
||||
targetPlayer->finishQuest( param1 );
|
||||
break;
|
||||
}
|
||||
case GmCommand::QuestIncomplete:
|
||||
{
|
||||
targetPlayer->unfinishQuest( param1 );
|
||||
break;
|
||||
}
|
||||
case GmCommand::QuestSequence:
|
||||
{
|
||||
targetPlayer->updateQuest( param1, param2 );
|
||||
break;
|
||||
}
|
||||
case GmCommand::GC:
|
||||
|
@ -357,28 +378,17 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
|||
" was set to " + std::to_string( targetPlayer->getGcRankArray()[targetPlayer->getGc() - 1] ) );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Inv:
|
||||
{
|
||||
if( targetActor->getInvincibilityType() == Common::InvincibilityType::InvincibilityRefill )
|
||||
targetActor->setInvincibilityType( Common::InvincibilityType::InvincibilityNone );
|
||||
else
|
||||
targetActor->setInvincibilityType( Common::InvincibilityType::InvincibilityRefill );
|
||||
|
||||
pPlayer->sendNotice( "Invincibility for " + targetPlayer->getName() +
|
||||
" was switched." );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Aetheryte:
|
||||
{
|
||||
if( param1 == 0 )
|
||||
if ( param1 == 0 )
|
||||
{
|
||||
if( param2 == 0 )
|
||||
if ( param2 == 0 )
|
||||
{
|
||||
for( uint8_t i = 0; i < 255; i++ )
|
||||
for ( uint8_t i = 0; i < 255; i++ )
|
||||
targetActor->getAsPlayer()->registerAetheryte( i );
|
||||
|
||||
|
||||
pPlayer->sendNotice( "All Aetherytes for " + targetPlayer->getName() +
|
||||
" were turned on." );
|
||||
" were turned on." );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -388,33 +398,46 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case GmCommand::Orchestrion:
|
||||
case GmCommand::Teri:
|
||||
{
|
||||
if( param1 == 1 )
|
||||
auto zoneInfo = g_zoneMgr.getZone( param1 );
|
||||
if ( !zoneInfo )
|
||||
{
|
||||
if( param2 == 0 )
|
||||
{
|
||||
for( uint8_t i = 0; i < 255; i++ )
|
||||
targetActor->getAsPlayer()->learnSong( i, 0 );
|
||||
|
||||
pPlayer->sendNotice( "All Songs for " + targetPlayer->getName() +
|
||||
" were turned on." );
|
||||
}
|
||||
else
|
||||
{
|
||||
targetActor->getAsPlayer()->learnSong( param2, 0 );
|
||||
pPlayer->sendNotice( "Song " + std::to_string( param2 ) + " for " + targetPlayer->getName() +
|
||||
" was turned on." );
|
||||
}
|
||||
pPlayer->sendUrgent( "Invalid zone " + std::to_string( param1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPlayer->setPosition( targetPlayer->getPos() );
|
||||
targetPlayer->performZoning( param1, targetPlayer->getPos(), 0 );
|
||||
pPlayer->sendNotice( targetPlayer->getName() + " was warped to zone " + std::to_string( param1 ) + " (" + zoneInfo->getName( ) + ")" );
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case GmCommand::TeriInfo:
|
||||
{
|
||||
pPlayer->sendNotice( "ZoneId: " + std::to_string( pPlayer->getZoneId() ) + "\nName: " +
|
||||
pPlayer->getCurrentZone()->getName() + "\nInternalName: " +
|
||||
pPlayer->getCurrentZone()->getInternalName() + "\nPopCount: " +
|
||||
std::to_string( pPlayer->getCurrentZone()->getPopCount() ) +
|
||||
"\nCurrentWeather:" + std::to_string( pPlayer->getCurrentZone()->getCurrentWeather() ) +
|
||||
"\nNextWeather:" + std::to_string( pPlayer->getCurrentZone()->getNextWeather() ) );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Jump:
|
||||
{
|
||||
|
||||
auto inRange = pPlayer->getInRangeActors();
|
||||
for( auto actor : inRange )
|
||||
{
|
||||
pPlayer->changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z,
|
||||
targetActor->getRotation() );
|
||||
}
|
||||
pPlayer->sendNotice( "Jumping to " + targetPlayer->getName() + " in range." );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
pPlayer->sendUrgent( "GM1 Command not implemented: " + std::to_string( commandId ) );
|
||||
break;
|
||||
|
@ -454,6 +477,7 @@ void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPac
|
|||
|
||||
if( !targetActor )
|
||||
return;
|
||||
|
||||
auto targetPlayer = targetActor->getAsPlayer();
|
||||
|
||||
switch( commandId )
|
||||
|
@ -481,30 +505,6 @@ void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPac
|
|||
pPlayer->sendNotice( "Jumping to " + targetPlayer->getName() );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Call:
|
||||
{
|
||||
if( targetPlayer->getZoneId() != pPlayer->getZoneId() )
|
||||
targetPlayer->setZone( pPlayer->getZoneId() );
|
||||
|
||||
targetPlayer->changePosition( pPlayer->getPos().x, pPlayer->getPos().y, pPlayer->getPos().z,
|
||||
pPlayer->getRotation() );
|
||||
pPlayer->sendNotice( "Calling " + targetPlayer->getName() );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Inspect:
|
||||
{
|
||||
pPlayer->sendNotice( "Name: " + targetPlayer->getName() +
|
||||
"\nGil: " + std::to_string( targetPlayer->getCurrency( 1 ) ) +
|
||||
"\nZone: " + targetPlayer->getCurrentZone()->getName() +
|
||||
"(" + std::to_string( targetPlayer->getZoneId() ) + ")" +
|
||||
"\nClass: " + std::to_string( static_cast< uint8_t >( targetPlayer->getClass() ) ) +
|
||||
"\nLevel: " + std::to_string( targetPlayer->getLevel() ) +
|
||||
"\nExp: " + std::to_string( targetPlayer->getExp() ) +
|
||||
"\nSearchMessage: " + targetPlayer->getSearchMessage() +
|
||||
"\nPlayTime: " + std::to_string( targetPlayer->getPlayTime() ) );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
pPlayer->sendUrgent( "GM2 Command not implemented: " + std::to_string( commandId ) );
|
||||
break;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _UPDATEHPMPTP_H
|
||||
|
||||
#include <src/servers/Server_Common/Network/GamePacketNew.h>
|
||||
#include <src/servers/Server_Zone/Actor/Actor.h>
|
||||
#include "src/servers/Server_Zone/Forwards.h"
|
||||
|
||||
namespace Core {
|
||||
|
|
Loading…
Add table
Reference in a new issue