Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From b55127aa00831b9386a03b3c5a4a762e424836a0 Mon Sep 17 00:00:00 2001
- From: evilmike <evilmike@gmail.com>
- Date: Sun, 9 Oct 2011 02:33:42 -0700
- Subject: [PATCH] Randomize triggering fleeing at low HP.
- Monsters get a random chance of fleeing at low HP, rather than a guaranteed
- chance whenever HP is less than 25%. This means that fleeing is less predictable
- and occurs at lower HP levels.
- The formula may be worth adjusting still. Particularly the 20 in there. I think
- that 20 is a good start, but also the highest it should go. 10 would be the
- lowest, I think.
- This also makes it so fleeing is triggered when a monster is hit, and not just
- whenever its HP is low. This includes being hit for 0 damage. This is done to
- make it so a monster won't just randomly start fleeing... you have to at least
- do something hostile to it first.
- ---
- crawl-ref/source/mon-behv.cc | 40 ++++++++++++++++++++++++++++------------
- 1 files changed, 28 insertions(+), 12 deletions(-)
- diff --git a/crawl-ref/source/mon-behv.cc b/crawl-ref/source/mon-behv.cc
- index 94970eb..d7e63a6 100644
- --- a/crawl-ref/source/mon-behv.cc
- +++ b/crawl-ref/source/mon-behv.cc
- @@ -187,11 +187,9 @@ void handle_behaviour(monster* mon)
- proxPlayer = false;
- #endif
- bool proxFoe;
- - bool isHurt = (mon->hit_points <= mon->max_hit_points / 4 - 1);
- bool isHealthy = (mon->hit_points > mon->max_hit_points / 2);
- bool isSmart = (mons_intel(mon) > I_ANIMAL);
- bool isScared = mon->has_ench(ENCH_FEAR);
- - bool isMobile = !mons_is_stationary(mon);
- bool isPacified = mon->pacified();
- bool patrolling = mon->is_patrolling();
- static std::vector<level_exit> e;
- @@ -611,15 +609,6 @@ void handle_behaviour(monster* mon)
- mon->target = menv[mon->foe].pos();
- }
- - // Smart monsters, undead, plants, and nonliving monsters cannot flee.
- - if (isHurt && !isSmart && isMobile
- - && mon->holiness() != MH_UNDEAD
- - && mon->holiness() != MH_PLANT
- - && mon->holiness() != MH_NONLIVING
- - && !mons_class_flag(mon->type, M_NO_FLEE))
- - {
- - new_beh = BEH_FLEE;
- - }
- break;
- case BEH_WANDER:
- @@ -881,7 +870,21 @@ void behaviour_event(monster* mon, mon_event_type event, int src,
- const beh_type old_behaviour = mon->behaviour;
- + // Set up random fleeing:
- + // Monster can flee if HP is less than 1/4 maxhp or less than 20 hp
- + // (whichever is lower). Chance starts quite low, and is 100% at 1 hp.
- + // These numbers could still use some adjusting.
- + //
- + // Assuming fleeThreshold is 20:
- + // at 20 hp: 5% chance of fleeing
- + // at 10 hp: 55% chance of fleeing
- + // (chance increases by 5% for every hp lost.)
- + int fleeThreshold = std::min(mon->max_hit_points / 4, 20);
- + bool willFlee = x_chance_in_y(fleeThreshold - mon->hit_points + 1,
- + fleeThreshold);
- +
- bool isSmart = (mons_intel(mon) > I_ANIMAL);
- + bool isMobile = !mons_is_stationary(mon);
- bool wontAttack = mon->wont_attack();
- bool sourceWontAttack = false;
- bool setTarget = false;
- @@ -969,7 +972,7 @@ void behaviour_event(monster* mon, mon_event_type event, int src,
- {
- mon->behaviour = BEH_RETREAT;
- }
- - else if (!mons_is_cornered(mon))
- + else if (!mons_is_cornered(mon) && (mon->hit_points > fleeThreshold))
- mon->behaviour = BEH_SEEK;
- if (src == MHITYOU)
- @@ -987,6 +990,19 @@ void behaviour_event(monster* mon, mon_event_type event, int src,
- // invisible foe.
- if (event == ME_WHACK)
- setTarget = true;
- +
- + // Smart monsters, undead, plants, and nonliving monsters cannot flee.
- + // Cannot flee if cornered. There is also a random chance involved.
- + if (willFlee && !isSmart && isMobile
- + && mon->holiness() != MH_UNDEAD
- + && mon->holiness() != MH_PLANT
- + && mon->holiness() != MH_NONLIVING
- + && !mons_class_flag(mon->type, M_NO_FLEE)
- + && !mons_is_cornered(mon))
- + {
- + mon->behaviour = BEH_FLEE;
- + }
- +
- break;
- case ME_ALERT:
- --
- 1.7.5.GIT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement