1
0

clean up rogue_hit

This commit is contained in:
dtb 2023-11-25 11:09:22 -07:00
parent b452c5e230
commit 4604ad4e4a
3 changed files with 25 additions and 35 deletions

View File

@ -114,42 +114,27 @@ mon_hit(object *monster)
} }
void void
rogue_hit(object *monster, boolean force_hit) rogue_hit(object *monster, boolean force_hit){
{
short damage, hit_chance;
if (monster) { if(check_imitator(monster))
if (check_imitator(monster)) { return;
return;
}
hit_chance = force_hit ? 100 : get_hit_chance(rogue.weapon);
if (wizard) { if(!rand_percent((force_hit ? 100 : get_hit_chance(rogue.weapon))
hit_chance *= 2; * (1 + wizard) /* <- hit chance */) && !fight_monster){
} (void)strlcpy(hit_message, "you miss ", sizeof(hit_message));
if (!rand_percent(hit_chance)) { }else{
if (!fight_monster) { if (con_mon)
(void)strlcpy(hit_message, "you miss ",
sizeof(hit_message));
}
goto RET;
}
damage = get_weapon_damage(rogue.weapon);
if (wizard) {
damage *= 3;
}
if (con_mon) {
s_con_mon(monster); s_con_mon(monster);
}
if (mon_damage(monster, damage)) { /* still alive? */ if(mon_damage(monster, get_weapon_damage(rogue.weapon)
if (!fight_monster) { * (1 + 2 * wizard) /* <- damage */)
(void)strlcpy(hit_message, "you hit ", && !fight_monster) /* still alive? */
sizeof(hit_message)); (void)strlcpy(hit_message, "you hit ",
} sizeof(hit_message));
}
RET: check_gold_seeker(monster);
wake_up(monster);
} }
check_gold_seeker(monster);
wake_up(monster);
} }
void void

View File

@ -98,9 +98,13 @@ one_move_rogue(short dirch, short pickup)
} }
} }
if (dungeon[row][col] & MONSTER) { if (dungeon[row][col] & MONSTER) {
rogue_hit(object_at(&level_monsters, row, col), 0); object *monster;
if((monster = object_at(&level_monsters, row, col)) != NULL)
rogue_hit(monster, 0);
(void)reg_move(); (void)reg_move();
return(MOVE_FAILED);
return MOVE_FAILED;
} }
if (dungeon[row][col] & DOOR) { if (dungeon[row][col] & DOOR) {
if (cur_room == PASSAGE) { if (cur_room == PASSAGE) {

View File

@ -178,7 +178,8 @@ zap_monster(object *monster, unsigned short kind)
} }
break; break;
case MAGIC_MISSILE: case MAGIC_MISSILE:
rogue_hit(monster, 1); if(monster != NULL)
rogue_hit(monster, 1);
break; break;
case CANCELLATION: case CANCELLATION:
if (monster->m_flags & HOLDS) { if (monster->m_flags & HOLDS) {