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

More help with projectile and stun hashtables

Status
Not open for further replies.
Level 8
Joined
Apr 30, 2009
Messages
338
I got my fireball spell to work perfectly via hashtables. The travel, impact, damage, and everything is cool. Now there is one more thing I wanted to try and code on my test spell map: dynamic debuff times.


In another thread I think I showed the correct code for stun debuff removal via hashtables on an instant-impact spell. Now the problem is I can't seem to get it right on my own projectile spell.


What I'm doing with this trigger here is saving all the spell information to the unique fireball projectile. When it impacts, it then transfers the damage and stun duration to the target. The damage transfers fine. The stun duration does not. It always is removed instantly.


I am pretty sure my problem is the handle of the target... let me try to explain:

The fireball spell is keyed to the fireball projectile to make it MUI. But the stun is keyed to the target unit. So the target unit in the fireball spell is "2 of Key(fireball) in Hashtable_Fireball" and the stun duration in the fireball spell is "4 of Key(fireball) in Hashtable_Fireball." When the spell does damage, I make a dummy unit that cast's an infinite stun on the target and I want to transfer the following data:

"4 of Key(fireball) in Hashtable_Fireball" = "duration of Key(target unit) in Hashtable_Stun"

I thought it would be easy to just put "2 of Key(fireball) in Hashtable_Fireball" as the target unit in my Stun table, but it seems to not work.


Any help? Below are the related triggers and my test map is attached.




