thats pretty awesome!! Ill have to try to put in my game
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?
(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
That happens? Never noticed it.Caba`drin said:or until their morale stabilizes and they stop routing.
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
),
Caba`drin said: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.Oddball_E8 said:is there a possibility of getting a video of this in action, im curious as to how well it works...
# 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
]),
(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
]),
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
Don't know how I did that, I'd compiled before I posted... In any case, fixed above.Sayd Ûthman said:Oh the variable :team is not assigned :
(call_script, "script_get_closest3_distance_of_enemies_at_pos1", ":team", pos1),
Sure, you'll want to edit the main skirmish script to check for that, after this runs: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?
(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"),
(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