mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-09-06 23:31:18 +00:00
Organize dScripts (#814)
* Organize dScripts whitespace Remove parent scope Remove parent scope from initial setter Remove debug Remove helper programs * Fix NtImagimeterVisibility script Co-authored-by: aronwk-aaron <aronwk.aaron@gmail.com>
This commit is contained in:
42
dScripts/ai/AG/AgImagSmashable.cpp
Normal file
42
dScripts/ai/AG/AgImagSmashable.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "AgImagSmashable.h"
|
||||
#include "EntityManager.h"
|
||||
#include "GeneralUtils.h"
|
||||
#include "GameMessages.h"
|
||||
#include "DestroyableComponent.h"
|
||||
|
||||
void AgImagSmashable::OnDie(Entity* self, Entity* killer) {
|
||||
bool maxImagGreaterThanZero = false;
|
||||
|
||||
if (killer) {
|
||||
DestroyableComponent* dest = static_cast<DestroyableComponent*>(killer->GetComponent(COMPONENT_TYPE_DESTROYABLE));
|
||||
if (dest) {
|
||||
maxImagGreaterThanZero = dest->GetMaxImagination() > 0;
|
||||
}
|
||||
|
||||
if (maxImagGreaterThanZero) {
|
||||
int amount = GeneralUtils::GenerateRandomNumber<int>(0, 3);
|
||||
for (int i = 0; i < amount; ++i) {
|
||||
GameMessages::SendDropClientLoot(killer, self->GetObjectID(), 935, 0, self->GetPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CrateAnimal(self);
|
||||
}
|
||||
|
||||
void AgImagSmashable::CrateAnimal(Entity* self) {
|
||||
int funnychance = GeneralUtils::GenerateRandomNumber<int>(0, 26);
|
||||
if (funnychance == 1) {
|
||||
EntityInfo info;
|
||||
info.lot = 8114;
|
||||
info.pos = self->GetPosition();
|
||||
info.spawner = nullptr;
|
||||
info.spawnerID = self->GetSpawnerID();
|
||||
info.spawnerNodeID = 0;
|
||||
|
||||
Entity* newEntity = EntityManager::Instance()->CreateEntity(info, nullptr);
|
||||
if (newEntity) {
|
||||
EntityManager::Instance()->ConstructEntity(newEntity);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user