1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  4. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  5. Units have been turned into heroes in our latest Icon Contest! Vote for the best icon set at the Icon Contest #18 Poll!
    Dismiss Notice
  6. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  7. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  8. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Trigger help

Discussion in 'Triggers & Scripts' started by Weigazod, May 24, 2016.

  1. Weigazod

    Weigazod

    Joined:
    Feb 22, 2009
    Messages:
    176
    Resources:
    0
    Resources:
    0
    I seriously need some one to check my triggers. They seem to have some problem

    1st Trigger

    This is my attempt to create a building with unobstructed sight. I plan to create a flying dummy above the location of the building to provide the said sight. That trigger is fine for now. However, i can't remove/kill the dummy after the building is destroyed. It seems to me any unit with the Locust ability can not be selected by using unit within range.

    [trigger=Dummy Create]Eye in the Sky
    Events
    Unit - A unit Finished construction
    Conditions
    (Unit-Type of (Constructed Structure)) Equal to Tower of Wisdom
    Actions
    Set Caster=(Constructed structure)
    Set CasterPoint=(Position of Caster)
    Unit - Create 1 Eye for (Owner of Caster) at CasterPoint facing Default building facing degrees
    Custom script: set udg_Caster = null
    Custom script: call RemoveLocation(udg_CasterPoint)[/trigger]

    [TRIGGER=Dummy Destroy]Destroy
    Events
    A unit dies
    Conditions
    (Unit-type of (Dying unit)) Equal to Tower of Wisdom
    Actions
    Set Target = (Dying unit)
    Set TargetPoint = (Position of Target)
    Set UnitGroup = (Units within 300.00 of TargetPoint matching ((Unit-type of Matching unit) Equal to Eye)
    Unit Group - Pick Every unit in UnitGroup and do (Actions)
    Loop - Actions
    Unit - Remove (Picked unit) from the game
    Custom script: set udg_Target = null
    Custom script: call RemoveLocation(udg_TargetPoint)
    Custom script: call DestroyGroup (udg_UnitGroup)
    [/TRIGGER]



    2nd Trigger

    This trigger is to create a building that every 20 seconds will provide unobstructed sight for 10 seconds using the similar dummy. However, even if the building is destroyed. The sight is still provided.


    [trigger=Eye in the Sky 2]Eye in the Sky 2
    Events
    Time - Every 20 seconds of game time
    Conditions
    Actions
    Set UnitGroup = (Units in (Playable map area) matching ((Unit-type of Matching unit) Equal to Arcane City))
    Unit Group - Pick Every unit in UnitGroup and do (Actions)
    Loop - Actions
    Unit - Create 1 Eye for (Owner of Picked unit) at (Position of (Picked unit)) facing Default building facing degrees
    Unit - Add a 10.00 seconds Generic expiration timer to (Last created unit)
    Custom script: call DestroyGroup (udg_UnitGroup)[/trigger]
     
  2. KILLCIDE

    KILLCIDE

    Administrator

    Joined:
    Jul 22, 2015
    Messages:
    3,497
    Resources:
    20
    Models:
    2
    Icons:
    10
    Spells:
    7
    Tutorials:
    1
    Resources:
    20
    Oh my, did you manually type out these triggers? xD You can just right click on the trigger name and select "Copy as text" next time.

    Yup. This is true :3 what you may need to do is use a Unit Indexer so that you can store the locust dummy into a UnitVariable[Custom value of Building]. This way, when the building is destroyed, you can remove it by UnitVariable[Custom value of destroyed building].

    Off topic: This leaks.
    • Unit - Create 1 Eye for (Owner of Picked unit) at (Position of (Picked unit)) facing Default building facing degrees
     
  3. Weigazod

    Weigazod

    Joined:
    Feb 22, 2009
    Messages:
    176
    Resources:
    0
    Resources:
    0
    Thanks for the help. I think i somehow understand it but i still don't know how to make it work. :thumbs_up:

    I just finished some tutorials in the triggers section and my brain is fried for now. Not sure if my Neuron will grow back. :goblin_boom:
     
  4. KILLCIDE

    KILLCIDE

    Administrator

    Joined:
    Jul 22, 2015
    Messages:
    3,497
    Resources:
    20
    Models:
    2
    Icons:
    10
    Spells:
    7
    Tutorials:
    1
    Resources:
    20
    It's extremely simple. The Unit Indexer will do everything for you. You just need to remember to just use the custom value of the structure.
     
  5. Weigazod

    Weigazod

    Joined:
    Feb 22, 2009
    Messages:
    176
    Resources:
    0
    Resources:
    0
    Yup, that's why i said i understand how it will work but don't know how to make it work. I haven't make a single array in my life.
     
  6. KILLCIDE

    KILLCIDE

    Administrator

    Joined:
    Jul 22, 2015
    Messages:
    3,497
    Resources:
    20
    Models:
    2
    Icons:
    10
    Spells:
    7
    Tutorials:
    1
    Resources:
    20
    Something like this will work:
    • Vision
      • Events
        • Unit - A unit Finishes construction
      • Conditions
      • Actions
        • Set TempUnit = (Constructed structure)
        • Set Unit_ID = (Custom value of TempUnit)
        • Set Loc = (Position of TempUnit)
        • Unit - Create 1 VisionDummy for (Triggering player) at Loc facing Default building facing degrees
        • Set VisionDummy[Unit_ID] = (Last created unit)
        • Custom script: call RemoveLocation(udg_Loc)

    What you're basically doing is attaching the vision dummy to the building by using the "structure's ID" as the index of the array. When the structure is destroyed, all you have to do is "Kill VisionDummy[ID of Destroyed Structure]."
     
  7. Weigazod

    Weigazod

    Joined:
    Feb 22, 2009
    Messages:
    176
    Resources:
    0
    Resources:
    0
    Ok, i will try to interpret each line. Please correct me if i am wrong.

    The 1st line is to set a variable for the constructed building
    The 2nd is to set a custom value for the variable in the 1st line
    The 3rd line is for setting a variable for the location of the constructed building.
    The 4th line take the role of creating the dummy
    And the last one is to make a custom value for the dummy and with that connect the custom value of the dummy to the custom value of the building.

    Therefore, basically if i need to destroy the dummy

    • Eye
      • Events
        • Unit - A unit Finishes construction
      • Conditions
        • (Unit-type of (Constructed structure)) Equal to Tower of Wisdom
      • Actions
        • Set Caster = (Constructed structure)
        • Set BuildingID = (Custom value of Caster)
        • Set CasterPoint = (Position of Caster)
        • Unit - Create 1 Eye for (Owner of Caster) at CasterPoint facing Default building facing degrees
        • Set Eye[BuildingID] = (Last created unit)
        • Custom script: set udg_Caster = null
        • Custom script: call RemoveLocation(udg_CasterPoint)



    This is everything i need?
    • Destroyed
      • Events
        • Unit - A unit Dies
      • Conditions
        • Or - Any (Conditions) are true
          • Conditions
            • (Unit-type of (Dying unit)) Equal to Tower of Wisdom
            • (Unit-type of (Dying unit)) Equal to Grand Library
            • (Unit-type of (Dying unit)) Equal to Arcane City
      • Actions
        • Unit - Kill Eye[BuildingID]
     
  8. KILLCIDE

    KILLCIDE

    Administrator

    Joined:
    Jul 22, 2015
    Messages:
    3,497
    Resources:
    20
    Models:
    2
    Icons:
    10
    Spells:
    7
    Tutorials:
    1
    Resources:
    20
    For the Destroyed trigger, you need to set BuildingID to the custom value of the dying structure. BuildingID will always be storing the most recent integer you put into it. In this case, it will be the most recent construction built. You also don't need to set Caster to null in the "Eye" trigger. Other than that, everything is good.
     
  9. Weigazod

    Weigazod

    Joined:
    Feb 22, 2009
    Messages:
    176
    Resources:
    0
    Resources:
    0
    I also don't know what that _null script will do. I read somewhere it said that it is some sort of leak prevention.
     
  10. KILLCIDE

    KILLCIDE

    Administrator

    Joined:
    Jul 22, 2015
    Messages:
    3,497
    Resources:
    20
    Models:
    2
    Icons:
    10
    Spells:
    7
    Tutorials:
    1
    Resources:
    20
    It only matters for local variables. Whenever you create variables through the variable editor, they are global variables (udg = user defined global).

    Can you post the updated triggers?
     
  11. Weigazod

    Weigazod

    Joined:
    Feb 22, 2009
    Messages:
    176
    Resources:
    0
    Resources:
    0
    • Destroyed
      • Events
        • Unit - A unit Dies
      • Conditions
        • Or - Any (Conditions) are true
          • Conditions
            • (Unit-type of (Dying unit)) Equal to Tower of Wisdom
            • (Unit-type of (Dying unit)) Equal to Grand Library
            • (Unit-type of (Dying unit)) Equal to Arcane City
      • Actions
        • Set BuildingID = (Custom value of (Dying unit))
        • Unit - Kill Eye[BuildingID]


    Excuse me, can you take a look?

    I don't understand why but when i test and build 2 buildings, i destroy the 1st one and the dummy for the 2nd one get killed. I don't know how to fix this.

    Also, do i need to set the array size?
     
  12. KILLCIDE

    KILLCIDE

    Administrator

    Joined:
    Jul 22, 2015
    Messages:
    3,497
    Resources:
    20
    Models:
    2
    Icons:
    10
    Spells:
    7
    Tutorials:
    1
    Resources:
    20
    Do you have a unit indexer in your map?

    No you don't. Leave it as default.
     
  13. Weigazod

    Weigazod

    Joined:
    Feb 22, 2009
    Messages:
    176
    Resources:
    0
    Resources:
    0
    You mean the [System] Unit Indexer?
     
  14. KILLCIDE

    KILLCIDE

    Administrator

    Joined:
    Jul 22, 2015
    Messages:
    3,497
    Resources:
    20
    Models:
    2
    Icons:
    10
    Spells:
    7
    Tutorials:
    1
    Resources:
    20
    Any unit indexer in the resource section will do. I recommend the one done by Bribe since its compatible with the vanilla editor.
     
  15. Weigazod

    Weigazod

    Joined:
    Feb 22, 2009
    Messages:
    176
    Resources:
    0
    Resources:
    0
  16. KILLCIDE

    KILLCIDE

    Administrator

    Joined:
    Jul 22, 2015
    Messages:
    3,497
    Resources:
    20
    Models:
    2
    Icons:
    10
    Spells:
    7
    Tutorials:
    1
    Resources:
    20
    Yes that one.

    Did you not have a unit indexer when you made that trigger? If not, that's why it's not working.
     
  17. Weigazod

    Weigazod

    Joined:
    Feb 22, 2009
    Messages:
    176
    Resources:
    0
    Resources:
    0
    Yup, I am pretty much stuck in the 200X.
     
  18. KILLCIDE

    KILLCIDE

    Administrator

    Joined:
    Jul 22, 2015
    Messages:
    3,497
    Resources:
    20
    Models:
    2
    Icons:
    10
    Spells:
    7
    Tutorials:
    1
    Resources:
    20
    200x? Sorry I don't quite understand. Regardless, the trigger should work fine after you import the unit indexer into your map. Just remember to never modify the custom value of units; leave that to the unit indexer.
     
  19. Weigazod

    Weigazod

    Joined:
    Feb 22, 2009
    Messages:
    176
    Resources:
    0
    Resources:
    0
    Took a day but it works. Yay. Thank you.:grin: