creature: clean up

This commit is contained in:
Marcin Kurczewski 2025-04-08 23:32:23 +02:00
parent 2cd7f04a1e
commit c5977558be
3 changed files with 8 additions and 33 deletions

View file

@ -1,39 +1,27 @@
#include "game/creature.h"
#include "game/box.h"
#include "game/carrier.h"
#include "game/effects.h"
#include "game/items.h"
#include "game/lara/common.h"
#include "game/los.h"
#include "game/lot.h"
#include "game/objects/common.h"
#include "game/objects/vars.h"
#include "game/random.h"
#include "game/room.h"
#include "game/spawn.h"
#include "global/vars.h"
#include <libtrx/game/collision.h>
#include <libtrx/game/math.h>
#include <libtrx/log.h>
bool Creature_ShootAtLara(
ITEM *item, int32_t distance, BITE *gun, int16_t extra_rotation,
int16_t damage)
{
bool hit;
bool is_hit;
if (distance > CREATURE_SHOOT_RANGE) {
hit = false;
is_hit = false;
} else {
hit = Random_GetControl()
is_hit = Random_GetControl()
< ((CREATURE_SHOOT_RANGE - distance)
/ (CREATURE_SHOOT_RANGE / 0x7FFF)
- CREATURE_MISS_CHANCE);
}
int16_t effect_num;
if (hit) {
if (is_hit) {
effect_num = Creature_Effect(item, gun, Spawn_GunShotHit);
} else {
effect_num = Creature_Effect(item, gun, Spawn_GunShotMiss);
@ -43,11 +31,11 @@ bool Creature_ShootAtLara(
Effect_Get(effect_num)->rot.y += extra_rotation;
}
if (hit) {
if (is_hit) {
Lara_TakeDamage(damage, true);
}
return hit;
return is_hit;
}
bool Creature_IsBoss(const int16_t item_num)

View file

@ -1,10 +1,6 @@
#pragma once
#include "global/const.h"
#include "global/types.h"
#include <libtrx/game/creature.h>
#include <libtrx/utils.h>
bool Creature_IsBoss(int16_t item_num);
bool Creature_ShootAtLara(

View file

@ -1,20 +1,10 @@
#include "game/creature.h"
#include "game/box.h"
#include "game/camera.h"
#include "game/effects.h"
#include "game/gun/gun_misc.h"
#include "game/items.h"
#include "game/lara/misc.h"
#include "game/los.h"
#include "game/lot.h"
#include "game/objects/common.h"
#include "game/objects/vars.h"
#include "game/random.h"
#include "game/room.h"
#include "game/spawn.h"
#include "global/const.h"
#include "global/vars.h"
#include <libtrx/game/collision.h>
#include <libtrx/game/lara/common.h>
@ -28,6 +18,7 @@ int32_t Creature_ShootAtLara(
ITEM *const item, const AI_INFO *const info, const BITE *const gun,
const int16_t extra_rotation, const int32_t damage)
{
const ITEM *const lara_item = Lara_GetItem();
const CREATURE *const creature = item->data;
ITEM *const target_item = creature->enemy;
@ -55,7 +46,7 @@ int32_t Creature_ShootAtLara(
}
int16_t effect_num = NO_EFFECT;
if (target_item == g_LaraItem) {
if (target_item == lara_item) {
if (is_hit) {
effect_num = Creature_Effect(item, gun, Spawn_GunHit);
Item_TakeDamage(target_item, damage, true);