B Tutorial Other Adding things such as overhead stab, crouching, extra formations options.

Users who are viewing this thread

Hi, I need help with this part.

Formation mod compatibility

Can it be done through the module system? I tried to follow the steps but somewhere I must be wrong because it doesn't work. Also I would like to do it by module system so it is final and I don't have to redo it every time I compile.

Thanks!
 
It can surely be done through the module system, you only have to search for the correct place. Check in mission_templates.py for the mission mst_lead_charge and look around there for the formation triggers which got added in your mod. And then you need to check for which keys are assigned to the commands.
 
It can surely be done through the module system, you only have to search for the correct place. Check in mission_templates.py for the mission mst_lead_charge and look around there for the formation triggers which got added in your mod. And then you need to check for which keys are assigned to the commands.
I've been trying to find that within lead charge, but didn't understand much, I'll search again.

There is no case, I suck at this things.

help?
Code:
(
    "lead_charge",mtf_battle_mode|mtf_synch_inventory,charge,
    "You lead your men to battle.",
    [
     (1,mtef_defenders|mtef_team_0,0,aif_start_alarmed,12,[]),
     (0,mtef_defenders|mtef_team_0,0,aif_start_alarmed,0,[]),
     (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,12,[]),
     (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,0,[]),
     ],
    [
      (ti_on_agent_spawn, 0, 0, [],
       [
         (store_trigger_param_1, ":agent_no"),
         (call_script, "script_agent_reassign_team", ":agent_no"),


         (assign, ":initial_courage_score", 5000),


         (agent_get_troop_id, ":troop_id", ":agent_no"),
         (store_character_level, ":troop_level", ":troop_id"),
         (val_mul, ":troop_level", 35),
         (val_add, ":initial_courage_score", ":troop_level"), #average : 20 * 35 = 700


         (store_random_in_range, ":randomized_addition_courage", 0, 3000), #average : 1500
         (val_add, ":initial_courage_score", ":randomized_addition_courage"),


         (agent_get_party_id, ":agent_party", ":agent_no"),
         (party_get_morale, ":cur_morale", ":agent_party"),


         (store_sub, ":morale_effect_on_courage", ":cur_morale", 70),
         (val_mul, ":morale_effect_on_courage", 30), #this can effect morale with -2100..900
         (val_add, ":initial_courage_score", ":morale_effect_on_courage"),


         #average = 5000 + 700 + 1500 = 7200; min : 5700, max : 8700
         #morale effect = min : -2100(party morale is 0), average : 0(party morale is 70), max : 900(party morale is 100)
         #min starting : 3600, max starting  : 9600, average starting : 7200
         (agent_set_slot, ":agent_no", slot_agent_courage_score, ":initial_courage_score"),
         ]),


      common_battle_init_banner,


      (ti_on_agent_killed_or_wounded, 0, 0, [],
       [
        (store_trigger_param_1, ":dead_agent_no"),
        (store_trigger_param_2, ":killer_agent_no"),
        (store_trigger_param_3, ":is_wounded"),


        (try_begin),
          (ge, ":dead_agent_no", 0),
          (neg|agent_is_ally, ":dead_agent_no"),
          (agent_is_human, ":dead_agent_no"),
          (agent_get_troop_id, ":dead_agent_troop_id", ":dead_agent_no"),
##          (str_store_troop_name, s6, ":dead_agent_troop_id"),
##          (assign, reg0, ":dead_agent_no"),
##          (assign, reg1, ":killer_agent_no"),
##          (assign, reg2, ":is_wounded"),
##          (agent_get_team, reg3, ":dead_agent_no"),
          #(display_message, "@{!}dead agent no : {reg0} ; killer agent no : {reg1} ; is_wounded : {reg2} ; dead agent team : {reg3} ; {s6} is added"),
          (party_add_members, "p_total_enemy_casualties", ":dead_agent_troop_id", 1), #addition_to_p_total_enemy_casualties
          (eq, ":is_wounded", 1),
          (party_wound_members, "p_total_enemy_casualties", ":dead_agent_troop_id", 1),
        (try_end),


        (call_script, "script_apply_death_effect_on_courage_scores", ":dead_agent_no", ":killer_agent_no"),
       ]),


      common_battle_tab_press,


      (ti_question_answered, 0, 0, [],
       [(store_trigger_param_1,":answer"),
        (eq,":answer",0),
        (assign, "$pin_player_fallen", 0),
        (try_begin),
          (store_mission_timer_a, ":elapsed_time"),
          (gt, ":elapsed_time", 20),
          (str_store_string, s5, "str_retreat"),
          (call_script, "script_simulate_retreat", 10, 20, 1),
        (try_end),
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission,0),]),


      (ti_before_mission_start, 0, 0, [],
       [
         (team_set_relation, 0, 2, 1),
         (team_set_relation, 1, 3, 1),
         (call_script, "script_place_player_banner_near_inventory_bms"),


         (party_clear, "p_routed_enemies"),


         (assign, "$g_latest_order_1", 1),
         (assign, "$g_latest_order_2", 1),
         (assign, "$g_latest_order_3", 1),
         (assign, "$g_latest_order_4", 1),
         ]),




      (0, 0, ti_once, [], [(assign,"$g_battle_won",0),
                           (assign,"$defender_reinforcement_stage",0),
                           (assign,"$attacker_reinforcement_stage",0),
                           (call_script, "script_place_player_banner_near_inventory"),
                           (call_script, "script_combat_music_set_situation_with_culture"),
                           (assign, "$g_defender_reinforcement_limit", 2),
                           ##diplomacy begin
                           (call_script, "script_init_death_cam"),
                           # (assign, "$g_dplmc_charge_when_dead", 0),
                           ##diplomacy end
                           ]),


      common_music_situation_update,
      common_battle_check_friendly_kills,


      (1, 0, 5, [


      #new (25.11.09) starts (sdsd = TODO : make a similar code to also helping ally encounters)
      #count all total (not dead) enemy soldiers (in battle area + not currently placed in battle area)
      (call_script, "script_party_count_members_with_full_health", "p_collective_enemy"),
      (assign, ":total_enemy_soldiers", reg0),


      #decrease number of agents already in battle area to find all number of reinforcement enemies
      (assign, ":enemy_soldiers_in_battle_area", 0),
      (try_for_agents,":cur_agent"),
        (agent_is_human, ":cur_agent"),
        (agent_get_party_id, ":agent_party", ":cur_agent"),
        (try_begin),
          (neq, ":agent_party", "p_main_party"),
          (neg|agent_is_ally, ":cur_agent"),
          (val_add, ":enemy_soldiers_in_battle_area", 1),
        (try_end),
      (try_end),
      (store_sub, ":total_enemy_reinforcements", ":total_enemy_soldiers", ":enemy_soldiers_in_battle_area"),


      (try_begin),
        (lt, ":total_enemy_reinforcements", 15),
        (ge, "$defender_reinforcement_stage", 2),
        (eq, "$defender_reinforcement_limit_increased", 0),
        (val_add, "$g_defender_reinforcement_limit", 1),
        (assign, "$defender_reinforcement_limit_increased", 1),
      (try_end),
      #new (25.11.09) ends


      (lt,"$defender_reinforcement_stage","$g_defender_reinforcement_limit"),
                 (store_mission_timer_a,":mission_time"),
                 (ge,":mission_time",10),
                 (store_normalized_team_count,":num_defenders", 0),
                 (lt,":num_defenders",6)],
           [(add_reinforcements_to_entry,0,7),(assign, "$defender_reinforcement_limit_increased", 0),(val_add,"$defender_reinforcement_stage",1)]),


      (1, 0, 5, [(lt,"$attacker_reinforcement_stage",2),
                 (store_mission_timer_a,":mission_time"),
                 (ge,":mission_time",10),
                 (store_normalized_team_count,":num_attackers", 1),
                 (lt,":num_attackers",6)],
           [(add_reinforcements_to_entry,3,7),(val_add,"$attacker_reinforcement_stage",1)]),


      common_battle_check_victory_condition,
      common_battle_victory_display,


      (1, 4,
      ##diplomacy begin
      0,
      ##diplomacy end
      [(main_hero_fallen)],
          [
              ##diplomacy begin
              (try_begin),
                (call_script, "script_cf_dplmc_battle_continuation"),
              (else_try),
                ##diplomacy end
                (assign, "$pin_player_fallen", 1),
                (str_store_string, s5, "str_retreat"),
                (call_script, "script_simulate_retreat", 10, 20, 1),
                (assign, "$g_battle_result", -1),
                (set_mission_result,-1),
                (call_script, "script_count_mission_casualties_from_agents"),
                (finish_mission,0),
                ##diplomacy begin
              (try_end),
              ##diplomacy end
            ]),


      common_battle_inventory,




      #AI Triggers
      # (0, 0, ti_once, [
          # (store_mission_timer_a,":mission_time"),(ge,":mission_time",2),
          # ],
       # [(call_script, "script_select_battle_tactic"),
        # (call_script, "script_battle_tactic_init"),
        # #(call_script, "script_battle_calculate_initial_powers"), #deciding run away method changed and that line is erased
        # ]),
        
      


      (3, 0, 0, [
          (call_script, "script_apply_effect_of_other_people_on_courage_scores"),
              ], []), #calculating and applying effect of people on others courage scores


      (3, 0, 0, [
          (try_for_agents, ":agent_no"),
            (agent_is_human, ":agent_no"),
            (agent_is_alive, ":agent_no"),
            (store_mission_timer_a,":mission_time"),
            (ge,":mission_time",3),
            (call_script, "script_decide_run_away_or_not", ":agent_no", ":mission_time"),
          (try_end),
              ], []), #controlling courage score and if needed deciding to run away for each agent
      
    


      # (5, 0, 0, [
          # (store_mission_timer_a,":mission_time"),


          # (ge,":mission_time",3),


          # (call_script, "script_battle_tactic_apply"),
          # ], []), #applying battle tactic
          
        


      common_battle_order_panel,
      common_battle_order_panel_tick,
      
       ( 0, 2, ti_once, [],
  [
     (get_player_agent_no, ":player_agent"),
     (agent_get_team, ":agent_team", ":player_agent"),
     (team_give_order, ":agent_team", grc_everyone, mordr_hold),    ])
    
      
    
    ]
    ##diplomacy begin
    + dplmc_battle_mode_triggers + dplmc_horse_cull,  #SB : horse cull
    ##diplomacy end
     # (ti_on_agent_spawn, 0, 0,
  # [
   # (ge, "$g_ally_party", 0), # if player has joined already started battle
   # (eq, "$attacker_reinforcement_stage", 0), # and there hasn't been any reinforcements yet
   # (eq, "$defender_reinforcement_stage", 0),
  # ],
  # [
    # (store_trigger_param_1, ":agent"),
    # (assign, ":agent_to_move", -1),
    # (try_begin),
      # (agent_is_human, ":agent"),
      # (agent_get_party_id, ":a_party", ":agent"),
      # (neq, ":a_party", "p_main_party"),
      # (assign, ":agent_to_move", ":agent"),
    # (else_try), 
      # (neg|agent_is_human, ":agent"),
      # (agent_get_rider, ":rider", ":agent"),
      # (agent_get_party_id, ":r_party", ":rider"),
      # (neq, ":r_party", "p_main_party"),
      # (assign, ":agent_to_move", ":agent"),
    # (try_end),   
    # (neq, ":agent_to_move", -1),
    # (get_scene_boundaries, pos10, pos11),
    # (set_fixed_point_multiplier, 100),
    # (position_get_x, "$g_scene_max_x", pos11),
    # (position_get_y, "$g_scene_max_y", pos11),
    # (val_add, "$g_scene_max_x", 2400), # 2400 has been subtracted automatically because of barriers from outer terrain
    # (val_add, "$g_scene_max_y", 2400),
    # (store_div, ":pos_x", "$g_scene_max_x", 2),
    # (store_div, ":pos_y", "$g_scene_max_x", 2),
    # (init_position, pos22), # map center
    # (store_random_in_range, ":x_shift", -1000, 1000),
    # (store_random_in_range, ":y_shift", -1000, 1000),
    # (val_add, ":pos_x", ":x_shift"),
    # (val_add, ":pos_y", ":y_shift"),
    # (position_set_x, pos22, ":pos_x"),
    # (position_set_y, pos22, ":pos_y"),
    # (agent_set_position, ":agent_to_move", pos22),
  # ]),


      ),
 
