OSP Code SP [WB] Order: Skirmish Mode

Users who are viewing this thread

Tempered said:
This sounds like a really good idea that has been needed in game for a long time.

How well does it work with the game's routing code? Will the skirmishers be prevented from routing while under the skirmish command?

It is integrated to work seamlessly with the Native routing code. In the actual skirmishing script, within the agent loop there are the following lines:
Code:
     (try_for_agents, ":agent"),
         (agent_is_alive, ":agent"),
         (agent_is_human, ":agent"),
         (agent_is_non_player, ":agent"),
         (agent_get_team, ":team", ":agent"),
         (eq, ":team", ":playerteam"), #On Player's side?
         (agent_slot_eq, ":agent", slot_agent_is_running_away, 0), #Is not routing or ordered to retreat
The final line ensures that the remainder of the code will not fire if the agent is actually supposed to be routing. So, if they were not skirmishing at the time their morale fell and they began to rout, it won't check anyway and they will go on their merry routing way. If they were skirmishing and trying to maintain distance when their morale falls, the script won't let them check to stop skirmishing and they will rout all the way out of the battle...or until their morale stabilizes and they stop routing.
 
It does. But rarely, as if some agents rout then the army loses power, and the less power an army has the more routs. Yup.
 
If I wanted to try this along side your use_weapon_triggers, should it look like this?:


...
common_battle_order_panel,
      common_battle_order_panel_tick,
      common_battle_inventory,
    ] + weapon_use_triggers, + order_skirmish_triggers
  ),
 
StinkyMcGirk said:
If I wanted to try this along side your use_weapon_triggers, should it look like this?:


...
common_battle_order_panel,
      common_battle_order_panel_tick,
      common_battle_inventory,
    ] + weapon_use_triggers, + order_skirmish_triggers
  ),


    ] + weapon_use_triggers + order_skirmish_triggers,
  ),
 
Got it all up and running, but it's strange - It's showing the debug information, and I don't know how to turn that off.  Also, when I loaded my save game, even though I was in the field in the heart of Swadia, it started me off at the 'Rivacheg' menu with a couple lines of errors.

EDIT:  Saved somewhere else, and found that the cheat menu at camp menu script was included somewhere, so just disabled debugging - no problems since, everything looks to be running fine.

EDIT2:  No wait... something is wrong.  I can't turn off both debugging messages... and for some reason I don't have any feedback on the screen about ANYTHING now.  Very confused.
 
hi has anyone gotten this working, and would like to share a download of the changed documents  :grin:
I don't know the module system and would like to use this in my current game, I'm a khergit mercenary
 
Thanks you so much again, I add this to rigale, giving credits. Thank you caba'drin  :grin:
 
