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

How to create a "dynamic" spell?

Status
Not open for further replies.
Level 6
Joined
Apr 23, 2008
Messages
263
yeah I dont know how to post triggers so:

Event - unit starts the effect of ability

Action - wait 3 seconds
- damage target unit of ability being cast

Of course this doesn't work, what advanced mechanics is needed to make this work? of course i want it to work when many spells of this type is being cast at the same time, thats why...


Event - unit starts the effect of ability

Action - set unit = target unit of ability being cast
- wait 3 seconds
- damage unit

...wont work
 
Level 6
Joined
Apr 23, 2008
Messages
263
As the damage of your spell seemed to work very different to mine I tried to start from scratch, experimenting my way forward.

  • Freeze Effect
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Freeze
    • Actions
      • Set tempPoint = (Position of (Triggering unit))
      • Set tempGroup = (Units within ((Real((Level of (Ability being cast) for (Triggering unit)))) x 300.00) of tempPoint matching (((Matching unit) belongs to an ally of (Owner of (Triggering unit))) Equal to False))
      • Unit Group - Pick every unit in tempGroup and do (Actions)
        • Loop - Actions
          • Hashtable - Save Handle Of(Picked unit) as (Key (Target unit of ability being cast)) of (Key (Picked unit)) in hashTable
          • Hashtable - Save Handle Of(Triggering unit) as (Key (Casting unit)) of (Key (Picked unit)) in hashTable
          • Hashtable - Save ((Level of (Ability being cast) for (Triggering unit)) x 100) as (Key damage) of (Key (Picked unit)) in hashTable
          • Hashtable - Save Handle OftempTimer as (Key timerhandle) of (Key (Picked unit)) in hashTable
          • Countdown Timer - Start (Load (Key timerhandle) of (Key (Picked unit)) in hashTable) as a One-shot timer that will expire in 3.00 seconds
          • Unit - Create 1 Dummy 1 for (Owner of (Triggering unit)) at tempPoint facing Default building facing degrees
          • Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Picked unit)
          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation(udg_tempPoint)
      • Custom script: call DestroyGroup(udg_tempGroup)
  • Freeze timer expires
    • Events
      • Time - tempTimer expires
    • Conditions
    • Actions
      • Unit - Cause (Load (Key (Casting unit)) of (Key freezeTargets) in hashTable) to damage (Load (Key (Target unit of ability being cast)) of (Key freezeTargets) in hashTable), dealing 200.00 damage of attack type Spells and damage type Normal
I got this so far, but it doesn't work, could you tell me what I should change?
 
Last edited:
Level 1
Joined
Jun 17, 2008
Messages
3
  • Spell DMG
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Level of (Triggering unit)) Greater than or equal to 1
      • (Level of (Triggering unit)) Less than or equal to 4
    • Actions
      • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing (Random real number between 1.00 and 50.00) damage of attack type Chaos and damage type Normal
      • Special Effect - Create a special effect at (Position of (Targeted unit)) using Abilities\Spells\Undead\DeathCoil\DeathCoilSpecialArt.mdl
This works for me. The important parts here are the event and the: Unit - Cause (Triggering unit......
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
  • Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • -------- Creates a local variable which won't be deleted until the spell is over --------
      • Custom script: local unit u
      • -------- save the target as a global variable --------
      • Set u = (Target unit of ability being cast)
      • -------- and save the global variable to the local one --------
      • Custom script: set u = udg_u
      • -------- Waits are unaccurate if you are waiting for less then 0.2 sec or if someone pauses the game but in this case there is not much which could go wrong --------
      • Wait 3.00 game-time seconds
      • -------- restore the casted unit saved in the local variable to the global variable --------
      • Custom script: set udg_u = u
      • -------- we don't have to save the triggering unit since it is local already (don't ask me why the others aren't but it is like that) --------
      • Unit - Cause (Triggering unit) to damage u, dealing 500.00 damage of attack type Spells and damage type Normal
      • -------- remove leaks (local variables have to be nulled (unless they are simple types such as real or integer)) --------
      • Custom script: set u = null
 
Level 6
Joined
Apr 23, 2008
Messages
263
if that works it's amazing, have to try right away

-----------------

the first thing, it has to work with a unit group, not a unit

the second thing, got error message from Custom script: local unit u
 
Level 6
Joined
Apr 23, 2008
Messages
263
I really don't want to take this to a point were I have to change my editor, thanks anyways guys.

I've been doing a lot of research about this I am trying to achieve, but the closest thing I can come to it is that you have a periodic event trigger which checks the remaining time of every unit, but this is absolutely terrible since then if you cast the spell between the periodic time event (if its once ever 1 seconds and you cast after 0.5 seconds), the duration of the spell will be 0 - 0.9 seconds more/less. I really cant explain this better, but I've given up.

Here you can find the THW tutorial on hashtables, look at the "Healing" trigger and you will know what I am talking about

More specifically: I can't manage to create a timer for each of the unit's that got hit by the spell, and then have a trigger activate when each one of the timers expire
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
if that works it's amazing, have to try right away

-----------------

the first thing, it has to work with a unit group, not a unit

the second thing, got error message from Custom script: local unit u

you can create local unit groups too
and for me "local unit u" works ( i dont have jngp though)
maybe it will work if you set it = null or = GetTriggerUnit() or something
 
Status
Not open for further replies.
Top