OSP Code Campaign [WB] Village Raids & Sieges--Allow Player Party Actions

Users who are viewing this thread

Village Raids
The inability for the player to flee from an encroaching enemy while raiding a village has been a frequently voiced "beef" throughout the forum. Not having seen anyone look into this, I thought I'd do so and post what I worked out.

For whatever they are worth, the following minor bits of code/tweaks allow the player's party to behave akin to an NPC lord's party during a village raid: they can move within a certain radius of the village with the raid continuing and if they move beyond this radius, the raid is terminated. At half the limit distance, a menu appears, asking if the player wants to continue the raid, serving as a warning.

Since some Native code needs to be tweaked, I've marked the edited Native code with three comment hashes ###

I've included notes to indicate lines that could be commented out to force the player to hold Spacebar or CTRL+Spacebar for time to pass...this would also give them more fine tuned control for reacting to an enemy party. I've marked these lines ###OPTIONAL COMMENT OUT

This Native trigger needs to be tweaked
Code:
#Player raiding a village
# This trigger will check if player's raid has been completed and will lead control to village menu.
  (1,
   [
      (ge,"$g_player_raiding_village",1),
      (try_begin),
        (neq, "$g_player_is_captive", 0),
        #(rest_for_hours, 0, 0, 0), #stop resting - abort
        (assign,"$g_player_raiding_village",0),
     ### (else_try),         ###Remove this entire Else-Try###
       ### (map_free), #we have been attacked during raid
       ### (assign,"$g_player_raiding_village",0),
      (else_try),
        (this_or_next|party_slot_eq, "$g_player_raiding_village", slot_village_state, svs_looted),
        (party_slot_eq, "$g_player_raiding_village", slot_village_state, svs_deserted),
        (start_encounter, "$g_player_raiding_village"),
        (rest_for_hours, 0),
        (assign,"$g_player_raiding_village",0),
        (assign,"$g_player_raid_complete",1),
      (else_try),
        (party_slot_eq, "$g_player_raiding_village", slot_village_state, svs_being_raided),
        (rest_for_hours_interactive, 3, 5, 1), #rest while attackable    ###CHANGE rest_for_hours to rest_for_hours_interactive; ###OPTIONAL COMMENT OUT
      (else_try),
        (rest_for_hours, 0, 0, 0), #stop resting - abort
        (assign,"$g_player_raiding_village",0),
        (assign,"$g_player_raid_complete",0),
      (try_end),
    ]),
Add this trigger immediately following the above.
Code:
(0.25,
   [
      (ge,"$g_player_raiding_village",1),
      (store_distance_to_party_from_party, ":distance", "$g_player_raiding_village", "p_main_party"),
      (try_begin),
        (gt, ":distance", raid_distance),
        (str_store_party_name_link, s1, "$g_player_raiding_village"),
        (display_message, "@You have broken off your raid of {s1}."),
        (call_script, "script_village_set_state", "$current_town", 0),
        (party_set_slot, "$current_town", slot_village_raided_by, -1),
        (assign, "$g_player_raiding_village", 0),
        (rest_for_hours, 0, 0, 0), #stop resting - abort
      (else_try),
        (ge, ":distance", raid_distance / 2),
        (map_free),
        (jump_to_menu, "mnu_village_loot_continue"),
      (try_end),
    ]), 
