mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-09 17:08:06 +00:00
fix: exploding asset bugs (#1890)
This commit is contained in:
@@ -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);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user