• 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

First Created Destructible Detection

Status
Not open for further replies.
Level 2
Joined
Apr 19, 2018
Messages
13
I have a trigger which creates a destructible, and removes it 4 seconds later. It is triggered when an ability is first cast. The ability has no cooldown (and I won't add one), so using Last Created Destructible will work only if that ability is cast one time. Is there any short way to only remove the destructibles as they were created and not the last one that was made? If it must be made with Jass, please put down the exact code. I haven't used Jass before except in custom script in the World Editor.
 
Level 2
Joined
Apr 19, 2018
Messages
13
Assign a destructible variable to the last created one after creating the destructible. This way, the reference is saved and you can do with it as you wish.
If I do that and the trigger runs again before the 4 seconds have passed, the destructible variable will be replaced by the new destructible from the next trigger and it will only remove the new destructible.
 
Level 2
Joined
Apr 19, 2018
Messages
13
Okay, I don't exactly know what a local variable is, so could you explain it to me? (It is a variable, right?) And I also don't know any easy way to index each cast. This is why I'm asking for help.
 
Level 9
Joined
Apr 23, 2011
Messages
527
Okay, I don't exactly know what a local variable is, so could you explain it to me? (It is a variable, right?) And I also don't know any easy way to index each cast. This is why I'm asking for help.

Local variables can only be referenced in the function it was made (it cannot be modified by other triggers, unlike global variables). It's exclusive to JASS, though.

Have a look at this tutorial for dynamic indexing.
The way I see it, you want to index an integer that goes +1 every second and the destructible itself. If the integer >= 4, then remove the destructible, reassign the indexes.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
It's exclusive to JASS, though.
Yes and No.

There is an action called "Custom script". it would look very similar to:

  • Custom script: unit u = gg_trig_unit // of BJ_GetTrigUnit() or GetTrigUnit() ???
  • ...
  • Wait 5.0 sek
  • ...
  • Custom script: udg_tempUnit = u
  • Unit - Kill tempUnit
Have a look at this tutorial for dynamic indexing.
The way I see it, you want to index an integer that goes +1 every second and the destructible itself. If the integer >= 4, then remove the destructible, reassign the indexes.
Time is real, not integer.

regards
-Ned
 
Last edited:
Level 9
Joined
Apr 23, 2011
Messages
527
Yes and No.

There is an action called "Custom script". it would look very similar to:

  • Custom Script: unit u = gg_trig_unit // of BJ_GetTrigUnit() or GetTrigUnit() ???
  • ...
  • Wait 5.0 sek
  • ...
  • Custom Script: udg_tempUnit = u
  • Unit - Kill tempUnit

Ah, I forgot about that.

Time is real, not integer.

regards
-Ned

That depends. I'd use a real if I wanted to use decimals for a timer, personally.
 
Level 8
Joined
Dec 28, 2014
Messages
90
I think it looks like this:

  • Summon Tree
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Summon Tree
    • Actions
      • Custom script: local destructable tree
      • Destructible - Create a Summer Tree Wall at (Target point of ability being cast) facing (Random angle) with scale 1.00 and variation 0
      • Custom script: set tree = GetLastCreatedDestructable()
      • Wait 4.00 seconds
      • Custom script: call RemoveDestructable(tree)
 
Status
Not open for further replies.
Top