Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
I have read some threads before and none of them helped, so I decided to post my own;
I made a trigger which should merge 2 units to form 1, like an archer mounting a hippogryph. For further detail, the base ability is based off ''pick up archer'' and renamed to ''Amalgamation''. I want the Melee AI to cast it when the ability is researched, to form, as mentioned before, 2 Dogs into a ''Hybrid''. Why doesn't this work?
I am quite new to this, so I apologise for not knowing this. Please do not post JAVA scripts. And if any trigger contains variables, please explain them.
The reason your trigger doesn’t work is because there is no triggering unit to refer to. The trigger was triggered by a time event, so something like “expired timer” would work (though it’s not relevant to the intended effect of your trigger). What you want to do is pick all dog units owned by that ai player and order them to use the spell.
Ah, I thought you only need to refer the type of unit you want to use in the conditions. But the problem is, whenever I store the unit I want to use in a variable, the event section does not seem to detect the variable I want to use in, let's say Unit - Unit Specific Event, nor does the list mention anything about gaining an ability or upgrade. Albeit it has ''Learns a Skill'' it seems to only apply to Heroes. I probably glimced over something and did not realise it, I cannot figure out how to ''refer'' to the Dog without using regions. Cheers for the links, will definitely come in use.
the event section does not seem to detect the variable I want to use in, let's say Unit - Unit Specific Event, nor does the list mention anything about gaining an ability or upgrade.
Look at the underlying JASS. It passes the value of the variable at the time the event is created, hence changing that variable does not change the value used by the event.
One has to use a generic (all units) event and then filter using a condition.
There's an action Unit Group - Pick Units. With that you can literally pick the unit you need by giving it conditions with which it knows what to look for.
After a bit of testing I've finally got it. +rep for the help and info to all of you
Merge
Events
Time - Every 1.00 seconds of game time
Conditions
(Current research level of Amalgamation for Player 1 (Red)) Equal to 1
Actions
Set Unit_Dog = (Random unit from (Units of type Dog))
Unit - Order Unit_Dog to Night Elf Hippogryph - Pick Up Archer
On a side note, is there a way to refer to every player without individually trying to copy and paste the same trigger but only change the --for Player X (Colour)--?
I'm not sure how bj_wantDestroyGroup works when creating a group for a variable. Doesn't the group get destroyed right after the line is ran? Anyway, I would instead just use Custom Script: call DestroyGroup(udg_GroupDog). Also, if you are using bj_wantDestroyGroup, you don't have to set it back to false. It is automatically set false for every group and you only need to set true if you want to.
You are also leaking another group in the DogPoint variable set. And the Picked Player does not refer to any player, because you have not picked any players at that point. Same with Picked Unit.
Thirdly, I don't know either how well that "Order to right-click" works or how reliable it is. I'd instead just use the exact thing I want to happen: in this case order the unit to explicitly move there.
Fourthly, you can just click and delete all those "Do nothing". They literally do nothing and there is no point using them.
Also, is it necessarily to run this trigger so often? How is the upgrade added to the player? Maybe run this just once then, or is it something periodic that should happen all the time?
Edit: Lastly, you have to clean the leaks at the end of the trigger (or after you don't need the variable anymore) outside the ifs. Because now it will leak those groups every second if they don't pass the ifs all the way down.
Edit2:
This is like something you should do:
Events
Time - Every 1.00 seconds of game time
Conditions
Actions
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
Set GroupDog = (Units owned by (Picked player) of type Dog)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked player) controller) Equal to Computer
(Number of units in GroupDog) Greater than 1
(Current research level of Amalgamation for (Picked player)) Equal to 1
Then - Actions
Set UnitDogA = (Random unit from GroupDog)
-------- The next line is to make sure that the random choosing doesn't choose the same dog again. --------
Unit Group - Remove UnitDogA from GroupDog
Set UnitDogB = (Random unit from GroupDog)
Unit - Order UnitDogA to Follow UnitDogB
Set DogPointA = (Position of UnitDogA)
Set DogPointB = (Position of UnitDogB)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Distance between DogPointA and DogPointB) Less than or equal to 900.00
Then - Actions
Unit - Order UnitDogA to Night Elf Hippogryph - Pick Up Archer
Else - Actions
Custom script: call RemoveLocation(udg_DogPointA)
Custom script: call RemoveLocation(udg_DogPointB)
Else - Actions
Custom script: call DestroyGroup(udg_GroupDog)
Though, this is not perfect: if the player has more than two dogs, the dogs will probably just change targets all the time (because the trigger is ran so often) and basically just roll around.
To get around this you could for example add the randomly chosen dogs to a different group and not pick any units from that group on the random pick up. Or use Unit Indexer and recognize this way if the dog was already picked once.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.