• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Need help fixing this spell

Status
Not open for further replies.
Level 16
Joined
Apr 4, 2011
Messages
995
I was working on a spell, messing around, and I came upon a problem that I don't know how to solve, the damage part of the spell isn't working correctly.


  • Events
    • Map initialization
  • Conditions
  • Actions
    • Hashtable - Create a hashtable
    • Set Scythe_Hash = (Last created hashtable)
    • -------- Level 1 --------
    • Set Scythe_Damage[1] = 40.00
    • Set Lightning_Strikes[1] = 2
    • -------- Level 2 --------
    • Set Scythe_Damage[2] = 80.00
    • Set Lightning_Strikes[2] = 3
    • -------- Level 3 --------
    • Set Scythe_Damage[3] = 120.00
    • Set Lightning_Strikes[3] = 4
    • -------- Level 4 --------
    • Set Scythe_Damage[4] = 160.00
    • Set Lightning_Strikes[4] = 5
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Wind Scythe
  • Actions
    • Set Scythe_Level = (Level of Wind Scythe for (Triggering unit))
    • Set Point1 = (Target point of ability being cast)
    • Special Effect - Create a special effect at Point1 using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
    • Set Point2 = (Point1 offset by 80.00 towards 0.00 degrees)
    • Unit - Create 1 Wind Scythe for (Owner of (Triggering unit)) at Point2 facing 90.00 degrees
    • Unit - Add a 3.20 second Generic expiration timer to (Last created unit)
    • Set Point2 = (Point1 offset by 80.00 towards 180.00 degrees)
    • Unit Group - Add (Last created unit) to Wind_Scythe_Unit
    • Unit - Create 1 Wind Scythe for (Owner of (Triggering unit)) at Point2 facing 270.00 degrees
    • Unit - Add a 3.20 second Generic expiration timer to (Last created unit)
    • Unit Group - Add (Last created unit) to Wind_Scythe_Unit
    • Hashtable - Save Scythe_Level as 1 of (Key (Triggering unit)) in Scythe_Hash
    • Custom script: call RemoveLocation(udg_Point1)
    • Custom script: call RemoveLocation(udg_Point2)
    • Special Effect - Destroy (Last created special effect)
  • Events
    • Time - Every 0.02 seconds of game time
  • Conditions
  • Actions
    • Unit Group - Pick every unit in Wind_Scythe_Unit and do (Actions)
      • Loop - Actions
        • Set Wind_Scythe = (Picked unit)
        • Set CastAngle = ((Facing of Wind_Scythe) + 4.00)
        • Set Scythe_Level = (Load 1 of (Key (Picked unit)) from (Last created hashtable))
        • Set Point1 = (Position of (Picked unit))
        • Set Point2 = (Point1 offset by 12.00 towards ((Facing of (Picked unit)) + 4.00) degrees)
        • Unit - Move Wind_Scythe instantly to Point2, facing CastAngle degrees
        • Unit Group - Pick every unit in (Units within 50.00 of Point2 matching (((Picked unit) belongs to an enemy of (Owner of Wind_Scythe)) Equal to True)) and do (Actions)
          • Loop - Actions
            • Unit - Cause Wind_Scythe to damage (Picked unit), dealing Scythe_Damage[Scythe_Level] damage of attack type Spells and damage type Normal
            • Special Effect - Create a special effect at Point2 using Objects\Spawnmodels\Other\BeastmasterBlood\BeastmasterBlood.mdl
            • Special Effect - Destroy (Last created special effect)
        • Custom script: call RemoveLocation(udg_Point1)
        • Custom script: call RemoveLocation(udg_Point2)
Put simply, the spell is supposed to make two flying sheep that spin around the cast point, dealing damage to the units it contacts with. I got the unit movement part, so far the spell makes two flying sheep that do a sideways eight around the cast point, but the spell doesn't do any damage. (The lightning strikes part is something unrelated don't worry about it)


Any help on this would be appreciated. Thanks
 
First of all, right before the "Unit Group - Pick every unit in (Units within 50.00 of Point2" loop, use this action:
  • Custom script: set bj_wantDestroyGroup = true