Last edited:
Brilliant! I understand now, and I got it to work. Thank you very much!
Unfortunately I'm dumb and I still don't understand.

example
Code:
anim_ready_overswing_spear = 478
means this Native animation would be found on that file between entries 477 and 479. If that entry was empty (unused), you would need to count until you found that exact entry number and add it there (not on a random unused animation).

In particular I don't understand where this line of code would be found.
 
In particular I don't understand where this line of code would be found.
You can find the animation ready_overswing_spear in module_animations.py of your Module System. The anim_ prefix is simply the reference to the animation, like itm_ for items or trp_ for troops. They are always unused in the files themselves but used in the other module files as a reference as explained here:

Unfortunately I'm dumb and I still don't understand.
You should never add a new line in module_animations.py but use one of the unused animation entries there.
 
Ahh right. But module_animations is compiled exclusively into actions.txt? I'm trying to add this into ACOK too, which doesn't have the source files released.
Edit:
If I've understood correctly the overswing_spear lines and overswing_musket will have been overwritten by another animation, and if I want to be able to actually use overswing_spear and musket flags then I'll have to use these specific lines, but I don't understand how to find which animations have replaced these lines.
Edit 2: maybe I'm getting it.
 
Last edited:
If you are editing a mod at which you don't have the txt files you need to watch out for the txt file edits in the opening post, not the module file ones. There it is explained how to look for the lines and what to replace them with, read it carefully again.
 
