can anyone arrange this properly??

G

gonecase

Guest
can any one arrange this script properly for me??? i mean with the InitTrig n other stuff... heres the script


//------------ Sadistic Gluttony Ability -------------

constant function Sadistic_Gluttony_Abi takes nothing returns integer
return 'A00Q'
endfunction

constant function Sadistic_Gluttony_Dmg takes integer l returns real
return 0.02 + 0.01*l
endfunction

constant function Sadistic_Gluttony_Dur takes integer level returns real
return 5. + level
endfunction

constant function Sadistic_Gluttony_Damage_Factor takes integer l returns real
if l == 0 then
return 1.
endif
return .35+(3-l)*0.1
endfunction

constant function Sadistic_Gluttony_Buf takes nothing returns integer
return 'B002'
endfunction

constant function Boot_Of_Travel takes nothing returns integer
return 'I009'
endfunction
//-------------------------------------------------------------------

//===========================================================
// Sadistic Gluttony
//===========================================================


function sadistic_cond takes nothing returns boolean
return GetSpellAbilityId() == Sadistic_Gluttony_Abi()
endfunction

function DamageModify_Child takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = GetHandleUnit(t,"u")
local real r = GetHandleReal(t,"h")

if GetHandleBoolean(t,"f") then
call UnitRemoveAbility( u, 'Avul' ) //add invulnerability
endif
call SetUnitState(u ,UNIT_STATE_LIFE, r )
//call DisplayTextToPlayer(Player(0), 0,0, "Afterlife, r = "+R2S(r))
set u = null
call FlushHandleLocals(t)
call DestroyTimer(t)
set t = null
endfunction

function restore_lost_hp takes nothing returns nothing
local trigger t = GetTriggeringTrigger()
local real e = GetEventDamage()
local unit u = GetTriggerUnit()
local real l = GetUnitState(u, UNIT_STATE_LIFE)
local real m = GetUnitState(u, UNIT_STATE_MAX_LIFE)
local timer p = null
local real d //damage dealt
local real a //damage absorbed

if e > m then
call UnitAddAbility(u, 'Avul') //add invulnerability
set p = CreateTimer()
call SetHandleBoolean(p, "f", true)
call SetUnitState(u ,UNIT_STATE_LIFE, m + 5000) //5000 approx. max dota damage?
endif
if e > l then
//call DisplayTextToPlayer(Player(0), 0,0, "Gonna Die, l = "+R2S(l)+" dmg = "+R2S(GetEventDamage()))
call SetUnitState(u ,UNIT_STATE_LIFE, m)
if p == null then
set p = CreateTimer()
endif
//else //
// call SetUnitState(u, UNIT_STATE_LIFE, l+GetEventDamage() )
endif
if p != null then
call SetHandleHandle(p,"u",u)
call SetHandleReal(p,"h",l)
call TimerStart(p, 0, false, function DamageModify_Child)
set a = GetHandleReal(t, "a")
call SetHandleReal(t, "a", a+e)
//call DisplayTextToPlayer(Player(0), 0,0, R2S(a+e)+" damage absorbed.")
else
set d = GetHandleReal(t, "d")
//call DisplayTextToPlayer(Player(0), 0,0, R2S(d+e)+" damage taken.")
call SetHandleReal(t, "d", d+e)
endif

set p = null
set t = null
set u = null
endfunction

function killed_hero takes nothing returns boolean
local trigger t = GetTriggeringTrigger()
local unit u = GetHandleUnit(t, "u")
local boolean a = IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO )
local boolean b = (u == GetKillingUnit())

set t = null
set u = null
return a and b
endfunction

function reduced_damage takes nothing returns nothing
call DisableTrigger(GetTriggeringTrigger())
endfunction

function use_bot takes nothing returns boolean
return GetItemTypeId(GetManipulatedItem()) == Boot_Of_Travel()
endfunction

function cancel_bot takes nothing returns nothing
local unit u = GetTriggerUnit()
call UnitDropItemPoint(u, GetManipulatedItem(), GetUnitX(u), GetUnitY(u) )
call UnitAddItem(u, GetManipulatedItem())
set u = null
endfunction

function vaikesh_attack takes nothing returns nothing
local real h = GetUnitState(GetTriggerUnit(), UNIT_STATE_MAX_LIFE)
local integer l = GetUnitAbilityLevel(GetAttacker(), Sadistic_Gluttony_Abi())
call UnitDamageTargetBJ(GetAttacker(), GetTriggerUnit(), h*Sadistic_Gluttony_Dmg(l), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL)
//call DisplayTextToPlayer(Player(0), 0,0, "Bonus Damage: "+R2S(h*Sadistic_Gluttony_Dmg(l)))
endfunction

function vaikesh_attack_cond takes nothing returns boolean
local trigger t = GetTriggeringTrigger()
local unit c = GetHandleUnit(t, "c")
local boolean b = GetAttacker() == c

set t = null
set c = null
return b
endfunction

function sadistic_gluttony_init takes nothing returns nothing
local trigger t = CreateTrigger()
local trigger p = CreateTrigger()
local trigger f = CreateTrigger()
local trigger r = CreateTrigger()
local unit u = GetTriggerUnit()
local integer l = GetUnitAbilityLevel(u, Sadistic_Gluttony_Abi())
local real h
local real d
local real a

call TriggerRegisterUnitEvent(t, u, EVENT_UNIT_DAMAGED)
call TriggerAddAction(t, function restore_lost_hp)

call TriggerRegisterAnyUnitEventBJ(r, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddCondition(r, Condition(function vaikesh_attack_cond))
call TriggerAddAction(r, function vaikesh_attack)
call SetHandleHandle(r, "c", u)

call TriggerRegisterAnyUnitEventBJ(p, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition(p, Condition(function killed_hero))
call TriggerAddAction(p, function reduced_damage)
call SetHandleHandle(p, "u", u)

call TriggerRegisterUnitEvent(f, u, EVENT_UNIT_USE_ITEM )
call TriggerAddCondition(f, Condition(function use_bot))
call TriggerAddAction(f, function cancel_bot)

call TriggerSleepAction(Sadistic_Gluttony_Dur(l))

if IsTriggerEnabled(p) then
set l = 0
//call DisplayTextToPlayer(Player(0), 0,0, "You didn't kill any hero")
endif

set h = Sadistic_Gluttony_Damage_Factor(l)
set d = GetHandleReal(t, "d")*(1.-h)
set a = GetHandleReal(t, "a")*h

call FlushHandleLocals(p)
call FlushHandleLocals(t)
call FlushHandleLocals(r)
call DestroyTrigger(p)
call DestroyTrigger(r)
call DestroyTrigger(t)
call DestroyTrigger(f)

//call DisplayTextToPlayer(Player(0), 0,0, "Total Dmg Absorbed: "+R2S(a))
//call DisplayTextToPlayer(Player(0), 0,0, "Total Dmg Taken: "+R2S(d))

//formula d = damage taken; therefore, you should get 1-h% back
// a = damage absorbed; therefore, you should take h% of the damage
call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_LIFE)-a+d)

set f = null
set t = null
set p = null
set u = null
set r = null
endfunction
 
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