Prometheus
Everything is mutable; nothing is sacred
- Reaction score
- 590
So basically, I thought I had fixed this. It only happens every once in a while. What happens is it will run this three times and shoot the enemy off. I mean, it looks awesome but its not intended.
JASS:
scope UshiroDageki initializer Init
//Config Header
globals
private constant integer ABID = 039;A000039; //This is the ID of the ability.
private constant integer PRLVL = 3 //This is the base chance, it is multiplied by the level of the ability.
private constant integer DMG = 50 //The base damage done per level. Level 1 = 50, Level 2 = 100, ect.
private constant real INIS = 400.00 //The initial speed the unit is knocked back with.
private constant real DEC = 10.00 //How much the unit slows down per second.
private constant string EFX = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl" //Effect that shows when the spell activates
private constant string ANIM = "slam" //The animation the unit does when the ability activates.
private constant boolean KILLD = true //If true the knockback will destroy destructables.
endglobals
//EndConfig Header
globals
private trigger t = CreateTrigger()
private group g = CreateGroup()
endglobals
private function Do takes nothing returns boolean
if GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE)>0 and IsUnitInGroup(GetFilterUnit(),g)==false then
call TriggerRegisterUnitEvent(t,GetFilterUnit(),EVENT_UNIT_DAMAGED)
elseif GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE)<0 and IsUnitInGroup(GetFilterUnit(),g)==true then
call GroupRemoveUnit(g,GetFilterUnit())
endif
return true
endfunction
private function AddUnits takes nothing returns nothing
//For registering a unit taking damage.
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, Condition(function Do))
endfunction
private function DA takes nothing returns nothing
local timer z = GetExpiredTimer()
call EnableTrigger(t)
call DestroyTimer(z)
set t = null
endfunction
private function UD_C takes nothing returns boolean
//Do all the conditions in one function instead of bothering with an if/then.
return GetUnitAbilityLevel(GetEventDamageSource(), ABID) > 0 and GetUnitAbilityLevel(GetEventDamageSource(), ABID)*PRLVL >= GetRandomInt(1, 100)
endfunction
private function UD_A takes nothing returns nothing
local unit u = GetEventDamageSource()
local unit h = GetTriggerUnit()
local integer i = GetUnitAbilityLevel(u, ABID)
local real r = GetEventDamage()
local timer z = CreateTimer()
call DisableTrigger(t)
call SetUnitAnimation(h, ANIM)
call DestroyEffect(AddSpecialEffect(EFX, GetUnitX(u), GetUnitY(u)))
call UnitDamageTarget(u,h,i*DMG,true,true,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_UNKNOWN,WEAPON_TYPE_WHOKNOWS)
call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_LIFE)+r)
call KnockbackTarget(h, GetUnitFacing(u), INIS, DEC, KILLD)
//Thank Rising_Dusk for his godly knockback system.
set u = null
set h = null
call TimerStart(z,1,false,function DA)
endfunction
private function Init takes nothing returns nothing
local integer i = 0
local timer z = CreateTimer()
call TimerStart(z,5,true,function AddUnits)
call TriggerAddAction(t, function UD_A)
call TriggerAddCondition(t, Condition(function UD_C))
endfunction
endscope