diff options
Diffstat (limited to 'src/ft_find_item.c')
-rw-r--r-- | src/ft_find_item.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/ft_find_item.c b/src/ft_find_item.c index 56e1351..59b4a4f 100644 --- a/src/ft_find_item.c +++ b/src/ft_find_item.c @@ -30,19 +30,44 @@ static uint16_t } static void + ft_set_ammo(uint8_t weap_id, t_player *pl) +{ + if (weap_id == 0) + pl->ammo[0] = FT_WEAP_ONE_STRT_AMMO; + else if (weap_id == 1) + pl->ammo[1] += FT_WEAP_TWO_STRT_AMMO; + else if (weap_id == 2) + pl->ammo[2] += FT_WEAP_THREE_STRT_AMMO; + if (pl->ammo[weap_id] > FT_WEAP_MAX_AMMO) + pl->ammo[weap_id] = FT_WEAP_MAX_AMMO; +} + +static void ft_weapon_check(const char map_char, t_player *pl, t_cub *cl) { uint8_t weap_id; if (ft_ischarset(FT_CHRST_WEAPONS, map_char)) { - weap_id = (map_char == '!') ? (0) : (1); + weap_id = 0; + if (map_char == '@') + weap_id = 1; + else if (map_char == '#') + weap_id = 2; cl->mlist.map[(uint64_t)pl->pos_y][(uint64_t)pl->pos_x] = '0'; cl->weaps[weap_id][0].s_pos_x = 0; cl->weaps[weap_id][0].s_pos_y = 0; pl->has_weapon[weap_id] = 1; - pl->handles_weapon = (weap_id == 1) ? (2) : (weap_id); - cl->sfx[((weap_id == 1) ? (2) : (weap_id)) + 6].sfx_play(cl->sfx); + pl->handles_weapon = (weap_id == 0) ? (0) : (pl->handles_weapon); + pl->handles_weapon = (weap_id == 1) ? (2) : (pl->handles_weapon); + pl->handles_weapon = (weap_id == 2) ? (4) : (pl->handles_weapon); + ft_set_ammo(weap_id, pl); + if (weap_id == 0) + cl->sfx[6].sfx_play(cl->sfx); + else if (weap_id == 1) + cl->sfx[8].sfx_play(cl->sfx); + else if (weap_id == 2) + cl->sfx[10].sfx_play(cl->sfx); } } |