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

Block damage spell. gets hit, but feels nothing?

Status
Not open for further replies.
Level 4
Joined
Sep 26, 2005
Messages
40
i'm trying to figure out a way to create a spell that blocks damage.. yet is not invunerable. if you've ever played Dota, it's something like the Faceless Void's passive ability that i'm trying to create.

the best i could come up with is using berserk ability and turning everything to 0 except the % damage recieved.. and set that to a negative value of -0.01%

if i set the negative higher than that, it heals him instead of just looking like it's blocking.

probablem is.. one creature hits him for a lot of damage, his life goes up quite noticably even with that small -0.01%


what i'd like to do is have it change his life none at all when hit during the spell duration.

the idea of the spell is to absorb damage, and feel nothing.

any ideas?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
You're unit will have to be stored as a global for you to be able to use the "takes damage" event.

THATS A LIE!
You do not have to store it as a global you can store it as a handle in a game cache for multincastability.
Some people say that GetTriggeringUnit() refers to the unit that took the damage as well meaning no storage of the unit is nessary.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
JASS:
function BlockDamage takes nothing returns nothing

local integer i = GetRandomInt( 1, x ) //x is an int between 1 and 100, 1 being 100 % chance, 100 being 1% chance, etc
local real r = GetEventDamage()

if i = 1 then

if GetUnitState( GetTriggerUnit(), UNIT_STATE_MAX_LIFE ) - r >= GetUnitState( GetTriggerUnit(), UNIT_STATE_LIFE ) then
call TriggerSleepAction( .75 )
call SetUnitState( GetTriggerUnit(), UNIT_STATE_LIFE, GetUnitState( GetTriggerUnit(), UNIT_STATE_LIFE ) + r )
else
call SetUnitState( GetTriggerUnit(), UNIT_STATE_LIFE, GetUnitState( GetTriggerUnit(), UNIT_STATE_LIFE ) + r )
endif

endif

endfunction

function Cond takes nothing returns boolean
return GetUnitAbilityLevel( GetTriggerUnit(), 'A000' ) > 0 // replace 'A000' with your ability rawcode
endfunction

function InitTrig_BlockDamage takes nothing returns nothing
set gg_trg_BlockDamage = CreateTrigger()
call TriggerRegisterUnitEvent( gg_trg_BlockDamage, YourUnitVariable, EVENT_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_BlockDamage, Condition( function Cond ) )
call TriggerAddAction( gg_trg_BlockDamage, function BlockDamage )
endfunction

this should work
 
Level 10
Joined
Apr 9, 2004
Messages
502
Dr Super Good said:
You're unit will have to be stored as a global for you to be able to use the "takes damage" event.

THATS A LIE!
You do not have to store it as a global you can store it as a handle in a game cache for multincastability.
Some people say that GetTriggeringUnit() refers to the unit that took the damage as well meaning no storage of the unit is nessary.

hmm i've treid using triggering unit but it doesn't work. Whatever, i know JASS allows for multiinstanceability but i don't think .GUI can normally do it.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Quote:
You're unit will have to be stored as a global for you to be able to use the "takes damage" event.


THATS A LIE!
You do not have to store it as a global you can store it as a handle in a game cache for multincastability.
Some people say that GetTriggeringUnit() refers to the unit that took the damage as well meaning no storage of the unit is nessary.

no offense, but do u even know how the handle vars work and what they are used for? it doesnt seem like it. You have to directly reference the function that will recieve the variable, and it has to be a preset time after you do whatever.

Unless i made some typos, my func should work. it just checks if the unit has the ability, then blocks the damage --- no messy globals, no handle vars ( which are used for periodic ( burn, slide, etc ) functions mostly ) and no damn Globals ( im just emphasizing the point )
 
Status
Not open for further replies.
Top