Second of all, the damage is not done properly, because you save the level of the ability to the caster, not the last created unit, which you manually pick in the periodic trigger. So, this line:
  • Hashtable - Save Scythe_Level as 1 of (Key (Triggering unit)) in Scythe_Hash
Should be:
  • Hashtable - Save Scythe_Level as 1 of (Key (Last created unit)) in Scythe_Hash
 
Level 16
Joined
Apr 4, 2011
Messages
995
Pharoah_

I did the two changes you said (I copied the custom script exactly and I changed the saving of the hashtable to last created unit), and after tinkering with it a bit, I realized the damage wasn't being done because the units werent being selected here:
  • Unit Group - Pick every unit in (Units within 50.00 of Point2 matching (((Picked unit) belongs to an enemy of (Owner of Wind_Scythe)) Equal to True)) and do (Actions)
Currently I have it as:
  • Unit Group - Pick every unit in (Units within 40.00 of Point2) and do (Actions)
Which deals the damage, but it also deals it to friendly units, and causes the two units which are the missile (the sheep) to spawn the blood effect also. Is there a way to get it so it just targets the enemies because it is also hurting the caster?
 
Oh, just spotted another case:
  • Unit Group - Pick every unit in (Units within 50.00 of Point2 matching (((Picked unit) belongs to an enemy of (Owner of Wind_Scythe)) Equal to True)) and do (Actions)
When you use "Matching" conditions, you need (Matching unit). Replace (Picked unit) with (Matching unit) and use (Picked unit) under the Loop - Actions only.

Finally, 40.00 range is too low, try 100-128.
 
Level 16
Joined
Apr 4, 2011
Messages
995
I have another spell related problem (I am new to hashtables)

This spell is supposed to make a stationary object which explodes after X seconds, dealing 100 damage, and draining mana and health over time according to the units intelligence. Currently the exploding part works (I think) and the 100 damage part of the second trigger is activating three times while the mana and health drain isn't working at all. Here are the triggers

  • Events
    • Map initialization
  • Conditions
  • Actions
    • -------- Wind Storm --------
    • Hashtable - Create a hashtable
    • Set Storm_Hash = (Last created hashtable)
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Wind Storm
  • Actions
    • Set Storm_Countdown[1] = 5.00
    • Set Storm_Countdown[2] = 4.50
    • Set Storm_Countdown[3] = 4.00
    • Set Storm_Countdown[4] = 3.50
    • Set Storm_Duration[1] = 1.50
    • Set Storm_Duration[2] = 2.00
    • Set Storm_Duration[3] = 2.50
    • Set Storm_Duration[4] = 3.00
    • Set Storm_Level = (Level of Wind Storm for (Triggering unit))
    • Set Point1 = (Target point of ability being cast)
    • Unit - Create 1 Wind Storm for (Owner of (Triggering unit)) at Point1 facing Default building facing degrees
    • Unit - Add Wind Storm Slow (Tornado) to (Last created unit)
    • Unit - Set level of Wind Storm Slow (Tornado) for (Last created unit) to Storm_Level
    • Unit Group - Add (Last created unit) to Storm_Unit
    • Special Effect - Create a special effect at Point1 using Abilities\Spells\Orc\Disenchant\DisenchantSpecialArt.mdl
    • Custom script: call RemoveLocation(udg_Point1)
    • Hashtable - Save Storm_Countdown[Storm_Level] as 0 of (Key (Last created unit)) in Storm_Hash
    • Hashtable - Save Storm_Level as 2 of (Key (Last created unit)) in Storm_Hash
  • Events
    • Time - Every 0.50 seconds of game time
  • Conditions
  • Actions
    • Unit Group - Pick every unit in Storm_Unit and do (Actions)
      • Loop - Actions
        • Set Storm_Level = (Load 2 of (Key (Last created unit)) from Storm_Hash)
        • Set Storm = (Picked unit)
        • Set Point1 = (Position of Storm)
        • Set Storm_Countdown[Storm_Level] = (Load 0 of (Key (Last created unit)) from Storm_Hash)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Storm_Countdown[Storm_Level] Greater than 0.00
          • Then - Actions
            • Set Storm_Countdown[Storm_Level] = (Storm_Countdown[Storm_Level] - 0.50)
            • Hashtable - Save Storm_Countdown[Storm_Level] as 0 of (Key (Last created unit)) in Storm_Hash
          • Else - Actions
            • Unit Group - Pick every unit in (Units within 600.00 of Point1 matching (((Matching unit) belongs to an enemy of (Owner of Storm)) Equal to True)) and do (Actions)
              • Loop - Actions
                • Special Effect - Create a special effect at Point1 using war3mapImported\EMPBomb.mdx
                • Special Effect - Destroy (Last created special effect)
                • Unit - Cause Storm to damage (Picked unit), dealing 100.00 damage of attack type Spells and damage type Normal
                • Unit Group - Add (Picked unit) to Storm_DOT
                • Set Point2 = (Position of (Picked unit))
                • Special Effect - Create a special effect at Point2 using Abilities\Spells\Human\Polymorph\PolyMorphTarget.mdl
                • Special Effect - Destroy (Last created special effect)
                • Hashtable - Save Storm_Duration[Storm_Level] as 1 of (Key (Picked unit)) in Storm_Hash
                • Custom script: call RemoveLocation(udg_Point2)
            • Unit - Explode Storm
        • Custom script: call RemoveLocation(udg_Point1)
  • Events
    • Time - Every 0.50 seconds of game time
  • Conditions
  • Actions
    • Unit Group - Pick every unit in Storm_DOT and do (Actions)
      • Loop - Actions
        • Set Storm_Duration[Storm_Level] = (Load 1 of (Key (Last created unit)) from Storm_Hash)
        • Set Storm_Level = (Load 2 of (Key (Last created unit)) from Storm_Hash)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Storm_Duration[Storm_Level] Greater than 0.00
          • Then - Actions
            • Set Storm_Duration[Storm_Level] = (Storm_Duration[Storm_Level] - 0.50)
            • Set Storm_Int = (Real((Intelligence of (Picked unit) (Include bonuses))))
            • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - Storm_Int)
            • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - Storm_Int)
            • Hashtable - Save Storm_Countdown[Storm_Level] as 1 of (Key (Last created unit)) in Storm_Hash
          • Else - Actions
            • Unit Group - Remove (Picked unit) from Storm_DOT
            • Hashtable - Clear all child hashtables of child (Key (Last created unit)) in Storm_Hash
Once again, any help is greatly appreciated, lol these hashtables are hard
 
1) You don't have to set the Storm_Coundown[] variable, everytime the spell is cast, you can set them once in the Map Initialization trigger. Unless you want values to be level-dependent, e.g. Level of ability + 2, then they don't need to be declared over and over again.

2) In the Else - actions of Wind Storm countdown, add a Trigger - Turn off trigger to avoid the looping of the trigger, because it still fires, since it considers Storm_Countdown[] less than 0. What is more, add a Trigger - Turn on Windstorm Countdown <gen> to Wind Storm Start trigger, to control when the trigger will fire up. Same goes to DOT trigger, use a Turn off, by checking if the DOT_Storm group is empty. If not, do the listed actions, else, turn the trigger off.

3)
  • Set Storm_Duration[Storm_Level] = (Load 1 of (Key (Last created unit)) from Storm_Hash)
    • Set Storm_Level = (Load 2 of (Key (Last created unit)) from Storm_Hash)
You are using Storm_Level before declaring it, swap the actions' queue.

4) Unit Group - Add (Last created unit) to Storm_Unit

You forgot to add the unit to Storm_DOT, that's why the Damage over time doesn't occur.

You need to generally improve the triggering, you use redundant variables and the way you load the values back, by replacing older ones is not the best.
Finally, you can fuse the DOT trigger and the Wind Storm Countdown into one trigger, especially when they share the same periodic event tick.
 
Status
Not open for further replies.
Top