Lines Matching refs:mon

38 static void _guess_invis_foe_pos(monster* mon)  in _guess_invis_foe_pos()  argument
40 const actor* foe = mon->get_foe(); in _guess_invis_foe_pos()
47 for (radius_iterator ri(mon->pos(), guess_radius, C_SQUARE, LOS_SOLID); ri; ++ri) in _guess_invis_foe_pos()
54 mon->target = possibilities[random2(possibilities.size())]; in _guess_invis_foe_pos()
56 mon->target = dgn_random_point_from(mon->pos(), guess_radius); in _guess_invis_foe_pos()
59 static void _mon_check_foe_invalid(monster* mon) in _mon_check_foe_invalid() argument
63 if (mons_is_avatar(mon->type)) in _mon_check_foe_invalid()
66 if (mon->foe != MHITNOT && mon->foe != MHITYOU) in _mon_check_foe_invalid()
68 if (actor *foe = mon->get_foe()) in _mon_check_foe_invalid()
71 if (foe_mons->alive() && summon_can_attack(mon, foe) in _mon_check_foe_invalid()
72 && (mon->has_ench(ENCH_INSANE) in _mon_check_foe_invalid()
73 || mon->friendly() != foe_mons->friendly() in _mon_check_foe_invalid()
74 || mon->neutral() != foe_mons->neutral())) in _mon_check_foe_invalid()
80 mon->foe = MHITNOT; in _mon_check_foe_invalid()
84 static bool _mon_tries_regain_los(monster* mon) in _mon_tries_regain_los() argument
87 if (mons_intel(*mon) < I_HUMAN || !mons_has_ranged_attack(*mon)) in _mon_tries_regain_los()
91 if (mons_class_flag(mon->type, M_FIGHTER) in _mon_tries_regain_los()
92 && !(mon->type == MONS_CENTAUR_WARRIOR) in _mon_tries_regain_los()
93 && !(mon->type == MONS_YAKTAUR_CAPTAIN)) in _mon_tries_regain_los()
106 static void _set_firing_pos(monster* mon, coord_def target) in _set_firing_pos() argument
109 const int current_distance = mon->pos().distance_from(target); in _set_firing_pos()
118 for (distance_iterator di(mon->pos(), true, true, LOS_RADIUS); in _set_firing_pos()
124 if (!mon->see_cell(*di)) in _set_firing_pos()
129 || !mon_can_move_to_pos(mon, p - mon->pos())) in _set_firing_pos()
134 const int distance = p.distance_from(mon->pos()); in _set_firing_pos()
146 mon->firing_pos = best_pos; in _set_firing_pos()
149 static void _decide_monster_firing_position(monster* mon, actor* owner) in _decide_monster_firing_position() argument
153 if (mon->foe == MHITYOU) in _decide_monster_firing_position()
155 const bool ignore_special_firing_AI = mon->friendly() in _decide_monster_firing_position()
156 || mon->berserk_or_insane(); in _decide_monster_firing_position()
159 if (mons_class_flag(mon->type, M_MAINTAIN_RANGE) in _decide_monster_firing_position()
163 _set_firing_pos(mon, you.pos()); in _decide_monster_firing_position()
165 else if (mon->type == MONS_MERFOLK_AVATAR && !ignore_special_firing_AI) in _decide_monster_firing_position()
166 find_merfolk_avatar_water_target(mon); in _decide_monster_firing_position()
167 else if (!mon->firing_pos.zero() in _decide_monster_firing_position()
168 && mon->see_cell_no_trans(mon->target)) in _decide_monster_firing_position()
172 mon->firing_pos.reset(); in _decide_monster_firing_position()
175 if (!(mon->firing_pos.zero() && try_pathfind(mon))) in _decide_monster_firing_position()
181 mon->target = you.pos(); in _decide_monster_firing_position()
187 monster* target = &env.mons[mon->foe]; in _decide_monster_firing_position()
188 mon->target = target->pos(); in _decide_monster_firing_position()
190 if (mons_class_flag(mon->type, M_MAINTAIN_RANGE) in _decide_monster_firing_position()
191 && !mon->berserk_or_insane() in _decide_monster_firing_position()
192 && !(mons_is_avatar(mon->type) in _decide_monster_firing_position()
193 && owner && mon->foe == owner->mindex())) in _decide_monster_firing_position()
195 _set_firing_pos(mon, mon->target); in _decide_monster_firing_position()
198 else if (mon->type == MONS_SPELLFORGED_SERVITOR in _decide_monster_firing_position()
199 && (mon->pos() - target->pos()).rdist() in _decide_monster_firing_position()
200 <= mon->props["ideal_range"].get_int() in _decide_monster_firing_position()
203 mon->firing_pos = mon->pos(); in _decide_monster_firing_position()
217 static bool _monster_guesses_invis_player(const monster &mon) in _monster_guesses_invis_player() argument
220 if (grid_distance(you.pos(), mon.pos()) == 1 && one_chance_in(3)) in _monster_guesses_invis_player()
225 if (mons_intel(mon) == I_HUMAN && one_chance_in(12)) in _monster_guesses_invis_player()
238 void handle_behaviour(monster* mon) in handle_behaviour() argument
243 if (mon->type == MONS_TEST_SPAWNER) in handle_behaviour()
247 if (mon->attitude != mi->attitude) in handle_behaviour()
249 mon->foe = mi->mindex(); in handle_behaviour()
250 mon->target = mi->pos(); in handle_behaviour()
251 mon->behaviour = BEH_SEEK; in handle_behaviour()
258 bool isFriendly = mon->friendly(); in handle_behaviour()
259 bool isNeutral = mon->neutral(); in handle_behaviour()
260 bool wontAttack = mon->wont_attack() && !mon->has_ench(ENCH_INSANE); in handle_behaviour()
263 bool proxPlayer = !crawl_state.game_is_arena() && mon->see_cell(you.pos()); in handle_behaviour()
266 if (proxPlayer && crawl_state.disables[DIS_MON_SIGHT] && !mon->wont_attack()) in handle_behaviour()
270 bool isHealthy = (mon->hit_points > mon->max_hit_points / 2); in handle_behaviour()
271 bool isSmart = (mons_intel(*mon) >= I_HUMAN); in handle_behaviour()
272 bool isScared = mon->has_ench(ENCH_FEAR); in handle_behaviour()
273 bool isPacified = mon->pacified(); in handle_behaviour()
274 bool patrolling = mon->is_patrolling(); in handle_behaviour()
283 if (mons_class_flag(mon->type, M_CONFUSED)) in handle_behaviour()
285 set_random_target(mon); in handle_behaviour()
289 if (mons_is_fleeing_sanctuary(*mon) in handle_behaviour()
290 && mons_is_fleeing(*mon) in handle_behaviour()
297 ASSERT(!crawl_state.game_is_arena() || mon->foe != MHITYOU); in handle_behaviour()
300 _mon_check_foe_invalid(mon); in handle_behaviour()
302 actor *owner = (mon->summoner ? actor_by_mid(mon->summoner) : nullptr); in handle_behaviour()
303 if (mon->type == MONS_SPECTRAL_WEAPON) in handle_behaviour()
305 if (mon->summoner && (!owner || !owner->alive())) in handle_behaviour()
306 end_spectral_weapon(mon, false); in handle_behaviour()
315 if (proxPlayer && !you.visible_to(mon)) in handle_behaviour()
316 proxPlayer = _monster_guesses_invis_player(*mon); in handle_behaviour()
321 && (mon->foe == MHITNOT || mon->foe == MHITYOU) in handle_behaviour()
322 && !mon->berserk_or_insane() in handle_behaviour()
323 && mon->behaviour != BEH_WITHDRAW in handle_behaviour()
324 && !mons_self_destructs(*mon) in handle_behaviour()
325 && !mons_is_avatar(mon->type)) in handle_behaviour()
328 mon->foe = you.pet_target; in handle_behaviour()
329 else if (mons_class_is_stationary(mon->type)) in handle_behaviour()
330 set_nearest_monster_foe(mon); in handle_behaviour()
334 if (mon->behaviour != BEH_SLEEP in handle_behaviour()
335 && (mon->has_ench(ENCH_INSANE) in handle_behaviour()
336 || ((mon->berserk() || mons_self_destructs(*mon)) in handle_behaviour()
337 && (mon->foe == MHITNOT in handle_behaviour()
338 || isFriendly && mon->foe == MHITYOU)))) in handle_behaviour()
343 && !mon->has_ench(ENCH_INSANE) in handle_behaviour()
345 && mons_intel(*mon) >= I_HUMAN) in handle_behaviour()
347 mon->foe = MHITYOU; in handle_behaviour()
350 set_nearest_monster_foe(mon); in handle_behaviour()
357 if (!isPacified && mon->foe == MHITNOT in handle_behaviour()
358 && mon->behaviour != BEH_SLEEP in handle_behaviour()
361 set_nearest_monster_foe(mon); in handle_behaviour()
365 if (!summon_can_attack(mon)) in handle_behaviour()
366 mon->target = you.pos(); in handle_behaviour()
369 if (mon->foe == mon->mindex()) in handle_behaviour()
370 mon->foe = MHITNOT; in handle_behaviour()
374 if (!mons_is_avatar(mon->type) && mon->foe != MHITNOT && mon->foe != MHITYOU in handle_behaviour()
375 && wontAttack && env.mons[mon->foe].wont_attack()) in handle_behaviour()
377 mon->foe = MHITNOT; in handle_behaviour()
382 && !mon->has_ench(ENCH_INSANE) in handle_behaviour()
383 && mon->foe != MHITNOT in handle_behaviour()
384 && (mon->foe == MHITYOU || env.mons[mon->foe].neutral())) in handle_behaviour()
386 mon->foe = MHITNOT; in handle_behaviour()
392 && !mons_is_avatar(mon->type) in handle_behaviour()
393 && mon->foe != MHITYOU && mon->foe != MHITNOT in handle_behaviour()
394 && proxPlayer && !mon->berserk_or_insane() in handle_behaviour()
398 mon->foe = MHITYOU; in handle_behaviour()
402 _mon_check_foe_invalid(mon); in handle_behaviour()
404 if (mon->has_ench(ENCH_HAUNTING)) in handle_behaviour()
406 actor* targ = mon->get_ench(ENCH_HAUNTING).agent(); in handle_behaviour()
409 mon->foe = targ->mindex(); in handle_behaviour()
410 mon->target = targ->pos(); in handle_behaviour()
416 const actor* afoe = mon->get_foe(); in handle_behaviour()
417 proxFoe = afoe && mon->can_see(*afoe); in handle_behaviour()
419 if (mon->foe == MHITYOU) in handle_behaviour()
432 if (mon->pos() == mon->firing_pos) in handle_behaviour()
433 mon->firing_pos.reset(); in handle_behaviour()
436 beh_type new_beh = mon->behaviour; in handle_behaviour()
437 unsigned short new_foe = mon->foe; in handle_behaviour()
440 switch (mon->behaviour) in handle_behaviour()
444 mon->target = mon->pos(); in handle_behaviour()
450 if (mon->foe == MHITNOT) in handle_behaviour()
454 || isNeutral && !mon->has_ench(ENCH_INSANE) in handle_behaviour()
456 || mons_self_destructs(*mon)) in handle_behaviour()
463 mon->target = you.pos(); in handle_behaviour()
472 if (!mon->see_cell(mon->target)) in handle_behaviour()
473 try_pathfind(mon); in handle_behaviour()
477 && !(mon->friendly() in handle_behaviour()
478 && mon->foe == MHITYOU in handle_behaviour()
479 && mon->is_travelling() in handle_behaviour()
480 && mon->travel_target == MTRAV_FOE)) in handle_behaviour()
484 if (afoe && (mons_foe_is_marked(*mon) in handle_behaviour()
485 || mon->has_ench(ENCH_HAUNTING))) in handle_behaviour()
487 mon->target = afoe->pos(); in handle_behaviour()
488 try_pathfind(mon); in handle_behaviour()
493 if (mon->target.origin() && afoe && mon->near_foe()) in handle_behaviour()
495 _guess_invis_foe_pos(mon); in handle_behaviour()
496 if (mon->target.origin()) in handle_behaviour()
501 set_nearest_monster_foe(mon); in handle_behaviour()
502 if (mon->foe == MHITNOT) in handle_behaviour()
507 mon->target = mon->get_foe()->pos(); in handle_behaviour()
511 if (mon->travel_target == MTRAV_MERFOLK_AVATAR) in handle_behaviour()
512 mon->travel_target = MTRAV_NONE; in handle_behaviour()
516 if (mons_is_avatar(mon->type)) in handle_behaviour()
520 mon->target = owner ? owner->pos() : mon->pos(); in handle_behaviour()
523 else if (isFriendly && mon->foe != MHITYOU) in handle_behaviour()
536 && afoe->visible_to(mon)) in handle_behaviour()
538 try_pathfind(mon); in handle_behaviour()
543 mon->target = foepos; in handle_behaviour()
548 ASSERT(mon->foe != MHITNOT); in handle_behaviour()
549 if (mon->foe_memory > 0) in handle_behaviour()
558 if (mon->pos() == mon->target) in handle_behaviour()
560 if (mon->foe == MHITYOU) in handle_behaviour()
565 mon->target = you.pos(); in handle_behaviour()
568 mon->foe_memory = 0; in handle_behaviour()
573 mon->target = env.mons[mon->foe].pos(); in handle_behaviour()
575 mon->foe_memory = 0; in handle_behaviour()
580 if (mon->foe_memory <= 0 in handle_behaviour()
581 && !(mon->friendly() && mon->foe == MHITYOU)) in handle_behaviour()
589 else if (grid_distance(mon->target, you.pos()) == 1 in handle_behaviour()
590 && _mon_tries_regain_los(mon)) in handle_behaviour()
592 _set_firing_pos(mon, you.pos()); in handle_behaviour()
595 mon->firing_pos.reset(); in handle_behaviour()
599 else if (mons_is_avatar(mon->type) in handle_behaviour()
603 mon->foe = owner->mindex(); in handle_behaviour()
609 ASSERT(mon->foe != MHITNOT); in handle_behaviour()
613 switch (mons_intel(*mon)) in handle_behaviour()
616 mon->foe_memory = random_range(450, 1000); in handle_behaviour()
619 mon->foe_memory = random_range(250, 550); in handle_behaviour()
622 mon->foe_memory = random_range(100, 300); in handle_behaviour()
626 _decide_monster_firing_position(mon, owner); in handle_behaviour()
638 if (mon->travel_target != MTRAV_PATROL) in handle_behaviour()
641 mon->travel_path.clear(); in handle_behaviour()
643 e_index = mons_find_nearest_level_exit(mon, e); in handle_behaviour()
646 e_index = mons_find_nearest_level_exit(mon, e, true); in handle_behaviour()
650 mon->travel_target = MTRAV_PATROL; in handle_behaviour()
652 mon->patrol_point = e[e_index].target; in handle_behaviour()
653 mon->target = e[e_index].target; in handle_behaviour()
657 mon->travel_target = MTRAV_NONE; in handle_behaviour()
659 mon->patrol_point.reset(); in handle_behaviour()
660 set_random_target(mon); in handle_behaviour()
664 if (pacified_leave_level(mon, e, e_index)) in handle_behaviour()
668 if (mon->strict_neutral() && mons_is_slime(*mon) in handle_behaviour()
671 set_random_slime_target(mon); in handle_behaviour()
678 if (proxFoe && !mons_is_batty(*mon) || mons_foe_is_marked(*mon)) in handle_behaviour()
686 if (mon->foe == MHITNOT && you.duration[DUR_SENTINEL_MARK] in handle_behaviour()
687 && (!isFriendly && !mons_is_avatar(mon->type) && !isNeutral in handle_behaviour()
689 || mon->has_ench(ENCH_INSANE))) in handle_behaviour()
696 check_wander_target(mon, isPacified); in handle_behaviour()
703 if (!proxFoe && !mons_is_avatar(mon->type) && mon->foe != MHITNOT in handle_behaviour()
705 && !mons_foe_is_marked(*mon) in handle_behaviour()
709 if (mon->is_travelling() && mon->travel_target != MTRAV_PATROL in handle_behaviour()
715 mon->travel_path.clear(); in handle_behaviour()
716 mon->travel_target = MTRAV_NONE; in handle_behaviour()
728 try_pathfind(mon); in handle_behaviour()
729 if (one_chance_in(10) && !target_is_unreachable(mon) in handle_behaviour()
730 || mons_can_attack(*mon)) in handle_behaviour()
737 mon->target = foepos; in handle_behaviour()
752 if (mon->foe == MHITYOU) in handle_behaviour()
753 mon->target = you.pos(); in handle_behaviour()
759 mon->target = foepos; in handle_behaviour()
766 if (mon->pos() != mon->props["last_pos"].get_coord()) in handle_behaviour()
769 mon->props.erase("last_pos"); in handle_behaviour()
776 && (!isNeutral || mon->has_ench(ENCH_INSANE)) in handle_behaviour()
786 mon->target = foepos; in handle_behaviour()
799 if (grid_distance(mon->target, mon->pos()) <= 1) in handle_behaviour()
802 if (mon->target != mon->patrol_point) in handle_behaviour()
803 mon->target = mon->patrol_point; in handle_behaviour()
809 else if (grid_distance(mon->pos(), you.pos()) > in handle_behaviour()
814 if (!mon->props.exists("idle_point")) in handle_behaviour()
816 mon->props["idle_point"] = mon->pos(); in handle_behaviour()
817 mon->props["idle_deadline"] = you.elapsed_time + 200; in handle_behaviour()
823 mon->target = clamp_in_bounds( in handle_behaviour()
824 mon->props["idle_point"].get_coord() in handle_behaviour()
827 if (you.elapsed_time >= mon->props["idle_deadline"].get_int()) in handle_behaviour()
835 if (mon->props.exists("idle_point") in handle_behaviour()
836 && grid_distance(mon->pos(), you.pos()) < LOS_DEFAULT_RANGE) in handle_behaviour()
838 mon->props.erase("idle_point"); in handle_behaviour()
839 mon->props.erase("idle_deadline"); in handle_behaviour()
840 mon->target = mon->patrol_point; in handle_behaviour()
843 if (mon->pos() == mon->props["last_pos"].get_coord()) in handle_behaviour()
845 if (!mon->props.exists("blocked_deadline")) in handle_behaviour()
846 mon->props["blocked_deadline"] = you.elapsed_time + 30; in handle_behaviour()
848 if (!mon->props.exists("idle_deadline")) in handle_behaviour()
849 mon->props["idle_deadline"] = you.elapsed_time + 200; in handle_behaviour()
851 if (you.elapsed_time >= mon->props["blocked_deadline"].get_int() in handle_behaviour()
852 || you.elapsed_time >= mon->props["idle_deadline"].get_int()) in handle_behaviour()
859 mon->props.erase("blocked_deadline"); in handle_behaviour()
860 mon->props.erase("idle_deadline"); in handle_behaviour()
868 mon->props.erase("last_pos"); in handle_behaviour()
869 mon->props.erase("idle_point"); in handle_behaviour()
870 mon->props.erase("blocked_deadline"); in handle_behaviour()
871 mon->props.erase("idle_deadline"); in handle_behaviour()
874 mon->props["last_pos"] = mon->pos(); in handle_behaviour()
883 changed = (new_beh != mon->behaviour || new_foe != mon->foe); in handle_behaviour()
884 mon->behaviour = new_beh; in handle_behaviour()
886 if (mon->foe != new_foe) in handle_behaviour()
887 mon->foe_memory = 0; in handle_behaviour()
889 mon->foe = new_foe; in handle_behaviour()
893 static bool _mons_check_foe(monster* mon, const coord_def& p, in _mons_check_foe() argument
902 return foe && foe != mon in _mons_check_foe()
903 && (ignore_sight || mon->can_see(*foe)) in _mons_check_foe()
906 || mon->has_ench(ENCH_INSANE)) in _mons_check_foe()
908 && summon_can_attack(mon, p) in _mons_check_foe()
911 || p == you.pos() && mon->has_ench(ENCH_INSANE); in _mons_check_foe()
915 void set_nearest_monster_foe(monster* mon, bool near_player) in set_nearest_monster_foe() argument
918 if (mon->good_neutral() || mon->strict_neutral() in set_nearest_monster_foe()
919 || mon->behaviour == BEH_WITHDRAW in set_nearest_monster_foe()
920 || mons_is_avatar(mon->type) in set_nearest_monster_foe()
921 || mon->has_ench(ENCH_HAUNTING)) in set_nearest_monster_foe()
926 const bool friendly = mon->friendly(); in set_nearest_monster_foe()
927 const bool neutral = mon->neutral(); in set_nearest_monster_foe()
929 coord_def center = mon->pos(); in set_nearest_monster_foe()
946 if (_mons_check_foe(mon, *di, friendly, neutral, second_pass)) in set_nearest_monster_foe()
949 mon->foe = MHITYOU; in set_nearest_monster_foe()
951 mon->foe = env.mgrid(*di); in set_nearest_monster_foe()
979 void behaviour_event(monster* mon, mon_event_type event, const actor *src, in behaviour_event() argument
982 if (!mon->alive()) in behaviour_event()
987 if (mons_is_projectile(mon->type)) in behaviour_event()
990 const beh_type old_behaviour = mon->behaviour; in behaviour_event()
992 bool isSmart = (mons_intel(*mon) >= I_HUMAN); in behaviour_event()
995 bool was_unaware = mon->asleep() || mon->foe == MHITNOT; in behaviour_event()
1003 if (is_sanctuary(mon->pos()) && mons_is_fleeing_sanctuary(*mon)) in behaviour_event()
1005 mon->behaviour = BEH_FLEE; in behaviour_event()
1006 mon->foe = MHITYOU; in behaviour_event()
1007 mon->target = env.sanctuary_pos; in behaviour_event()
1015 dprf("Disturbing %s", mon->name(DESC_A, true).c_str()); in behaviour_event()
1018 if (mon->asleep()) in behaviour_event()
1019 mon->behaviour = BEH_WANDER; in behaviour_event()
1026 if (!isSmart || mon->foe == MHITNOT || mons_is_wandering(*mon)) in behaviour_event()
1028 if (mon->is_patrolling()) in behaviour_event()
1032 mon->target = src_pos; in behaviour_event()
1038 if (mon->has_ench(ENCH_GOLD_LUST)) in behaviour_event()
1039 mon->del_ench(ENCH_GOLD_LUST); in behaviour_event()
1043 if (mon->behaviour == BEH_WITHDRAW && src != &you) in behaviour_event()
1055 if (!mons_is_threatening(*mon) in behaviour_event()
1056 && mon->attitude != ATT_FRIENDLY in behaviour_event()
1057 && mon->attitude != ATT_GOOD_NEUTRAL) in behaviour_event()
1062 mon->foe = src_idx; in behaviour_event()
1066 try_pathfind(mon); in behaviour_event()
1067 if (mons_intel(*mon) > I_BRAINLESS && !mons_can_attack(*mon) in behaviour_event()
1068 && target_is_unreachable(mon)) in behaviour_event()
1070 mon->behaviour = BEH_RETREAT; in behaviour_event()
1072 else if (mon->has_ench(ENCH_FEAR)) in behaviour_event()
1075 if (src == mon) in behaviour_event()
1078 if (you.can_see(*mon)) in behaviour_event()
1082 mon->name(DESC_THE).c_str(), in behaviour_event()
1083 mon->pronoun(PRONOUN_POSSESSIVE).c_str()); in behaviour_event()
1085 mon->del_ench(ENCH_FEAR, true); in behaviour_event()
1087 else if (!mons_is_fleeing(*mon)) in behaviour_event()
1088 mon->behaviour = BEH_SEEK; in behaviour_event()
1090 if (src == &you && mon->angered_by_attacks()) in behaviour_event()
1092 if (mon->attitude == ATT_FRIENDLY && mon->is_summoned()) in behaviour_event()
1094 summon_dismissal_fineff::schedule(mon); in behaviour_event()
1099 mon->attitude = ATT_HOSTILE; in behaviour_event()
1105 if (mons_is_elven_twin(mon)) in behaviour_event()
1106 elven_twins_unpacify(mon); in behaviour_event()
1117 dprf("Alerting %s", mon->name(DESC_A, true).c_str()); in behaviour_event()
1121 if (mon->friendly() && mon->is_patrolling() in behaviour_event()
1122 && !mon->asleep()) in behaviour_event()
1128 if (mon->behaviour == BEH_WITHDRAW) in behaviour_event()
1132 if (mon->friendly() && mons_self_destructs(*mon)) in behaviour_event()
1139 if (mon->neutral() && !mon->has_ench(ENCH_INSANE)) in behaviour_event()
1141 if (mon->asleep()) in behaviour_event()
1142 mon->behaviour = BEH_WANDER; in behaviour_event()
1149 if (!mons_is_retreating(*mon)) in behaviour_event()
1150 mon->behaviour = BEH_SEEK; in behaviour_event()
1152 if (mon->foe == MHITNOT) in behaviour_event()
1153 mon->foe = src_idx; in behaviour_event()
1156 && (mon->foe == MHITNOT || src && mon->foe == src->mindex() in behaviour_event()
1157 || mons_is_wandering(*mon))) in behaviour_event()
1159 if (mon->is_patrolling()) in behaviour_event()
1162 mon->target = src_pos; in behaviour_event()
1166 && !you.see_cell(mon->pos())) in behaviour_event()
1168 try_pathfind(mon); in behaviour_event()
1176 if (mon->is_stationary() || mon->berserk_or_insane()) in behaviour_event()
1178 mon->del_ench(ENCH_FEAR, true, true); in behaviour_event()
1183 if (mon->holiness() & (MH_PLANT | MH_NONLIVING)) in behaviour_event()
1185 mon->del_ench(ENCH_FEAR, true, true); in behaviour_event()
1189 msg = getSpeakString(mon->name(DESC_PLAIN) + " flee"); in behaviour_event()
1193 mon->behaviour = BEH_FLEE; in behaviour_event()
1194 mon->foe = src_idx; in behaviour_event()
1195 mon->target = src_pos; in behaviour_event()
1198 else if (mon->friendly() && !crawl_state.game_is_arena()) in behaviour_event()
1199 mon->foe = MHITYOU; in behaviour_event()
1201 if (you.see_cell(mon->pos())) in behaviour_event()
1208 if (!mons_is_retreating(*mon)) in behaviour_event()
1212 if (mon->pacified()) in behaviour_event()
1218 if (mons_is_cornered(*mon)) in behaviour_event()
1220 if (mon->friendly() && !crawl_state.game_is_arena()) in behaviour_event()
1222 mon->foe = MHITYOU; in behaviour_event()
1225 else if (!mon->is_child_tentacle()) in behaviour_event()
1227 msg = getSpeakString(mon->name(DESC_PLAIN) + " cornered"); in behaviour_event()
1231 mon->del_ench(ENCH_FEAR, true); in behaviour_event()
1232 mon->behaviour = BEH_SEEK; in behaviour_event()
1234 else if (mons_is_fleeing(*mon)) in behaviour_event()
1238 mon->props["last_pos"].get_coord() = mon->pos(); in behaviour_event()
1239 mon->behaviour = BEH_CORNERED; in behaviour_event()
1242 mon->behaviour = BEH_SEEK; in behaviour_event()
1251 mon->target = src_pos; in behaviour_event()
1252 if (src->is_player() && mon->angered_by_attacks()) in behaviour_event()
1255 mon->attitude = ATT_HOSTILE; in behaviour_event()
1258 if (mon->props.exists("no_annotate")) in behaviour_event()
1259 mon->props["no_annotate"] = false; in behaviour_event()
1260 set_unique_annotation(mon); in behaviour_event()
1261 mons_att_changed(mon); in behaviour_event()
1268 mon->del_ench(ENCH_CHARM); in behaviour_event()
1269 gozag_break_bribe(mon); in behaviour_event()
1270 mons_att_changed(mon); in behaviour_event()
1274 handle_behaviour(mon); in behaviour_event()
1277 if (!mon->alive()) in behaviour_event()
1280 ASSERT_IN_BOUNDS_OR_ORIGIN(mon->target); in behaviour_event()
1284 …ut in behavioural event, allow_shout: %d, foe: %d", mon->name(DESC_A, true).c_str(), allow_shout, in behaviour_event()
1287 && mon->foe == MHITYOU && !mon->wont_attack()) in behaviour_event()
1289 monster_consider_shouting(*mon); in behaviour_event()
1292 const bool isPacified = mon->pacified(); in behaviour_event()
1299 mon->behaviour = old_behaviour; in behaviour_event()
1303 if (!msg.empty() && mon->visible_to(&you)) in behaviour_event()
1304 mons_speaks_msg(mon, msg, MSGCH_TALK, silenced(mon->pos())); in behaviour_event()
1306 if (mons_allows_beogh_now(*mon)) in behaviour_event()
1311 mons_speaks_msg(mon, getSpeakString("orc_priest_preaching"), in behaviour_event()
1326 || mon->foe != MHITYOU && mon->target != you.pos()); in behaviour_event()
1329 void make_mons_stop_fleeing(monster* mon) in make_mons_stop_fleeing() argument
1331 if (mons_is_retreating(*mon)) in make_mons_stop_fleeing()
1332 behaviour_event(mon, ME_CORNERED); in make_mons_stop_fleeing()
1391 static void _mons_indicate_level_exit(const monster* mon) in _mons_indicate_level_exit() argument
1393 const dungeon_feature_type feat = env.grid(mon->pos()); in _mons_indicate_level_exit()
1394 const bool is_shaft = (get_trap_type(mon->pos()) == TRAP_SHAFT); in _mons_indicate_level_exit()
1397 simple_monster_message(*mon, " passes through the gate."); in _mons_indicate_level_exit()
1401 simple_monster_message(*mon, in _mons_indicate_level_exit()
1411 simple_monster_message(*mon, in _mons_indicate_level_exit()
1413 mon->airborne() ? "goes down" in _mons_indicate_level_exit()
1418 void make_mons_leave_level(monster* mon) in make_mons_leave_level() argument
1420 if (mon->pacified()) in make_mons_leave_level()
1422 if (you.can_see(*mon)) in make_mons_leave_level()
1423 _mons_indicate_level_exit(mon); in make_mons_leave_level()
1427 mon->flags |= MF_HARD_RESET; in make_mons_leave_level()
1428 monster_die(*mon, KILL_DISMISSED, NON_MONSTER); in make_mons_leave_level()