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

Users who are viewing this thread

builder of the gods

Sergeant at Arms
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
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
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

Grandmaster Knight
M&BWBWF&SNWVC
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
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
 
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.
 
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
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.
 
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
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).
 

Vetrogor

Sergeant at Arms
Bugs are countless. One need to overhaul the code. In quotes just few of them from the first look.
Bugs:
1)
Python:
jacobhinds_morale_recover = (
   3, 0, 0, [(eq, "$g_battle_won", 0)],[ # no recovery once battle is over
Was: "$g_battle_won" = 1 - this triggered only when battle was won.
2)
Python:
agent_assign_rank_closeness = (ti_on_order_issued, 0, 0, [], [

    (store_trigger_param_1,":order"),
    (store_trigger_param_2,":agent"),

   (agent_get_slot, ":closeness", ":agent", slot_agent_rank_closeness),
Was: slot_agent_is_running_away
But the trigger itself is mostly not used.
3) Not a bug but constant initial_morale = 10000 is not used.
4) Another feature doesn't work. Inside this trigger agent_assign_rank_closeness, only player_agent slot will be assigned. The rest will miss. Cause ti_on_order_issued called only for agent that issued order.
 
Last edited:
Top Bottom