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

View file

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

View file

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