//TESH.scrollpos=0
//TESH.alwaysfold=0
//!====================================================================================
// Дистанция 2D
//!====================================================================================
function DistanceXY2D takes real X, real Y, real X2, real Y2 returns real
return SquareRoot((X2 - X) * (X2 - X) + (Y2 - Y) * (Y2 - Y))
endfunction
//!====================================================================================
// Рандом группа
//!====================================================================================
function GroupPickRandomUnitJass takes group whichGroup returns unit
// If the user wants the group destroyed, remember that fact and clear
// the flag, in case it is used again in the callback.
local boolean wantDestroy = bj_wantDestroyGroup
set bj_wantDestroyGroup = false
set bj_groupRandomConsidered = 0
set bj_groupRandomCurrentPick = null
call ForGroup(whichGroup, function GroupPickRandomUnitEnum)
// If the user wants the group destroyed, do so now.
if (wantDestroy) then
call DestroyGroup(whichGroup)
endif
return bj_groupRandomCurrentPick
endfunction
Name | Type | is_array | initial_value |
HandleBoard | leaderboard | No |
//TESH.scrollpos=10
//TESH.alwaysfold=0
function HandleCounter_Update takes nothing returns nothing
local integer i = 0
local integer id
local location array P
local real result=0
loop
exitwhen i >= 50
set i = i + 1
set P[i] = Location(0,0)
set id = GetHandleId(P[i])
set result = result + (id-0x100000)
endloop
set result = result/i-i/2
loop
call RemoveLocation(P[i])
set P[i] = null
exitwhen i <= 1
set i = i - 1
endloop
call LeaderboardSetItemValue(udg_HandleBoard,0,R2I(result))
endfunction
function HandleCounter_Actions takes nothing returns nothing
set udg_HandleBoard = CreateLeaderboard()
call LeaderboardSetLabel(udg_HandleBoard, "Handle Counter")
call PlayerSetLeaderboard(GetLocalPlayer(),udg_HandleBoard)
call LeaderboardDisplay(udg_HandleBoard,true)
call LeaderboardAddItem(udg_HandleBoard,"Handles",0,Player(0))
call LeaderboardSetSizeByItemCount(udg_HandleBoard,1)
call HandleCounter_Update()
call TimerStart(GetExpiredTimer(),0.01,true,function HandleCounter_Update)
endfunction
function InitTrig_HandleCounter takes nothing returns nothing
call TimerStart(CreateTimer(),0,false,function HandleCounter_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Loop_R2a takes nothing returns nothing
local trigger t = GetTriggeringTrigger()
local integer id = GetHandleId(t)
local unit dummy = LoadUnitHandle(hash,id,35)
local integer i = LoadInteger(hash,id,36) - ( 8 )
local integer r = LoadInteger(hash,id,37)
if i < 1 then
call RemoveUnit(dummy)
call FlushChildHashtable(hash,id)
call DestroyTrigger(t)
else
call SetUnitVertexColor(dummy, 255, 255, 255, i )
call SaveInteger(hash,id,36,i)
endif
if i < r then
call SetUnitTimeScale(dummy, 0 )
elseif i < 240 then
call SetUnitTimeScale(dummy, GetRandomReal(300,500) * 0.01 )
endif
set dummy = null
set t = null
endfunction
function OmnishashDummyCreate takes unit a returns nothing
local trigger t = CreateTrigger()
local integer id = GetHandleId(t)
local integer i = GetRandomInt(1,2)
local unit dummy = CreateUnit(Player(13),'e000',GetUnitX(a)+GetRandomReal(-100,100)*Cos(GetUnitFacing(a)*bj_DEGTORAD),GetUnitY(a)+GetRandomReal(-100,100)*Sin(GetUnitFacing(a)*bj_DEGTORAD),GetUnitFacing(a))
if i == 1 then
call SetUnitAnimationByIndex(dummy,1)
else
call SetUnitAnimationByIndex(dummy,7)
endif
call SetUnitTimeScale(dummy, 0 )
call SaveUnitHandle(hash,id,35,dummy)
call SaveInteger(hash,id,36,255)
call SaveInteger(hash,id,37,GetRandomInt(220,230))
call TriggerAddAction(t,function Loop_R2a)
call TriggerRegisterTimerEvent(t,0.03125,true)
set a = null
set t = null
set dummy = null
endfunction
function Trig_Omnislash_Loop takes nothing returns nothing
local trigger t = GetTriggeringTrigger()
local integer id = GetHandleId(t)
local integer i = LoadInteger(hash,id,28)
local real angle = LoadReal(hash,id,29)
local integer count = LoadInteger(hash,id,30)
local unit a = LoadUnitHandle(hash,id,31)
local unit b = LoadUnitHandle(hash,id,32)
local effect e = LoadEffectHandle(hash,id,34)
local group g
local real x = GetUnitX(a)
local real y = GetUnitY(a)
local real xx = GetUnitX(b)
local real yy = GetUnitY(b)
local real d = bj_RADTODEG * Atan2(yy - y , xx - x)
call SetUnitFacingTimed(a, d, 0.00)
if count > 0 then
if i > 11 then
if DistanceXY2D(x,y,xx,yy) <= 120 then
set g = CreateGroup()
set i = 0
set count = count - 1
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl",b,"chest"))
call UnitDamageTarget(a,b,25,false,false,ATTACK_TYPE_HERO,DAMAGE_TYPE_NORMAL,null)
call GroupEnumUnitsInRange(g,xx,yy, 500.00, null)
loop
set b = GroupPickRandomUnitJass(g)
exitwhen IsUnitEnemy(b,GetOwningPlayer(a)) and IsUnitType(b,UNIT_TYPE_DEAD)!=true and IsUnitType(b,UNIT_TYPE_STRUCTURE)!=true or b ==null
call GroupRemoveUnit(g,b)
endloop
call DestroyGroup(g)
if b != null then
set angle = GetUnitFacing(a)
call SetUnitAnimation(a,"attack")
call OmnishashDummyCreate(a)
call SaveUnitHandle(hash,id,32,b)
call SaveInteger(hash,id,28,i)
call SaveReal(hash,id,29,angle)
call SaveInteger(hash,id,30,count)
else
call DestroyEffect(e)
call PauseUnit(a,false)
call SetUnitInvulnerable( a, false )
call SetUnitPathing( a, true )
call SetUnitTimeScale(a, 100 * 0.01)
call SetUnitVertexColor( a, 255, 255, 255, 255 )
call FlushChildHashtable(hash,id)
call DestroyTrigger(t)
endif
else
call SetUnitX(a,x+60*Cos(d*bj_DEGTORAD))
call SetUnitY(a,y+60*Sin(d*bj_DEGTORAD))
endif
set g = null
else
set i = i + 1
if i > 3 then
call SaveInteger(hash,id,28,15)
else
call SetUnitX(a,x+60*Cos(angle*bj_DEGTORAD))
call SetUnitY(a,y+60*Sin(angle*bj_DEGTORAD))
endif
call SaveInteger(hash,id,28,i)
endif
else
call DestroyEffect(e)
call PauseUnit(a,false)
call SetUnitInvulnerable( a, false )
call SetUnitPathing( a, true )
call SetUnitTimeScale(a, 100 * 0.01)
call SetUnitVertexColor( a, 255, 255, 255, 255 )
call FlushChildHashtable(hash,id)
call DestroyTrigger(t)
endif
set a = null
set b = null
set e = null
set t = null
endfunction
function Trig_Omnislash_Actions takes nothing returns nothing
local unit a = GetTriggerUnit()
local unit b = GetSpellTargetUnit()
local trigger t = CreateTrigger()
local integer id = GetHandleId(t)
local effect e = AddSpecialEffectTarget("Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl",a,"weapon")
local integer array slash
set slash[1] = 8
set slash[2] = 9
set slash[3] = 10
set slash[4] = 12
local integer lvl = GetUnitAbilityLevel(a, 'A000')
call PauseUnit(a,true)
call SetUnitInvulnerable( a, true )
call SetUnitPathing( a, false )
call SetUnitTimeScale(a, 250 * 0.01)
call SetUnitVertexColor( a, 255, 255, 255, 100 )
call SaveInteger(hash,id,28,15)
call SaveReal(hash,id,29,0)
call SaveInteger(hash,id,30,slash[lvl])
call SaveUnitHandle(hash,id,31,a)
call SaveUnitHandle(hash,id,32,b)
call SaveEffectHandle(hash,id,34,e)
call TriggerAddAction(t,function Trig_Omnislash_Loop)
call TriggerRegisterTimerEvent(t,0.03125,true)
set a = null
set b = null
set e = null
endfunction
function Trig_Omnislash_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
//===========================================================================
function InitTrig_Omnislash takes nothing returns nothing
set gg_trg_Omnislash = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Omnislash, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Omnislash, Condition( function Trig_Omnislash_Conditions ) )
call TriggerAddAction( gg_trg_Omnislash, function Trig_Omnislash_Actions )
endfunction
globals
hashtable hash = InitHashtable()
endglobals