HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Death Spell...

12-21-2005, 12:41 AM#1
Ignitedstar
Unfortunately for my skill, I have no idea how to do this(or if it's possible), so I thought I could turn to you guys. The help will be credited, so people will know that I didn't steal from you guys.

Okay, so the whole point in this "Death" spell is for it make it so that, the lower the targeted unit's life is from their Max health, the more likely chance that they will die instantly.

Of course if they're at their full health, it's a 100% blockage. It's more of a ratio thing. If the unit has approx. 41% of their life, then they have a 59% chance to die instantly. 32% HP, 68% death; 1% HP, 99% death, and so forth.

So, can you guys help? I think it's a little too much to ask for.
12-21-2005, 01:12 AM#2
aaero
Hey, I can help on this one. I'll give you the GUI since there are better people on the site to give you the JASS...but I bet you just want the GUI to learn from.

First make a custom ability based off of a single target spell like Slow. If you want it to target magic immune, you can use Finger of Death.

Your trigger should look like this:

Code:
Events - 
    A unit finishes casting a spell
Conditions  -
    Spell being cast Equal to Death
Actions -
    if ((Random Number between 1 and 100) > (Percentage of Life (Target Unit of Ability Being Cast)) then
      Actions -
          Unit - Kill Target Unit of Ability Being Cast

That's all. If this spell will be cast often, then you will have a memory leak to worry about (Target Unit of Ability Being Cast would need to be set to a local variable and taken care of). A more likely issue is the fact that the casting unit won't get "credit" for killing the target unit. If that's an issue, post again and someone (maybe me!) will help you take care of that.

Don't worry about giving credit by the way. And feel free to ask questions if you don't understand something or if something doesn't work.
12-21-2005, 01:20 AM#3
Anitarf
I have a few comments:

The event usually used for this is "a unit starts the effect of an ability". That's what happens when the unit casts the spell. The "finishes casting" comes afterwards, and sometimes it doesn't even happen, if the unit is interrupted by a new order before it finishes it's cast animation's backswing.

Do not fear, there is no leak.

For awarding experience for the kill, the best way is to use the damage unit trigger action. Instead of killing the target unit, have the casting unit deal an absurd ammount (just to be sure) of damage to it.
12-21-2005, 01:31 AM#4
aaero
Anitarf is right about the event and he must be right about the leak (though I thought when you retrieved a unit like that it would leak), but I didn't suggest that he force the caster to deal the damage for one reason.

Anitarf -
Maybe it's just been my experience, but there seems to be errors when you force a unit to damage another unit. If the unit you attempt to damage is already dead, the damage is instead dealt to the damage dealer. I've had this happen to me in a number of abilities (it's always a fairly rare occurence made more likely if there is a delay before the damage) and for this reason I always spawn a dummy unit to deal the damage. Have you never experienced that problem?

Also, I didn't suggest spawning a dummy because I think if someone has no idea how to start their spell, it's generally best to give them the simplest method first so it's easier to understand. That's just personal opinion though :)
12-21-2005, 06:44 AM#5
Anitarf
Dynamically created objects like locations and groups leak, but in this case, the function gives you an already existing unit, it doesn't create a new one.

As far as the damage triggers go, I have been reluctant to use them myself, they had some bugs when they first came out, but I think that was mostly fixed. It seems to work without problems where I use it so far, but I never attempt to damage dead units, I check if the unit is alive in all spells (both :) ) where I use it.

If you wanted to keep things simple, why mention the leak at all? :) Even if it was a leak, it's fairly insignificant.
12-21-2005, 06:52 AM#6
Ignitedstar
Thanks a lot, aaero and Anitarf. How easy was it to make that I wonder...