Spellpack Damage Dodge

NetherHawk

New Member
Reaction score
26
well this spellpack's theme is dodging incoming damage
based on: Dota's dispersion, aphotic shield and backtrack

Jass,MUI and leakless i hope
uses NewGen and local handle vars

i nearly killed all my brain cells doing these spells -- i wanna credit GalS~ and cr4xzZz for answering my queries =D enjoy

copy all the triggers and u will be fine, not forgeting the units, abilities, buffs.
overall : medium import difficulty

Dispersion
JASS:
globals
    real Min_Dispersion_Damage_Ratio  
endglobals


function DispersionFilter takes nothing returns boolean
	return IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE)==false and IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetTriggerUnit()))
endfunction

function DispersionDamage takes nothing returns nothing
	local unit u = GetTriggerUnit()
	local unit p = GetEnumUnit()
	local unit d = CreateUnit(GetOwningPlayer(u),'h002',GetUnitX(u),GetUnitY(u),0)
	local real r = Min_Dispersion_Damage_Ratio
	call UnitAddAbility(d,'A004')
	call IssueTargetOrderById(d,OrderId("thunderbolt"),p) // for the minor stun effect
        call UnitApplyTimedLife(d,'BTLF',1.00)
	call UnitDamageTarget(u,p,r,true,false,ATTACK_TYPE_HERO,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)// this is the dispersion damage
endfunction

function DispersionMain takes nothing returns nothing
	local unit u = GetTriggerUnit()
	local unit d
	local group g = CreateGroup()
	local real r = GetEventDamage()
	local boolexpr b = Condition(function DispersionFilter)
	local real r1 = GetUnitState(u,UNIT_STATE_LIFE)
	set Min_Dispersion_Damage_Ratio = ReturnMinReal(r,r1)// checks that damage being dealt will not exceed her life
	call DelayedDamageCheck(u,r)
	call GroupEnumUnitsInRange(g,GetUnitX(u),GetUnitY(u),400,b)
	call ForGroup(g,function DispersionDamage)
	call DestroyGroup(g)
	call DestroyBoolExpr(b)
	set d = CreateUnit(GetOwningPlayer(u),'h001',GetUnitX(u),GetUnitY(u),0)
	call SetUnitPathing(d,false)
	call SetUnitInvulnerable(d,true)
	call SetUnitAnimation(d,"Death") // just the purple effects
	call PolledWait(2)
	call RemoveUnit(d)
endfunction

function Dispersion_Chance takes nothing returns boolean
	return GetRandomInt(1,100)<=GetUnitAbilityLevel(GetTriggerUnit(),'A002')*10 and GetEventDamage()>5 
endfunction // you can adjust the chance for dispersion to occur here

function Dispersion_Jass_Actions takes nothing returns nothing
	local trigger tr2 = CreateTrigger()
	local unit u = GetTriggerUnit()
	call TriggerRegisterUnitEvent(tr2,u,EVENT_UNIT_DAMAGED)
	call TriggerAddCondition(tr2,Condition(function Dispersion_Chance))
	call TriggerAddAction(tr2,function DispersionMain)
endfunction

function Dispersion_Jass_Conditions takes nothing returns boolean
	return GetLearnedSkill()=='A002'and GetUnitAbilityLevel(GetTriggerUnit(),'A002')==1 and IsUnitIllusion(GetTriggerUnit())==false
endfunction

//===========================================================================
function InitTrig_Dispersion_Jass takes nothing returns nothing
        local trigger tr1 = CreateTrigger()
	call TriggerRegisterAnyUnitEventBJ(tr1,EVENT_PLAYER_HERO_SKILL)
	call TriggerAddCondition(tr1,Condition(function Dispersion_Jass_Conditions))
	call TriggerAddAction(tr1,function Dispersion_Jass_Actions)
endfunction


