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

[Trigger] Hashtables, help...

Status
Not open for further replies.
Level 2
Joined
Jul 22, 2013
Messages
6
I will admit, I do not understand hashtables what so ever. I am trying to use Simple Spell Power system in my map. I am trying to make an AoE ability do extra damage based on spell power. It does not do anything that I can tell, though...I followed a tutorial on how to do this for AoE abilities, but...I dunno...I can't really explain. I will post my triggers, and hopefully someone can help me with my problem.

Edit: For reference, Simple Spell Power System and Hashtables Tutorial that I tried to follow and modify/use.

  • Rain of Fire SP
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Rain of Fire Level 1
          • (Ability being cast) Equal to Rain of Fire Level 2
          • (Ability being cast) Equal to Rain of Fire Level 3
    • Actions
      • -------- ////////// --------
      • -------- Set SP_Unit --------
      • Set SP_Unit = (Triggering unit)
      • Hashtable - Save Handle OfSP_Unit as 4 of RoFCaster in SP_Hashtable
      • -------- ////////// --------
      • -------- Run the SP Get Trigger to get SP_CurrentValue from SP_Unit --------
      • Trigger - Run SP Get <gen> (ignoring conditions)
      • -------- ////////// --------
      • -------- Use the SP_CurrentValue --------
      • Set SP_CurrentValue = (SP_CurrentValue / 2.00)
      • Unit Group - Pick every unit in (Units within 600.00 of (Target point of ability being cast) matching (((Matching unit) belongs to an enemy of (Triggering player)) Equal to True)) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to AoEDMG
          • Set RemainingTime = 8.00
          • Hashtable - Save RemainingTime as 5 of (Key (Picked unit)) in SP_Hashtable
  • Rain of Fire Damage
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in AoEDMG and do (Actions)
        • Loop - Actions
          • Set SP_Unit = (Load 4 of RoFCaster in SP_Hashtable)
          • Set RemainingTime = (Load 5 of (Key (Picked unit)) from SP_Hashtable)
          • Custom script: set udg_SP_Key = GetHandleId(udg_SP_Unit)
          • Trigger - Run SP Get <gen> (ignoring conditions)
          • Set SP_CurrentValue = (SP_CurrentValue / 2.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RemainingTime Greater than 0.00
        • Then - Actions
          • Unit - Cause SP_Unit to damage (Picked unit), dealing SP_CurrentValue damage of attack type Spells and damage type Normal
          • Floating Text - Create floating text that reads (String((Integer(SP_CurrentValue)))) above (Picked unit) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
          • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 0.75 seconds
          • Set RemainingTime = (RemainingTime - 1.00)
        • Else - Actions
          • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in SP_Hashtable
          • Unit Group - Remove (Picked unit) from AoEDMG
  • SP Get
    • Events
    • Conditions
    • Actions
      • Custom script: set udg_SP_Key = GetHandleId(udg_SP_Unit)
      • Set SP_CurrentValue = (Load 1 of SP_Key from SP_Hashtable)
The SP Get trigger is not mine, it came with the system. Figured I'd post it, since I do refer to it in one of those triggers. The trigger I based this off of DID work, and did do damage and showed floating text to indicate the damage. Currently, this does not seem to be doing anything...No numbers, no damage. If someone could help, I would greatly appreciate it...and I'm sorry if I explained horribly, but if I need to add any more information I will, just ask for it.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Event: Time - Elapsed game time is 1.00 seconds
Should be
Time - Every 1.00 seconds of gametime.

You have some leaks too.

Hashtables are reaaaaaaaaaally easy to work with JASS and makes their functioning a lot more efficient.

  • t
    • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in SP_Hashtable
    • Unit Group - Remove (Picked unit) from AoEDMG
    • IF Number of units in AoEDMG is = 0 Turn off Rain of Fire Damage <<<<<<<<-----------
  • Set SP_CurrentValue = (SP_CurrentValue / 2.00)
  • Trigger - Turn on Rain of Fire Damage <<<<<<<<-----------
  • Unit Group - Pick every unit in (Units within 600.00 of (Target point of ability being cast) matching (((Matching unit) belongs to an enemy of (Triggering player)) Equal to True)) and do (Actions)
    • Loop - Actions
      • Unit Group - Add (Picked unit) to AoEDMG
      • Set RemainingTime = 8.00
      • Hashtable - Save RemainingTime as 5 of (Key (Picked unit)) in SP_Hashtable
 
Level 2
Joined
Jul 22, 2013
Messages
6
Ahahahaha! Thank you...I was so focused on seeing what I had done wrong with the hashtables, I didn't bother to look at the event. >_< I feel a little stupid now :p Yeah, I figured there were leaks. I am still working on getting rid of them.

Edit: I changed the event, still doesn't work @_@
 
Level 2
Joined
Jul 22, 2013
Messages
6
Okay, thanks for the help guys...I am now just going to create my own spell power system, using a hashtable I make myself...That way I can keep track of where everything is stored, and how...Trying to work off someone elses is just confusing me. I have gotten one spell working, and think I have the hang of it now.
 
Level 2
Joined
Jul 22, 2013
Messages
6
He meant he would use his own hashtable variable instead of looking/using the one in the tutorial/system. He didn't mean that he was going to implement his own custom hashtable data structure. ;P

^ Yep.

Also, I've gotten it working. When I started this thread, I had absolutely no understanding of hash-tables. Now that I made my own, I know how they work now. Also, what I was trying to do in that trigger just wouldn't have worked...

I ended up making a Rain of Fire spell based off Healing Ward. Made my own ward, gave it a separate buff.

  • Rain of Fire WARD
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) has buff RoFDummyBuff ) Equal to True)) and do (Actions)
        • Loop - Actions
          • Set RoFDummyUnit = (Picked unit)
          • Set RoFLoC = (Position of (Picked unit))
          • Set RoFOwner = (Owner of (Picked unit))
          • Unit Group - Pick every unit in (Units in (Playable map area) owned by RoFOwner) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is A Hero) Equal to True
                • Then - Actions
                  • Set SP_CurrentValue = (Load 1 of (Key (Picked unit)) from MYHASH)
                  • Set RoFHero = (Picked unit)
                • Else - Actions
                  • Do nothing
          • Unit - Cause RoFHero to damage circular area after 0.00 seconds of radius 350.00 at RoFLoC, dealing (SP_CurrentValue / 3.00) damage of attack type Spells and damage type Normal
          • Floating Text - Create floating text that reads ((String((SP_CurrentValue / 3.00))) + (AoE (350) Damage)) at RoFLoC with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
          • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 0.75 seconds
      • Custom script: call RemoveLocation (udg_RoFLoC)
