function AntiLeak takes nothing returns boolean
return true
endfunction
library Knockback initializer Init
// *******************************************************************************
// ** **
// ** Knockback(Ex) **
// ** ————————————— **
// ** **
// ** Just a function I made for efficient knockbacking **
// ** ** Made by Silvenon
// *******************************************************************************
public struct Data
unit u
real d1
real d2
real sin
real cos
real r
string s = ""
effect e = null
endstruct
globals
private timer Tim = CreateTimer()
private Data array Ar
private boolean array BoolAr
private integer Total = 0
private boolexpr Cond = null
private real MAX_X
private real MAX_Y
private real MIN_X
private real MIN_Y
endglobals
public function TreeFilter takes nothing returns boolean
local integer d = GetDestructableTypeId(GetFilterDestructable())
return d == 'ATtr' or d == 'BTtw' or d == 'KTtw' or d == 'YTft' or d == 'JTct' or d == 'YTst' or d == 'YTct' or d == 'YTwt' or d == 'JTwt' or d == 'JTwt' or d == 'FTtw' or d == 'CTtr' or d == 'ITtw' or d == 'NTtw' or d == 'OTtw' or d == 'ZTtw' or d == 'WTst' or d == 'LTlt' or d == 'GTsh' or d == 'Xtlt' or d == 'WTtw' or d == 'Attc' or d == 'BTtc' or d == 'CTtc' or d == 'ITtc' or d == 'NTtc' or d == 'ZTtc'
endfunction
private constant function Interval takes nothing returns real
return 0.04
endfunction
private function KillTree takes nothing returns nothing
if BoolAr[0] then
call KillDestructable(GetEnumDestructable())
else
set BoolAr[1] = true
endif
endfunction
private function Execute takes nothing returns nothing
local Data kd
local integer i = 0
local real x
local real y
local rect r
loop
exitwhen i >= Total
set kd = Ar
if kd.s != null and kd.s != null then
set x = GetUnitX(kd.u)
set y = GetUnitY(kd.u)
call DestroyEffect(AddSpecialEffect(kd.s, x, y))
set x = x + kd.d1 * kd.cos
set y = y + kd.d1 * kd.sin
else
set x = GetUnitX(kd.u) + kd.d1 * kd.cos
set y = GetUnitY(kd.u) + kd.d1 * kd.sin
endif
set r = Rect(x - kd.r, y - kd.r, x + kd.r, y + kd.r)
set BoolAr[0] = kd.r != 0
call EnumDestructablesInRect(r, Cond, function KillTree)
call RemoveRect(r)
set r = null
if (x < MAX_X and y < MAX_Y and x > MIN_X and y > MIN_Y) and not BoolAr[1] then
call SetUnitX(kd.u, x)
call SetUnitY(kd.u, y)
endif
set kd.d1 = kd.d1 - kd.d2
if kd.d1 <= 0 or (x > MAX_X or y > MAX_Y or x < MIN_X or y < MIN_Y) or BoolAr[1] then
if kd.e != null then
call DestroyEffect(kd.e)
endif
call PauseUnit(kd.u, false)
set Ar = Ar[Total - 1]
set Total = Total - 1
call kd.destroy()
set BoolAr[0] = false
set BoolAr[1] = false
endif
set i = i + 1
endloop
if Total == 0 then
call PauseTimer(Tim)
endif
endfunction
function KnockbackEx takes unit u, real d, real a, real w, real r, integer t, string s, string p returns Data
local Data kd = Data.create()
local integer q = R2I(w / Interval())
set kd.u = u
set kd.d1 = 2 * d / (q + 1)
set kd.d2 = kd.d1 / q
set kd.sin = Sin(a)
set kd.cos = Cos(a)
set kd.r = r
if s != "" and s != null then
if t == 2 then
if p != "" and p != null then
set kd.e = AddSpecialEffectTarget(s, u, p)
else
set kd.e = AddSpecialEffectTarget(s, u, "chest")
endif
elseif t == 1 then
set kd.s = s
endif
endif
call SetUnitPosition(u, GetUnitX(u), GetUnitY(u))
call PauseUnit(u, true)
if Total == 0 then
call TimerStart(Tim, Interval(), true, function Execute)
endif
set Total = Total + 1
set Ar[Total - 1] = kd
return kd
endfunction
function Knockback takes unit u, real d, real a, real w returns Data
return KnockbackEx(u, d, a, w, 0, 1, "Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl", "")
endfunction
private function Init takes nothing returns nothing
set Cond = Filter(function TreeFilter)
set BoolAr[0] = false
set BoolAr[1] = false
set MAX_X = GetRectMaxX(bj_mapInitialPlayableArea) - 64
set MAX_Y = GetRectMaxY(bj_mapInitialPlayableArea) - 64
set MIN_X = GetRectMinX(bj_mapInitialPlayableArea) + 64
set MIN_Y = GetRectMinY(bj_mapInitialPlayableArea) + 64
endfunction
endlibrary
function SetUnitXY takes unit u, real x, real y returns nothing
local real minx = GetRectMinX ( bj_mapInitialPlayableArea )
local real maxx = GetRectMaxX ( bj_mapInitialPlayableArea )
local real miny = GetRectMinY ( bj_mapInitialPlayableArea )
local real maxy = GetRectMaxY ( bj_mapInitialPlayableArea )
if ( x < minx ) then
call SetUnitX ( u, minx )
elseif ( x > maxx ) then
call SetUnitX ( u, maxx )
else
call SetUnitX ( u, x )
endif
if ( y < miny ) then
call SetUnitY ( u, miny )
elseif ( y > maxy ) then
call SetUnitY ( u, maxy )
else
call SetUnitY ( u, y )
endif
endfunction
library Jump initializer Init_Jump
// *******************************************************************************
// ** **
// ** Jump **
// ** ———————— **
// ** **
// ** Just a function I made for efficient jumping **
// ** **
// *******************************************************************************
//========================================//
//Credits to Shadow1500 for this function!//
//========================================//
private function JumpParabola takes real dist, real maxdist, real curve returns real
local real t = (dist * 2) / maxdist - 1
return (- t * t + 1) * (maxdist / curve)
endfunction
//=======================================//
//Credits to PitzerMike for this function//
//=======================================//
//===========================================================================
private function TreeKill takes nothing returns nothing
call KillDestructable(GetEnumDestructable())
endfunction
globals
private integer DUMMY_ID = 'h005'
private constant real Interval = 0.035
private boolexpr Bool
private location Loc = Location(0, 0)
private timer Tim = CreateTimer()
private integer Total = 0
endglobals
private function TreeFilter takes nothing returns boolean
local destructable d = GetFilterDestructable()
local boolean i = IsDestructableInvulnerable(d)
local unit u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), DUMMY_ID,GetWidgetX(d), GetWidgetY(d), 0)
local boolean result = false
call UnitAddAbility(u, 'Ahrl')
if i then
call SetDestructableInvulnerable(d, false)
endif
set result = IssueTargetOrder(u, "harvest", d)
call RemoveUnit(u)
if i then
call SetDestructableInvulnerable(d, true)
endif
set u = null
set d = null
return result
endfunction
public struct Data
unit u
integer q
real md
real d
real c
real sin
real cos
integer i = 1
real r
string s
static method create takes unit u, integer q, real x2, real y2, real c, real r, string s1, string s2 returns Data
local Data dat = Data.allocate()
local real x1 = GetUnitX(u)
local real y1 = GetUnitY(u)
local real dx = x1 - x2
local real dy = y1 - y2
local real a = Atan2(y2 - y1, x2 - x1)
set dat.u = u
set dat.q = q
set dat.md = SquareRoot(dx * dx + dy * dy)
set dat.d = dat.md / q
set dat.c = c
set dat.sin = Sin(a)
set dat.cos = Cos(a)
set dat.r = r
set dat.s = s2
if s1 != "" and s1 != null then
call DestroyEffect(AddSpecialEffect(s1, x1, y1))
endif
call UnitAddAbility(u, 'Amrf')
call UnitRemoveAbility(u, 'Amrf')
call PauseUnit(u, true)
return dat
endmethod
method onDestroy takes nothing returns nothing
local real x
local real y
local rect r
if .r != 0 then
set x = GetUnitX(.u)
set y = GetUnitY(.u)
set r = Rect(x - .r, y - .r, x + .r, y + .r)
call EnumDestructablesInRect(r, Bool, function TreeKill)
call RemoveRect(r)
set r = null
endif
if .s != "" and .s != null then
call DestroyEffect(AddSpecialEffect(.s, x, y))
endif
call PauseUnit(.u, false)
endmethod
endstruct
globals
private Data array Ar
endglobals
private function Execute takes nothing returns nothing
local Data dat
local integer i = 0
local real x
local real y
local location l
local real h
local rect r
loop
exitwhen i >= Total
set dat = Ar
set x = GetUnitX(dat.u) + dat.d * dat.cos
set y = GetUnitY(dat.u) + dat.d * dat.sin
call MoveLocation(Loc, x, y)
set h = JumpParabola(dat.d * dat.i, dat.md, dat.c) - GetLocationZ(Loc)
call SetUnitX(dat.u, x)
call SetUnitY(dat.u, y)
call SetUnitFlyHeight(dat.u, h, 0)
if dat.i >= dat.q then
call dat.destroy()
set Total = Total - 1
set Ar = Ar[Total]
else
set dat.i = dat.i + 1
endif
set i = i + 1
endloop
if Total == 0 then
call PauseTimer(Tim)
endif
set l = null
endfunction
function Jump takes unit whichUnit, real dur, real destX, real destY, real curve, real radius, string sfx1, string sfx2 returns nothing
local Data dat = Data.create(whichUnit, R2I(dur / Interval), destX, destY, curve, radius, sfx1, sfx2)
if Total == 0 then
call TimerStart(Tim, Interval, true, function Execute)
endif
set Ar[Total] = dat
set Total = Total + 1
endfunction
//==================================================================================
function Init_Jump takes nothing returns nothing
set Bool = Filter(function TreeFilter)
endfunction
endlibrary
function CreateTextTagUnit takes string s, unit whichUnit, real zOffset, real size, integer red, integer green, integer blue, integer transparency, real velocityA, real velocityB, real lifespan, boolean perma, boolean visible returns nothing
local texttag LastTextTag = CreateTextTag()
call SetTextTagText(LastTextTag, s, size * 0.023 / 10)
call SetTextTagPosUnit(LastTextTag, whichUnit, zOffset)
call SetTextTagColor(LastTextTag, red, green, blue, transparency)
call SetTextTagVelocity( LastTextTag, velocityA, velocityB )
call SetTextTagLifespan( LastTextTag, lifespan )
call SetTextTagPermanent( LastTextTag, perma )
call SetTextTagVisibility( LastTextTag, visible )
endfunction
this is a code ~~