1. The poll for our 11th Music Contest is up! Help us choose the most awesome cinematic tracks by casting a vote!
    Dismiss Notice
  2. Melee Mapping contest #3 - Poll is up! Vote for the best 4v4 melee maps!
    Dismiss Notice
  3. The 30th edition of the Modeling Contest is finally up! The Portable Buildings need your attention, so come along and have a blast!
    Dismiss Notice
  4. The Aftermath has been revealed for the 19th Terraining Contest! Be sure to check out the Results and see what came out of it.
    Dismiss Notice

Assigning Particular Set Ability to Various Player Units

Discussion in 'World Editor Help Zone' started by IamFierce, Jan 18, 2019.

  1. IamFierce

    IamFierce

    Joined:
    Jan 18, 2019
    Messages:
    11
    Resources:
    0
    Resources:
    0
    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 :)
     
  2. Astrella

    Astrella

    Joined:
    Oct 3, 2008
    Messages:
    147
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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?
     
  3. Sieben

    Sieben

    Joined:
    Nov 23, 2013
    Messages:
    528
    Resources:
    0
    Resources:
    0
    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:
     
  4. IamFierce

    IamFierce

    Joined:
    Jan 18, 2019
    Messages:
    11
    Resources:
    0
    Resources:
    0
    Yes, i will post it later this afternoon when I am home!
     
  5. IamFierce

    IamFierce

    Joined:
    Jan 18, 2019
    Messages:
    11
    Resources:
    0
    Resources:
    0
    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?
     
  6. Sieben

    Sieben

    Joined:
    Nov 23, 2013
    Messages:
    528
    Resources:
    0
    Resources:
    0
    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?
     
  7. IamFierce

    IamFierce

    Joined:
    Jan 18, 2019
    Messages:
    11
    Resources:
    0
    Resources:
    0
    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.