- Joined
- Dec 17, 2016
- Messages
- 2
JASS:
scope Slash initializer init
globals
private constant integer ID = 'UNIS'
private constant string EF = "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl"
private constant string EFW = "Abilities\\Weapons\\AvengerMissile\\AvengerMissile.mdl"
private constant string EFB = "mdl"
private constant real AS = 200.0
private constant attacktype A_Type = ATTACK_TYPE_HERO
private constant damagetype D_Type = DAMAGE_TYPE_MAGIC
private constant weapontype W_Type = WEAPON_TYPE_METAL_HEAVY_SLICE
endglobals
private constant function Percent takes integer level returns integer
return 14 + (1 * level)
endfunction
private function True takes nothing returns boolean
return true
endfunction
private function Conditions takes nothing returns boolean
return IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetAttacker())) and GetRandomInt(0, 100) <= Percent(GetUnitAbilityLevel(GetAttacker(), ID)) and IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) == false and GetUnitAbilityLevel(GetAttacker(), ID) > 0 and GetWidgetLife(GetTriggerUnit()) > 0.405
endfunction
private function Actions takes nothing returns nothing
local unit u = GetAttacker()
local unit t = GetTriggerUnit()
local integer ii = -1
local effect Eff
local effect Efe
local real Damage = I2R(GetHeroAgi(u, true))
local real Slash = GetRandomReal(2, 4) + ( 1 * GetUnitAbilityLevel(u, ID))
local real x1 = GetUnitX(u)
local real y1 = GetUnitY(u)
local real x2 = GetUnitX(t)
local real y2 = GetUnitY(t)
set Eff = AddSpecialEffectTarget(EFW, u, "weapon")
call PauseUnit(u, true)
call SetUnitPathing(u, false)
call SetUnitTimeScalePercent(u, AS)
call SetUnitVertexColor(u, 150, 150, 150, 150)
call SetUnitPosition(u, x2 + 70 * Cos(GetRandomReal(180, -180 * bj_PI)), y2 + 70 * Sin(GetRandomReal(-1, 1 * bj_PI)))
call SetUnitFacingToFaceUnitTimed(u, t, .05)
call SetUnitAnimation(u, "attack")
call DestroyEffect(AddSpecialEffectTarget(EFB, u, "origin"))
call UnitDamageTarget(u, t, Damage, true, false, A_Type, D_Type, W_Type)
if UnitAddAbility(u, 'Amrf') and UnitRemoveAbility(u, 'Amrf') then
endif
call SetUnitFlyHeight(u, 70, 1000)
call TriggerSleepAction(.05)
loop
set ii = ii + 1
exitwhen ii > Slash
if GetWidgetLife(u) > 0.405 then
if GetWidgetLife(t) > 0.405 then
call SetUnitPosition(u, x2 + 70 * Cos(GetRandomReal(-180, 180 * bj_PI)), y2 + 70 * Sin(GetRandomReal(-180, 180 * bj_PI)))
call SetUnitFacingToFaceUnitTimed(u, t, 0.05)
call SetUnitAnimation(u, "attack")
call DestroyEffect(AddSpecialEffectTarget(EF, t, "chest"))
call DestroyEffect(AddSpecialEffectTarget(EFB, u, "origin"))
call UnitDamageTarget(u, t, Damage, true, false, A_Type, D_Type, null)
set Slash = Slash - 1
if GetWidgetLife(t) < 0.405 then
call ModifyHeroStat(bj_HEROSTAT_AGI, u, bj_MODIFYMETHOD_ADD, R2I(.20))
endif
call TriggerSleepAction(.05)
endif
endif
endloop
call SetUnitFlyHeight(u, 0, 1000)
call SetUnitFacingToFaceUnitTimed(u, t, .05)
call PauseUnit(u, false)
call SetUnitPathing(u, true)
call SetUnitTimeScalePercent(u, 100)
call SetUnitVertexColor(u, 250, 250, 250, 250)
call DestroyEffect(Eff)
call IssueTargetOrder(u, "attack", t)
set Eff = null
set u = null
set t = null
endfunction
//===========================================================================
private function init takes nothing returns nothing
local trigger tt = CreateTrigger()
local integer i = 0
loop
exitwhen i > 15
call TriggerRegisterPlayerUnitEvent(tt, Player(i), EVENT_PLAYER_UNIT_ATTACKED, Filter(function True))
set i = i + 1
endloop
call TriggerAddCondition(tt, Condition(function Conditions))
call TriggerAddAction(tt, function Actions)
call Preload(EF)
endfunction
endscope