mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-11 09:58:05 +00:00
Merge branch 'main' into object-debugger-stuff
This commit is contained in:
@@ -5,16 +5,17 @@
|
|||||||
|
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "ScriptComponent.h"
|
#include "ScriptComponent.h"
|
||||||
|
#include "GameMessages.h"
|
||||||
|
#include "Amf3.h"
|
||||||
|
|
||||||
ScriptComponent::ScriptComponent(Entity* parent, const int32_t componentID, std::string scriptName, bool serialized, bool client) : Component(parent, componentID) {
|
ScriptComponent::ScriptComponent(Entity* parent, const int32_t componentID, const std::string& scriptName, bool serialized, bool client) : Component(parent, componentID) {
|
||||||
|
using namespace GameMessages;
|
||||||
m_Serialized = serialized;
|
m_Serialized = serialized;
|
||||||
m_Client = client;
|
m_Client = client;
|
||||||
|
m_ScriptName = scriptName;
|
||||||
|
|
||||||
SetScript(scriptName);
|
SetScript(scriptName);
|
||||||
}
|
RegisterMsg<GetObjectReportInfo>(this, &ScriptComponent::OnGetObjectReportInfo);
|
||||||
|
|
||||||
ScriptComponent::~ScriptComponent() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
|
void ScriptComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
|
||||||
@@ -50,3 +51,16 @@ void ScriptComponent::SetScript(const std::string& scriptName) {
|
|||||||
// and they may also be used by other script components so DON'T delete them.
|
// and they may also be used by other script components so DON'T delete them.
|
||||||
m_Script = CppScripts::GetScript(m_Parent, scriptName);
|
m_Script = CppScripts::GetScript(m_Parent, scriptName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScriptComponent::OnGetObjectReportInfo(GameMessages::GameMsg& msg) {
|
||||||
|
auto& infoMsg = static_cast<GameMessages::GetObjectReportInfo&>(msg);
|
||||||
|
|
||||||
|
auto& scriptInfo = infoMsg.info->PushDebug("Script");
|
||||||
|
scriptInfo.PushDebug<AMFStringValue>("Script Name") = m_ScriptName.empty() ? "None" : m_ScriptName;
|
||||||
|
auto& networkSettings = scriptInfo.PushDebug("Network Settings");
|
||||||
|
for (const auto* const setting : m_Parent->GetNetworkSettings()) {
|
||||||
|
networkSettings.PushDebug<AMFStringValue>(GeneralUtils::UTF16ToWTF8(setting->GetKey())) = setting->GetValueAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@@ -21,8 +21,7 @@ class ScriptComponent final : public Component {
|
|||||||
public:
|
public:
|
||||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SCRIPT;
|
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SCRIPT;
|
||||||
|
|
||||||
ScriptComponent(Entity* parent, const int32_t componentID, std::string scriptName, bool serialized, bool client);
|
ScriptComponent(Entity* parent, const int32_t componentID, const std::string& scriptName, bool serialized, bool client = false);
|
||||||
~ScriptComponent() override;
|
|
||||||
|
|
||||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||||
|
|
||||||
@@ -43,6 +42,8 @@ public:
|
|||||||
* @param scriptName the name of the script to find
|
* @param scriptName the name of the script to find
|
||||||
*/
|
*/
|
||||||
void SetScript(const std::string& scriptName);
|
void SetScript(const std::string& scriptName);
|
||||||
|
|
||||||
|
bool OnGetObjectReportInfo(GameMessages::GameMsg& msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -60,6 +61,8 @@ private:
|
|||||||
* Whether or not this script is a client script
|
* Whether or not this script is a client script
|
||||||
*/
|
*/
|
||||||
bool m_Client;
|
bool m_Client;
|
||||||
|
|
||||||
|
std::string m_ScriptName;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCRIPTCOMPONENT_H
|
#endif // SCRIPTCOMPONENT_H
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
#include "CDClientManager.h"
|
#include "CDClientManager.h"
|
||||||
#include "CDObjectSkillsTable.h"
|
#include "CDObjectSkillsTable.h"
|
||||||
#include "RenderComponent.h"
|
#include "RenderComponent.h"
|
||||||
|
#include "TeamManager.h"
|
||||||
|
#include "ProximityMonitorComponent.h"
|
||||||
|
|
||||||
//TODO: this has to be updated so that you only get killed if you're in a certain radius.
|
//TODO: this has to be updated so that you only get killed if you're in a certain radius.
|
||||||
//And so that all entities in a certain radius are killed, not just the attacker.
|
//And so that all entities in a certain radius are killed, not just the attacker.
|
||||||
@@ -17,22 +19,40 @@ void ExplodingAsset::OnStartup(Entity* self) {
|
|||||||
self->SetProximityRadius(10.0f, "crateHitters");
|
self->SetProximityRadius(10.0f, "crateHitters");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExplodingAsset::ProgressPlayerMissions(Entity& self, Entity& player) {
|
||||||
|
const auto missionID = self.GetVar<int32_t>(u"missionID");
|
||||||
|
auto achievementIDs = self.GetVarAsString(u"achieveID");
|
||||||
|
auto* const missionComponent = player.GetComponent<MissionComponent>();
|
||||||
|
if (missionComponent) {
|
||||||
|
if (missionID != 0) {
|
||||||
|
missionComponent->ForceProgressValue(missionID,
|
||||||
|
static_cast<uint32_t>(eMissionTaskType::SCRIPT),
|
||||||
|
self.GetLOT(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!achievementIDs.empty()) {
|
||||||
|
for (const auto& achievementID : GeneralUtils::SplitString(achievementIDs, u'_')) {
|
||||||
|
const auto achievementIDInt = GeneralUtils::TryParse<int32_t>(achievementID);
|
||||||
|
if (!achievementIDInt) continue;
|
||||||
|
missionComponent->ForceProgressValue(achievementIDInt.value(),
|
||||||
|
static_cast<uint32_t>(eMissionTaskType::SCRIPT),
|
||||||
|
self.GetLOT());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ExplodingAsset::OnHit(Entity* self, Entity* attacker) {
|
void ExplodingAsset::OnHit(Entity* self, Entity* attacker) {
|
||||||
std::vector<Entity*> entities;
|
const auto* const proximityComponent = self->GetComponent<ProximityMonitorComponent>();
|
||||||
entities.push_back(attacker);
|
if (!proximityComponent) return;
|
||||||
|
|
||||||
if (!self->GetBoolean(u"bIsHit")) {
|
if (!self->GetBoolean(u"bIsHit")) {
|
||||||
for (Entity* en : entities) {
|
for (const auto objID : proximityComponent->GetProximityObjects("crateHitters")) {
|
||||||
if (en->GetObjectID() == attacker->GetObjectID()) {
|
auto* const entity = Game::entityManager->GetEntity(objID);
|
||||||
if (Vector3::DistanceSquared(en->GetPosition(), self->GetPosition()) > 10 * 10) continue;
|
if (!entity) continue;
|
||||||
|
|
||||||
auto* destroyable = en->GetComponent<DestroyableComponent>();
|
auto* const destroyable = entity->GetComponent<DestroyableComponent>();
|
||||||
if (destroyable == nullptr) {
|
if (destroyable) destroyable->Smash(attacker->GetObjectID());
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
destroyable->Smash(attacker->GetObjectID());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,26 +68,17 @@ void ExplodingAsset::OnHit(Entity* self, Entity* attacker) {
|
|||||||
// Technically supposed to get first skill in the skill component but only 1 object in the live game used this.
|
// Technically supposed to get first skill in the skill component but only 1 object in the live game used this.
|
||||||
skillComponent->CalculateBehavior(147, 4721, LWOOBJID_EMPTY, true);
|
skillComponent->CalculateBehavior(147, 4721, LWOOBJID_EMPTY, true);
|
||||||
}
|
}
|
||||||
|
const auto* const team = TeamManager::Instance()->GetTeam(attacker->GetObjectID());
|
||||||
const auto missionID = self->GetVar<int32_t>(u"missionID");
|
|
||||||
auto achievementIDs = self->GetVar<std::u16string>(u"achieveID");
|
|
||||||
|
|
||||||
// Progress all scripted missions related to this asset
|
// Progress all scripted missions related to this asset
|
||||||
auto* missionComponent = attacker->GetComponent<MissionComponent>();
|
if (team) {
|
||||||
if (missionComponent != nullptr) {
|
for (const auto& member : team->members) {
|
||||||
if (missionID != 0) {
|
auto* const memberEntity = Game::entityManager->GetEntity(member);
|
||||||
missionComponent->ForceProgressValue(missionID,
|
if (memberEntity) {
|
||||||
static_cast<uint32_t>(eMissionTaskType::SCRIPT),
|
ProgressPlayerMissions(*self, *memberEntity);
|
||||||
self->GetLOT(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!achievementIDs.empty()) {
|
|
||||||
for (const auto& achievementID : GeneralUtils::SplitString(achievementIDs, u'_')) {
|
|
||||||
missionComponent->ForceProgressValue(std::stoi(GeneralUtils::UTF16ToWTF8(achievementID)),
|
|
||||||
static_cast<uint32_t>(eMissionTaskType::SCRIPT),
|
|
||||||
self->GetLOT());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ProgressPlayerMissions(*self, *attacker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,7 +4,8 @@
|
|||||||
class ExplodingAsset : public CppScripts::Script
|
class ExplodingAsset : public CppScripts::Script
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void OnStartup(Entity* self);
|
void OnStartup(Entity* self) override;
|
||||||
void OnHit(Entity* self, Entity* attacker);
|
void OnHit(Entity* self, Entity* attacker) override;
|
||||||
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status);
|
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
|
||||||
|
void ProgressPlayerMissions(Entity& self, Entity& player);
|
||||||
};
|
};
|
||||||
|
@@ -1126,6 +1126,13 @@ void HandlePacket(Packet* packet) {
|
|||||||
// Update the characters xml to ensure the update above is not only saved, but so the client picks up on the changes.
|
// Update the characters xml to ensure the update above is not only saved, but so the client picks up on the changes.
|
||||||
c->SaveXMLToDatabase();
|
c->SaveXMLToDatabase();
|
||||||
|
|
||||||
|
// Fix the destroyable component
|
||||||
|
auto* destroyableComponent = player->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
|
if (destroyableComponent != nullptr) {
|
||||||
|
destroyableComponent->FixStats();
|
||||||
|
}
|
||||||
|
|
||||||
WorldPackets::SendCreateCharacter(packet->systemAddress, characterComponent->GetReputation(), player->GetObjectID(), c->GetXMLData(), username, c->GetGMLevel(), c->GetPropertyCloneID());
|
WorldPackets::SendCreateCharacter(packet->systemAddress, characterComponent->GetReputation(), player->GetObjectID(), c->GetXMLData(), username, c->GetGMLevel(), c->GetPropertyCloneID());
|
||||||
WorldPackets::SendServerState(packet->systemAddress);
|
WorldPackets::SendServerState(packet->systemAddress);
|
||||||
|
|
||||||
@@ -1143,13 +1150,6 @@ void HandlePacket(Packet* packet) {
|
|||||||
|
|
||||||
player->GetCharacter()->SetTargetScene("");
|
player->GetCharacter()->SetTargetScene("");
|
||||||
|
|
||||||
// Fix the destroyable component
|
|
||||||
auto* destroyableComponent = player->GetComponent<DestroyableComponent>();
|
|
||||||
|
|
||||||
if (destroyableComponent != nullptr) {
|
|
||||||
destroyableComponent->FixStats();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Tell the player to generate BBB models, if any:
|
//Tell the player to generate BBB models, if any:
|
||||||
if (g_CloneID != 0) {
|
if (g_CloneID != 0) {
|
||||||
const auto& worldId = Game::zoneManager->GetZone()->GetZoneID();
|
const auto& worldId = Game::zoneManager->GetZone()->GetZoneID();
|
||||||
|
Reference in New Issue
Block a user