• Register
Post tutorial Report RSS PARADIGM WORLDS: Modding - breaking down troop cost for Paradigm.

This tutorial breaks down script responsible for cost of each troop in Paradigm Worlds. It may be used in any Warband mod.

Posted by on - Basic QA/Testing

This tutorial breaks down script responsible for cost of each troop in Paradigm Worlds. It may be used in any Warband mod.


Cost of each troop is calculated by a part of program in the module_scripts.py.

Paradigm Worlds version is naturally tweaked native script. Let's see. One note: code presented below is easier to read in any text viewer, I personally use notepad+. You can copy-paste code right into text editor so comments marked # will be better visible


# script_game_get_troop_wage #<---- name of script
# This script is called from the game engine for calculating troop wages. #<---- what it does
# Input:
# param1: troop_id, param2: party-id #to work this script needs 2 variables. First is troop_id <-which troop to calculate, 2nd isn't currently used
# Output: reg0: weekly wage

("game_get_troop_wage",
[
(store_script_param_1, ":troop_id"),
(store_script_param_2, ":unused"), #party id

(assign,":wage", 0), #<----wage at beginning is 0
(try_begin),
(this_or_next|eq, ":troop_id", "trp_player"),
(eq, ":troop_id", "trp_kidnapped_girl"),
(else_try),
(is_between, ":troop_id", pretenders_begin, pretenders_end),
(else_try),
####
(call_script, "script_store_troop_military_power", ":troop_id"), #<---- now, this is special Paradigm Worlds script. Military power reflects non only statistics, but also cost of equipment and its quality. That way price for each troop is scaled more fair.

(assign, ":military_troop_power", reg0),
(val_mul, ":military_troop_power", 75), #val_mul means multiply
(val_div, ":military_troop_power", 100), #val_mul means divide

###to balance variables military power / troop level a simple math operation is used. x75/100= 3/4

###


(store_character_level, ":troop_level", ":troop_id"), #### check troop level

(val_add, ":troop_level", ":military_troop_power"), ### add together: troop level, and military power
(val_div, ":troop_level", 2), ### divide by two

(assign, ":wage", ":troop_level"), ###keep result in new variable 'wage'

(val_add, ":wage", 1),
(val_mul, ":wage", ":wage"),
(val_div, ":wage", 100),
(try_end),

(try_begin), #mounted troops cost 65% more than the normal cost
(neg|is_between, ":troop_id", companions_begin, companions_end),
(troop_is_mounted, ":troop_id"), ####<- check if troop category is mounted
(val_mul, ":wage", 4),
(val_div, ":wage", 3),
(try_end),

# (try_begin), #ranged troops cost 50% more than the normal cost# ### ranged are now weak at close combat no reason to nerf them arbitrary by price
# (neg|is_between, ":troop_id", companions_begin, companions_end),
# (troop_is_guarantee_ranged, ":troop_id"),
# (val_mul, ":wage", 3),
# (val_div, ":wage", 2),
# (try_end),



(try_begin), #mercenaries cost little bit more than the normal cost (125%)

(is_between, ":troop_id", mercenary_troops_begin, mercenary_troops_end), ### ***
(val_mul, ":wage", 5),
(val_div, ":wage", 4),
(try_end),

### *** This variables with characteristic names ending with _begin, _end <- they usually refer to constant ### variables that affect whole mod. They cannot be changed during game or it may corrupt save or just ### crash game at some point. If they are changed that I inform players that game is not-save-compatible.

### these variables are stored in file module_constants.py

(try_begin),
(is_between, ":troop_id", companions_begin, companions_end), #<- if troop belongs to companions
(store_character_level, ":troop_level", ":troop_id"), #<- check again his level
(val_add, ":wage", ":troop_level"), # <- add level to 'wage'
(val_mul, ":wage", 20), #multiply result by 20
(try_end),


(try_begin),
(is_between, ":troop_id", broker_troops_s_begin, broker_troops_s_end), # checks if troop is from broker
(val_mul, ":wage", 4),
(val_div, ":wage", 3),
(try_end),


(try_begin),
(is_between, ":troop_id", ll_legion_begin, ll_legion_end), #legion new troops lowering price madg
(val_div, ":wage", 3),
#(val_mul, ":wage", 2), <- this line starts with # which means that is 'commented out' - compiler will be 'blind' for that line, it will be treated like just remark on margin of notebook

(try_end),




(try_begin),
(is_between, ":troop_id", broker_troops_vs_begin, broker_troops_vs_end),
(val_mul, ":wage", 3),
(val_div, ":wage", 2),
(try_end),

(try_begin),
(is_between, ":troop_id", customizable_troops_begin, customizable_troops_end),
(val_mul, ":wage", 3),
(val_div, ":wage", 2),
(try_end),





(party_get_skill_level, ":party_tactics_level", "p_main_party", "skl_tactics"), #<--- checks skill value. #### automatically finds 'best' value


(store_skill_level, ":pro_level", "skl_trainer", "trp_player"), #<- in this case skill is checked for # player, not 'best' in party!
(store_skill_level, ":tactics_level", "skl_tactics", "trp_player"),
(store_skill_level, ":leadership_level", "skl_leadership", "trp_player"),

(val_mul,":party_tactics_level", 3), #was 0 , changed to 3 - madguarang kg so each point in skill
(val_mul,":pro_level", 3), #was 0 , changed to 3 - madguarang kg gives 3% of 'discount'
(val_mul,":tactics_level", 5), #was 0 , changed to 3 - madguarang kg however tactics gives 5%
(val_mul,":leadership_level", 5), #was 0 , changed to 3 - madguarang kg and leadership another 5%

(assign, ":discount", 100), #100% price ## this shows how Paradigm Worlds makes each skill important on many levels. This part of script counts 'discount' for troop cost. skl_trainer is a Professional skill in Paradigm Worlds.

(val_add, ":discount", ":tactics_level"),
(val_add, ":discount", ":pro_level"),
(val_add, ":discount", ":leadership_level"),
(val_add, ":discount", ":party_tactics_level"),


(val_mul, ":wage", 100), #wage = wage * (100 - 5*leadership)/100
(val_div, ":wage", ":discount"),

(try_begin),
(neq, ":troop_id", "trp_player"),
(neq, ":troop_id", "trp_kidnapped_girl"),
(neg|is_between, ":troop_id", pretenders_begin, pretenders_end),
(val_max, ":wage", 1),
(try_end),

(assign, ":doomwage", "$doomsday_clock"), #with every day cost is higher because people fear more
(val_div, ":doomwage", 12),
(val_add, ":wage", ":doomwage"),

###last most powerful tweaker <- this is useful, when general calculation, and variables relation are satisfying, but we want to have a 'global' tweaker for future reference


(val_mul, ":wage", 100),
(val_div, ":wage", 180),

### so actually wage is *100/180 = 0.55 of all calculated cost.


(assign, reg0, ":wage"),
(set_trigger_result, reg0), ###<- this sends game info about price
]),


You can easily tweak most values yourself. You can check PW tutorials page on Warband modding, there are links to all you need to begin modding. If you already have Python and Warband installed, then you can copy paste code or download latest version of Paradigm Worlds source code and see/change/tweak everything for yourself.



This article is a part of tutorials for Paradigm Worlds / Warband modding.

You can check downloads sections for recent source code version of Paradigm Worlds.


Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: