Author Topic: [OSP][Code] Overhauled Morale and Routing (Also Reduces Stuttering)  (Read 14506 times)

0 Members and 1 Guest are viewing this topic.

Ikaguia

  • Grandmaster Knight
  • *
  • Defender of the Potato cult.
    • Skype - Ikaguia
    • Steam - Ikaguia
    • Twitch.tv - Ikaguia
    • View Profile
  • Faction: Sarranid
  • MP nick: Ikaguia
  • WBWF&SNW
Re: [OSP][Code] Overhauled Morale and Routing (Also Reduces Stuttering)
« Reply #15 on: January 05, 2015, 02:12:42 PM »
Probably, but I'm not an expert on how saves handle new global variables being thrust on them.

as long as the variables are assigned before being used (i.e: they are not assigned at the game_start script, which would not be run a 2nd time on a script), the save is compatible. however, any saves you made with these new variables will not be compatible with normal native.

Sorry for my poor English, I'm Brazilian.

NUQAR'S Kentucky "Nuqar" James XXL

  • BioAfrikaner
  • Duke
  • *
  • 🖕IF YOUR EASILY OFFENDED...GROW SOME BALLS...!!🖕
    • Twitter - yaqobhyndes
    • View Profile
    • Artwork Gallery
  • Faction: Khergit
Re: [OSP][Code] Overhauled Morale and Routing (Also Reduces Stuttering)
« Reply #16 on: May 03, 2015, 02:52:13 PM »
I've re-overhauled the morale system once again (this is about the fifth time for me). There are a couple of small bugs in the current code, but the main issue is that the tide of battle doesn't play a big enough part in getting soldiers to rout. As a result, I've recoded the script that deals with the battle ratio, giving a soft limit of around 5:1 odds before everyone on that team begins to flee. Allied deaths and routs are taken into account as well, which should allow an outnumbered army to turn the tide and rout a larger force if they do well enough.
I'm currently experimenting with making the equation work realistically -- at the moment, if A = ally strength and E = enemy strength, it's (√A-√E)^3 + (A-E), which is then added to the minimum amount of morale required to get an agent to rout. Adjusted w.r.t. teams, of course.

This of course makes massive armies more volatile and smaller ones more stable, so I've revamped the "morale recovery" script -- every 3 seconds, every agent gets a bonus to morale that is equivalent either to the number of friendly allies on the field, or the battle ratio -- whichever is larger. That way a 300 v 300 battle is more prone to morale shocks, but is more likely to recover from a chain rout. Similarly, if you rout a small group of bandits, they're probably not coming back. This will require quite a lot of testing to get right.

Not sure as to how long this will take to balance, but when it's done I might make it compatible with modmerger as there are quite a few fiddly script replacements.

Redleg

  • Sergeant Knight at Arms
  • *
  • Cedat Fortuna Peritis
    • View Profile
    • Taleworlds Forum- Calradia 1050 A.D.: Mercenary Uprising mod
  • Faction: Nord
Re: [OSP][Code] Overhauled Morale and Routing (Also Reduces Stuttering)
« Reply #17 on: May 03, 2015, 05:39:07 PM »
Good luck with this.  It sounds like a good idea, especially if it smooths out battles and makes sense.

Zephilinox

  • Knight
  • *
  • Perisno Developer
    • Skype - Zephilinox
    • Steam - 01111010
    • Twitter - Zephilinox
    • Twitch.tv - Zephilinox
    • YouTube - Zephilinox
    • View Profile
  • Faction: Swadian
  • WB
Re: [OSP][Code] Overhauled Morale and Routing (Also Reduces Stuttering)
« Reply #18 on: May 05, 2015, 10:02:58 AM »
I've re-overhauled the morale system once again (this is about the fifth time for me). There are a couple of small bugs in the current code, but the main issue is that the tide of battle doesn't play a big enough part in getting soldiers to rout. As a result, I've recoded the script that deals with the battle ratio, giving a soft limit of around 5:1 odds before everyone on that team begins to flee. Allied deaths and routs are taken into account as well, which should allow an outnumbered army to turn the tide and rout a larger force if they do well enough.
I'm currently experimenting with making the equation work realistically -- at the moment, if A = ally strength and E = enemy strength, it's (√A-√E)^3 + (A-E), which is then added to the minimum amount of morale required to get an agent to rout. Adjusted w.r.t. teams, of course.

