Compare commits

..

5 Commits

Author SHA1 Message Date
David Markowitz
b34236b900 Merge branch 'main' into loot-rework 2025-10-15 20:21:13 -07:00
David Markowitz
bb654752ca fix: coin dupe on team 2025-10-15 20:20:27 -07:00
David Markowitz
8384126783 change default team loot to shared 2025-10-13 21:17:11 -07:00
David Markowitz
409053e7af Allow dupe powerup pickups 2025-10-13 20:26:00 -07:00
David Markowitz
28c6bfcbd7 feat: Loot rework 2025-10-13 19:03:26 -07:00
2 changed files with 24 additions and 49 deletions

View File

@@ -4,9 +4,6 @@
#include "DestroyableComponent.h"
#include "EntityInfo.h"
#include "EntityManager.h"
#include "dConfig.h"
#include "GeneralUtils.h"
void GfBanana::SpawnBanana(Entity* self) {
auto position = self->GetPosition();
@@ -47,36 +44,7 @@ void GfBanana::OnHit(Entity* self, Entity* attacker) {
const auto bananaId = self->GetVar<LWOOBJID>(u"banana");
if (bananaId == LWOOBJID_EMPTY) {
if (GeneralUtils::GenerateRandomNumber<short>(1, 100) == 100 && self->GetVar<LWOOBJID>(u"apeId") == LWOOBJID_EMPTY && Game::config->GetValue("angry_apes") == "1") {
// ape appears if you hurt the trees feeling while it has no banana
// play fx effect
GameMessages::SendPlayEmbeddedEffectOnAllClientsNearObject(self, u"camshake-bridge", self->GetObjectID(), 100.0f);
auto position = self->GetPosition();
auto rotation = QuatUtils::LookAt(self->GetPosition(), position);
EntityInfo info {};
info.pos = position;
info.rot = rotation;
info.lot = m_GorillaLOT;
info.spawner = nullptr;
info.spawnerID = self->GetObjectID();
info.spawnerNodeID = 0;
auto* entity = Game::entityManager->CreateEntity(info);
Game::entityManager->ConstructEntity(entity, UNASSIGNED_SYSTEM_ADDRESS);
self->SetVar<LWOOBJID>(u"apeId", entity->GetObjectID());
self->AddTimer("apeTimer", 10);
}
return;
}
if (bananaId == LWOOBJID_EMPTY) return;
auto* bananaEntity = Game::entityManager->GetEntity(bananaId);
@@ -88,29 +56,39 @@ void GfBanana::OnHit(Entity* self, Entity* attacker) {
return;
}
auto bananaFloor = (bananaEntity->GetPosition() - NiPoint3Constant::UNIT_Y * 8);
bananaEntity->SetPosition(bananaFloor);
bananaEntity->SetPosition(bananaEntity->GetPosition() - NiPoint3Constant::UNIT_Y * 8);
auto* bananaDestroyable = bananaEntity->GetComponent<DestroyableComponent>();
bananaDestroyable->SetHealth(0);
bananaDestroyable->Smash(attacker->GetObjectID());
/*
auto position = self->GetPosition();
const auto rotation = self->GetRotation();
position.y += 12;
position.x -= rotation.GetRightVector().x * 5;
position.z -= rotation.GetRightVector().z * 5;
EntityInfo info {};
info.pos = position;
info.rot = rotation;
info.lot = 6718;
info.spawnerID = self->GetObjectID();
auto* entity = Game::entityManager->CreateEntity(info);
Game::entityManager->ConstructEntity(entity, UNASSIGNED_SYSTEM_ADDRESS);
*/
Game::entityManager->SerializeEntity(self);
}
void GfBanana::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "bananaTimer") {
SpawnBanana(self);
} else if (timerName == "apeTimer") {
if (self->GetVar<LWOOBJID>(u"apeId") == LWOOBJID_EMPTY) return;
auto entity = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"apeId"));
if (entity) {
GameMessages::SendPlayEmbeddedEffectOnAllClientsNearObject(self, u"camshake-bridge", self->GetObjectID(), 100.0f);
entity->GetComponent<DestroyableComponent>()->Smash(self->GetObjectID(), eKillType::SILENT); // to destroy the anchor too
Game::entityManager->DestroyEntity(entity);
}
self->SetVar(u"apeId", LWOOBJID_EMPTY);
}
}

View File

@@ -11,7 +11,4 @@ public:
void OnHit(Entity* self, Entity* attacker) override;
void OnTimerDone(Entity* self, std::string timerName) override;
private:
LOT m_GorillaLOT = 13524;
};