mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 06:57:28 +00:00
Add property Teleport behavior (#846)
* Add property Teleport behavior Untested. Will mark pr as ready for review when this has been tested * Fix issues
This commit is contained in:
parent
5374c555f5
commit
a28a2e60cf
@ -48,6 +48,7 @@
|
||||
#include "PlayEffectBehavior.h"
|
||||
#include "DamageAbsorptionBehavior.h"
|
||||
#include "VentureVisionBehavior.h"
|
||||
#include "PropertyTeleportBehavior.h"
|
||||
#include "BlockBehavior.h"
|
||||
#include "ClearTargetBehavior.h"
|
||||
#include "PullToPointBehavior.h"
|
||||
@ -263,7 +264,9 @@ Behavior* Behavior::CreateBehavior(const uint32_t behaviorId) {
|
||||
case BehaviorTemplates::BEHAVIOR_DAMAGE_REDUCTION:
|
||||
behavior = new DamageReductionBehavior(behaviorId);
|
||||
break;
|
||||
case BehaviorTemplates::BEHAVIOR_PROPERTY_TELEPORT: break;
|
||||
case BehaviorTemplates::BEHAVIOR_PROPERTY_TELEPORT:
|
||||
behavior = new PropertyTeleportBehavior(behaviorId);
|
||||
break;
|
||||
case BehaviorTemplates::BEHAVIOR_PROPERTY_CLEAR_TARGET:
|
||||
behavior = new ClearTargetBehavior(behaviorId);
|
||||
break;
|
||||
|
@ -35,6 +35,7 @@ set(DGAME_DBEHAVIORS_SOURCES "AirMovementBehavior.cpp"
|
||||
"OverTimeBehavior.cpp"
|
||||
"PlayEffectBehavior.cpp"
|
||||
"ProjectileAttackBehavior.cpp"
|
||||
"PropertyTeleportBehavior.cpp"
|
||||
"PullToPointBehavior.cpp"
|
||||
"RemoveBuffBehavior.cpp"
|
||||
"RepairBehavior.cpp"
|
||||
|
61
dGame/dBehaviors/PropertyTeleportBehavior.cpp
Normal file
61
dGame/dBehaviors/PropertyTeleportBehavior.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
#include "PropertyTeleportBehavior.h"
|
||||
|
||||
#include "BehaviorBranchContext.h"
|
||||
#include "BehaviorContext.h"
|
||||
#include "Character.h"
|
||||
#include "CharacterComponent.h"
|
||||
#include "ChatPackets.h"
|
||||
#include "WorldPackets.h"
|
||||
#include "EntityManager.h"
|
||||
#include "Game.h"
|
||||
#include "ZoneInstanceManager.h"
|
||||
#include "dZoneManager.h"
|
||||
|
||||
void PropertyTeleportBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
auto* caster = EntityManager::Instance()->GetEntity(context->caster);
|
||||
if (!caster) return;
|
||||
|
||||
auto* character = caster->GetCharacter();
|
||||
if (!character) return;
|
||||
|
||||
LWOOBJID objId = caster->GetObjectID();
|
||||
|
||||
LWOMAPID targetMapId = m_MapId;
|
||||
LWOCLONEID targetCloneId = character->GetPropertyCloneID();
|
||||
|
||||
if (dZoneManager::Instance()->GetZoneID().GetCloneID() == character->GetPropertyCloneID()) {
|
||||
targetMapId = character->GetLastNonInstanceZoneID();
|
||||
targetCloneId = 0;
|
||||
} else {
|
||||
character->SetLastNonInstanceZoneID(dZoneManager::Instance()->GetZoneID().GetMapID());
|
||||
}
|
||||
|
||||
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, targetMapId, targetCloneId, false, [objId](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
|
||||
|
||||
auto* entity = EntityManager::Instance()->GetEntity(objId);
|
||||
if (!entity) return;
|
||||
|
||||
const auto sysAddr = entity->GetSystemAddress();
|
||||
|
||||
if (zoneClone != 0) ChatPackets::SendSystemMessage(sysAddr, u"Transfering to your property!");
|
||||
else ChatPackets::SendSystemMessage(sysAddr, u"Transfering back to previous world!");
|
||||
|
||||
Game::logger->Log("PropertyTeleportBehavior", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", sysAddr.ToString(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort);
|
||||
if (entity->GetCharacter()) {
|
||||
entity->GetCharacter()->SetZoneID(zoneID);
|
||||
entity->GetCharacter()->SetZoneInstance(zoneInstance);
|
||||
entity->GetCharacter()->SetZoneClone(zoneClone);
|
||||
entity->GetComponent<CharacterComponent>()->SetLastRocketConfig(u"");
|
||||
}
|
||||
|
||||
entity->GetCharacter()->SaveXMLToDatabase();
|
||||
|
||||
WorldPackets::SendTransferToWorld(sysAddr, serverIP, serverPort, mythranShift);
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
void PropertyTeleportBehavior::Load() {
|
||||
this->m_CancelIfInteracting = GetBoolean("cancel_if_interacting"); // TODO unused
|
||||
this->m_MapId = LWOMAPID(GetInt("mapID"));
|
||||
}
|
21
dGame/dBehaviors/PropertyTeleportBehavior.h
Normal file
21
dGame/dBehaviors/PropertyTeleportBehavior.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "Behavior.h"
|
||||
|
||||
class PropertyTeleportBehavior final : public Behavior
|
||||
{
|
||||
public:
|
||||
/*
|
||||
* Inherited
|
||||
*/
|
||||
|
||||
explicit PropertyTeleportBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {
|
||||
}
|
||||
|
||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
void Load() override;
|
||||
|
||||
private:
|
||||
LWOMAPID m_MapId;
|
||||
bool m_CancelIfInteracting;
|
||||
};
|
Loading…
Reference in New Issue
Block a user