• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Assigning Particular Set Ability to Various Player Units

Status
Not open for further replies.
Level 4
Joined
Jan 18, 2019
Messages
71
Hello everyone,

I’ve been reading and lurking and learning from many years of posts in creating my new map in honor of the coming Reforged. For that, many thanks to those who have asked the same questions I have had as I’ve learned the ropes.

That being said, I have come across an issue that has particular given me grief.

When a specific task is target a generic created unit, meaning one that hasn’t been created prior to the map starting, how do you ensure that that unit to which you are trying to modify, in this instance, set the ability of, without it being applied to other units performing various actions (Some being the exact same action)?

I know that you can set conditions: “If unit is a... If ability is casted,” but even so, I’ve noticed that even after activating the following triggers after the conditions have been met, the system can still assign the following triggers to another unit that matches “apply [whatever] to [triggering, killing, casting ability] units.

How to ensure that the system stays true to the target unit?

Much thanks :)
 
Level 4
Joined
Jan 18, 2019
Messages
71
Could you post a code excerpt maybe? Cause I'm not 100% sure what you are trying to do. Do you want your trigger to only apply to units of a certain unit-type or only to a very specific unit?
Yes, i will post it later this afternoon when I am home!
 
Level 4
Joined
Jan 18, 2019
Messages
71
I'm not sure I understood your question, but from what I got, I think you might want to store that created unit in a variable, so you can refer to it later.
You'll find variable tutorials here:

Thank you for the point to the tutorial sections! That is what I am talking about. Isn’t every unit doing a particular action global? Is there not a chance, even after setting conditions, of the wrong unit receiving the wrong variable assigning?
 
Level 11
Joined
Nov 23, 2013
Messages
665
Is there not a chance, even after setting conditions, of the wrong unit receiving the wrong variable assigning?
If things are done properly, it should work fine.

You need to set the variable to the unit when you create the unit, using the 'Set Variable' action , like this:

  • Trigger A
    • Actions
      • Unit - Create 1 Paladin for Player 1 (Red) at (<Where you need>) facing X degrees
      • Set Unit1 = (Last created unit)
You need to do it for every unit you intend to refer to later.
And then, you will be able to use triggers like this:

  • Trigger B
    • Events
      • Unit - A unit Starts using an ability
    • Conditions
      • (Triggering unit) Equal Unit1
    • Actions
      • Do <whatever you want>
So, what happens in those triggers:
- First, just after creating a specific unit, you assign that unit to a variable (here, I called it Unit1, but call it whatever you want). It tells the game that whenever you will use this variable, it will refer to that specific unit (and only this one, unless you assign another unit to the variable).
- In Trigger B, the event detects when a unit, any unit, uses an ability; then, in the condition, I check if that unit is Unit1 (aka the unit you created before). If this is the case, the actions are triggered.

I think you will find more explanations in the tutorials I linked :)

Was that what you needed?
 
Level 4
Joined
Jan 18, 2019
Messages
71
If things are done properly, it should work fine.

You need to set the variable to the unit when you create the unit, using the 'Set Variable' action , like this:

  • Trigger A
    • Actions
      • Unit - Create 1 Paladin for Player 1 (Red) at (<Where you need>) facing X degrees
      • Set Unit1 = (Last created unit)
You need to do it for every unit you intend to refer to later.
And then, you will be able to use triggers like this:

  • Trigger B
    • Events
      • Unit - A unit Starts using an ability
    • Conditions
      • (Triggering unit) Equal Unit1
    • Actions
      • Do <whatever you want>
So, what happens in those triggers:
- First, just after creating a specific unit, you assign that unit to a variable (here, I called it Unit1, but call it whatever you want). It tells the game that whenever you will use this variable, it will refer to that specific unit (and only this one, unless you assign another unit to the variable).
- In Trigger B, the event detects when a unit, any unit, uses an ability; then, in the condition, I check if that unit is Unit1 (aka the unit you created before). If this is the case, the actions are triggered.

I think you will find more explanations in the tutorials I linked :)

Was that what you needed?

Yes, that was exactly what I needed to know. And you are right, there was much to be discovered in the tutorial section. Thank you very much for taking the time to write out a great explanation.
 
Status
Not open for further replies.
Top