Ok, I am trying to make a code so that the castles (if so instructed) can train the troops garrisoned there.
So far I have made everything work, down to a single problem. I have a slot in centers, and if set to 0, then the script is "off", if it is set to -1, then it upgrades the party as a whole, and if it is set to an actual value, that value is a troop number, so the castle will train that specific troop. Here is the script, coming into the script, are the following:
":center", the current center being tested.
":center_stacks", the number of companion stacks at the ":center"
"
p_gained", the xp that will be used in the upgrading process.
The error I am having is in the marked lines:
What I need to do is figure out a way to find if the troop of the stack specified is able to upgrade, and how manyare ready to be upgraded.
I really need help with this as it is all I have left of a awesome script.
So far I have made everything work, down to a single problem. I have a slot in centers, and if set to 0, then the script is "off", if it is set to -1, then it upgrades the party as a whole, and if it is set to an actual value, that value is a troop number, so the castle will train that specific troop. Here is the script, coming into the script, are the following:
":center", the current center being tested.
":center_stacks", the number of companion stacks at the ":center"
"
The error I am having is in the marked lines:
插入代码块:
(try_begin),
(neg|party_slot_eq, ":center", slot_town_train_troop, -1),
(party_get_slot, ":train_troop", ":center", slot_town_train_troop),
(try_for_range, ":stack", 0, ":center_stacks"),
(party_stack_get_troop_id, ":troop_train", ":center", ":stack"),
(eq, ":troop_train", ":train_troop"),
(party_add_xp_to_stack, ":center", ":stack", ":xp_gained"),
(call_script, script_game_get_upgrade_xp, ":troop_train"), #Mark
(troop_get_xp, ":cur_xp", ":troop_train"), #Mark
(gt, ":cur_xp", reg0), #Mark
(store_random_in_range,":rand", 1, 3),
(troop_get_upgrade_troop, ":up_troop", ":troop_train", ":rand"),
(try_begin),
(eq, ":up_troop", -1),
(troop_get_upgrade_troop, ":up_troop", ":troop_train", 1),
(try_end),
(party_remove_members, ":center", ":troop_train", 1), #Mark
(party_add_members, ":center", ":up_troop", 1), #Mark
(try_end),
(else_try),
(party_slot_eq, ":center", slot_town_train_troop, -1),
(party_upgrade_with_xp, ":center", ":xp_gained", 0),
(try_end),
I really need help with this as it is all I have left of a awesome script.



