- Joined
- Mar 13, 2013
- Messages
- 299
I apologize if this question has been asked/answered already. I looked through this thread and got what I could from it, but couldn't find anything more specific to what I need - however I've never used scripts before so it was a significant help!
Anyway, I'm trying to randomize the hero training process for an otherwise normal melee map. I would suspect this should be simple for most people here, but I'm having a problem: basically, I can not train a new hero at tier 2. It works 'fine' at tier 1 and tier 3, but for some reason it will not allow me to train a new hero at tier 2.
I've posted my entire code at the bottom as a screenshot, but the 'meat' of it is this line:
When I do this it behaves as though the "replace" just hid the trained hero and added a random hero, but still assumes I have two heroes. So when I reach tier 2 I can't train a new one. Is there some way to reset the number of heroes I have back to the number I actually have? Or, is it 'obvious' to anyone here that something else is the problem? How do I fix it?
additional "optional" information:
Brief explanation of variables:
Pheros is a 'hero array' i set at map initialization. It has 36 elements - (max of 12 players and a max of 3 heroes for each player 3x12 = 36). So, elements 1, 2, and 3 would represent the first, second, and third hero for player 1. elements 4, 5, and 6 would represent the first, second, and third hero for player 2, and so on.. The heroes are assigned randomly in the array, with of course some simple checking to ensure no one gets the same hero twice and no one gets a non-neutral hero of another race. Note: this is all 'set in stone' at the onset of a given game, but that doesn't mean that there must be 12 players nor does it mean that any player must have 3 heroes.
y is the player number given by:
Second edit: i just pasted all my code as a screenshot:
random hero
initialization
variables
and yes, in advance, i know there are probably much more efficient ways of doing what I have done thus far, but please understand that that's not why I am here - unless of course it results in the specified problem, then by all means explain.
Anyway, I'm trying to randomize the hero training process for an otherwise normal melee map. I would suspect this should be simple for most people here, but I'm having a problem: basically, I can not train a new hero at tier 2. It works 'fine' at tier 1 and tier 3, but for some reason it will not allow me to train a new hero at tier 2.
I've posted my entire code at the bottom as a screenshot, but the 'meat' of it is this line:
- Unit - Replace (Trained unit) with a PHeros[(((y-1)x3) + x)] using The new unit's max life and mana.
- Unit - Remove (Trained unit) from the game
- Unit - Create 1 Pheros[(((y - 1)x3) + x)] for Pnum at (Position of (Triggering unit)) facing Default building facing degrees
When I do this it behaves as though the "replace" just hid the trained hero and added a random hero, but still assumes I have two heroes. So when I reach tier 2 I can't train a new one. Is there some way to reset the number of heroes I have back to the number I actually have? Or, is it 'obvious' to anyone here that something else is the problem? How do I fix it?
additional "optional" information:
Brief explanation of variables:
Pheros is a 'hero array' i set at map initialization. It has 36 elements - (max of 12 players and a max of 3 heroes for each player 3x12 = 36). So, elements 1, 2, and 3 would represent the first, second, and third hero for player 1. elements 4, 5, and 6 would represent the first, second, and third hero for player 2, and so on.. The heroes are assigned randomly in the array, with of course some simple checking to ensure no one gets the same hero twice and no one gets a non-neutral hero of another race. Note: this is all 'set in stone' at the onset of a given game, but that doesn't mean that there must be 12 players nor does it mean that any player must have 3 heroes.
y is the player number given by:
- Set y = (Player number of Pnum)
- Set x = 0
- set grp = (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))
- Set y = (Player number of Pnum)
- Unit Group - Pick every unit in grp and do (Actions)
- Loop - Actions
- Set x = (x+1)
- Set pnum = (Triggering player)
Second edit: i just pasted all my code as a screenshot:
random hero
initialization
variables
and yes, in advance, i know there are probably much more efficient ways of doing what I have done thus far, but please understand that that's not why I am here - unless of course it results in the specified problem, then by all means explain.
Last edited: