• 🏆 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!

[Trigger] Every X seconds of game time (variable) and remove variables

Status
Not open for further replies.
Level 13
Joined
May 11, 2008
Messages
1,198
so which variable do i use for every x seconds of game time? i can't figure it out. i'm trying to do an automatic spell and it works but it's buggy because i have so many triggers for it doing their thing at the same time. but i need to condense it all into one clean trigger to get rid of the memory leak.

so as far as i can see, the biggest obstacle is figuring out how i can add every 10, every 20, every 30, every 40 seconds all to the same trigger, it seems like i can add x and change x with another trigger, but i can't do that if i don't know which variable to use.
so, for example:
Events
Time - Every 40.00 seconds of game time
right, now how do i change that 40.00 seconds to a variable? which variable do i use? i can't figure it out.

another thing i can't figure out...
removing variables is hard to do.
i know how to remove few kinds. at any rate, how would you remove an array variable? is it even possible?
for example:
Set unitgroups = (Units owned by players[0] of type Footman)
*insert actions done with variable*
Custom script: call DestroyGroup(udg_unitgroups)

"Custom script: call DestroyGroup(udg_nameofvariable)"
that's how to get rid of a unit group. but what about a unit group array?
i guess i don't understand alot about variables and triggers and why they cause the bugs and crashing so maybe this isn't possible but i thought i'd ask.
 
Level 11
Joined
Oct 20, 2007
Messages
342
For every "variable" seconds do a action.
try this:
  • Repeat by varaible
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Wait A_Real_Variable seconds
      • Trigger - Run (This trigger) (checking conditions)
Removing unit group variable with array
see this:
  • Unit group with array
    • Events
    • Conditions
    • Actions
      • Set Unit_Group[1] = (Units in (Playable map area))
      • Custom script: call DestroyGroup (udg_Unit_Group[1])
 
Level 13
Joined
May 11, 2008
Messages
1,198
i already tried that for removing unit group variable with array. it didn't work. that was the first thing i tried, it would seem like it would logically work, but it doesn't.
i'll give that other thing a try...but i'm not sure i understand your instructions...
oh nevermind i think i got it
 
Level 3
Joined
May 3, 2008
Messages
29
i already tried that for removing unit group variable with array. it didn't work. that was the first thing i tried, it would seem like it would logically work, but it doesn't.
i'll give that other thing a try...but i'm not sure i understand your instructions...
oh nevermind i think i got it

To change event time to a variable, use a Timer variable and Timer expires event.
 
Level 13
Joined
May 11, 2008
Messages
1,198
oh okay. well i've never messed around with timer variables...i don't understand them. yeah your suggestion about the timers seems more logical, i'll give that a try some other time, i already fixed my problem. and as for the removing unit groups issue, i'll just add on alot of unitgroup variables and pretend i'm using array i guess.

maybe i'll look into wardraft or enfos map and see what they have for timer triggers/variables.
i need to learn to use the timer variables.
i have a timer on my leaderboard based on how much gold/lumber neutral hostile has. lol.
i give him some every second and take some away every minute or something like that.

btw when i did what jareph suggested it was totally meaningless and i couldn't figure out for the life of me how i was supposed to variate the variable.

here is what i did, in case you guys want to know...

this is for one player. i made 2 more sets of these triggers for the other 2 players that i needed these for. you can change the sections where it checks what player it's happening to in the players array variable. as you can see here i had 4 different variables for the unit groups variable, since i couldn't use arrays because i can't remove the units from them. (you have to remove the units from the unit groups to get rid of massive memory leak) so for the other 2 sets i had to make 8 more variables for unit groups, for a total of ten. funny thing is all my other triggers use a total of one unit group variable. but for this ability i needed to add 12 more.
also there are buff variables, 3 (2 for the other 2 sets)of those, with array of 4 each.
in case you're curious, each buff is a seperate aura buff and each of those is named appropriately and are found under the devotion aura ability under the buffs data entries.

since i put all this out there anyway...does anyone know of a way i can place the flamestrike randomly? i'm not sure i want to...but just curiously...would it take alot more editing? or would it be a really simple matter?

and in case your eye isn't so keen, this is the main method i used:
Trigger - Add to flamestrike autocast 1 <gen> the event (Time - Every 40.00 seconds of game time)
Trigger - Turn on flamestrike autocast 1 <gen>

but obviously there's alot more to it than that. anyway this was driving me crazy especially since my ability stopped working and i couldn't figure out why so i loaded up trigger from an older version of my map and worked on that along time under the impression that that old trigger worked and it didn't so i had to go back one more version and start over again hahahaha.... but as i said i fixed it finally.

btw the custom scripts below the else actions are not else actions...i've never used else actions in my maps. this format of copy and paste doesn't work so well when the forum takes out the spaces.

and for those who don't know the archer is a dummy unit.