This is my new trigger. I know having it run every 1 second of game time probably isn't good, but I just can't seem to figure out any other way to get this to work, and be MUI.

If anyone reads this, can you please tell me how to destroy floating text, but still have it display for the specified time? I've tried the GUI version of destroying it, and the custom script, but it doesn't even appear if I do either of them.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
  • (Units in (Playable map area) matching (((Matching unit) has buff RoFDummyBuff ) Equal to True))
Leaks. Declare the group in a variable, use the variable, then use "call DestroyGroup(udg_YourVariableName)" as a custom script

  • (Units in (Playable map area) owned by RoFOwner)
Leaks too

  • Unit - Cause RoFHero to damage circular area after 0.00 seconds of radius 350.00 at RoFLoC, dealing (SP_CurrentValue / 3.00) damage of attack type Spells and damage type Normal
Circular damage is bugged. You have pick units around and damage them individually or cast some AoE ability (like war stomp or thunderclap) witht he desired damage (as long as it's fixed)

You have to turn on the trigger when it has at least 1 unit, and turn off the trigger if it has 0. Else you waste resources.
 
Level 2
Joined
Jul 22, 2013
Messages
6
  • (Units in (Playable map area) matching (((Matching unit) has buff RoFDummyBuff ) Equal to True))
Leaks. Declare the group in a variable, use the variable, then use "call DestroyGroup(udg_YourVariableName)" as a custom script

  • (Units in (Playable map area) owned by RoFOwner)
Leaks too

  • Unit - Cause RoFHero to damage circular area after 0.00 seconds of radius 350.00 at RoFLoC, dealing (SP_CurrentValue / 3.00) damage of attack type Spells and damage type Normal
Circular damage is bugged. You have pick units around and damage them individually or cast some AoE ability (like war stomp or thunderclap) witht he desired damage (as long as it's fixed)

You have to turn on the trigger when it has at least 1 unit, and turn off the trigger if it has 0. Else you waste resources.

Alright, thank you! I knew I had leaks, but haven't gotten around to fixing them/learning what leaks and how to fix it.
 
Status
Not open for further replies.
Top