//TESH.scrollpos=0
//TESH.alwaysfold=0
library Knockback initializer Init
// **************************************************************************
// ** **
// ** Knockback(Ex) **
// ** ————————————— **
// ** **
// ** A function made for efficient knockbacking **
// ** **
// ** By: Silvenon **
// ** **
// **************************************************************************
//=======================================//
//Credits to PitzerMike for this function//
//=======================================//
globals
private constant integer DUMMY_ID = 'h000'
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
//===========================================================================
globals
private timer Tim = CreateTimer()
private integer Total = 0
private boolexpr Cond = null
private integer array Ar
private boolean array BoolAr
private real MAX_X
private real MAX_Y
private real MIN_X
private real MIN_Y
endglobals
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
public struct Data
unit u
real d1
real d2
real sin
real cos
real r
string s = ""
effect e = null
static method create takes unit u, integer q, real d, real a, real r, integer t, string s, string p returns Data
local Data dat = Data.allocate()
set dat.u = u
set dat.d1 = 2 * d / (q + 1)
set dat.d2 = dat.d1 / q
set dat.sin = Sin(a)
set dat.cos = Cos(a)
set dat.r = r
if s != "" and s != null then
if t == 2 then
if p != "" and p != null then
set dat.e = AddSpecialEffectTarget(s, u, p)
else
set dat.e = AddSpecialEffectTarget(s, u, "chest")
endif
elseif t == 1 then
set dat.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 Data.Execute)
endif
set Total = Total + 1
set Ar[Total - 1] = dat
return dat
endmethod
static method Execute takes nothing returns nothing
local Data dat
local integer i = 0
local real x
local real y
local rect r
local real rad
loop
exitwhen i >= Total
set dat = Ar[i]
if dat.s != "" and dat.s != null then
set x = GetUnitX(dat.u)
set y = GetUnitY(dat.u)
call DestroyEffect(AddSpecialEffect(dat.s, x, y))
set x = x + dat.d1 * dat.cos
set y = y + dat.d1 * dat.sin
else
set x = GetUnitX(dat.u) + dat.d1 * dat.cos
set y = GetUnitY(dat.u) + dat.d1 * dat.sin
endif
if dat.r != 0 then
set BoolAr[0] = dat.r > 0
set rad = dat.r
if not BoolAr[0] then
set rad = rad * (-1)
endif
set r = Rect(x - rad, y - rad, x + rad, y + rad)
call EnumDestructablesInRect(r, Cond, function KillTree)
call RemoveRect(r)
set r = null
endif
if (x < MAX_X and y < MAX_Y and x > MIN_X and y > MIN_Y) and not BoolAr[1] then
call SetUnitX(dat.u, x)
call SetUnitY(dat.u, y)
endif
set dat.d1 = dat.d1 - dat.d2
if dat.d1 <= 0 or (x > MAX_X or y > MAX_Y or x < MIN_X or y < MIN_Y) or BoolAr[1] then
set Ar[i] = Ar[Total - 1]
set Total = Total - 1
call dat.destroy()
endif
set i = i + 1
endloop
if Total == 0 then
call PauseTimer(Tim)
endif
endmethod
method onDestroy takes nothing returns nothing
if .e != null then
call DestroyEffect(.e)
endif
call PauseUnit(.u, false)
set BoolAr[0] = false
set BoolAr[1] = false
endmethod
endstruct
function KnockbackEx takes unit u, real d, real a, real w, real r, integer t, string s, string p returns nothing
call Data.create(u, R2I(w / Interval()), d, a, r, t, s, p)
endfunction
function Knockback takes unit u, real d, real a, real w returns nothing
call Data.create(u, R2I(w / Interval()), d, a, 0, 0, "", "")
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
Name | Type | is_array | initial_value |
A_BadiesInRange | group | No | |
A_BadiesTaunt | integer | Yes | |
A_ChimuraGrp | group | No | |
A_ChimuraQUEST | quest | No | |
A_ChimuraQUESTREQ | questitem | Yes | |
A_Chimuras | unit | Yes | UnitNull |
A_ChimuraSkip | boolean | No | |
A_TmpCircle | unit | No | |
AAAP_NightElves | player | No | Player01 |
AAPG_NightElves | force | No | Force01 |
Acolyte01 | unit | No | |
Acolyte02 | unit | No | |
Acolyte03 | unit | No | |
AcolyteInvulBrown | unit | No | |
AcolyteInvulDarkGreen | unit | No | |
AcolyteInvulPurple | unit | No | |
AcolyteInvulTeal | unit | No | |
AI_set_sequence | integer | No | 3 |
AI_set_target | integer | No | 4 |
AI_set_x1 | integer | No | 1 |
AI_set_x2 | integer | No | 6 |
AI_set_y1 | integer | No | 2 |
AI_set_y2 | integer | No | 7 |
AI_stop | integer | No | 5 |
AIStarted | boolean | No | false |
Anetheron | unit | No | |
Archimonde | unit | No | UnitNull |
ArchimondeAttacking | boolean | No | false |
ArchimondeHasWon | boolean | No | false |
ArchimondeMist | weathereffect | No | |
ArchimondeTarget | unit | No | UnitNull |
ArchimondeTimer | timer | No | |
Azgalor | unit | No | |
CameraPoint | location | No | |
CinDoomguard01 | unit | No | |
CinDoomguard02 | unit | No | |
CinDoomguard03 | unit | No | |
CinematicTower01 | unit | No | |
CinematicTower02 | unit | No | |
CinFrostWyrm01 | unit | No | |
CinGargoyle01 | unit | No | |
CinGargoyle02 | unit | No | |
CinGargoyle03 | unit | No | |
CurrentSelection | group | No | |
DarkGreenSpiritTowers | integer | No | 0 |
DefeatCancel | boolean | No | false |
FirstSentinelsCreated | boolean | No | false |
Furion | unit | No | UnitNull |
GameOver | boolean | No | false |
GameTimer | timer | No | |
GameTimerWindow | timerdialog | No | |
GoldMineTotal | integer | No | 0 |
GoldMineTresspassers | group | No | |
HiddenUnits | group | No | |
HornofCenarius | item | No | |
InCinematic | boolean | No | false |
IntroCinematicCancelled | boolean | No | false |
IntroEffectGone | boolean | No | true |
IntroLookOverHereUnit01 | unit | No | |
IntroLookOverHereUnit02 | unit | No | |
IntroTeleportEffect | effect | No | |
InvulnerableGroup | group | No | |
Jaina | unit | No | UnitNull |
JainaCancelled | boolean | No | false |
JainaCastleDestroyed | boolean | No | false |
JainaEffectGone | boolean | No | true |
JainaIsGone | boolean | No | false |
JainaNightElves | force | No | Force01 |
JainasCastle | unit | No | |
JainaTeleportEffect | effect | No | |
JainaUnitsRemoved | boolean | No | false |
KazRogal | unit | No | UnitNull |
KiteTimer | timer | No | |
LittlerTimmyLitter | group | No | |
NeutralBuildings | group | No | |
P_Archimonde | player | No | Player06 |
P_FirstUndeadBase | player | No | Player02 |
P_FourthUndeadBase | player | No | Player11 |
P_FurbolgTribe | player | No | Player08 |
P_Jaina | player | No | Player09 |
P_SecondUndeadBase | player | No | Player03 |
P_TempHuntresses | player | No | Player04 |
P_ThirdUndeadBase | player | No | Player10 |
P_Thrall | player | No | Player00 |
P_Trolls | player | No | Player07 |
PotentialTargets | group | No | |
PurpleSpiritTowers | integer | No | 0 |
QuestArchimonde | quest | No | |
QuestArchimondeReqCOP | questitem | No | |
QuestArchimondeReqTime | questitem | No | |
QuestJaina | quest | No | |
QuestJainaReqProtect | questitem | No | |
QuestThrall | quest | No | |
QuestThrallReqProtect | questitem | No | |
RandomUnitToDestroy01 | unit | No | UnitNull |
RandomUnitToDestroy02 | unit | No | UnitNull |
ScaledSize | real | No | 200.00 |
ScaleWait | real | No | 1.00 |
ScalingArchimondeTimer | timer | No | |
SecondSentinelsCreated | boolean | No | false |
Shandris | unit | No | |
SpawningWisps | boolean | No | false |
StarFallEffect | effect | No | |
SummonEffect | effect | No | |
TempHuntress01 | unit | No | |
TempHuntress02 | unit | No | |
TempHuntress03 | unit | No | |
TempHuntress04 | unit | No | |
TempHuntress05 | unit | No | |
TempHuntress06 | unit | No | |
TempHuntress07 | unit | No | |
TempHuntress08 | unit | No | |
TempHuntress09 | unit | No | |
TempHuntress10 | unit | No | |
TempHuntress11 | unit | No | |
ThirdSentinelsCreated | boolean | No | false |
Thrall | unit | No | UnitNull |
ThrallCancelled | boolean | No | false |
ThrallEffectGone | boolean | No | true |
ThrallFortressDestroyed | boolean | No | false |
ThrallisGone | boolean | No | false |
ThrallsFortress | unit | No | |
ThrallTeleportEffect | effect | No | |
ThrallUnitsRemoved | boolean | No | false |
Tyrande | unit | No | UnitNull |
UndeadVisibility | fogmodifier | No | |
Victory | boolean | No | false |
VictoryCancel | boolean | No | false |
VictoryHard | boolean | No | false |
Winterchill | unit | No | |
WispGroup01 | group | No | |
WispGroup02 | group | No | |
WispGroup03 | group | No | |
WispGroup04 | group | No | |
WispTimer00 | timer | No | |
WispTimer01 | timer | No | |
WispTimer02 | timer | No | |
WispTimer03 | timer | No | |
WispTimer04 | timer | No |
//TESH.scrollpos=6
//TESH.alwaysfold=0
function Trig_ChimuraPatrols_Conditions takes nothing returns boolean
if ( not ( GetUnitTypeId(GetEnteringUnit()) == 'echm' ) ) then
return false
endif
return true
endfunction
function Trig_ChimuraPatrols_Actions takes nothing returns nothing
local unit enteru = GetEnteringUnit()
local location loc
local integer rndnum = GetRandomInt(1,7)
if ( rndnum == 1 ) then
set loc = Location(GetRectCenterX(gg_rct_ChimPat1), GetRectCenterY(gg_rct_ChimPat1))
call IssuePointOrderLoc( enteru, "patrol", loc )
elseif ( rndnum == 2 ) then
set loc = Location(GetRectCenterX(gg_rct_ChimPat2), GetRectCenterY(gg_rct_ChimPat2))
call IssuePointOrderLoc( enteru, "patrol", loc )
elseif ( rndnum == 3 ) then
set loc = Location(GetRectCenterX(gg_rct_ChimPat3), GetRectCenterY(gg_rct_ChimPat3))
call IssuePointOrderLoc( enteru, "patrol", loc )
elseif ( rndnum == 4 ) then
set loc = Location(GetRectCenterX(gg_rct_ChimPat4), GetRectCenterY(gg_rct_ChimPat4))
call IssuePointOrderLoc( enteru, "patrol", loc )
elseif ( rndnum == 5 ) then
set loc = Location(GetRectCenterX(gg_rct_ChimPat5), GetRectCenterY(gg_rct_ChimPat5))
call IssuePointOrderLoc( enteru, "patrol", loc )
elseif ( rndnum == 6 ) then
set loc = Location(GetRectCenterX(gg_rct_ChimPat6), GetRectCenterY(gg_rct_ChimPat6))
call IssuePointOrderLoc( enteru, "patrol", loc )
elseif ( rndnum == 7 ) then
set loc = Location(GetRectCenterX(gg_rct_ChimPat7), GetRectCenterY(gg_rct_ChimPat7))
call IssuePointOrderLoc( enteru, "patrol", loc )
endif
set enteru = null
set rndnum = 0
call RemoveLocation(loc)
set loc = null
endfunction
//===========================================================================
function InitTrig_ChimuraPatrols takes nothing returns nothing
set gg_trg_ChimuraPatrols = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_ChimuraPatrols, gg_rct_ChimPat1 )
call TriggerRegisterEnterRectSimple( gg_trg_ChimuraPatrols, gg_rct_ChimPat2 )
call TriggerRegisterEnterRectSimple( gg_trg_ChimuraPatrols, gg_rct_ChimPat3 )
call TriggerRegisterEnterRectSimple( gg_trg_ChimuraPatrols, gg_rct_ChimPat4 )
call TriggerRegisterEnterRectSimple( gg_trg_ChimuraPatrols, gg_rct_ChimPat5 )
call TriggerRegisterEnterRectSimple( gg_trg_ChimuraPatrols, gg_rct_ChimPat6 )
call TriggerRegisterEnterRectSimple( gg_trg_ChimuraPatrols, gg_rct_ChimPat7 )
call TriggerAddCondition( gg_trg_ChimuraPatrols, Condition( function Trig_ChimuraPatrols_Conditions ) )
call TriggerAddAction( gg_trg_ChimuraPatrols, function Trig_ChimuraPatrols_Actions )
endfunction
//TESH.scrollpos=12
//TESH.alwaysfold=0
function Trig_ChimuraPatorls2_Actions takes nothing returns nothing
local unit u
local location loc
local integer int = 1
local integer rndnum
set u = udg_A_Chimuras[1]
loop
exitwhen( int == 6 )
if ( GetUnitCurrentOrder(u) == String2OrderIdBJ("stop") ) then
set rndnum = GetRandomInt(1,7)
if ( rndnum == 1 ) then
set loc = Location(GetRectCenterX(gg_rct_ChimPat1), GetRectCenterY(gg_rct_ChimPat1))
call IssuePointOrderLoc( u, "patrol", loc )
elseif ( rndnum == 2 ) then
set loc = Location(GetRectCenterX(gg_rct_ChimPat2), GetRectCenterY(gg_rct_ChimPat2))
call IssuePointOrderLoc( u, "patrol", loc )
elseif ( rndnum == 3 ) then
set loc = Location(GetRectCenterX(gg_rct_ChimPat3), GetRectCenterY(gg_rct_ChimPat3))
call IssuePointOrderLoc( u, "patrol", loc )
elseif ( rndnum == 4 ) then
set loc = Location(GetRectCenterX(gg_rct_ChimPat4), GetRectCenterY(gg_rct_ChimPat4))
call IssuePointOrderLoc( u, "patrol", loc )
elseif ( rndnum == 5 ) then
set loc = Location(GetRectCenterX(gg_rct_ChimPat5), GetRectCenterY(gg_rct_ChimPat5))
call IssuePointOrderLoc( u, "patrol", loc )
elseif ( rndnum == 6 ) then
set loc = Location(GetRectCenterX(gg_rct_ChimPat6), GetRectCenterY(gg_rct_ChimPat6))
call IssuePointOrderLoc( u, "patrol", loc )
elseif ( rndnum == 7 ) then
set loc = Location(GetRectCenterX(gg_rct_ChimPat7), GetRectCenterY(gg_rct_ChimPat7))
call IssuePointOrderLoc( u, "patrol", loc )
endif
endif
set int = int + 1
set u = udg_A_Chimuras[int]
call RemoveLocation( loc )
endloop
set u = null
call RemoveLocation( loc )
set loc = null
endfunction
//===========================================================================
function InitTrig_ChimuraPatorls2 takes nothing returns nothing
set gg_trg_ChimuraPatorls2 = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_ChimuraPatorls2, 2 )
call TriggerAddAction( gg_trg_ChimuraPatorls2, function Trig_ChimuraPatorls2_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function IsUnitABuilding takes nothing returns boolean
return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false and IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD) == false and IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING) == false and IsUnitEnemy(GetFilterUnit(), Player(4)) == true )
endfunction
function Do_Pushback takes nothing returns nothing
local unit c = GetTriggerUnit()
local unit t = GetEnumUnit()
local real x1 = GetUnitX(c)
local real y1 = GetUnitY(c)
local real x2 = GetUnitX(t)
local real y2 = GetUnitY(t)
local real dist = 500
local real angle = Atan2(y2 - y1, x2 - x1)
local real dur = 2
call Knockback(t, dist, angle, dur)
set c = null
set t = null
endfunction
function Trig_KnockBack_Splash_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A008'
endfunction
function Trig_KnockBack_Splash_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local unit targetunitpoint = GetSpellTargetUnit()
local location targetlocpoint = GetSpellTargetLoc()
local real xrect
local real yrect
local real zrect
local rect targetarea
local group effectedunits = CreateGroup()
local group g = CreateGroup()
if targetunitpoint == null then
set xrect = GetLocationX(targetlocpoint) - 300
set yrect = GetLocationY(targetlocpoint) - 300
else
set xrect = GetUnitX(targetunitpoint) - 300
set yrect = GetUnitY(targetunitpoint) - 300
endif
set targetarea = Rect(xrect,yrect,GetUnitX(caster),GetUnitY(caster))
call GroupEnumUnitsInRect(g, targetarea, Condition(function IsUnitABuilding))
call GroupAddGroup(g, effectedunits)
call ForGroup(effectedunits, function Do_Pushback)
call DestroyGroup(effectedunits)
call DestroyGroup(g)
call RemoveRect(targetarea)
call RemoveLocation(targetlocpoint)
set caster = null
set targetunitpoint = null
endfunction
//===========================================================================
function InitTrig_KnockBack_Splash takes nothing returns nothing
set gg_trg_KnockBack_Splash = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_KnockBack_Splash, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_KnockBack_Splash, Condition( function Trig_KnockBack_Splash_Conditions ) )
call TriggerAddAction( gg_trg_KnockBack_Splash, function Trig_KnockBack_Splash_Actions )
endfunction