I have a problem with setting something up like the max amount of heroes that a player can have.
I didnt really had a clue what to use but i made a silly trigger which kinda works.
- 3players on 1 team.
- 1 shared building to buy heroes.
- building changes owner when clicked.
- trainability is the same for each player.
I have set up a var like MaxP1 which contains the maxamount of heroes which gets increased by 1 for a certain player once he uses the train ability as you can see in trigger below.
The problem is not this trigger, but now im trying to make a trigger which will decrease the maxhero by 1 if the trained hero of a specified player dies so that he can train the ability again for example: if he had 2 heroes and 1 dies.
funny how you create everything with ugly code and yet you use something like IncrementInteger(maxP1, +, 1)
instead of bothering with something like max hero make Boolean or integer array for each player and work on it, as index you use player and it's easy
Also you should set trigger on unit death and see if given unit was hero and mod variable for specific player (owner).
Other way is for example adding trained hero to something like "TeamHeros[]" Unit group and before train count alive unit in that group.
Hey man, i didnt really knew what you meant with the integer array but i got the other part of your solution and got it to work.
Although it works, what i actually wanted was that the trigger only activates when a specific unit dies, else the trigger will be run a lot of senseless times because a lot of other units also die.
I have something similar created ... and ran into more problems I have suspected: I made a display panel showning the number of workers (total = active + in training + in transports).
Most of these problems do not apply to your task. But maybe you have to keep in mind that a player can cancel the training progress, the training building is destroyed during traing, a hero changes its owner due to a mind control ability ....
Why do you not use a requirement to control the training ability within the data modul? This would be a very easy job and it would be fail safe because the counting of the heros is transfered to the game engine.
expression view of the requirement
use
(CountUnit(Raynor,QueuedOrBetter) + CountUnit(Swann,QueuedOrBetter) + CountUnit(TychusChaingun,QueuedOrBetter)) < {Not more than 2 heros are allowed at a time}2
show
(empty)
Or in the tree view ...
"Limit number of heros"
use
less than (tool tip: "Not more than 2 heros are allowed at a time")
sum
count unit "Raynor" queued or better
count unit "Swann" queued or better
count unit "Tychus" queued or better
... ( more heros can easily added )
constant 2
show
If you restrict at the training ability of each hero training with this requirement your job is done ;)
Hey, i have put the requirement to the train ability and it works perfectly.
But doesnt this also affect the other players amount of heroes? because all players use like the same ability TrainRaynor , i mean like if i have 2 heroes the other player on my team cant build any heros anymore because there are already 2 heroes trained on the battlefield with that ability? or is it an individual requirement for each player?
By applying the requirement to the train ability of the raynor unit i notice that i could only add 1 requirement, is it also possible to add multiple requirements to a train ability?
requirements are individual. Each player's heros are counted separately.
you can't add multiple requirements to a single ability. But requirements can be more complex to cover more complex problem (see below). What do you want to add?
example 1 Limit number of Brutalisk to "1 Brutalisk per Hive + 1 additional Brutalisk" and have the prerequisite to build them (Hive + Queen + Ultralisk Cavern)
use
CountUnit(UltraliskCavern,CompleteOnly)[TechTreeCheat] && (CountUnit(Queen,CompleteOnly)[TechTreeCheat] || {Have at least a queen}CountUnit(QueenBurrowed,CompleteOnly)[TechTreeCheat]) && CountUnit(Hive,CompleteOnly)[TechTreeCheat] >= {1 Brutalisk per Hive + 1 additional Brutalisk}CountUnit(Brutalisk,QueuedOrBetter)
show
example 2 "Learm Protoss Air Armor Level 3" (No changes in prerequisite, but if you have started Level 2 you can already click Level 3, if it is the same CybCore)
I love requirements ;) They are just pure logic ... But I hate the UI of the requirements: Why is it so difficult to copy them from the expression view? Sonetimes I need a dozend attempts to copy them into the clipboard *grrrr*
sup ppl,
I have a problem with setting something up like the max amount of heroes that a player can have. I didnt really had a clue what to use but i made a silly trigger which kinda works.
- 3players on 1 team. - 1 shared building to buy heroes. - building changes owner when clicked. - trainability is the same for each player.
I have set up a var like MaxP1 which contains the maxamount of heroes which gets increased by 1 for a certain player once he uses the train ability as you can see in trigger below.
The problem is not this trigger, but now im trying to make a trigger which will decrease the maxhero by 1 if the trained hero of a specified player dies so that he can train the ability again for example: if he had 2 heroes and 1 dies.
help is appreciated :]
funny how you create everything with ugly code and yet you use something like IncrementInteger(maxP1, +, 1)
instead of bothering with something like max hero make Boolean or integer array for each player and work on it, as index you use player and it's easy
Also you should set trigger on unit death and see if given unit was hero and mod variable for specific player (owner).
Other way is for example adding trained hero to something like "TeamHeros[]" Unit group and before train count alive unit in that group.
@Nerfpl: Go
Hey man, i didnt really knew what you meant with the integer array but i got the other part of your solution and got it to work. Although it works, what i actually wanted was that the trigger only activates when a specific unit dies, else the trigger will be run a lot of senseless times because a lot of other units also die.
I have something similar created ... and ran into more problems I have suspected: I made a display panel showning the number of workers (total = active + in training + in transports).
Most of these problems do not apply to your task. But maybe you have to keep in mind that a player can cancel the training progress, the training building is destroyed during traing, a hero changes its owner due to a mind control ability ....
Why do you not use a requirement to control the training ability within the data modul? This would be a very easy job and it would be fail safe because the counting of the heros is transfered to the game engine.
expression view of the requirement
Or in the tree view ...
If you restrict at the training ability of each hero training with this requirement your job is done ;)
@JanChris: Go
Hey, i have put the requirement to the train ability and it works perfectly. But doesnt this also affect the other players amount of heroes? because all players use like the same ability TrainRaynor , i mean like if i have 2 heroes the other player on my team cant build any heros anymore because there are already 2 heroes trained on the battlefield with that ability? or is it an individual requirement for each player?
By applying the requirement to the train ability of the raynor unit i notice that i could only add 1 requirement, is it also possible to add multiple requirements to a train ability?
@Rice87: Go
example 1 Limit number of Brutalisk to "1 Brutalisk per Hive + 1 additional Brutalisk" and have the prerequisite to build them (Hive + Queen + Ultralisk Cavern)
example 2 "Learm Protoss Air Armor Level 3" (No changes in prerequisite, but if you have started Level 2 you can already click Level 3, if it is the same CybCore)
example 3 "Terran - Limit Structure Damage AddOn Upgrades (Individual)" (Used to specilize Terran buildings: 1 AddOn @ Level 1, + 2 AddOns @, + 3 AddOns @ level 3, making 6 possible assembly levels in total)
I love requirements ;) They are just pure logic ... But I hate the UI of the requirements: Why is it so difficult to copy them from the expression view? Sonetimes I need a dozend attempts to copy them into the clipboard *grrrr*
@JanChris: Go
Cool man thnx, in the future ill prolly be using more requirements. and thnx for the advanced examples it gives me good insight.
cheers,