Caba`drin said:
Oddball_E8 said:
is there a possibility of getting a video of this in action, im curious as to how well it works...
I'll see if I can find any time to do so, but this isn't a high priority for me. I'd be more than happy if another had any interest in doing that and wanted to fool around with it.

Having been asked to provide videos for the Volley Fire code and deciding to do so, and with Cromcrom's timely bump (cheers), I was reminded I never posted videos for this. Two have now been added to the OP. (They aren't great...but they give an idea.)
 
By request, an agent-based, simplified and automatic/AI compatible version:
Code:
  # script_skirmish
  # Input: Nothing 
  # Output: Nothing
  # Cycle through agents, checking and maintaining distance
 ("skirmish", [  
     (set_fixed_point_multiplier, 1),
     (get_scene_boundaries, pos2, pos3),
     (position_get_x, ":bound_right", pos2),
     (position_get_y, ":bound_top", pos2),
     (position_get_x, ":bound_left", pos3),
     (position_get_y, ":bound_bottom", pos3),
     
     (try_for_agents, ":agent"),
         (agent_is_alive, ":agent"),
         (agent_is_human, ":agent"),
         (agent_is_non_player, ":agent"),
         (agent_slot_eq, ":agent", slot_agent_is_running_away, 0), #Is not routing or ordered to retreat
	 (agent_slot_eq, ":agent", slot_agent_is_skirmisher, 1), #Is set to use skirmishing AI
	 (try_begin),
		(agent_get_ammo, ":ammo", ":agent"),
		(le, ":ammo", 0),		 
		(agent_set_slot, ":agent", slot_agent_is_skirmisher, 0), #Out of ammo, no longer skirmish
	 (try_end),
	 (agent_slot_eq, ":agent", slot_agent_is_skirmisher, 1), #Still Skirmisher?
         
         (agent_get_position, pos1, ":agent"),   
         (position_get_x, ":agent_x", pos1),
         (position_get_y, ":agent_y", pos1),
         (store_sub, ":dist_right", ":agent_x", ":bound_right"),
         (store_sub, ":dist_top", ":agent_y", ":bound_top"),
         (store_sub, ":dist_left", ":bound_left", ":agent_x"),
         (store_sub, ":dist_bottom", ":bound_bottom", ":agent_y"),
         (try_begin), #If agent is too close to edge of map, stop skirmishing. Will resume when back into map
             (this_or_next|le, ":dist_right", 20),  #Limits accidental routing, of cav in particular
             (this_or_next|le, ":dist_top", 20),
             (this_or_next|le, ":dist_left", 20),
             (le, ":dist_bottom", 20),
             (agent_stop_running_away, ":agent"),
         (else_try),
             (agent_get_team, ":team", ":agent"),
             (call_script, "script_get_closest3_distance_of_enemies_at_pos1", ":team", pos1), # Find distance of nearest 3 enemies
             (assign, ":avg_dist", reg0),
             (assign, ":closest_dist", reg1),
             (try_begin),
                 (this_or_next|lt, ":avg_dist", skirmish_min_distance),
                 (lt, ":closest_dist", 700), #If enemy group is getting near or an enemy is on top of agent
                 (agent_start_running_away, ":agent"),         
             (else_try),    
                 (ge, ":avg_dist", skirmish_max_distance), #If distance from enemy is (too) large, resume previous order
                 (agent_stop_running_away, ":agent"),         
             (try_end), #Distance to enemy
         (try_end), #Distance from edge
     (try_end), #Agent loop
    ]),

Code:
(0.5, 0, 0, [(get_player_agent_no, ":player"),(agent_slot_eq, ":player", slot_agent_is_skirmisher, 1)], [(call_script, "script_skirmish")]),  #Use player's slot to track if any skirmishers are active
(ti_on_agent_spawn, 0, 0, [],
   [
    (store_trigger_param_1, ":agent"),
    (agent_get_troop_id, ":troop_no", ":agent"),
    (neq, ":troop_no", "trp_player"),
	
	##! - Do your stuff to pick the correct troops, however you want to do it
        ##Need code here to choose for which types of troops/agent you want to modify the AI
	
    (agent_set_slot, ":agent", slot_agent_is_skirmisher, 1),
	
    (get_player_agent_no, ":player"),
    (agent_is_active, ":player"),
    (agent_set_slot, ":player", slot_agent_is_skirmisher, 1), #Notes that there are skimishers active, rather than a global	
   ]),
 
Code:
slot_agent_is_skirmisher = 26 #or higher, depending on if you've added other agent slots
skirmish_min_distance = 1500 #Min distance you wish maintained, in cm. Where agent will retreat
skirmish_max_distance = 2500 #Max distance to maintain, in cm. Where agent will stop retreating
 
Sayd Ûthman said:
Oh the variable :team is not assigned :

(call_script, "script_get_closest3_distance_of_enemies_at_pos1", ":team", pos1),
Don't know how I did that, I'd compiled before I posted...  In any case, fixed above.
Simply add              (agent_get_team, ":team", ":agent"), immediately above that line.
 
Is there some way of making it so agents may make a decision to drop the skirmish behaviour and draw melee weapons and stand and fight instead? For example, if cavalry gets within their minimum range?
 
Dain Ironfoot said:
Is there some way of making it so agents may make a decision to drop the skirmish behaviour and draw melee weapons and stand and fight instead? For example, if cavalry gets within their minimum range?
Sure, you'll want to edit the main skirmish script to check for that, after this runs:
(call_script, "script_get_closest3_distance_of_enemies_at_pos1", ":team", pos1), # Find distance of nearest 3 enemies

Since that script only gets the distance, but not the closest agent, you might want to add a line or two to that native script.
For instance, after these lines:
Code:
          (lt, ":cur_dist", ":min_distance_1"),
          (assign, ":min_distance_3", ":min_distance_2"),
          (assign, ":min_distance_2", ":min_distance_1"),
          (assign, ":min_distance_1", ":cur_dist"),
I would add (assign, reg4, ":cur_agent"), #Added for Skirmish

Then you can use the agent ID stored in reg4 to check if the closest agent is mounted, etc, once back in the main skirmish script.

Perhaps something as simple as:
Code:
             (call_script, "script_get_closest3_distance_of_enemies_at_pos1", ":team", pos1), # Find distance of nearest 3 enemies
             (assign, ":avg_dist", reg0),
             (assign, ":closest_dist", reg1),
             (assign, ":closest_enemy", reg4), #NEW LINE
             (agent_get_horse, ":horse", ":closest_enemy"), #NEW LINE
             (try_begin),
                 (this_or_next|lt, ":avg_dist", skirmish_min_distance),
                 (lt, ":closest_dist", 700), #If enemy group is getting near or an enemy is on top of agent
                 (eq, ":horse", -1), #NEW LINE - No horse
                 (agent_start_running_away, ":agent"),         
             (else_try),    
                 (this_or_next|ge, ":horse", 0), #NEW LINE - has horse
                 (ge, ":avg_dist", skirmish_max_distance), #If distance from enemy is (too) large, resume previous order
                 (agent_stop_running_away, ":agent"),         
             (try_end), #Distance to enemy

That doesn't cover equipping a melee weapon, but that could be done after the (agent_stop_running_away) operation.
 
What exactly does "skirmish" mean?
I watched the videos on the first page of the thread, does it mean archers avoid melee?

One stupid question, sorry but I'm a woman. On the other hand, I know lots of other things concerning M&B!  :razz:
 
Back
Top Bottom