#script_game_get_skill_modifier_for_troop
# This script is called from the game engine when a skill's modifiers are needed
# INPUT: arg1 = troop_no, arg2 = skill_no
# OUTPUT: trigger_result = modifier_value
("game_get_skill_modifier_for_troop",
[(store_script_param, ":troop_no", 1),#This script is called by engine whenever it needs to calculate skills of a troop. This script should not be called from any other script or trigger.
(store_script_param, ":skill_no", 2),#Both of these parameters are called for every trp_ and skl_ by the game.
(assign, ":modifier_value", 0),#This is the modifier value, it must have a value for the final operation, thus it is assigned 0. So it will have a value even if all the tries below fail.
(try_begin),#Begins Trying For Skills
(eq, ":skill_no", "skl_wound_treatment"), #This is the skill we are trying.
(call_script, "script_get_troop_item_amount", ":troop_no", "itm_book_wound_treatment_reference"), #This a check, it will get number of "itm_book_wound_treatment_reference" items.
(gt, reg0, 0), #The above script registers number of "itm_book_wound_treatment_reference" player has in invetory to reg0. This is a condition, if reg0 is greater 1 this try will succed.
(val_add, ":modifier_value", 1),#This adds 1 to ":modifier_value", so the value is now 1.
(else_try),#Once the try above fails, (if skl_ it is looking for is not skl_wound_treatment), it will try this one, untill it finds the skl_ it is looking for.
(eq, ":skill_no", "skl_trainer"),
(call_script, "script_get_troop_item_amount", ":troop_no", "itm_book_training_reference"),
(gt, reg0, 0),
(val_add, ":modifier_value", 1),
(else_try),
(eq, ":skill_no", "skl_surgery"),
(call_script, "script_get_troop_item_amount", ":troop_no", "itm_book_surgery_reference"),
(gt, reg0, 0),
(val_add, ":modifier_value", 1),
#This is try checks for if item is equipped in a slot
(else_try),
(eq, ":skill_no", "skl_power_draw"),
(troop_get_inventory_slot,":cur_item1",":troop_no",ek_item_0),#Here we are getting items from slots 0,1,2,3
(troop_get_inventory_slot,":cur_item2",":troop_no",ek_item_1),#Those slots are where weapons are placed.
(troop_get_inventory_slot,":cur_item3",":troop_no",ek_item_2),#We get them all to a different :local. Now all those :local variables are equal to one of the items in slots.
(troop_get_inventory_slot,":cur_item4",":troop_no",ek_item_3),#Then we check each item, if it is the one we want.
(this_or_next|eq, ":cur_item1", "itm_bonus_giving_item"),#These are conditions similar to the conditions above.
(this_or_next|eq, ":cur_item2", "itm_bonus_giving_item"),#But we check multiple variables, so we use this_or_next|
(this_or_next|eq, ":cur_item3", "itm_bonus_giving_item"),#As the name suggests it is either this contion or the next.
(eq, ":cur_item4", "itm_bonus_giving_item"),#Since this one is the last one we don't need this_or_next. When any of the items is the item we want the script succeds.
(val_add, ":modifier_value", 1),#And when succeded adds 1.
(try_end),#Ends Trying For Skills.
(set_trigger_result, ":modifier_value"),#This the execution of the scipt: :troop_no gets :modifier_value bonus to :skill_no.
]),