Change (rest_for_hours,  to (rest_for_hours_interactive,  in the following menu options
Code:
(
    "village_loot_no_resist",0,
  //...//
    [
       ("village_loot",[], "Plunder the village, then raze it.",
        //...//
          (rest_for_hours_interactive, 3, 5, 1), #rest while attackable (3 hours will be extended by the trigger)  ###HERE ###OPTIONAL COMMENT OUT
          (change_screen_return),

//...//
(
    "village_loot_continue",0,
//...//
("disembark_yes",[],"Yes.",[ (rest_for_hours_interactive, 3, 5, 1), #rest while attackable (3 hours will be extended by the trigger)  ###OPTIONAL COMMENT OUT
                              (change_screen_return),
                              ]),

 
Sieges
The inability for the player to access their inventory or party window during a siege has been a frequently voiced "beef" throughout the forum. Not having seen anyone look into this, I thought I'd do so and post what I worked out.

For whatever they are worth, the following minor bits of code/tweaks allow the player to have some added flexibility when besieging a town or castle: they player can exit from the auto-rest and access whichever menus they choose, without canceling the siege. Further, they can move within a certain radius of the besieged center with the siege continuing and if they move beyond this radius, the siege is terminated. At half the limited distance, a message scrolls on screen, notifying the player that their siege lines are stretched too thin and serving as a warning.

Since some Native code needs to be tweaked, I've marked the edited Native code with three comment hashes ###

This Native trigger needs to be tweaked: one else_try block needs to be commented out
Code:
#Auto-menu
  (0,
   [          
     (try_begin),
       (gt, "$g_last_rest_center", 0),
       (party_get_battle_opponent, ":besieger_party", "$g_last_rest_center"),
       (gt, ":besieger_party", 0),
       (store_faction_of_party, ":encountered_faction", "$g_last_rest_center"),
       (store_relation, ":faction_relation", ":encountered_faction", "fac_player_supporters_faction"),
       (store_faction_of_party, ":besieger_party_faction", ":besieger_party"),
       (store_relation, ":besieger_party_relation", ":besieger_party_faction", "fac_player_supporters_faction"),
       (ge, ":faction_relation", 0),
       (lt, ":besieger_party_relation", 0),
       (start_encounter, "$g_last_rest_center"),
       (rest_for_hours, 0, 0, 0), #stop resting
     (else_try),
       (store_current_hours, ":cur_hours"),
       (assign, ":check", 0),
       (try_begin),
         (neq, "$g_check_autos_at_hour", 0),
         (ge, ":cur_hours", "$g_check_autos_at_hour"),
         (assign, ":check", 1),
         (assign, "$g_check_autos_at_hour", 0),
       (try_end),
       (this_or_next|eq, ":check", 1),
       (map_free),
       (try_begin),
         (ge,"$auto_menu",1),
         (jump_to_menu,"$auto_menu"),
         (assign,"$auto_menu",-1),
       (else_try),
         (ge,"$auto_enter_town",1),
         (start_encounter, "$auto_enter_town"),
       #(else_try),  ### Comment out this entire else_try
         #(ge,"$auto_besiege_town",1), ### Here
         #(start_encounter, "$auto_besiege_town"), ###And here, too
       (else_try),
         (ge,"$g_camp_mode", 1),
         (assign, "$g_camp_mode", 0),
         (assign, "$g_infinite_camping", 0),
         (assign, "$g_player_icon_state", pis_normal),
         
         (rest_for_hours, 0, 0, 0), #stop camping
                  
         (display_message, "@Breaking camp..."),
       (try_end),
     (try_end),
     ]),
Add this trigger immediately following the above.
Code:
 (0.25,
   [
      (gt,"$auto_besiege_town",0),
      (gt,"$g_player_besiege_town", 0),
      (ge, "$g_siege_method", 1),
   
      (store_distance_to_party_from_party, ":distance", "$g_player_besiege_town", "p_main_party"),
      (try_begin),
        (gt, ":distance", raid_distance / 2),
        (str_store_party_name_link, s1, "$g_player_besiege_town"),
        (display_message, "@You have broken off your siege of {s1}."),
        (call_script, "script_lift_siege", "$g_player_besiege_town", 0),
        (assign, "$g_player_besiege_town", -1),
        (rest_for_hours, 0, 0, 0), #stop resting - abort
      (else_try),
        (ge, ":distance", raid_distance / 3),
        (map_free),
        (str_store_party_name_link, s1, "$g_player_besiege_town"),
        (display_message, "@You cannot maintain your siege of {s1} from this distance. You risk your lines breaking."),
      (else_try),
        (store_current_hours, ":cur_hours"),
        (ge, ":cur_hours", "$g_siege_method_finish_hours"),
        (neg|is_currently_night),
        (rest_for_hours, 0, 0, 0), #stop resting, if resting
        (start_encounter, "$auto_besiege_town"),
      (try_end),
    ]),
 
Sorry, I'm new at this.  I want to use the spacebar to make time pass, but I"m not quite sure what to change to implement that.  I have changed the text as described in the first spoiler, but I don't know how to modify it for the spacebar time pass.  I also don't understand what to do with the second spoiler info.
 
.. holy... how can I not have seen this yet? This is rather interesting. If I'm reading this(the second this) allows the player to access the party screen while waiting after declaring a siege and before actually fighting it? Very nice, very nice. Baffling that I'd not seen it. :sad:

@Ed; I'm sorry but I'm not able to answer you. :razz:
 
OK I finally realised I was looking in the wrong file for the second spoiler for the raid tweak so I figured that out, but I'm still not sure how to change it to time lapse with the space bar.  The ### lines say "CHANGE rest_for_hours to rest_for_hours_interactive", but the text already reads "rest_for_hours_interactive".
 
Sayd Ûthman said:
Excellent !!
FrisianDude said:
.. holy... how can I not have seen this yet? This is rather interesting. If I'm reading this(the second this) allows the player to access the party screen while waiting after declaring a siege and before actually fighting it? Very nice, very nice. Baffling that I'd not seen it. :sad:
Nice to have folks see this, might see some more use now. So thanks for the question edbzoso, heh!

As for Frisian, yes you are reading it correctly. You need to click to stop the auto-rest that happens when you start a siege, but then you should be able to do whatever you'd like. If you get too far away, the siege auto-cancels, but you are warned. Only caveat is once you've stopped the auto-rest, you need to hold down spacebar or ctrl-spacebar yourself. (I didn't bother to code a button/option to start the automatic rest up again as it didn't seem particularly necessary.)

edbzoso said:
OK I finally realised I was looking in the wrong file for the second spoiler for the raid tweak so I figured that out, but I'm still not sure how to change it to time lapse with the space bar.  The ### lines say "CHANGE rest_for_hours to rest_for_hours_interactive", but the text already reads "rest_for_hours_interactive".
In the Native module system, module_simple_triggers it does not include the _interactive part, so above notes both how it should look at the change made. Once you locate that line in simple_triggers you either can include _interactive OR place a hash mark (#) at the front of the line. The hash mark will comment the line out, so it isn't used, which will force you to use spacebar to pass time while raiding. (The same goes for the module_game_menus changed. Either add "_interactive" or add a hash to the beginning of those lines.)
 
I'm having troubles installing this or placing this into the game..
Is it the simple_trigger.txt I gotta modify?
Or what is?
I'm very confused..
 
deagon said:
I'm having troubles installing this or placing this into the game..
Is it the simple_trigger.txt I gotta modify?
Or what is?
I'm very confused..
You'll need to download the source code, or the "module system" and edit those files. Then you'll compile new .txt files. There are tutorials and the module system download in the main Forge board and the 'Unofficial Tutorials' sub-board for getting this setup.
 
Hi, I could use some help pls.  :smile: I play a mod, let's say Native Expansion, and I'd like to implement your edited village raiding script. So I removed that (else-try) block from the native module system, added the second script right after, and compiled it. Then I took new rows corresponding with those scripts from simple_triggers.txt (one starting with 1.000000, the other with 0.250000) and placed it into NE's simple_triggers.txt (replacing the first one, adding the second one). I also added "breaking_off_raid" string to NE's quick_string.txt... So, that should do it, shouldn't it? Am I missing something important or doing something terribly wrong?

Edit: I assume those "rest_for_hours" to "rest_for_hours_interactive" changes don't affect the basic idea, which is the ability to break off raid..
 
melchar said:
Hi, I could use some help pls.  :smile: I play a mod, let's say Native Expansion, and I'd like to implement your edited village raiding script. So I removed that (else-try) block from the native module system, added the second script right after, and compiled it. Then I took new rows corresponding with those scripts from simple_triggers.txt (one starting with 1.000000, the other with 0.250000) and placed it into NE's simple_triggers.txt (replacing the first one, adding the second one). I also added "breaking_off_raid" string to NE's quick_string.txt... So, that should do it, shouldn't it? Am I missing something important or doing something terribly wrong?

Edit: I assume those "rest_for_hours" to "rest_for_hours_interactive" changes don't affect the basic idea, which is the ability to break off raid..

Well, the address of global variables used by NE may be not the same as at the native Module System. That can make your copied simple trigger mess your game.
 
dunde said:
melchar said:
Hi, I could use some help pls.  :smile: I play a mod, let's say Native Expansion, and I'd like to implement your edited village raiding script. So I removed that (else-try) block from the native module system, added the second script right after, and compiled it. Then I took new rows corresponding with those scripts from simple_triggers.txt (one starting with 1.000000, the other with 0.250000) and placed it into NE's simple_triggers.txt (replacing the first one, adding the second one). I also added "breaking_off_raid" string to NE's quick_string.txt... So, that should do it, shouldn't it? Am I missing something important or doing something terribly wrong?

Edit: I assume those "rest_for_hours" to "rest_for_hours_interactive" changes don't affect the basic idea, which is the ability to break off raid..

Well, the address of global variables used by NE may be not the same as at the native Module System. That can make your copied simple trigger mess your game.

Hm, I've just tried to replace the original Native files with newly compiled ones, but the raids remain unchanged in my native game, too. Do I have to start new game or something?
 
thanks :lol: working for native. Although trying to make it work in NE is just a waste of time, I guess.. nevermind.
 
Caba`drin said:
Sieges
The inability for the player to access their inventory or party window during a siege has been a frequently voiced "beef" throughout the forum. Not having seen anyone look into this, I thought I'd do so and post what I worked out.

For whatever they are worth, the following minor bits of code/tweaks allow the player to have some added flexibility when besieging a town or castle: they player can exit from the auto-rest and access whichever menus they choose, without canceling the siege. Further, they can move within a certain radius of the besieged center with the siege continuing and if they move beyond this radius, the siege is terminated. At half the limited distance, a message scrolls on screen, notifying the player that their siege lines are stretched too thin and serving as a warning.

Since some Native code needs to be tweaked, I've marked the edited Native code with three comment hashes ###

This Native trigger needs to be tweaked: one else_try block needs to be commented out
Code:
#Auto-menu
  (0,
   [          
     (try_begin),
       (gt, "$g_last_rest_center", 0),
       (party_get_battle_opponent, ":besieger_party", "$g_last_rest_center"),
       (gt, ":besieger_party", 0),
       (store_faction_of_party, ":encountered_faction", "$g_last_rest_center"),
       (store_relation, ":faction_relation", ":encountered_faction", "fac_player_supporters_faction"),
       (store_faction_of_party, ":besieger_party_faction", ":besieger_party"),
       (store_relation, ":besieger_party_relation", ":besieger_party_faction", "fac_player_supporters_faction"),
       (ge, ":faction_relation", 0),
       (lt, ":besieger_party_relation", 0),
       (start_encounter, "$g_last_rest_center"),
       (rest_for_hours, 0, 0, 0), #stop resting
     (else_try),
       (store_current_hours, ":cur_hours"),
       (assign, ":check", 0),
       (try_begin),
         (neq, "$g_check_autos_at_hour", 0),
         (ge, ":cur_hours", "$g_check_autos_at_hour"),
         (assign, ":check", 1),
         (assign, "$g_check_autos_at_hour", 0),
       (try_end),
       (this_or_next|eq, ":check", 1),
       (map_free),
       (try_begin),
         (ge,"$auto_menu",1),
         (jump_to_menu,"$auto_menu"),
         (assign,"$auto_menu",-1),
       (else_try),
         (ge,"$auto_enter_town",1),
         (start_encounter, "$auto_enter_town"),
       #(else_try),  ### Comment out this entire else_try
         #(ge,"$auto_besiege_town",1), ### Here
         #(start_encounter, "$auto_besiege_town"), ###And here, too
       (else_try),
         (ge,"$g_camp_mode", 1),
         (assign, "$g_camp_mode", 0),
         (assign, "$g_infinite_camping", 0),
         (assign, "$g_player_icon_state", pis_normal),
         
         (rest_for_hours, 0, 0, 0), #stop camping
                  
         (display_message, "@Breaking camp..."),
       (try_end),
     (try_end),
     ]),
Add this trigger immediately following the above.
Code:
 (0.25,
   [
      (gt,"$auto_besiege_town",0),
      (gt,"$g_player_besiege_town", 0),
      (ge, "$g_siege_method", 1),
   
      (store_distance_to_party_from_party, ":distance", "$g_player_besiege_town", "p_main_party"),
      (try_begin),
        (gt, ":distance", raid_distance / 2),
        (str_store_party_name_link, s1, "$g_player_besiege_town"),
        (display_message, "@You have broken off your siege of {s1}."),
        (call_script, "script_lift_siege", "$g_player_besiege_town", 0),
        (assign, "$g_player_besiege_town", -1),
        (rest_for_hours, 0, 0, 0), #stop resting - abort
      (else_try),
        (ge, ":distance", raid_distance / 3),
        (map_free),
        (str_store_party_name_link, s1, "$g_player_besiege_town"),
        (display_message, "@You cannot maintain your siege of {s1} from this distance. You risk your lines breaking."),
      (else_try),
        (store_current_hours, ":cur_hours"),
        (ge, ":cur_hours", "$g_siege_method_finish_hours"),
        (neg|is_currently_night),
        (rest_for_hours, 0, 0, 0), #stop resting, if resting
        (start_encounter, "$auto_besiege_town"),
      (try_end),
    ]),

this might be old but i have a problem
i managed to get the village one working but the siege it doesn't work anymore why ? -latest module system) i can move around but that will insta break siege without any notification and when i try to siege it again i'll have to wait without moving another thing is after waiting the ladder building when ever i click wait another day it insta go to camp map then back to the siege menu (i think this is due to the rest disabled) any idea how can i make it work ?
 
Back
Top Bottom