[WB] Scripting question - Modding prisoner limit (Solved)

Users who are viewing this thread

Woden87

Recruit
I'm trying to make a custom mod using the Module System, with the intention of making the prisoner limit scale with party size. I've already coded it, and it seemed like it initially worked when I tested it (I had a prisoner limit of one with zero Prisoner Management skill), but I got a CTD after walking around for a bit on the world map. It was less than a day total into the game, and happened briefly after I fought a group of looters and took one prisoner (so I'm not certain if having that prisoner was part of the cause or not). Further testing has not resulted in any more CTDs, but I am getting the red script error text every time the game checks the prisoner limit, and the limit is not changing from that initial value of one.

This is being tested on Warband 1.158, steam version, as an add-on to the Floris 2.55 Expanded mod pack (making it using their Module System-based source kit), if any of that matters.

I'm still very much an amateur with the scripting language M&B uses, so I'd appreciate any help.

rgl.log crash data:
SCRIPT ERROR ON OPCODE 21: Invalid Script Parameter ID: 0; LINE NO: 0:
At script: game_get_party_prisoner_limit. ERROR: Hash vector failed at index 1143

Modified game_get_party_prisoner_limit script:
Code:
    #script_game_get_party_prisoner_limit:
    # This script is called from the game engine when the prisoner limit is needed for a party.
    # INPUT: arg1 = party_no
    # OUTPUT: reg0 = prisoner_limit
    ("game_get_party_prisoner_limit",
      [
        (store_script_param, ":party_no", 1),
        (assign, ":troop_no", "trp_player"),
        (store_party_size_wo_prisoners, ":party_size", ":party_no"),
        
        (store_skill_level, ":skill", "skl_prisoner_management", ":troop_no"),
        (assign, ":limit", ":skill"),
        (store_sub, ":divisor", 15, ":skill"),
        (val_div, ":party_size", ":divisor"),
        (val_add, ":limit", ":party_size"),
        (val_max, ":limit", 1), # Always allow at least one prisoner slot, for capturing lords
		
        (assign, reg0, ":limit"),
        (set_trigger_result, reg0),
    ]),


Edit: I noticed that the first line of code (storing the input parameter) had improper syntax; that one had already been presented but commented out, and I didn't notice the error. Correcting the syntax on that line doesn't seem to fix the script, though.


Edit 2: I've played with it some more, and have a new version that seems to be working. Here it is if anyone else wants to see it:

Code:
    #script_game_get_party_prisoner_limit:
    # This script is called from the game engine when the prisoner limit is needed for a party.
    # INPUT: arg1 = party_no
    # OUTPUT: reg0 = prisoner_limit
    ("game_get_party_prisoner_limit",
      [
        (store_party_size_wo_prisoners, ":party_size", "p_main_party"),
        (store_skill_level, ":skill", "skl_prisoner_management", "trp_player"),
		
        # Prisoner limit = (Prisoner Management * 2) + (Party size / (12 - Party Management, to a minimum value of 2)), with one prisoner slot guaranteed.
		
        (store_mul, ":limit", ":skill", 2),
        (store_sub, ":divisor", 12, ":skill"),
        (val_max, ":divisor", 2),
        (val_div, ":party_size", ":divisor"),
        (val_add, ":limit", ":party_size"),
        (val_max, ":limit", 1), # Always allow at least one prisoner slot, for capturing lords
        (assign, reg0, ":limit"),
        (set_trigger_result, reg0),
    ]),

I suspect that the function was not actually getting the party input parameter that the comments claimed; changing it to just use a hard reference to the player's party seems to work.



Edit 3: And a more balanced (I feel) version of the tweak.
Formula = (Prisoner Management skill * 2) + ((Party size * (25 + PM skill)) / 100)... resulting in prisoner slots equal to about 25% to about 75% of your party size, depending on skill level.

Module System version:
Code:
    #script_game_get_party_prisoner_limit:
    # This script is called from the game engine when the prisoner limit is needed for a party.
    # INPUT: arg1 = party_no
    # OUTPUT: reg0 = prisoner_limit
    ("game_get_party_prisoner_limit",
      [
        (store_party_size_wo_prisoners, ":party_size", "p_main_party"),
        (store_skill_level, ":skill", "skl_prisoner_management", "trp_player"),
        (store_mul, ":limit", ":skill", 2),
        (store_mul, ":mult", ":skill", 5),
        (val_add, ":mult", 25),
        (val_mul, ":party_size", ":mult"),
        (val_div, ":party_size", 100),
        (val_add, ":limit", ":party_size"),
        (val_max, ":limit", 1), # Always allow at least one prisoner slot, for capturing lords
        (assign, reg0, ":limit"),
        (set_trigger_result, reg0),
    ]),

scripts.txt version:
game_get_party_prisoner_limit -1
11 2157 2 1224979098644774912 648518346341351424 2170 3 1224979098644774913 1369094286720630786 360287970189639680 2122 3 1224979098644774914 1224979098644774913 2 2122 3 1224979098644774915 1224979098644774913 5 2105 2 1224979098644774915 25 2107 2 1224979098644774912 1224979098644774915 2108 2 1224979098644774912 100 2105 2 1224979098644774914 1224979098644774912 2111 2 1224979098644774914 1 2133 2 72057594037927936 1224979098644774914 2075 1 72057594037927936
 
Back
Top Bottom