This of course makes massive armies more volatile and smaller ones more stable, so I've revamped the "morale recovery" script -- every 3 seconds, every agent gets a bonus to morale that is equivalent either to the number of friendly allies on the field, or the battle ratio -- whichever is larger. That way a 300 v 300 battle is more prone to morale shocks, but is more likely to recover from a chain rout. Similarly, if you rout a small group of bandits, they're probably not coming back. This will require quite a lot of testing to get right.

Not sure as to how long this will take to balance, but when it's done I might make it compatible with modmerger as there are quite a few fiddly script replacements.

I'm not sure if you fixed it, but I had to edit your script to ensure it wasn't checking horses for morale, as battles wouldn't end.

NUQAR'S Kentucky "Nuqar" James XXL

  • BioAfrikaner
  • Duke
  • *
  • 🖕IF YOUR EASILY OFFENDED...GROW SOME BALLS...!!🖕
    • Twitter - yaqobhyndes
    • View Profile
    • Artwork Gallery
  • Faction: Khergit
Re: [OSP][Code] Overhauled Morale and Routing (Also Reduces Stuttering)
« Reply #19 on: May 05, 2015, 10:10:16 AM »
Whoa, well spotted. I'm still using that script, thanks for pointing this out.

dragos

  • Guest
Re: [OSP][Code] Overhauled Morale and Routing (Also Reduces Stuttering)
« Reply #20 on: May 07, 2015, 11:00:51 AM »
Cool! Thank you Jacobhinds

Redleg

  • Sergeant Knight at Arms
  • *
  • Cedat Fortuna Peritis
    • View Profile
    • Taleworlds Forum- Calradia 1050 A.D.: Mercenary Uprising mod
  • Faction: Nord
Re: [OSP][Code] Overhauled Morale and Routing (Also Reduces Stuttering)
« Reply #21 on: September 02, 2015, 06:17:46 PM »
Jacobhinds,
Any news on the updating for this code?  I would like to try it in my mod, Calradia 1050 A.D.

NUQAR'S Kentucky "Nuqar" James XXL

  • BioAfrikaner
  • Duke
  • *
  • 🖕IF YOUR EASILY OFFENDED...GROW SOME BALLS...!!🖕
    • Twitter - yaqobhyndes
    • View Profile
    • Artwork Gallery
  • Faction: Khergit
Re: [OSP][Code] Overhauled Morale and Routing (Also Reduces Stuttering)
« Reply #22 on: September 02, 2015, 06:21:04 PM »
I'm still tweaking it. It's been a long process and there's now a ton more code, so if more people show interest I'll focus my efforts on releasing it.

Antoni

  • Sergeant
  • *
    • View Profile
  • Faction: Sarranid
Re: [OSP][Code] Overhauled Morale and Routing (Also Reduces Stuttering)
« Reply #23 on: September 10, 2015, 05:16:02 AM »
cool, i'll try this. thank you..
 

Nikephoros

  • Language Moderator
  • *
  • Feccia di Bisanzio
    • Steam - Nikephoros
    • Twitch.tv - AB_Nikephoros
    • View Profile
  • Faction: Vaegir
  • MP nick: AB_Nikephoros
  • M&BWB
Re: [OSP][Code] Overhauled Morale and Routing (Also Reduces Stuttering)
« Reply #24 on: November 01, 2015, 03:23:51 PM »
To fix the horse issue, i added a line with agent_is_human in module_scripts, is it the right way to fix it?

Code: [Select]
#script_all_enemies_routed
    # This script checks that all enemies are routed or killed.
    # INPUT: none
    # OUTPUT: reg0 = enemies routed 0 or 1
    ("all_enemies_routed", [
      (try_for_agents, ":agent"),
(neg|agent_is_ally, ":agent"),
(agent_is_alive, ":agent"),
                (agent_is_human, ":agent"),
(agent_get_slot, ":routing", ":agent", slot_agent_is_running_away),
(eq, ":routing", 0),
(val_add, reg0, 1),
      (try_end),
]),
(click to show/hide)


