• 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.

[Solved] Hashtable Question

Status
Not open for further replies.
Level 16
Joined
May 2, 2011
Messages
1,351
Hello guys,

here is what I want to do
Each player has a timer that starts at when some event occurs. This will be array Timer[N]. The event of starting timer will be when townhall is built
Also, Each Player will have some unit variable Townhall[N], where N is player number

My question is:
could there possible be event in one trigger that says
Timer N expires
order townhall[of the timer or of N which is the player Number] to train peasant
let timer go again

in other words, is there any way I can axis the N of the timer array? like... There is triggering player.. but I havent seen triggering timer or something -.-....Edit: ok ive just seen triggering timer.. but is there a way to find out what N of the triggering timer is?

im also not very confident of my hastable yet, but let that aside for now



Edit: would be pretty easy if I can create trigger array maybe?
Edit: ok i just discovered there can be a trigger variable !!!! Edit: but how are we supposed to set it all up?
 
Last edited:
Level 16
Joined
May 2, 2011
Messages
1,351
yes that is possible. There is not even a need for hashtables.

with
JASS:
set some_timer_variable = GetExpiredTimer()
its quite simple, for learning I wont show any trigger unless you ask for it.
I did find this
  • Countdown Timer - Start (Expiring timer) as a One-shot timer that will expire in 5.00 seconds
Which makes me manipulate the expiring timer. But how can I take The index N of the expiring timer?
 
Level 5
Joined
May 6, 2013
Messages
125
One Timer per player, so i guess it would be totally fine to check for the correct timer in a loop. Just use a for loop and compare the expired timer to the ones in the array. GUI cant compare triggers if i remember correctly, so will have to compare Key(Expired Timer) == Key(TimerArray[Integer A]) or use a custom script,
 
Level 16
Joined
May 2, 2011
Messages
1,351
One Timer per player, so i guess it would be totally fine to check for the correct timer in a loop. Just use a for loop and compare the expired timer to the ones in the array. GUI cant compare triggers if i remember correctly, so will have to compare Key(Expired Timer) == Key(TimerArray[Integer A]) or use a custom script,

Just a quick question,
the key is some real value, yes?
Edit: also, I can get id of expiring timer, but how can i get id of timer[A]
when I go to variables, it says no variable of this type
I use gui
Edit: must I put it in hashtable then take it from there? thats sounds... psshhhh
 
Level 16
Joined
May 2, 2011
Messages
1,351
  • Custom script: set udg_HandleIdNoTable = GetHandleId(GetExpiredTimer())
thats what i used for my problem i hope it works

One Timer per player, so i guess it would be totally fine to check for the correct timer in a loop. Just use a for loop and compare the expired timer to the ones in the array. GUI cant compare triggers if i remember correctly, so will have to compare Key(Expired Timer) == Key(TimerArray[Integer A]) or use a custom script,


Edit: Ok Brilliant!
Thank you very very much
you're awsome!
 
Last edited:
Level 16
Joined
May 2, 2011
Messages
1,351
Here is the trigger

[TRIGGER=SetUpVariables]Events
Unit - A unit Finishes construction
Conditions
(Unit-type of (Triggering unit)) Equal to Demon Gate
Actions
Set PlayerNumber = (Player number of (Owner of (Triggering unit)))
Set Gate[PlayerNumber] = (Triggering unit)
Countdown Timer - Start TimeForDemonSpawn[PlayerNumber] as a One-shot timer that will expire in 10.00 seconds
Countdown Timer - Create a timer window for (Last started timer) with title Invasion
For each (Integer A) from 1 to 12, do (Actions)
Loop - Actions
Countdown Timer - Hide (Last created timer window) for (Player((Integer A)))
Countdown Timer - Show (Last created timer window) for (Player(PlayerNumber))
[/TRIGGER]

[TRIGGER=SpawnADemon]Events
Time - TimeForDemonSpawn[1] expires
Time - TimeForDemonSpawn[2] expires
Time - TimeForDemonSpawn[3] expires
Time - TimeForDemonSpawn[4] expires
Time - TimeForDemonSpawn[5] expires
Time - TimeForDemonSpawn[6] expires
Time - TimeForDemonSpawn[7] expires
Time - TimeForDemonSpawn[8] expires
Time - TimeForDemonSpawn[9] expires
Time - TimeForDemonSpawn[10] expires
Time - TimeForDemonSpawn[11] expires
Time - TimeForDemonSpawn[12] expires
Conditions
Actions
For each (Integer A) from 1 to 12, do (Actions)
Loop - Actions
Custom script: set udg_HandleIdNoTable = GetHandleId(GetExpiredTimer())
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Key (Expiring timer)) Equal to HandleIdNoTable
Then - Actions
Set RandomInteger = (Random integer number between 1 and 3)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
RandomInteger Equal to 1
Then - Actions
Player - Make Doom Guard (Demon Gate) Available for training/construction by (Player((Integer A)))
Unit - Order Gate[(Integer A)] to train/upgrade to a Doom Guard (Demon Gate)
Player - Make Doom Guard (Demon Gate) Unavailable for training/construction by (Player((Integer A)))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
RandomInteger Equal to 2
Then - Actions
Player - Make Infernal (Demon Gate) Available for training/construction by (Player((Integer A)))
Unit - Order Gate[(Integer A)] to train/upgrade to a Infernal (Demon Gate)
Player - Make Infernal (Demon Gate) Unavailable for training/construction by (Player((Integer A)))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
RandomInteger Equal to 3
Then - Actions
Player - Make Fel Ravager (Demon Gate) Available for training/construction by (Player((Integer A)))
Unit - Order Gate[(Integer A)] to train/upgrade to a Fel Ravager (Demon Gate)
Player - Make Fel Ravager (Demon Gate) Unavailable for training/construction by (Player((Integer A)))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Gate[(Integer A)] is alive) Equal to True
Then - Actions
Countdown Timer - Start (Expiring timer) as a One-shot timer that will expire in 100.00 seconds
Else - Actions
Else - Actions
[/TRIGGER]

This is the trigger I used. I still needed to use some custom scripts, specifically in GetHandleId() function
 
Status
Not open for further replies.
Top