mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 02:43:44 +00:00
fix: exploding assets only explode once
The live script (L_EXPLODING_ASSET.lua) does everything inside "if not bIsHit": smash the attacker if they stand within 10 units, cast the explosion skill, smash itself and progress missions. The server only guarded the attacker smash, so another hit before the asset despawned cast the skill and progressed missions again. The TODO asking to kill everything in a radius is obsolete: live smashes only the attacker directly, and everyone else in range takes the explosion skill's damage, which the server already casts. Removed it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,9 +10,6 @@
|
||||
#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.
|
||||
//And so that all entities in a certain radius are killed, not just the attacker.
|
||||
|
||||
void ExplodingAsset::OnStartup(Entity* self) {
|
||||
self->SetProximityRadius(20.0f, "outRadius");
|
||||
self->SetVar<int32_t>(u"playersNearChest", 0);
|
||||
@@ -46,14 +43,16 @@ void ExplodingAsset::OnHit(Entity* self, Entity* attacker) {
|
||||
const auto* const proximityComponent = self->GetComponent<ProximityMonitorComponent>();
|
||||
if (!proximityComponent) return;
|
||||
|
||||
if (!self->GetBoolean(u"bIsHit")) {
|
||||
for (const auto objID : proximityComponent->GetProximityObjects("crateHitters")) {
|
||||
auto* const entity = Game::entityManager->GetEntity(objID);
|
||||
if (!entity || entity->GetObjectID() != attacker->GetObjectID()) continue;
|
||||
// Like the live script, the asset only explodes once. Only the attacker is smashed directly, and only when
|
||||
// standing close to the asset; everyone else in range is hit by the explosion skill.
|
||||
if (!attacker || self->GetBoolean(u"bIsHit")) return;
|
||||
|
||||
auto* const destroyable = entity->GetComponent<DestroyableComponent>();
|
||||
if (destroyable) destroyable->Smash(attacker->GetObjectID());
|
||||
}
|
||||
for (const auto objID : proximityComponent->GetProximityObjects("crateHitters")) {
|
||||
auto* const entity = Game::entityManager->GetEntity(objID);
|
||||
if (!entity || entity->GetObjectID() != attacker->GetObjectID()) continue;
|
||||
|
||||
auto* const destroyable = entity->GetComponent<DestroyableComponent>();
|
||||
if (destroyable) destroyable->Smash(attacker->GetObjectID());
|
||||
}
|
||||
|
||||
attacker = attacker->GetOwner();
|
||||
|
||||
Reference in New Issue
Block a user