Universal script for losing faction relation when fighting non-lord parties?

Users who are viewing this thread

solecist

Sergeant
I've done some really shady workarounds, like putting in some faction loss into certain dialog options that occur before attacking someone, but it seems fairly flawed. Is there anyway I can make a universal script that will cause loss of relation with a faction upon fighting them?

Thanks in advance.
 
I've been trying to achieve the same thing, but I haven't made much progress. I'm using a tweak that allows the player to attack either party during pre-join (a battle already taking place), but when I join a side, I don't loose any relation with the faction I joined up against. The freedom to attack anyone is a nice addition, but it's pretty unbalanced since the consequences for joining against another faction are almost nonexistent (unless you take a lord prisoner after the fight). So far, I've tried adding a small script in the pre_join menu right before you attack the enemy, but it was bugged out and hardly worked...

That being said, you should check out module_game_menu and search for "encounter_attack" and see if there's a way to deal negative relation before a battle.

Regarding a universal relation script, the only mod I can think of that's implemented something similar is the old "Bandit King" mod. If I recall correctly, they created a witness script that dealt relation damage after a battle, depending on what parties where nearby to 'witness' the attack. So, if the player just finished fighting some mountain bandits, and a Lord party was nearby, you'd gain a relation boost with that lord/faction. Likewise, if you attacked a faction caravan and a lord of the same faction witnessed it, you'd suffer a relation hit.

If you want to take a look at the witness source, It's right here:
http://banditking.googlecode.com/svn/tags/ (The witness script is near the bottom of module_scripts)

Besides that, I'm not sure, Although I do know that being able to gain/loose relation with all the factions (including bandits) would be a welcome addition to the game.   
 
I sort of figured it out, man. Check out this pre_join code. Seems to work fine (only tested it once, though).

Code:
  (
    "pre_join",0,
    "You come across a battle between {s2} and {s1}. You decide to...",
    "none",
    [
        (str_store_party_name, 1,"$g_encountered_party"),
        (str_store_party_name, 2,"$g_encountered_party_2"),
    
      ],
    [
      ("pre_join_help_attackers",[
          #(store_faction_of_party, ":attacker_faction", "$g_encountered_party_2"),
          #(store_relation, ":attacker_relation", ":attacker_faction", "fac_player_supporters_faction"),
          #(store_faction_of_party, ":defender_faction", "$g_encountered_party"),
          #(store_relation, ":defender_relation", ":defender_faction", "fac_player_supporters_faction"),
          #(ge, ":attacker_relation", 0),
         # (lt, ":defender_relation", 0),
          ],
          "Move in to help the {s2}.",[
              (select_enemy,0),
              (store_faction_of_party, ":attacker_faction", "$g_encountered_party_2"),
              (store_faction_of_party, ":defender_faction", "$g_encountered_party"),                   
              (call_script, "script_change_player_relation_with_faction", ":attacker_faction", 5),
              (call_script, "script_change_player_relation_with_faction", ":defender_faction", -5),              
              (assign,"$g_enemy_party","$g_encountered_party"),
              (assign,"$g_ally_party","$g_encountered_party_2"),
              (jump_to_menu,"mnu_join_battle")]),
      ("pre_join_help_defenders",[
          #(store_faction_of_party, ":attacker_faction", "$g_encountered_party_2"),
          #(store_relation, ":attacker_relation", ":attacker_faction", "fac_player_supporters_faction"),
          #(store_faction_of_party, ":defender_faction", "$g_encountered_party"),
          #(store_relation, ":defender_relation", ":defender_faction", "fac_player_supporters_faction"),
          #(ge, ":defender_relation", 0),
          #(lt, ":attacker_relation", 0),
          ],
          "Rush to the aid of the {s1}.",[
              (select_enemy,1),
              (store_faction_of_party, ":attacker_faction", "$g_encountered_party_2"),
              (store_faction_of_party, ":defender_faction", "$g_encountered_party"),                     
              (call_script, "script_change_player_relation_with_faction", ":attacker_faction", -5),
              (call_script, "script_change_player_relation_with_faction", ":defender_faction", 5),
              (assign,"$g_enemy_party","$g_encountered_party_2"),
              (assign,"$g_ally_party","$g_encountered_party"),
              (jump_to_menu,"mnu_join_battle")]),
      ("pre_join_leave",[],"Don't get involved.",[(leave_encounter),(change_screen_return)]),
    ]
  ),
 
Damn, that's all you had to do? I've been tweaking those lines around for days trying to find something that works without errors...

Anyways, it works great, simple and effective. Although, there is a minor balance issue; The player can constantly leave/rejoin the pre-battle, and still rack up his relation gains/penalties. You could max out your relation with a Kingdom without even fighting. This might not be so bad if your joining a battle between two kingdoms (the negative relation tradeoff balances things out), but if your helping a Kingdom Lord against some hostile bandits, it becomes more exploitable. However, this isn't a major issue if your actually playing the game normally, so it's not game-breaking.

Thanks for posting the code, by the way. I've created some new bandit factions for a personal mod, so this will be very useful. You might consider posting this in TML's tweaks as well, since it should work as a text modification.
 
Hmm, good point on the exploit. I'm not too up on this stuff but I'll try and figure it out. Wish some python nerd would come in here and fix it with two lines of code. :razz:
 
Alright, here's a slight workaround. I know there will be something about this that will cause some sort of unforeseen issue, but I tested it quite a bit and haven't noticed any major issues.

What this does is set the faction relations back to what they were before the battle started, but only when you click "Leave". So if you get out of battle some other way (like retreating then rejoining), you can still spam your relation up...but at least this way it's much more time-consuming and morale-damaging.

Anyway, a few dozen lines below pre_join you'll see "join_leave" (it's below join_attack and join_order_attack). Just make sure your code looks like this:

Code:
      ("join_leave",[],"Leave.",[
  
        (try_begin),
           (neg|troop_is_wounded, "trp_player"),
           (call_script, "script_objectionable_action", tmt_aristocratic, "str_flee_battle"),
           (party_stack_get_troop_id, ":enemy_leader","$g_enemy_party",0),
           (call_script, "script_add_log_entry", logent_player_retreated_from_lord, "trp_player",  -1, ":enemy_leader", -1),
                         #NEW SECTION 
                          (store_faction_of_party, ":enemy_faction", "$g_enemy_party"),
                          (store_faction_of_party, ":ally_faction", "$g_ally_party"),                     
                          (call_script, "script_change_player_relation_with_faction", ":enemy_faction", 5),
                          (call_script, "script_change_player_relation_with_faction", ":ally_faction", -5),   
                        #END NEW
           (display_message, "@Player retreats from battle"),
        (try_end),

          (leave_encounter),(change_screen_return)]),
    ]
  ),
 
Back
Top Bottom