Ti vedo... E ti piango.

NUQAR'S Kentucky "Nuqar" James XXL

  • BioAfrikaner
  • Duke
  • *
  • 🖕IF YOUR EASILY OFFENDED...GROW SOME BALLS...!!🖕
    • Twitter - yaqobhyndes
    • View Profile
    • Artwork Gallery
  • Faction: Khergit
Re: [OSP][Code] Overhauled Morale and Routing (Also Reduces Stuttering)
« Reply #25 on: January 29, 2016, 06:20:05 PM »
Here's the new version. Before I replace the one in the OP, it would be great if somebody could test this out on their own module to see if I've missed anything out.

(click to show/hide)

Replace the following scripts in module_scripts.py:

script_apply_death_effect_on_courage_scores,
script_decide_run_away_or_not*
(choose correct script depending on whether you have FormAI or not. Also, if you don't have my Form Musket Square script installed, delete or comment out any lines with instances of script_agent_remove_from_square).

(click to show/hide)

Add these to the the top of the file, then add each trigger to the lead_charge template (plus quick_battle_battle if you want them in custom battles)
(click to show/hide)

Go through module_mission_templates.py and comment out any examples of this.
(click to show/hide)

Also in module module_mission_templates.py, replace any instances of this:
(val_mul, ":troop_level", 35),
with this:
(val_mul, ":troop_level", 100),


(click to show/hide)
« Last Edit: February 04, 2016, 05:28:50 PM by jacobhinds »

Lord of Shadows

  • Sergeant Knight
  • *
  • You cannot fight the shadow.
    • View Profile
  • Faction: Neutral
  • MP nick: Shadow
  • WBNWVCWF&SM&B
Re: [OSP][Code] Overhauled Morale and Routing (Also Reduces Stuttering)
« Reply #26 on: January 29, 2016, 06:37:32 PM »
Hi. I have 2 questions:
1. What is improved in the new version?
2. Would this be compatible with Chel's Battle Morale code?

NUQAR'S Kentucky "Nuqar" James XXL

  • BioAfrikaner
  • Duke
  • *
  • 🖕IF YOUR EASILY OFFENDED...GROW SOME BALLS...!!🖕
    • Twitter - yaqobhyndes
    • View Profile
    • Artwork Gallery
  • Faction: Khergit
Re: [OSP][Code] Overhauled Morale and Routing (Also Reduces Stuttering)
« Reply #27 on: January 29, 2016, 06:51:23 PM »
1. It's been completely overhauled. There are some bugs in the old version due to me not understanding the code in some places. Now it's more straightforward:
- Both armies start out with similar amounts of morale.
- The weight of numbers affects how likely each troop is to rout.
- No army can rout until more than 10% of their army is dead/wounded/routed.
- Morale is replenished every few seconds by a factor of the number of remaining allies. If there's nobody left on the field, nobody will come back.

2. Since they basically do the same thing, they might clash a bit. Even then, Chel's code uses workarounds from before routing was even a feature in warband (I think taleworlds actually used his idea). Unless you're stuck on pre-2010 mount and blade, use my code.

Lord of Shadows

  • Sergeant Knight
  • *
  • You cannot fight the shadow.
    • View Profile
  • Faction: Neutral
  • MP nick: Shadow
  • WBNWVCWF&SM&B
Re: [OSP][Code] Overhauled Morale and Routing (Also Reduces Stuttering)
« Reply #28 on: January 29, 2016, 06:55:02 PM »
Thanks for the answer. :)
I remember having both codes in my mod at some point but I'm not really sure if they conflicted... Thanks anyway.

Giggityninja

  • Sergeant
  • *
    • View Profile
  • Faction: Swadian
Re: [OSP][Code] Overhauled Morale and Routing (Also Reduces Stuttering)
« Reply #29 on: January 30, 2016, 11:23:47 PM »
For some reason, the script that allows you to leave a battle if all enemy troops are routing, is sometimes causing a victory message to pop up seconds after a battle has begun. I am using Form Ai by the way, but I did put the main script under FormAi_scripts.py's native replacements section as it said to do.