HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Mana Steal

07-05-2005, 04:39 AM#1
Limb_Smasher
Im trying to make it so when a unit with the Mana Reaper item has a mana steal (like life steal). It takes 10% of their attack damage and adds it to their mana. This is what i have and it doesnt work.
Code:
Mana Reaper
    Events
        Unit - A unit Acquires an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Mana Reaper
    Actions
        Set ManaStealUnit = (Triggering unit)

Code:
Mana Reaper2
    Events
        Unit - A unit Is attacked
    Conditions
        (Attacking unit) Equal to ManaStealUnit
        ((Attacked unit) belongs to an ally of (Owner of ManaStealUnit)) Equal to False
    Actions
        Unit - Set mana of ManaStealUnit to ((Mana of ManaStealUnit) + ([b][u](Damage taken)[/u][/b] / 10.00))

I know the Damage taken doesnt work because it needs to specify the unit taking damage. Have any ideas how i could do this?
07-05-2005, 07:24 AM#2
Anitarf
The Damage Taken is an event response used with the "unit takes damage" specific unit event, so naturally it doesn't work with unit is attacked event. Just use "unit takes damage" and it will work.
07-05-2005, 07:36 AM#3
mogmiester
but unfortunatley the trigger will also run if the unit uses a spell, which could be overcome by completely triggering the spells, but then you'd have to factor in spell immunity/resistance, or check if you can designate conditions on the damage source(ie attack/spell)
07-05-2005, 07:53 AM#4
Anitarf
Quote:
Originally Posted by mogmiester
but unfortunatley the trigger will also run if the unit uses a spell, which could be overcome by completely triggering the spells, but then you'd have to factor in spell immunity/resistance, or check if you can designate conditions on the damage source(ie attack/spell)
You can always dummy-cast all damage spells so it's not the hero that deals damage (I would say this is the best solution, however, it requires the whole map to be tailored to this single item).

You can also check if the damage dealt is within the projected hero's attack damage (projecting the damage can be troublesome as you have to take into account all possible effects if you want to be accurate, also, spells that deal similar damage to the hero's attack still get through).

You can also set a boolean to true whenever the hero attacks and to false whenever he begins casting an ability and only award mana steal if the boolean is true (doesn't work flawlessly with spells and attacks that have a delay in effect (such as projectiles)).


Anyway, Lord Vexorian accomplished this for his stackable orbs, and he says that except for rare exceptions, he managed to differentiate between damage from attacks and from spells.
07-05-2005, 04:17 PM#5
Limb_Smasher
Quote:
Originally Posted by Anitarf
You can also set a boolean to true whenever the hero attacks and to false whenever he begins casting an ability and only award mana steal if the boolean is true (doesn't work flawlessly with spells and attacks that have a delay in effect (such as projectiles)).

Quote:
Originally Posted by Anitarf
The Damage Taken is an event response used with the "unit takes damage" specific unit event, so naturally it doesn't work with unit is attacked event. Just use "unit takes damage" and it will work.

1. thats a good idea with the booleans, that i can do
2. again my problem how do i specify the unit in the event "Unit takes damage"?
07-07-2005, 07:17 AM#6
TaintedReality
I found a way that I believe would work to find the unit's damage. However, it might be kind of unflexible, but it still would work with a lot of abilities. You would need to edit it so there are no leaks,its multiinstanceable, etc. I just threw this up really quick as a base.

Code:
ManaSteal
    Events
        Unit - A unit Is attacked
    Conditions
        ((Attacking unit) has an item of type ManaStealer) Equal to True
    Actions
        Set StartLife = (Integer((Life of Attacked Unit)))
        Wait 2.00 seconds
        Set EndLife = (Integer((Life of Attacked Unit)))
        Set DamageTaken = (StartLife - EndLife)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Mana of (Attacked unit)) Greater than or equal to (DamageTaken x 0.10)
            Then - Actions
                Unit - Set mana of (Attacking unit) to ((Mana of (Attacking unit)) + (DamageTaken x 0.10))
                Unit - Set mana of (Attacked unit) to ((Mana of (Attacked unit)) - (DamageTaken x 0.10))
            Else - Actions
                Unit - Set mana of (Attacking unit) to ((Mana of (Attacking unit)) + (Mana of (Attacked unit)))
                Unit - Set mana of (Attacked unit) to 0.00


Hopefully this works, I haven't really tested it out yet but I should soon when I start to create my warrior class.
07-07-2005, 07:46 AM#7
Anitarf
Quote:
Originally Posted by Limb_Smasher
1. thats a good idea with the booleans, that i can do
2. again my problem how do i specify the unit in the event "Unit takes damage"?
1. It's not such a good idea, but ok...
2. Make another trigger which, whenever a unit enters playable map area, adds to your damage detection trigger a specific unit event for that unit.
07-09-2005, 03:36 AM#8
Limb_Smasher
Quote:
Originally Posted by Anitarf
Make another trigger which, whenever a unit enters playable map area, adds to your damage detection trigger a specific unit event for that unit.
Still dont know how to do that, could ya show me how? thanks
07-09-2005, 11:37 AM#9
Anitarf
Quote:
Originally Posted by Limb_Smasher
Still dont know how to do that, could ya show me how? thanks
Action -> Trigger -> Add new event