OSP Code Combat Overhauled Morale and Routing (Also Reduces Stuttering)

HarryPham123

Knight
Best answers
0

builder of the gods

Sergeant at Arms
Best answers
0
The new version is MUCH better than native thx for the cool code
in exchange a funny addition:
what this does that is tells you the enemy or you troops are routing in a tactical way it does this only one time but for both teams

behing (agent_start_running_away, ":cur_agent"),

implent it as following
Code:
                 (agent_start_running_away, ":cur_agent"),
		 #For rome implentation
	        (try_begin),
		     (neg, "$g_message", 1), #not already displayed
	             (neg|agent_is_ally,":cur_agent"),
		     (display_message,"@The enemy is routing, the odds are shifting to your side!",0x6495ed),
		     (assign, "$g_message", 1),
		 (try_end),
		 (try_begin),
		     (neg, "$g_message1", 1), #not already displayed
		     (eq|agent_is_ally,":cur_agent"),
		     (display_message,"@Your troops are routing, it looks like you are losing the battle!",0x6495ed),
		     (assign, "$g_message1", 1),
		 (try_end),
		  #For rome implentation

then in module mission templates
Code:
common_check_message_time = ( #checks if messages are allowed to display
   ti_before_mission_start, 0, 0, [],
   [
		(assign, "$g_message", 0),
		(assign, "$g_message", 1),
   ]))

i maybe will later add a sreenshot
 

produno

Master Knight
M&BWBWF&SNW
Best answers
0
typo?


Code:
common_check_message_time = ( #checks if messages are allowed to display
   ti_before_mission_start, 0, 0, [],
   [
		(assign, "$g_message", 0),
		(assign, "$g_message1", 0),
   ]))
 

builder of the gods

Sergeant at Arms
Best answers
0
produno said:
typo?


Code:
common_check_message_time = ( #checks if messages are allowed to display
   ti_before_mission_start, 0, 0, [],
   [
		(assign, "$g_message", 0),
		(assign, "$g_message1", 0),
   ]))
Yes stupid thx

Code:
common_check_message_time = ( #checks if messages are allowed to display
   ti_before_mission_start, 0, 0, [],
   [
		(assign, "$g_message", 0),
		(assign, "$g_message", 1),
   ]) # there was a ) to much
 

Namakan

Sergeant Knight at Arms
M&BWBWF&SNWVC
Best answers
3
builder of the gods said:
produno said:
typo?


Code:
common_check_message_time = ( #checks if messages are allowed to display
   ti_before_mission_start, 0, 0, [],
   [
      (assign, "$g_message", 0),
      (assign, "$g_message1", 0),
   ]))
Yes stupid thx

Code:
common_check_message_time = ( #checks if messages are allowed to display
   ti_before_mission_start, 0, 0, [],
   [
      (assign, "$g_message", 0),
      (assign, "$g_message", 1),
   ]) # there was a ) to much

I think he was talking about the variables (?)
 

builder of the gods

Sergeant at Arms
Best answers
0
Namakan said:
builder of the gods said:
produno said:
typo?


Code:
common_check_message_time = ( #checks if messages are allowed to display
   ti_before_mission_start, 0, 0, [],
   [
      (assign, "$g_message", 0),
      (assign, "$g_message1", 0),
   ]))
Yes stupid thx

Code:
common_check_message_time = ( #checks if messages are allowed to display
   ti_before_mission_start, 0, 0, [],
   [
      (assign, "$g_message", 0),
      (assign, "$g_message", 1),
   ]) # there was a ) to much

I think he was talking about the variables (?)
Yes just make it $ sry
 

Seek n Destroy

Marquis
WBWF&S
Best answers
0
Hah, thought so when testing the scripts too. At first I declared max_morale as being 100 just to check and the results were rather chaotic  :lol:
I somehow feel like I've gained some frames back with this, I can't be certain without testing two different builds in the same conditions but at the very least I can say is that the routing seems more responsive. Does it take troops levels into account? I haven't noticed much difference between the rate which low level and higher level troops rout but maybe that's just because there's not too much of a level gap in my troops. I might just start paying attention to how routing works and add some more purpose to officer and banner carriers, thanks for the code.
 

Kentucky James VII

BioAfrikaner
Duke
Best answers
1
The guy working on the module system overhaul noticed significant stutter reduction.

Troop level is taken into account but not by a huge margin. I think the decide_run_away_or_not script handles this.
 

Seek n Destroy

Marquis
WBWF&S
Best answers
0
I'm certain someone with a better computer will notice much more of a difference, I'm working on a resource intensive mod and looking into some possible optimization so this certainly comes in handy. Can't wait to see what Xenoargh pulls out too.
script_decide_run_away_or_not seems to take agent hp into account and his courage score which seems to be defined in the lead_charge mission template and is indeed based on troop level. By playing around a bit with those two I should be able to add some more fluctuations to the morale/courage system, higher starting courage when in the presence of officer troops and some significant drops in morale when the player or a lord gets smashed as a nice throwback to the old TW games where the well timed death of an enemy captain or general could turn the tide of battle.

script_decide_run_away_or_not said:
            (agent_is_ally, ":cur_agent"),
            (val_sub, ":agent_hit_points", 100), #ally agents will be more tend to run away, to make game more funnier/harder
So that's another reason why allies always seem more of an hindrance than actual help...
 

Redleg

Sergeant Knight at Arms
Best answers
0
Jacob,
I apologize for resurrecting this old thread but had a question about this coding.  Your code looks like it takes into account the total number of agents (not including horses).  Does this make the code work differently for different battle-size settings?  For example, I use battle size of 150 (my PC is old) and rarely find any routing occurring.  Is your code optimized for a particular battle size, and if so, which of the constants should I change to make it work better for battle size of 150.  I have tried reducing the max_morale value but haven't seem much of a difference in routing behavior.
 

Kentucky James VII

BioAfrikaner
Duke
Best answers
1
I made it so that routing happens towards the end of battles regardless of size, but there's always the possibility of a bit of broken code on my end (I may have forgotten to upload it from my most recent build) or some native script on yours. I would suggest doing a test where you print the morale ratio or some other variable to the rgl_log and see if enough morale penalties are being generated so you can tweak from there.
 

Redleg

Sergeant Knight at Arms
Best answers
0
NUQAR'S Kentucky "Nuqar" James XXL said:
I made it so that routing happens towards the end of battles regardless of size, but there's always the possibility of a bit of broken code on my end (I may have forgotten to upload it from my most recent build) or some native script on yours. I would suggest doing a test where you print the morale ratio or some other variable to the rgl_log and see if enough morale penalties are being generated so you can tweak from there.
Thanks for the info.  I wanted to tell you that the code does make the battles smoother compared to before (I am using PBOD with formations AI).