Backtrack
JASS:
function Trig_Backtrack_Jass_Conditions takes nothing returns boolean
	return GetLearnedSkill()=='A003'and IsUnitIllusion(GetTriggerUnit())==false
endfunction

function Backtrack_Main takes nothing returns nothing
	local unit u = GetTriggerUnit()
	local real r = GetEventDamage()
	if(r > 0)then
		if(GetRandomInt(1,100)<=(5 + (5*GetUnitAbilityLevel(u,'A003'))))then // chance to backtrack
			call SetUnitState(u,UNIT_STATE_LIFE,GetUnitState(u,UNIT_STATE_LIFE)+ r)
			call DestroyEffect(AddSpecialEffectTarget("Abilities\\Weapons\\WingedSerpentMissile\\WingedSerpentMissile.mdl",u,"hand,left"))
		endif
	endif
endfunction

function Trig_Backtrack_Jass_Actions takes nothing returns nothing
	local trigger tr
	if GetUnitAbilityLevel(GetTriggerUnit(),'A003')==1 then
		set tr=CreateTrigger()
		call TriggerRegisterUnitEvent(tr,GetTriggerUnit(),EVENT_UNIT_DAMAGED)
		call TriggerAddAction(tr,function Backtrack_Main)
	endif
endfunction

//===========================================================================
function InitTrig_Backtrack_Jass takes nothing returns nothing
        set gg_trg_Backtrack_Jass=CreateTrigger()
	call TriggerRegisterAnyUnitEventBJ(gg_trg_Backtrack_Jass,EVENT_PLAYER_HERO_SKILL)
	call TriggerAddCondition(gg_trg_Backtrack_Jass,Condition(function Trig_Backtrack_Jass_Conditions))
	call TriggerAddAction(gg_trg_Backtrack_Jass,function Trig_Backtrack_Jass_Actions)
endfunction


JASS:
globals
     unit AphoticShield_Caster
endglobals     


function Aphotic_Spell takes nothing returns boolean
	return GetSpellAbilityId()=='A005'
endfunction

function Aphotic_Filter takes nothing returns boolean
	if(IsUnitAlly(GetFilterUnit(),GetOwningPlayer(AphoticShield_Caster)))then
		return false
	endif
        if(IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)) then
                return false
        endif
	if(IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE))then
		return false
	endif
	return true
endfunction

function Aphotic_Lightning takes nothing returns nothing
        call UnitDamageTargetBJ(AphoticShield_Caster,GetEnumUnit(),(75 + (50*I2R(GetUnitAbilityLevel(AphoticShield_Caster,'A005')))),ATTACK_TYPE_HERO,DAMAGE_TYPE_MAGIC)
        call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl",GetEnumUnit(),"chest") )
endfunction

function Aphotic_ForkedLightning takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local unit ux = GetHandleUnit(t,"AphoticTarget")
	local location l = GetUnitLoc(ux)
	local group g1 = GetUnitsInRangeOfLocMatching(600,l,Condition(function Aphotic_Filter))
        call ForGroup(g1, function Aphotic_Lightning)
	call DestroyGroup(g1)  
        call RemoveLocation(l)
        call PauseTimer(t)
        call DestroyTimer(t)            
        set ux = null
        set t = null
        set l = null     
endfunction

function Aphotic_Heal takes nothing returns nothing
	local trigger tr = GetTriggeringTrigger()
	local real r = GetHandleReal(tr,"AphoticLife")
        local unit ux = GetTriggerUnit()
        local timer t = CreateTimer()
	if(r<GetEventDamage())then
		call DelayedDamageCheck(GetTriggerUnit(),r)
		call DestroyEffect(GetHandleFX(tr,"AphoticFX"))
		call DisableTrigger(tr)
		call SetHandleBoolean(tr,"AphoticDone",true)
		set AphoticShield_Caster = GetHandleUnit(tr,"AphoticOwner")
		call SetHandleHandle(t,"AphoticTarget",ux)
		call TimerStart(t,0,true,function Aphotic_ForkedLightning)
	elseif(GetEventDamage()>0)then
		call DelayedDamageCheck(GetTriggerUnit(),GetEventDamage())
		call SetHandleReal(tr,"AphoticLife",r-GetEventDamage())
	endif
