• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

GetExpiredTimer

Status
Not open for further replies.
Level 10
Joined
Dec 15, 2012
Messages
650
:ogre_haosis: I just share what I know to here. I don't know how many people knew this. It's useful.
  • Jump Start
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
    • Actions
      • Unit - Add Crow Form to (Triggering unit)
      • Unit - Remove Crow Form from (Triggering unit)
      • Animation - Change (Triggering unit) flying height to 175.00 at 750.00
      • Unit - Turn collision for (Triggering unit) Off
      • Countdown Timer - Start Timer[(Player number of (Triggering player))] as a One-shot timer that will expire in 0.20 seconds //You can just use "register event" for all units and players
      • Set Jump_Unit[(Player number of (Triggering player))] = (Triggering unit)
  • Jump End
    • Events
      • Time - Timer[1] expires
      • Time - Timer[2] expires
      • Time - Timer[3] expires
      • Time - Timer[4] expires
      • Time - Timer[5] expires
      • Time - Timer[6] expires
      • Time - Timer[7] expires
      • Time - Timer[8] expires
      • Time - Timer[9] expires
      • Time - Timer[10] expires
      • Time - Timer[11] expires
      • Time - Timer[12] expires
    • Conditions
    • Actions
      • For each (Integer B) from 1 to 12, do (Actions)
        • Loop - Actions
          • Custom script: if GetExpiredTimer() == udg_Timer[bj_forLoopBIndex] then
          • Set Off = (Integer B)
          • Custom script: endif
      • Unit - Add Crow Form to Jump_Unit[Off]
      • Unit - Remove Crow Form from Jump_Unit[Off]
      • Animation - Change Jump_Unit[Off] flying height to 0.00 at 1000.00
      • Unit - Turn collision for Jump_Unit[Off] On
 
Level 10
Joined
Dec 15, 2012
Messages
650
Then how about this ?? I only know GUI xD
  • Start
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set Index = (Index + 1)
      • Set StupidUnit[Index] = (Triggering unit)
      • Countdown Timer - Start Timer[Index] as a One-shot timer that will expire in 10.00 seconds
      • Trigger - Add to End <gen> the event (Time - Timer[Index] expires)
  • End
    • Events
    • Conditions
    • Actions
      • Set Index_End = (Index_End + 1)
      • For each (Integer A) from Index_End to Index, do (Actions)
        • Loop - Actions
          • Custom script: if GetExpiredTimer() == udg_Timer[bj_forLoopBIndex]
          • -------- Do action with StupidUnit[bj_forLoopBIndex] --------
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
That's still linear search. Try storing the timer index on the hashtable using the timer as a key. I dunno it looks on GUI though, gimme a minute.

EDIT:

  • Actions
    • Custom script: set udg_Key=GetHandleId(udg_Timer[udg_TimerIndex])
    • Hashtable - Save (Key Key) as 0 of TimerIndex in HashTable
  • Actions
    • Set TimerIndex = (Load (Key (Expiring timer)) of 0 from HashTable)
    • -------- Do actions --------
There, you add those actions to the onCast, on the onExpire you replace the loop with that one.
 
Level 10
Joined
Dec 15, 2012
Messages
650
Thank you for replying to this thread ! I appreciated it.
@ Malhorne, I think I don't need it becus I developed a new one :D
@ Waterknight, add 8k events at once !? I never use hashtable -.- don't tell me how hashtable pro as I'm a noob ;_;
@ Maker, it doesn't really matter xD
@ chobibo, I don't know about hashtable but I think this the same trick from what you gave. Check this :
(don't tell me this is someting like AVL Tree 'T_T')
  • Jump Start
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to @ Jump
    • Actions
      • Set Index = (Index + 1)
      • Countdown Timer - Start Timer[Index] as a One-shot timer that will expire in 0.60 seconds
      • Trigger - Add to Jump End <gen> the event (Time - Timer[Index] expires)
      • Unit - Add Crow Form to (Triggering unit)
      • Unit - Remove Crow Form from (Triggering unit)
      • Animation - Change (Triggering unit) flying height to 400.00 at 600.00
      • Unit - Turn collision for (Triggering unit) Off
      • Set Jump_Unit[Index] = (Triggering unit)
  • Jump End
    • Events
    • Conditions
    • Actions
      • Set Off = (Off + 1)
      • Unit - Add Crow Form to Jump_Unit[Off]
      • Unit - Remove Crow Form from Jump_Unit[Off]
      • Animation - Change Jump_Unit[Off] flying height to 0.00 at 1000.00
      • Unit - Turn collision for Jump_Unit[Off] On
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Actually, in jass, you normally do not register timer expiration events but use the direct functionality of

native TimerStart (timer whichTimer, real timeout, boolean periodic, code handlerFunc) returns nothing

to run a specific function on expiration.

And my idea was to not have to use hashtable but it was also kinda a joke.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
  • Trigger - Add to Jump End <gen> the event (Time - Timer[Index] expires)


122581-albums6790-picture76610.png

That mah boi, creates 1 event per cast. I haven't tested it mah boi, but I think that'll run the trigger action twice for the second cast, thrice for the third cast, you get mah point mah boi? Better start learning them hashtables mah boi, it won't be that hard and it would make yer life easier, yes sir! I bet it will!
 
Last time I used the no collision event, when trying to order the unit to go through a blizzard cliff it will try and go around it if you don't directly or close enough to the edge of it(even though it can go over the cliff).

So if you are using blizzard cliffs it would be better to replace the unit with a flying one(like crow form already does).
 
Status
Not open for further replies.
Top