flamestrike autolearn
Events
Unit - A unit Learns a skill
Conditions
(Learned Hero Skill) Equal to Auto Flame Strike (devotion aura)
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Triggering unit)) Equal to players[0]
Then - Actions
Set flamebuff[0] = Auto Flame Strike - Level 1
Set flamebuff[1] = Auto Flame Strike - Level 2
Set flamebuff[2] = Auto Flame Strike - Level 3
Set flamebuff[3] = Auto Flame Strike - Level 4
Trigger - Add to flamestrike autocast 1 <gen> the event (Time - Every 40.00 seconds of game time)
Trigger - Turn on flamestrike autocast 1 <gen>
Trigger - Turn on flamestrike autolearn Copy <gen>
Trigger - Turn off (This trigger)
Else - Actions

flamestrike autolearn Copy
Events
Unit - A unit Learns a skill
Conditions
And - All (Conditions) are true
Conditions
((Triggering unit) has buff flamebuff[0]) Equal to True
(Learned Hero Skill) Equal to Auto Flame Strike (devotion aura)
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Triggering unit)) Equal to players[0]
Then - Actions
Trigger - Add to flamestrike autocast 1 Copy <gen> the event (Time - Every 30.00 seconds of game time)
Trigger - Turn on flamestrike autocast 1 Copy <gen>
Trigger - Turn on flamestrike autolearn Copy Copy <gen>
Trigger - Turn off (This trigger)
Else - Actions

flamestrike autolearn Copy Copy
Events
Unit - A unit Learns a skill
Conditions
And - All (Conditions) are true
Conditions
((Triggering unit) has buff flamebuff[1]) Equal to True
(Learned Hero Skill) Equal to Auto Flame Strike (devotion aura)
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Triggering unit)) Equal to players[0]
Then - Actions
Trigger - Add to flamestrike autocast 1 Copy Copy <gen> the event (Time - Every 20.00 seconds of game time)
Trigger - Turn on flamestrike autocast 1 Copy Copy <gen>
Trigger - Turn on flamestrike autolearn Copy Copy Copy <gen>
Trigger - Turn off (This trigger)
Else - Actions

flamestrike autolearn Copy Copy Copy
Events
Unit - A unit Learns a skill
Conditions
And - All (Conditions) are true
Conditions
((Triggering unit) has buff flamebuff[2]) Equal to True
(Learned Hero Skill) Equal to Auto Flame Strike (devotion aura)
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Triggering unit)) Equal to players[0]
Then - Actions
Trigger - Add to flamestrike autocast 1 Copy Copy Copy <gen> the event (Time - Every 10.00 seconds of game time)
Trigger - Turn on flamestrike autocast 1 Copy Copy Copy <gen>
Trigger - Turn off (This trigger)
Else - Actions

flamestrike autocast 1
Events
Conditions
Actions
Set unitgroups1 = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to |cffBC310ERed Dragon Demon Hunter|r))
Unit Group - Pick every unit in unitgroups1 and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) has buff flamebuff[0]) Equal to True
(Owner of (Picked unit)) Equal to players[0]
Then - Actions
Set points = (Position of (Picked unit))
Unit - Create 1 Archer for (Owner of (Picked unit)) at points facing Default building facing degrees
Unit - Order (Last created unit) to Human Blood Mage - Flame Strike points
Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
Custom script: call RemoveLocation(udg_points)
Else - Actions
Custom script: call DestroyGroup(udg_unitgroups1)

flamestrike autocast 1 Copy
Events
Conditions
Actions
Set unitgroups2 = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to |cffBC310ERed Dragon Demon Hunter|r))
Unit Group - Pick every unit in unitgroups2 and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) has buff flamebuff[1]) Equal to True
(Owner of (Picked unit)) Equal to players[0]
Then - Actions
Set points = (Position of (Picked unit))
Unit - Create 1 Archer for (Owner of (Picked unit)) at points facing Default building facing degrees
Unit - Order (Last created unit) to Human Blood Mage - Flame Strike points
Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
Custom script: call RemoveLocation(udg_points)
Else - Actions
Custom script: call DestroyGroup(udg_unitgroups2)

flamestrike autocast 1 Copy Copy
Events
Conditions
Actions
Set unitgroups3 = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to |cffBC310ERed Dragon Demon Hunter|r))
Unit Group - Pick every unit in unitgroups3 and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) has buff flamebuff[2]) Equal to True
(Owner of (Picked unit)) Equal to players[0]
Then - Actions
Set points = (Position of (Picked unit))
Unit - Create 1 Archer for (Owner of (Picked unit)) at points facing Default building facing degrees
Unit - Order (Last created unit) to Human Blood Mage - Flame Strike points
Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
Custom script: call RemoveLocation(udg_points)
Else - Actions
Custom script: call DestroyGroup(udg_unitgroups3)

flamestrike autocast 1 Copy Copy Copy
Events
Conditions
Actions
Set unitgroups4 = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to |cffBC310ERed Dragon Demon Hunter|r))
Unit Group - Pick every unit in unitgroups4 and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) has buff flamebuff[3]) Equal to True
(Owner of (Picked unit)) Equal to players[0]
Then - Actions
Set points = (Position of (Picked unit))
Unit - Create 1 Archer for (Owner of (Picked unit)) at points facing Default building facing degrees
Unit - Order (Last created unit) to Human Blood Mage - Flame Strike points
Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
Custom script: call RemoveLocation(udg_points)
Else - Actions
Custom script: call DestroyGroup(udg_unitgroups4)
 
Last edited:
Status
Not open for further replies.
Top