Making neutral factions to take sides during battle

正在查看此主题的用户

Cloud Breaker

Master Knight
I believe I found the relevant code here.

# script_let_nearby_parties_join_current_battle
  # Input: arg1 = besiege_mode, arg2 = dont_add_friends
  # Output: none
  ("let_nearby_parties_join_current_battle",
    [
      (store_script_param, ":besiege_mode", 1),
      (store_script_param, ":dont_add_friends", 2),
      (assign, ":join_distance", 5),
      (try_begin),
        (is_currently_night),
        (assign, ":join_distance", 3),
      (try_end),
      (try_for_parties, ":party_no"),
        (party_get_battle_opponent, ":eek:pponent",":party_no"),
        (lt, ":eek:pponent", 0), #party is not itself involved in a battle
        (party_get_attached_to, ":attached_to",":party_no"),
        (lt, ":attached_to", 0), #party is not attached to another party
        (get_party_ai_behavior, ":behavior", ":party_no"),
        (neq, ":behavior", ai_bhvr_in_town),

     
        (store_distance_to_party_from_party, ":distance", ":party_no", "p_main_party"),
        (lt, ":distance", ":join_distance"),

        (store_faction_of_party, ":faction_no", ":party_no"),
        (store_faction_of_party, ":enemy_faction", "$g_enemy_party"),
        (try_begin),
          (eq, ":faction_no", "fac_player_supporters_faction"),
          (assign, ":reln_with_player", 100),
        (else_try),
          (store_relation, ":reln_with_player", ":faction_no", "fac_player_supporters_faction"),
        (try_end),
        (try_begin),
          (eq, ":faction_no", ":enemy_faction"),
          (assign, ":reln_with_enemy", 100),
        (else_try),
          (store_relation, ":reln_with_enemy", ":faction_no", ":enemy_faction"),
        (try_end),

        (assign, ":enemy_side", 1),
        (try_begin),
          (neq, "$g_enemy_party", "$g_encountered_party"),
          (assign, ":enemy_side", 2),
        (try_end),

        (try_begin),
          (eq, ":besiege_mode", 0),
          (lt, ":reln_with_player", 0),
          (gt, ":reln_with_enemy", 0),
          (party_get_slot, ":party_type", ":party_no"),
          (eq, ":party_type", spt_kingdom_hero_party),
          (get_party_ai_behavior, ":ai_bhvr", ":party_no"),
          (neq, ":ai_bhvr", ai_bhvr_avoid_party),
          (party_quick_attach_to_current_battle, ":party_no", ":enemy_side"), #attach as enemy
          (str_store_party_name, s1, ":party_no"),
          (display_message, "str_s1_joined_battle_enemy"),
        (else_try),
          (eq, ":dont_add_friends", 0),
          (gt, ":reln_with_player", 0),
          (lt, ":reln_with_enemy", 0),
          (assign, ":do_join", 1),
          (try_begin),
            (eq, ":besiege_mode", 1),
            (assign, ":do_join", 0),
            (eq, ":faction_no", "$players_kingdom"),
            (faction_slot_eq, "$players_kingdom", slot_faction_marshall, "trp_player"),
            (assign, ":do_join", 1),
          (try_end),
          (eq, ":do_join", 1),
          (party_get_slot, ":party_type", ":party_no"),
          (eq, ":party_type", spt_kingdom_hero_party),
          (party_stack_get_troop_id, ":leader", ":party_no", 0),
  #      (troop_get_slot, ":player_relation", ":leader", slot_troop_player_relation),
          (call_script, "script_troop_get_player_relation", ":leader"),
          (assign, ":player_relation", reg0),
          (ge, ":player_relation", 0),
          (party_quick_attach_to_current_battle, ":party_no", 0), #attach as friend
          (str_store_party_name, s1, ":party_no"),
          (display_message, "str_s1_joined_battle_friend"),
        (try_end),
      (try_end),
  ]),
   
  # script_party_wound_all_members_aux
  # Input: arg1 = party_no
  ("party_wound_all_members_aux",
    [
      (store_script_param_1, ":party_no"),
     
      (party_get_num_companion_stacks, ":num_stacks",":party_no"),
      (try_for_range, ":i_stack", 0, ":num_stacks"),
        (party_stack_get_troop_id, ":stack_troop",":party_no",":i_stack"),
        (try_begin),
          (neg|troop_is_hero, ":stack_troop"),
          (party_stack_get_size, ":stack_size",":party_no",":i_stack"),
          (party_wound_members, ":party_no", ":stack_troop", ":stack_size"),
        (else_try),
          (troop_set_health, ":stack_troop", 0),
        (try_end),
      (try_end),
      (party_get_num_attached_parties, ":num_attached_parties", ":party_no"),
      (try_for_range, ":attached_party_rank", 0, ":num_attached_parties"),
        (party_get_attached_party_with_rank, ":attached_party", ":party_no", ":attached_party_rank"),
        (call_script, "script_party_wound_all_members_aux", ":attached_party"),
      (try_end),
     
  ]),

I'm trying to make bandit/deserter parties to gang up on me, and manhunters to help me when fighting against bandits/deserters.

My guess is that I need to make the script that define manhunters as ally to the PC.       
(eq, ":faction_no", "fac_player_supporters_faction"),
Problem there would be that manhunters will aid the PC even when his opponent is not a bandit party.

Same with deserters and bandits, who'd help whoever my opponent is, regardless of what faction they belong to.
(store_faction_of_party, ":enemy_faction", "$g_enemy_party"),

I need help.
 
magelord already did this if im not mistaken.

http://forums.taleworlds.com/index.php/topic,46290.msg1226161.html#msg1226161
 
If I understand this right, you want bandits/deserters to gang up on you, but only when you're already fighting a bandit/deserter party, and you want manhunters to help you, but only when your fighting a bandit/deserter party.

you need to add some logic in the join_battles script to check for which party template you are fighting. You'll need to store the template id of the first party you come in contact with, $g_encountered_party_template, and compare that with the party you're trying to attach to the battle, :template_of_party_to_attach. If :template_of_party_to_attach is one of the bandit or deserter templates, and your not fighting a bandit or deserter template, fail the script. Likewise, if :template_of_party_to_attach is pt_manhunter, aif you're not fighting a bandit or manhunter type, fail the script.
 
后退
顶部 底部