FireballA: Takes all relevant stats from the caster and stores it to the created fireball projectile. Activates FireballB, which moves the projectile.
  • FireballA
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Fireball
    • Actions
      • -------- 0 of Key = Caster --------
      • -------- 1 of Key = Damage --------
      • -------- 2 of Key = Target --------
      • -------- 3 of Key = Speed --------
      • -------- 4 of Key = Stun Duration --------
      • Set temp_point0 = (Position of (Triggering unit))
      • Set temp_point1 = (Position of (Target unit of ability being cast))
      • Set temp_point2 = (temp_point0 offset by 50.00 towards ((Angle from temp_point0 to temp_point1) - 35.00) degrees)
      • Custom script: call RemoveLocation( udg_temp_point0 )
      • Unit - Create 1 projectile for (Owner of (Triggering unit)) at temp_point2 facing temp_point1
      • Custom script: call RemoveLocation( udg_temp_point1 )
      • Custom script: call RemoveLocation( udg_temp_point2 )
      • Hashtable - Save Handle Of(Triggering unit) as 0 of (Key (Last created unit)) in H_Fireball
      • Hashtable - Save ((20.00 + (60.00 x (Real((Level of (Ability being cast) for (Triggering unit)))))) + ((0.45 + (0.45 x (Real((Level of (Ability being cast) for (Triggering unit)))))) x (Load 100 of (Key (Triggering unit)) from H_Spellpower))) as 1 of (Key (Last created unit)) in H_Fireball
      • Hashtable - Save Handle Of(Target unit of ability being cast) as 2 of (Key (Last created unit)) in H_Fireball
      • Hashtable - Save 20.00 as 3 of (Key (Last created unit)) in H_Fireball
      • Hashtable - Save (Real((Level of Fireball for (Triggering unit)))) as 4 of (Key (Last created unit)) in H_Fireball
      • Unit Group - Add (Last created unit) to FireballGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (FireballB <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on FireballB <gen>
        • Else - Actions


FireballB: Moves all existing fireballs towards their targets and causes the damage/stun when the fireball impacts. It is here that I think I messed up with the transfer of the duration between the H_Fireball and H_Stun hashtables.
  • FireballB
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in FireballGroup) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in FireballGroup and do (Actions)
            • Loop - Actions
              • -------- 0 of Key = Caster --------
              • -------- 1 of Key = Damage --------
              • -------- 2 of Key = Target --------
              • -------- 3 of Key = Speed --------
              • -------- 4 of Key = Stun Duration --------
              • Set temp_point0 = (Position of (Picked unit))
              • Set temp_point1 = (Position of (Load 2 of (Key (Picked unit)) in H_Fireball))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between temp_point0 and temp_point1) Less than or equal to 20.00
                • Then - Actions
                  • Unit - Cause (Load 0 of (Key (Picked unit)) in H_Fireball) to damage (Load 2 of (Key (Picked unit)) in H_Fireball), dealing (Load 1 of (Key (Picked unit)) from H_Fireball) damage of attack type Spells and damage type Fire
                  • Special Effect - Create a special effect attached to the origin of (Load 2 of (Key (Picked unit)) in H_Fireball) using Abilities\Spells\Other\Incinerate\FireLordDeathExplode.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Unit - Create 1 dummy for (Owner of (Picked unit)) at temp_point0 facing Default building facing degrees
                  • Unit - Order (Last created unit) to Neutral - Firebolt (Load 2 of (Key (Picked unit)) in H_Fireball)
                  • Unit - Hide (Last created unit)
                  • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                  • Hashtable - Save (Load 4 of (Key (Picked unit)) from H_Fireball) as (Key duration) of (Key (Load 2 of (Key (Picked unit)) in H_Fireball)) in H_Stun
                  • Unit Group - Add (Load 2 of (Key (Picked unit)) in H_Fireball) to Stunned
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Stun <gen> is on) Equal to False
                    • Then - Actions
                      • Trigger - Turn on Stun <gen>
                    • Else - Actions
                      • Do nothing
                  • Unit Group - Remove (Picked unit) from FireballGroup
                  • Unit - Kill (Picked unit)
                  • Floating Text - Create floating text that reads (- + ((String((Integer((Load 1 of (Key (Picked unit)) from H_Fireball))))) + -)) at temp_point1 with Z offset 96.00, using font size 14.00, color (100.00%, 92.50%, 12.50%), and 0.00% transparency
                  • 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 1.00 seconds
                  • Floating Text - Set the velocity of (Last created floating text) to (Random real number between 96.00 and 256.00) towards (Random real number between 97.50 and 135.00) degrees
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in H_Fireball
                • Else - Actions
                  • Set temp_point2 = (Position of (Picked unit))
                  • Set temp_point3 = (temp_point2 offset by (Load 3 of (Key (Picked unit)) from H_Fireball) towards (Angle from temp_point0 to temp_point1) degrees)
                  • Hashtable - Save ((Load 3 of (Key (Picked unit)) from H_Fireball) + 0.20) as 3 of (Key (Picked unit)) in H_Fireball
                  • Unit - Move (Picked unit) instantly to temp_point3, facing temp_point1
                  • Custom script: call RemoveLocation( udg_temp_point2 )
                  • Custom script: call RemoveLocation( udg_temp_point3 )
              • Custom script: call RemoveLocation( udg_temp_point0 )
              • Custom script: call RemoveLocation( udg_temp_point1 )
        • Else - Actions
          • Trigger - Turn off (This trigger)


Stun: Pretty simple - checks every 0.1 seconds if the unit should still be stunned and removes the stun if not.
  • Stun
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Stunned) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Unit Group - Pick every unit in Stunned and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Load (Key duration) of (Key (Picked unit)) from H_Stun) Less than or equal to 0.00
                • Then - Actions
                  • Unit - Remove Stunned buff from (Picked unit)
                  • Unit Group - Remove (Picked unit) from Stunned
                • Else - Actions
                  • Hashtable - Save ((Load (Key duration) of (Key (Picked unit)) from H_Stun) - 0.10) as (Key duration) of (Key (Picked unit)) in H_Stun
 

Attachments

  • HashtablesTestMap.w3x
    52.5 KB · Views: 54
Level 37
Joined
Mar 6, 2006
Messages
9,240
I believe you can only have one map initialization trigger. Put all "create hahstable" thingies in the same trigger.

Where's your stun hashtable creation trigger?

Don't hide the dummy. Set it's model path to say

NONE.mdl

and it will be invisible.

Remove all "do nothing" calls.
 
Level 8
Joined
Apr 30, 2009
Messages
338
lol, yep I forgot to create the stun hashtable

so Do Nothing calls are just wasted lines?

And my map seems to work fine with multiple initialization triggers, but for a real map I will definitely want just one so I can remove the trigger when it finishes
 
Status
Not open for further replies.
Top