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

Need some help with this one...

Status
Not open for further replies.
Level 3
Joined
Aug 12, 2008
Messages
34
Okay, so I got this spell (once again)... and this time, I need your help (again).

So the idea behind it is that if a unit / hero should take damage (from a SINGLE attack) equal to or higher than 100 / 90 / 80 (decreasing for every level), it will release a small AoE attack attack that will deal 150 / 160 / 170 damage (increasing for every level) to nearby units. This cannot occur more than once every 2 sec.

What triggers or spell can I use for this?

Any help is appreciated, thanks. :D

~Razorwind~
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
First of all, you could implement this system.
It will do most of the work for you, detecting the incoming damage.

Then you should just create another trigger (with the event Game - GDD_Event becomes 0.00).
Check whether the hero has the spell you wish.
Check whether the incoming damage is greater than 110 - (spell level * 10)
-> Create AoE damage actions

For it to happen every 2 seconds, you could create a hashtable.
Save a boolean as "false" under the unit ID.
Create and start a timer, save the unit ID in the hashtable under the timer ID (further explanation below)
When the timer finishes, set the variable back to "true" and pause/destroy the timer.

The timer-part may be unclear, so:
  • Actions
    • Custom script: local timer time = CreateTimer()
    • Hashtable - Save False as (Key Damaged Unit) of 0 in HashTable
    • Custom script: set udg_HandleID = GetHandleId(time)
    • Hashtable - Save (Key Damaged Unit) as HandleID of 0 in HashTable
    • Custom script: call TimerStart(time, 2., false, function timerEnds)
    • Custom script: set time = null
As you can see:
1) You create a timer
2) You save "false" for the damaged unit (I suppose you know how hashtables work?)
3) You set an integer variable called "HandleID" to the ID of the timer.
4) You save the ID of the damaged unit inside the ID of the timer.
5) You run the timer (will end in 2. seconds, you can change that).


Then you need this (just copy it in the map's header):

JASS:
function timerEnds takes nothing returns nothing
    local integer h = GetHandleId(GetExpiredTimer())
    
    call SaveBoolean(udg_HashTable, 0, LoadInteger(udg_HashTable, 0, h), true)
    call PauseTimer(GetExpiredTimer())
    call DestroyTimer(GetExpiredTimer())
    call FlushChildHashtable(udg_HashTable, h)
endfunction

Change "udg_HashTable" with your hashtable's name ( + udg_ in front) and you're done.

Note: I don't know whether this is the most efficient method, it's the first one I can come up with... didn't really think about that.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
You need a timer system for the cooldown. You need a unit is attacked event and unit is damaged event for deetecting an attack and getting its damage. You will need some scaleable data structure to make it MUI.

That is the basics of what you need. For the attack damage detection youcould probably use an existing system available on the internet from sites such as this.
 
Level 3
Joined
Aug 12, 2008
Messages
34
I thank you both for the creative answers, but it currently seems that I've managed to handle the problem with the wonderful link you sent and came up with some triggers. I copied and pasted the triggers and variables and came up with this. However, I don't know if they might be leaking or cause errors;

  • Unstable Guard
  • Events
    • Game - GDD_Damage becomes Greater than or equal to 100.00
    • Conditions
      • (Myrmidon 0017 <gen> has buff Unstable Guard) Equal to True
    • Actions
      • Trigger - Turn off (This trigger)
      • Unit - Create 1 Dummy for Neutral Passive at (Position of Myrmidon 0017 <gen>) facing (Position of (Triggering unit))
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Unit - Remove (Last created unit) from the game
      • Wait 2.00 seconds
      • Trigger - Turn on (This trigger)
At least it works in-game :)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
It does leak (2 locations). I think you need to remove the "facing (position of Triggering Unit)" though, as there is no triggering unit. Just make it face 0., or let it face the damage source (a variable).
And that only works if only 1 unit in the entire map is able to cast that spell (which I didn't know, so I made it MUI).
 
Status
Not open for further replies.
Top