fix: replaced magic values for their variables counterparts

This commit is contained in:
Theo Champion 2025-09-18 12:30:41 +02:00
parent 66c3bda4df
commit 82664c5d13

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/17 14:14:30 by kcolin #+# #+# */
/* Updated: 2025/09/17 16:55:39 by tchampio ### ########.fr */
/* Updated: 2025/09/18 12:28:33 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -56,15 +56,15 @@ void handle_shooting(t_cub3d_data *data)
if (data->player.weapon->clip <= 0 && data->player.weapon->remaining_ammos > 0)
{
ft_printf("reloading\n");
if (data->player.weapon->remaining_ammos < 8)
if (data->player.weapon->remaining_ammos < data->player.weapon->base_clip)
{
data->player.weapon->clip = data->player.weapon->remaining_ammos;
data->player.weapon->remaining_ammos = 0;
}
else
{
data->player.weapon->clip = 8;
data->player.weapon->remaining_ammos -= 8;
data->player.weapon->clip = data->player.weapon->base_clip;
data->player.weapon->remaining_ammos -= data->player.weapon->base_clip;
}
}
if (data->player.weapon->clip <= 0)
@ -74,7 +74,7 @@ void handle_shooting(t_cub3d_data *data)
data->player.weapon->clip--;
if (data->player.aimed_zombie)
{
data->player.aimed_zombie->health -= 32;
data->player.aimed_zombie->health -= data->player.weapon->damages;
data->player.points += 10;
ft_printf("Shooting %p, now at %d HP %d/%d\n", data->player.aimed_zombie,
data->player.aimed_zombie->health, data->player.weapon->clip, data->player.weapon->remaining_ammos);