2021-12-05 17:54:36 +00:00
|
|
|
#include "AgImagSmashable.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "GeneralUtils.h"
|
|
|
|
#include "GameMessages.h"
|
2023-01-07 05:17:05 +00:00
|
|
|
#include "EntityInfo.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "DestroyableComponent.h"
|
2023-03-04 07:16:37 +00:00
|
|
|
#include "eReplicaComponentType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void AgImagSmashable::OnDie(Entity* self, Entity* killer) {
|
|
|
|
bool maxImagGreaterThanZero = false;
|
|
|
|
|
|
|
|
if (killer) {
|
2023-03-04 07:16:37 +00:00
|
|
|
DestroyableComponent* dest = static_cast<DestroyableComponent*>(killer->GetComponent(eReplicaComponentType::DESTROYABLE));
|
2021-12-05 17:54:36 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|