endfunction

function Aphotic_Setting takes nothing returns nothing
	local trigger tr = CreateTrigger()
	local triggeraction ta = TriggerAddAction(tr,function Aphotic_Heal)
        local effect fx = AddSpecialEffectTarget("Defensive Barrier big.mdx",GetSpellTargetUnit(),"chest")
	call TriggerRegisterUnitEvent(tr,GetSpellTargetUnit(),EVENT_UNIT_DAMAGED)
	call UnitRemoveBuffsBJ(1,GetSpellTargetUnit())
	call SetHandleReal(tr,"AphoticLife",75 + I2R(50*GetUnitAbilityLevel(GetTriggerUnit(),'A005') ) )
	call SetHandleHandle(tr,"AphoticFX",fx)
	call SetHandleHandle(tr,"AphoticCaster",GetTriggerUnit())
	call SetHandleBoolean(tr,"AphoticDone",false)
	call PolledWait(20)
	if(GetHandleBoolean(tr,"AphoticDone")==true)then
		call DestroyEffect(fx)
	endif
        call DestroyEffect(fx)
	call FlushHandleLocals(tr)
	call TriggerRemoveAction(tr,ta)
	call DestroyTrigger(tr)
endfunction

function InitTrig_Aphotic_Shield_Jass takes nothing returns nothing
        set gg_trg_Aphotic_Shield_Jass=CreateTrigger()
	call TriggerRegisterAnyUnitEventBJ(gg_trg_Aphotic_Shield_Jass,EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddCondition(gg_trg_Aphotic_Shield_Jass,Condition(function Aphotic_Spell))
	call TriggerAddAction(gg_trg_Aphotic_Shield_Jass,function Aphotic_Setting)
endfunction


any bugs, leaks or comments feel free to tell me =]
-- Fixed FX bug, Damage bug with Aphotic Shield
@Daxtreme: i have learnt my lesson, only 3 here =[
 
S

sinners_la_b

Guest
Did you just copy and past this from Open Dota cause it is exactly the same.

Your Aphotic Shield doesnt work for me
 

NetherHawk

New Member
Reaction score
26
nope written myself =D
check the jass forums for all my annoying questions.

why dosnt it work o.0
 
S

sinners_la_b

Guest
Well the function Aphotic_Heal never gets ran. And i believe in the main function that the action has to be added after the effect

does it work for you?
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
Well I don't see mistakes in your code ^_^ And I can't find the Aphotic_Heal function that sinners is talking about. Gonna try ur map now :p

EDIT: It's really interesting when I have aphotic and backtrack triggers - I get healed ^^. But don't worry that's not a bug. Anyway, the Aphotic Shield effect does not disappear after 20 seconds. And if the shield explodes (the effect disappears then) it doesn't deal any damage to surrounding enemies. And btw dispersion doesn't have a mini-stun effect I think DotA removed that a long time ago (or I'm mistaking?).
offtopic: do u have skype, nether?
 

NetherHawk

New Member
Reaction score
26
@cr4xzZz :erm sorry no.. only msn messenger.
mini stun thingy: oh? i just copied the description and made it like that. Removing it would be good though, might lag if too many units surronding the unit.

i manage to find out why the FX does not disappear, i forgot to destroy it. I'll change it tomorrow, the editor on this com keeps crashing god knows why. i need to use the other one which is currently occupied =[
just to let u guys know: add in DestroyEffect(fx) after the polled wait of 20 sec.
ill point it out.
er do fx-es need to be nulled? ill go check aphotic shield.
 

NapaHero

