Welcome to the Builder Academy

Question Feedback Request - Simple Morale Check Script

More
19 Nov 2017 01:27 #7114 by Banlock
I would be interested in hearing what you folks think, and if there are ways to improve this.

I remember in the old days of D&D there was a morale check mechanic, which gave the DM a way to determine if a monster (or group of monsters) would fight to the death or flee. Setting wimpy works for individuals, but not masses of low level guys who might be killed before they can flee -- so I wanted a script that would work on mobs that are encountered as groups and are aggressive. The in-world affect would be a group of soldiers realizing that the PCs are killing them with no effort, causing them to be demoralized and for the whole group to flee (even those who are uninjured). Obviously not appropriate for all mobs.

What I ended up with was a death trigger (so no morale checks until after the first mob dies) that counts all the levels of fighting mobs in the room (so two level 3 mobs would total 6) and then counts all of the levels of the fighting and visible PCs in the room. The script then makes a comparison similar to the one in "consider" and gives slightly outclassed mobs a 50% chance of becoming demoralized and fleeing and very outclassed mobs a 100% chance of fleeing (maybe I should change to 75%, I've play-tested this a little but still tweaking it). There are some color echoes for groups that think they outclass the PCs, as well as signs of panic for the mobs on the wrong side of the power equation.

It ended up kind of interesting, as incapacitation sometimes means a delay in the death trigger, so a lone PCs can end up killing two mobs before the trigger fires. Fleeing also doesn't keep wandering mobs from wandering back one by one to be killed, not sure what to do about that as it doesn't look like I can set wimpy from a trigger. But I suppose a non-generic trigger could transform the mobs into wimpy versions. The script also ignores non-fighting mobs that happen to be in the room, like wildlife, so they aren't affected.

Anyway, here is the script:
Code:
* Run check on mob death, tally total mob levels versus PC levels and assign * probability of the remaining mobs fleeing. The levels of Mobs that aren't * fighting should not be counted and they shouldn't be forced to flee. * Using code from the "while damage" example tigger to loop through the fight set room_var %actor.room% set target_char %room_var.people% set pclevels 0 set moblevels 0 set mobcount 0 set runaway 0 * Now loop through everyone fighting (and visible) to get MOB and PC total levels while %target_char% * Set the next target before this one perhaps dies. set tmp_target %target_char.next_in_room% * PCs level totals if %target_char.canbeseen% && %target_char.is_pc% && %target_char.fighting% eval pclevels (%pclevels% + %target_char.level%) * Mob level totals elseif !%target_char.is_pc% && %target_char.fighting% eval moblevels (%moblevels% + %target_char.level%) eval mobcount (%mobcount% + 1) end * Set the next target. set target_char %tmp_target% * Loop back. done * Compare total mob levels fighting versus PC levels fighting to determine * if mobs will flee if (%moblevels% - %pclevels%) > 4 if %mobcount% > 1 %echo% Your foes seem confident they will defeat you! else %echo% Your foe seems confident they will defeat you! end elseif ((%moblevels% - %pclevels%) >= 2) && ((%moblevels% - %pclevels%) <= 4) if %mobcount% > 1 %echo% Your foes fight well. else %echo% Your foe fights well. end elseif %moblevels% == 0 * They are all dead! elseif ((%moblevels% - %pclevels%) >= 0) && ((%moblevels% - %pclevels%) <= 1) if %mobcount% > 1 %echo% You and your foes seem well matched. else %echo% You and your foe seem well matched. end elseif ((%moblevels% - %pclevels%) <= -1) && ((%moblevels% - %pclevels%) >= -2) switch %random.2% case 1 * Time to bolt set runaway 1 if %mobcount% > 1 %echo% Your foes cast grim glances at their fallen comrades. else %echo% Your foe casts grim glances at their fallen comrades. end break case 2 * Maybe hang in one more round if %mobcount% > 1 %echo% Your foes cast uneasy glances at their fallen comrades. else %echo% Your foe casts uneasy glances at their fallen comrades. end break default * Shouldn't reach done elseif ((%moblevels% - %pclevels%) <= -3) if %mobcount% > 1 %echo% Your foes seem panicked by your ferocity in combat! else %echo% Your foe seems panicked by your ferocity in combat! end set runaway 1 end * Now we want to loop through the mobs again and tell the demoralized mobs to flee set room_var_2 %actor.room% set target_char_2 %room_var_2.people% while %target_char_2% * Set the next target before this one perhaps dies. set tmp_target_2 %target_char_2.next_in_room% if !%target_char_2.is_pc% && %target_char_2.fighting% && %runaway% == 1 %force% %target_char_2% flee end * Set the next target. set target_char_2 %tmp_target_2% * Loop back. done
The following user(s) said Thank You: zusuk

Please Log in or Create an account to join the conversation.

More
19 Nov 2017 22:11 #7117 by WhiskyTest
This is a great idea! Well done :)

I'm not great with scripting but is this part correct?
Code:
elseif %moblevels% == 0 * They are all dead! elseif ((%moblevels% - %pclevels%) >= 0) && ((%moblevels% - %pclevels%) <= 1)
Is there a line missing after the *They are all dead! comment?

Please Log in or Create an account to join the conversation.

More
19 Nov 2017 23:29 #7120 by Banlock
Thanks and nice catch with that line. It looks like it was left over from the debugging. I had an '%echo%' there at one point in the evolution of the trigger.

If I can figure it out, I might make my first real contribution a way to push stuff to the log instead of having to %echo% things out. It might help the trigger editing/debugging process. I know dg* has a way to write to the log, but I'm not seeing (maybe missing?) a way to do that from a trigger. Or maybe someone has already done that?

Please Log in or Create an account to join the conversation.

Time to create page: 0.218 seconds