WB Auto Upgrade Troop Pain in the #$%^

正在查看此主题的用户

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"
":mad:p_gained", the xp that will be used in the upgrading process.
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),
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.
 
The first problem is with:

(store_random_in_range,":rand", 1, 3),
(troop_get_upgrade_troop, ":up_troop", ":troop_train", ":rand"),

troop_get_upgrade_troop can only take a 0 or a 1. The documentation for that in the 1.011 module system is incorrect. So change the randomizer to 0, 2 and (troop_get_upgrade_troop, ":up_troop", ":troop_train", 1), should have a 0.

Also, where is reg0 being assigned a value. If it is another script or trigger then the data could be corrupted.
 
                        (call_script, script_game_get_upgrade_xp, ":troop_train"),  #Mark
You need to put the script name into quotes:
                        (call_script, "script_game_get_upgrade_xp", ":troop_train"),  #FIXED
this should make sure that reg0 is set correctly:
                        (gt, ":cur_xp", reg0),  #this problem should go away
 
Thanks for the help, but it isn't quite what I'm getting at (although I have now made those changes).
What I mean is that (and yes, I know that this command dosnt actually exist) i need a party_upgrade_stack_with_xp, or a script equivelant.

Also, just quickly, it's 1 and 3 because it's always 1 less than the max value.
 
Also, just quickly, it's 1 and 3 because it's always 1 less than the max value.
No, it isn't. The troop_get_upgrade_troop takes a 0 for the first node and 1 for the second. So you would need a range of 0-2.

Are you using the 1.132 module system for Warband because I found this operation for you (party_add_xp_to_stack, <party_id>, <stack_no>, <xp_amount>),
 
adding xp to a stack does not actually upgrade the stack until you upgrade the entire party. He already used that operation on the 7th line.
 
Somebody 说:
adding xp to a stack does not actually upgrade the stack until you upgrade the entire party. He already used that operation on the 7th line.
Sorry, I thought he meant xp not upgrade. He still needs to change the numbers for the troop_get_upgrade_troop.

I spent 4 days, with the 1.011 module system, trying to figure out why I was getting invalid upgrade troops. It turned out that the documentation is wrong. I am guessing that he is using a module system version that has the unfixed comments.
 
Hey, I just wanted to say thanks gfor the help, and ithilienranger, you were right. Sorry, I thought that the (store_random_in_range... used the one less than the max value though I was apparently wrong...

Anyways, I just wanted to let everyone know that I made a party_template "none" which has nothing in it, and then added people, used the "party_upgrade_with_xp" command, before adding the people back into the main center and deleating the party template.
 
You were partially right about that, it does not count the max value. However, you had both the max and min one more than needed.
 
后退
顶部 底部