Trigger help

Status
Not open for further replies.
Level 7
Joined
Feb 22, 2009
Messages
260
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]
 
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.

It seems to me any unit with the Locust ability can not be selected by using unit within range.
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
 
Level 7
Joined
Feb 22, 2009
Messages
260
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

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:
 
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]."
 
Level 7
Joined
Feb 22, 2009
Messages
260
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]."

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]
 
Level 7
Joined
Feb 22, 2009
Messages
260
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.

I also don't know what that _null script will do. I read somewhere it said that it is some sort of leak prevention.
 
Level 7
Joined
Feb 22, 2009
Messages
260
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?

  • 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?
 
Status
Not open for further replies.
Top