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

Hashtable save is forever ?

Status
Not open for further replies.
Level 4
Joined
Apr 15, 2016
Messages
61
Is there any problem if I store one unit in a variable every cast ? More precisely, I have 2 trigger for this spell. One is when I begin channeling the spell, so the unit is stored in the variable (note that the variable is not created in the spell, only the unit is saved) and then the other trigger has the actual spell effect, with the event - starts the effect of an ability using the unit that was stored in the hashtable when it began channeling. But... should I turn off the trigger "Begin channeling" (so it would save only once and then it would work well forever [look the thread tittle] or let it on (storing every time I begin casting) ?



ANOTHER QUESTION (THIS HAS NOTHING TO DO WITH WORLD EDITOR): Why did I get banned ? I didn't even know man, last time I visited here was a long (but not so long, 3 months maybe) ago and then suddenly I got banned. I use this site alot, get models all the time here. Y didi u bna me host ?

HDM was my name.
 
Level 4
Joined
Apr 15, 2016
Messages
61
Haha maybe they banned me for this stupid english xd. On a serious note, I really want to know WHY I got banned...

What I'm asking is:

1 - Having two triggers for one ability is healthy ? Imagine if I wanted to make a spell that when the effect (not SFX, I mean the actions, what the spell does, like, dash, sends a missile, steal life, stuns the area around, etc) started it would do, let's say, dash to the target location. A dash spell (or charge, whatever). I would use the event "Starts the Effect of an Ability" and would trigger the actions. But I would like to have an special effect (SFX) at the beginning of the cast (I know you can do it on Object Editor, but we are only supposing), so I created another trigger with the event "Begins Casting an ability" for that SAME ability. In the end you have two triggers for one ability, one when begins cast and the other when starts the effect. Is it healthy ? For the game ofc. No bug ? No Crash ?

2 - When anything is stored in an hashtable, it stays there forever ? If I store an unit in a hashtable, does it stays there no matter the reason ? Death ? Cancel the trigger? etc ?

I'm asking this because I have two triggers for one skill. One is the ability itself (uses the event starts the effect of an ability, and the actions are VERY WELL Triggered, it's a dash ability. "Set Caster = Caster" Turn on "Dash Period", etc). The other has the event "Begins Casting an ability", used for the same ability, which STORES the caster in an HASHTABLE that is USED IN THE FIRST SPELL TRIGGER (the spell itself). Could you get it ?

Summing up, one trigger creates the caster (in a hash) and the other trigger has the ability actions, and uses the caster stored in the hash. The difference is that the caster is created in a BEGINs casting trigger, and the spell effect is in a STARTS THE EFFECT trigger. Does this work normally ? I'm worried about the caster being stored in a hashtable everytime the ability begins being cast (that's why the tittle).
 
That is fine, especially since you are storing it in a hashtable. I assume you are using the "Key" of the caster as the ID, right?

And yes, data is stored in a hashtable until you clear it. When a unit is removed from the map, it might become null--but as far as I know it still takes up space. When you are done using a particular key in the hashtable, you should flush it (e.g. usually at the end of the spell).

Just to give you a little bit of insight into how a hashtable works--you store things with two keys and they map to the object you're storing. One key pair (parent key, child key) maps to a unique item. If you store something under that same (parent key, child key) pair, then the old item will be replaced in the hashtable. The hashtable will continue to reference that object until you remove the item from the hashtable, flush the parent key, or destroy the hashtable.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
"using the unit that was stored in the hashtable"
I am perfectly sure that all data given at "channeling" is also available at "effect".

You dont need a hashtable at all.

But to answer the question, your hashtable saves will remain until overwritten (same keys), removed (manually removed by RemoveSavedHandle(), FlushChild() or FlushParent()) or when the game ends.
 
Level 4
Joined
Apr 15, 2016
Messages
61
But I'm storing the caster in the hashtable on EVERY cast. Is it good ? Healthy ? Or should I turn off this trigger after it stores the caster (so cast the skill once, store the caster in the hashtable, then turn of this trigger, then the caster would be in the hashtable forever) ?

I'll post the trigger, wait a sec.

  • GGEz
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to The_Ability
    • Actions
      • -------- ----------------------------------------------------------------------------------------- --------
      • -------- ----------------------------------- Indexing ------------------------------------- --------
      • -------- ----------------------------------------------------------------------------------------- --------
      • Set HereComesTheIndex_MaxIndex = (BlaBla_MaxIndex + 1)
      • -------- -----------------------------------------------------------------------------
      • Set Caster[MaxIndex] = (Triggering unit)
/\ There are more actions, but I wont be pasting here, it doesn't matter.


  • GGHard
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to The_Ability (the same as above)
    • Actions
      • Set TempUnit = (Casting unit)
      • Custom script: call SaveInteger(udg_HashIcreated, GetUnitTypeId(udg_TempUnit), 0, 0)
      • Trigger - Turn off (This trigger) <- should be here ? or not ? if I take it off, then it means that on EVERY cast it will store. does this work normaly ?
The first tirgger uses the caster stored in the hashtable AND the caster MUI (index). Like I said, one trigger "Starts the Effect". The other "Begins Channeling" (maybe I forgot to say it was channel, MY FAULT SORRY). The world greatest questions. Does this work normaly ? Should the "Trigger - Turn Off" be there ?

NOTE: As you can see, there is a caster in the first trigger and another caster in the second trigger, which is stored in a hashtable.

You might be wondering now "Why the heck did he do this ? Two casters" believe me, it was the only way I could. The second trigger was using a unit that was ALREADY in the map (so it would be TempUnit = Footman 001, you got it ?). This was the only way I could find.
 
Last edited:
Level 4
Joined
Apr 15, 2016
Messages
61
Not ? and what is that "call SaveInteger(udg_HashIcreated, GetUnitTypeId(udg_TempUnit), 0, 0)" ?

You are right, there is no need for an hashtable, but I don't know how to do so.

The action I use the "What I thought that was" the caster hash is this one

  • Custom script: call SetUnitAnimationByIndex(udg_Caster[udg_My_MaxIndex], LoadInteger(udg_My_Hash, GetUnitTypeId(udg_Caster[udg_My_MaxIndex]), 1))
Basically what I want is to play the unit 1 animation (in this case, it's walk animation). I don't know how to do it with a index variable, so I used that other trigger.

How can I use this /\ script with no use of an hashtable ? What should I write ?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
What you are saving in the hashtable is an integer with the value of 0.
You use the unit type id of the caster and 0 as the keys to store it in.
In the custom script, you still use the caster from the variables and you use the index for his animation from the hashtable using the unit type id of the caster and 1 as keys.
So, you wont even be using the value that you stored in the hashtable.

So technically, you havent been using a hashtable at all... as far as you have shown your trigger.
 
Level 4
Joined
Apr 15, 2016
Messages
61
So how Can I make that Caster play the walk animation during all the ability without using the Hashtable and the caster stored there ? It's a dash/charge skill, so it has periodic trigger and index.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
So how Can I make that Caster play the walk animation during all the ability without using the Hashtable and the caster stored there ?
What he was saying is your hashtable calls are incorrect, not that you do not have to use them.

It is perfectly fine to save to a hashtable millions of times as long as after the value is no longer needed in the hashtable you clear it from the hashtable with the appropriate natives.
 
Status
Not open for further replies.
Top