Yes but I have the same problem that Grank had, the overswing_spear lines aren't in these text files and neither are the overswing_musket. The line numbers won't match either.
But if I understand correctly, the tag "overswing_musket" in morghs will mean this item uses animations x,y.z reading down the list in actions.txt, so if I can find which animations are x,y,z then I can write onto these ones if they're not being used already.
 
Ah, just now I understand your problem. Use the normal module system and count on which place the animations are positioned which you want to replace. And then you need to replace exactly the same place of animation with the mentioned ones. So if an animation is on the 20th place, you need to replace the 20th animation at the txt file. They should all have a name at the beginning, so you should be able to count down there.
 
Yeah I managed it with the two handed overhead stab so far, fortunately the equip_bayonet actions were closeby to use as a marker because counting down 500 odd animations would have been a real chore.
 
Is there any way to further improve thrust attacks through manipulating the values present in the actions text file? I want to make spears effective against face hugging ai. Increasing the animation speed doesn't have the desired effect, nor does adjusting the two values that define the range of motion for each segment of the animation. Even changing the range of motion to something absurd like -100->50 doesn't improve their close range performance. I even tried pairing it will manipulating the melee_damage_speed_power line in the module ini as I expected reducing the value would eliminate speed penalty imposed from face hugging enemies, but no luck.

I think there must be some tweak that can be done because I remember playing an old mod with an antiquity theme where spears retained their ability to damage opponents even at close range.

Any suggestions?
 
Back
Top Bottom