Back from the dead...
Reaction score
43
>>btw dispersion doesn't have a mini-stun effect I think DotA removed that a long time ago (or I'm mistaking?).

No, you're not mistaken. In DotA, after the shield explodes, the trigger picks every unit nearby, creates Death Coil (Special) Special Effect attached at the origin of the units and makes the caster damage the units.
 

NetherHawk

New Member
Reaction score
26
nope i use forked lightning =D
I HAVE FIXED APHOTIC SHIELD =DDDDD (used a 0. timer to start the forked lightning now, i guess it was the triggerunit messing things up when it was supposed to be enumunit)

im so happy^^ try it out again cr4zxXx
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
I will :p And yes, effects need to be nulled at the end. The only things that can't be nulled are integer, real, boolean and something else, but I can't remember what it was

EDIT: Aphotic Shield is still not damaging enemies after it explodes... I suggest posting the code, because I can't open the map right now (I'm making my 1st jass spellpack :p )
 
S

sinners_la_b

Guest
+ rep good job. However this is just my personal preference but in Aphotic_Lightning all of those bj_LastCreatedUnit could be replaced with a unit variable

Sinners
 

NetherHawk

New Member
Reaction score
26
argh Aphotic Shield is a pain, i changed he damagin method to napahero's
there is 1 strange thing thought, the death coil effect appears on the caster but does not damage him haha...
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
There's a better way to create the Aphotic Shield damage group and it works perfectly:
JASS:
        set g = GetUnitsInRangeOfLocMatching(350.00, <LOCATION>, Condition( function <FUNCTION>) )
        loop
            set p = FirstOfGroup(g)
            exitwhen p == null
            call UnitDamageTarget(<CASTER>, p, ( 50.00 * I2R(GetUnitAbilityLevelSwapped('XXXX', <CASTER>)) ), true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
            set pl = GetUnitLoc(p)
            call DestroyEffect(AddSpecialEffectLoc("<DEATH COIL SFX>", pl ))
            call GroupRemoveUnit(g, p)
            call RemoveLocation (pl)
        endloop
        call DestroyGroup (g)


And you have to set at the start the local variables without giving them values and at the end u have to null them.
JASS:
local group g
local unit p
local location pl
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
Well... :/
Oh, wait, I saw a BJ! :p
JASS:
        call UnitDamageTargetBJ(AphoticShield_Caster,GetEnumUnit(),(75 + (50*I2R(GetUnitAbilityLevel(AphoticShield_Caster,'A005')))),ATTACK_TYPE_HERO,DAMAGE_TYPE_MAGIC)

=> (GetEnumUnit () should be in a variable..)
JASS:
        call UnitDamageTarget(AphoticShield_Caster, GetEnumUnit (), ( 75.00 + (50.00 *  I2R(GetUnitAbilityLevelSwapped( 'A005' , AphoticShield_Caster))) ), true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )

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

=>
JASS:
    if (buffType == bj_REMOVEBUFFS_POSITIVE) then
        call UnitRemoveBuffs(whichUnit, true, false)
    elseif (buffType == bj_REMOVEBUFFS_NEGATIVE) then
        call UnitRemoveBuffs(whichUnit, false, true)
    elseif (buffType == bj_REMOVEBUFFS_ALL) then
        call UnitRemoveBuffs(whichUnit, true, true)
    elseif (buffType == bj_REMOVEBUFFS_NONTLIFE) then
        call UnitRemoveBuffsEx(whichUnit, true, true, false, false, false, true, false)
    else
    endif

I don't know how to fix this BJ. That's what JassCraft gives me... I hope you can understand it, because I can't help u with that part X_X
 

NetherHawk

New Member
Reaction score
26
wow so many true and falses. I only understand the damage target, cuz i asked for help in the help forum yesterday =D.

Oh... so you can remove wither positive or negative buffs. that's wicked. you dont see that in GUI. Whats a non-life buff?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top