OSP Code QoL Bodyguards/Escorts in Town/Village Scenes (Open Source)

Users who are viewing this thread

Somebody said:
Entry points 0 and 1 should already use the pilgrim disguise overrides in mt_sneak_caught_fight.
But they are mtf_scene_source, not visitor_source so one cannot ad-hoc spawn a NPC to those entry points in my experience.

...though since that is a different template, I'll need to adjust the code I've posted above. I didn't anticipate folks using that mission template and I forgot it was its own template when I just made the above post.

EDIT - provided alternative trigger, taking the mission template into account, above.
 
Sometimes bodyguards stop to show up (maybe after a negative rep hit ?). They become available again later.
 
Hmm maybe I failed in a quest - because I think plundering an enemy village doesn't alter renown, does it ?

I need to check the code a bit, I don't understand what happens in this case.
 
Is it possible to make it so they can be my regular troops and not just NPCs?
By removing the lines of "is hero" I get one troop of each kind because of the stack. How do I access the rest of the troops?
Basically I'd like to have whatever troops I have first, for example, the first type would be swadian knight, and I have 10 of them. Then the 10 of them should be with me.
 
Code:
    (try_for_range, ":i", 1, ":num_of_stacks"),
        (party_stack_get_troop_id, ":troop_id", "p_main_party", ":i"),
        #(neq, ":troop_id", "trp_player"),
        (try_begin),
          (troop_is_hero, ":troop_id"),
          (neg|troop_is_wounded, ":troop_id"),
          (val_sub, ":max_guards", 1),
        (else_try),
          (party_stack_get_size, ":size", "p_main_party", ":i"),
	  (party_stack_get_num_wounded, ":wounded", "p_main_party", ":i"),
	  (val_sub, ":size", ":wounded"),
          (val_sub, ":max_guards", ":size"),
          (try_begin), #too many
            (lt, ":max_guards", 0),
            (val_add, ":size", ":max_guards"),
          (try_end),
        (try_end),
                
        (try_begin), #For prison-breaks
            (this_or_next|eq, "$talk_context", tc_escape),
            (eq, "$talk_context", tc_prison_break),      
            (troop_set_slot, ":troop_id", slot_troop_will_join_prison_break, 1),
        (try_end),

        (add_visitors_to_current_scene, ":entry_point", ":troop_id", ":size"),

        (le, ":max_guards", 0),
        (assign, ":num_of_stacks", 0), #Break Loop       
    (try_end), #Stack Loop
 
I am sorry for being so newbie in these things...but its mission_templates, ain't it? And it's on the beggining or in the end of it? Thank you
 
Hi guys, I've been using this submod under Floris Expanded Modpack 2.54. The bodyguards have been spawning regularly for me for a large part of my game. But recently, my bodyguard has stopped spawning. My leadership is 5, renown is about 200, and my team is fully healed. This means that I should have one bodyguard with me. I have checked the Mod Options for Enable Bodyguards. Anyone has any idea?
 
Sorry for the thread necro.
I have a basic knowledge of Python, but since the game syntax is not python syntax I'm having a bit of trouble understanding this algorithm.
Am I right in thinking that the algorithm basically works as follows?

>Identifies the scenrario (town centre, tavern, bandit ambush etc.)
>Searches for a valid entry point for the guards
>Gets n number of guards and spawns them at valid entry
>moves them to the position of the player

If so, would it be easy enough for one to add more scenarios to the code, as in, for scenes added by other mods which have the player clearing a location of bandits etc?
They would just have to identify the scenario and add in a new if / try block for the scenario which selects the entry point and from there the algorithm would do the rest?
 
By any chance would anyone have the diplomacy 4.3 with this bit of code in it already written that I could download? when I try putting this script in I get rgl errors
 
Somebody said:
I actually wrote a bodyguard script myself (along the same lines), but used a lot of workarounds so they follow the player and get injured properly in the various encounters (they're spawned agents that are stored in slot_center_mercenary_troop/amount for p_main_party, gets kicked back to the actual party when wounded, etc). Not going to bother digging everything up for now.

I wrote a bunch of debugging scripts to test their functionality. You might find them helpful.
Code:
  (
    "town_cheats",0,
    "Do whatever you want",
    "none",[],
    [

      ("summon_drunk",
      [(party_slot_eq, "$current_town", slot_party_type, spt_town),
       # (troop_get_slot, ":town", "trp_belligerent_drunk", slot_troop_cur_center),
       (try_begin),
         # (is_between, ":town", towns_begin, towns_end),
         (troop_slot_eq, "trp_belligerent_drunk", slot_troop_cur_center, "$current_town"),
         (assign, reg10, 1),
       (else_try),
         (assign, reg10, 0),
       (try_end),
       ],
      "{reg10?Dismiss:Get} a drunkard.",
      [
        (try_begin),
          (eq, reg10, 1), 
          (troop_set_slot, "trp_belligerent_drunk", slot_troop_cur_center, -1),
        (else_try),
          (troop_set_slot, "trp_belligerent_drunk", slot_troop_cur_center, "$current_town"),
        (try_end),
      ]),
      

      ("summon_ass",
      [(party_slot_eq, "$current_town", slot_party_type, spt_town),
       (try_begin),
         # (is_between, ":town", towns_begin, towns_end),
         (troop_slot_eq, "trp_hired_assassin", slot_troop_cur_center, "$current_town"),
         (assign, reg11, 1),
       (else_try),
         (assign, reg11, 0),
       (try_end),
      ],
      "{reg11?Scare away:Hire} an assassin.",
      [
        (try_begin),
          (eq, reg11, 1), 
          (troop_set_slot, "trp_hired_assassin", slot_troop_cur_center, -1),
        (else_try),
          (troop_set_slot, "trp_hired_assassin", slot_troop_cur_center, "$current_town"),
        (try_end),
      ]),

      ("summon_bandit",
      [
       (neg|party_slot_eq, "$current_town", slot_party_type, spt_castle),
       (party_get_slot, reg12, "$current_town", slot_center_has_bandits),
       # (try_begin),
         # (party_slot_ge, "$current_town", slot_center_has_bandits, 1),
         # (assign, reg12, 1),
       # (else_try),
         # (assign, reg12, 0),
       # (try_end).
      ],
      "{reg12?Kick out:Get ambushed by} some bandits.",
      [
       (try_begin), #cleanse
         (ge, reg12, 1),
         (party_set_slot, "$current_town", slot_center_has_bandits, 0),
       (else_try), #ambush
         (store_random_in_range, ":bandit", bandits_begin, bandits_end),
         (party_set_slot, "$current_town", slot_center_has_bandits, ":bandit"),
         (assign, "$town_nighttime", 1),
         (assign, "$sneaked_into_town", 0),
         (assign, "$g_defending_against_siege", 0),
         (call_script, "script_cf_enter_center_location_bandit_check"),
         # (assign, "$town_nighttime", 1),
       (try_end),
      ]),
can i ask you where i should put these in module_scripts.py / module_game_menus.py ?(at the end or the start ?) i'm not yet sure on how to debug thanks
 
Somebody said:
Assuming you're talking about the code it's just a new menu. It's implemented here since that was posted like a decade ago.
ah i see thank you and i assume that file is from diplomacy 1.171 ?  if so well it's gonna be a good practice to see how the menus are added there since i plan to merging it with my mod (didn't use it as a base just to train my self so doing it manualy is the best for me can you give any advice? thanks
and sorry this isn't the right place to ask for it :smile:
 
Back
Top Bottom