Party size morale modifier

Users who are viewing this thread

DMcain

Veteran
I have this nifty idea to calculate an optimum party size based on my leadership score when calculating the morale modifier.  My problem is, I can't figure out where to put it in the morale calculation script, or the way to code the effect I want. Here's the block of code I'm working with (copied from the default module_scripts.py):

Code:
      (party_get_num_companion_stacks, ":num_stacks","p_main_party"),
      (assign, ":num_men", 0),
      (try_for_range, ":i_stack", 0, ":num_stacks"),
        (party_stack_get_troop_id, ":stack_troop","p_main_party",":i_stack"),
        (try_begin),
          (troop_is_hero, ":stack_troop"),
          (val_add, ":num_men", 3),
        (else_try),
          (party_stack_get_size, ":stack_size","p_main_party",":i_stack"),
          (val_add, ":num_men", ":stack_size"),
        (try_end),
      (try_end),
      (assign, "$g_player_party_morale_modifier_party_size", ":num_men"),

Here's the code for calculating my optimal party size:

Code:
      (store_skill_level, ":player_leadership", "skl_leadership", "trp_player"),
      (store_mul, "$g_optimum_party_size", ":player_leadership", 10),
      (assign, ":opt_party_size", "$g_optimum_party_size"),

From here, I want a range of -500 to 0 for the party size modifier. I do NOT want a bonus for having a small party here, that is calculated later in the script. I've tried (assign, ":num_men", ":eek:pt_party_size"), (val_sub, ":num_men", ":eek:pt_party_size"), and (val_add, ":num_men", ":eek:pt_party_size"). I even tried some off-the-wall stuff like (store_mul, "$g_optimum_party_size", ":player_leadership", -10). I even tossed in (val_clamp, ":num_men", -500, 0). Everything I've tried comes close, but doesn't quite work out.

In case all this has confused folks, I'll give some numbers to play with.

Default calculations with Party leader, 1 hero, and 3 troop stacks of 15 each:
party leader = -3
hero = -3
stack 1 = -15
stack 2 = -15
stack 3 = -15
total penalty = -51

Desired calculations with Party leader, 1 hero, and 3 troop stacks of 25 each (assume leadership 3)
party leader = -3
hero = -3
stack 1 = -15
stack 2 = -15
stack 3 = -15
optimal party = 30
total penalty = -21

Desired calculations with Party leader, 1 hero, and 1 troop stacks of 15(assume leadership 3)
party leader = -3
hero = -3
stack 1 = -15
optimal party = 30
total penalty = 0 (actual calculation = +9)

Again, sorry if this has confused folks, but I sometimes find it difficult to explain my ideas. If any further clarification is needed, just ask and I'll try my best to explain.

Thanks folks.
DMCain
 
Back
Top Bottom