hi i have a problem with an imported spell. I makes monster lagg when it knocks all units back instead of one. Could someone take a look into it and change it so that i would knockback only heroes pls
Here it is:
thx a lot
Here it is:
JASS:
constant function Powerbash_SpellId takes nothing returns integer
return 'A02A' // Powerbash rawcode
endfunction
constant function Powerbash_Initialdamage takes real level returns real
return 0 + level * 50 // Initial damage a unit suffers when bashed
endfunction
constant function Powerbash_Movement takes real level returns real
return 2 + level * 0.5 // The distance per 0.01 seconds the target unit moves when bashed
endfunction
constant function Powerbash_Time takes real level returns real
return 2 + level * 0 // How long a unit is bashed and moving
endfunction
constant function Powerbash_Braketime takes real level returns real
return 1 + level * 0 // How long a unit is getting slower until total stop
endfunction
constant function Powerbash_Brakedegree takes real level returns real
return 0.98 // This is the value with that the movement gets multiplied 100 times a second to get
endfunction // a smooth-brake effect. If you use bigger Brake Times, you should also set this
// higher, like 9.85 or 9.955
constant function Powerbash_Movementdamage takes real level returns real
return 0 + level * 0 // The damage a target suffers each move, not used yet
endfunction
constant function Powerbash_Treedamage takes real level returns real
return 5 + level * 5 // The damage a target suffers when crashing through a tree
endfunction
//===============================================================================
function Trig_Powerbash_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == Powerbash_SpellId() ) ) then
return false
endif
return true
endfunction
function Powerbash_GetUnit takes timer t returns unit
return GetHandleHandle(t,"target")
endfunction
function Powerbash_GetUnit2 takes timer t returns unit
return GetHandleHandle(t,"caster")
endfunction
function Powerbash_GetAngle takes timer t returns real
return GetHandleReal(t,"angle")
endfunction
function TreeCheck takes nothing returns boolean
return ( IsDestructableAliveBJ(GetEnumDestructable()) == true )
endfunction
function CountDestructablesInRect_Enum takes nothing returns nothing
if ( TreeCheck() ) then
set bj_randomSubGroupWant = bj_randomSubGroupWant + 1
else
call DoNothing( )
endif
endfunction
function CountDestructablesInCircle takes location where, real radius returns integer
local integer old = bj_randomSubGroupWant
local integer new
set bj_randomSubGroupWant = 0
call EnumDestructablesInCircleBJ(radius, where, function CountDestructablesInRect_Enum)
set new = bj_randomSubGroupWant
set bj_randomSubGroupWant = old
return new
endfunction
function Tree_Killer takes nothing returns nothing
call KillDestructable( GetEnumDestructable() )
endfunction
function Move_Speed takes unit handletarget returns real
return GetHandleReal(handletarget, "movement")
endfunction
function GetGroup takes location targetloc returns group
return GetUnitsInRangeOfLocAll(200, targetloc)
endfunction
function GetPin takes timer t2 returns unit
return GetHandleHandle(t2,"pin")
endfunction
function bashothers takes nothing returns nothing
local timer t2 = GetExpiredTimer()
local real angle = GetHandleReal(t2,"angle")
local unit pin = GetPin(t2)
local location otherloc = GetUnitLoc(pin)
local real movement = Powerbash_Movement(3)*1.5
local location moveto = PolarProjectionBJ(otherloc, movement, angle)
local integer runcounter = GetHandleInt(t2,"runcounter")
call SetUnitPositionLoc(pin, moveto)
call DestroyEffect(AddSpellEffectByIdLoc(Powerbash_SpellId(), EFFECT_TYPE_SPECIAL, moveto) )
set pin = null
call RemoveLocation(otherloc)
set otherloc = null
call RemoveLocation(moveto)
set moveto = null
set runcounter = runcounter + 1
call SetHandleInt(t2,"runcounter",runcounter)
if runcounter >= 15 then
call DestroyTimer(t2)
endif
set t2 = null
endfunction
function Trig_ConditionA takes nothing returns boolean
return ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_GROUND) == true )
endfunction
function Trig_ConditionB takes nothing returns boolean
return ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) != true )
endfunction
function Trig_letsbowlevenmore_Conditions takes nothing returns boolean
if ( not GetBooleanAnd( Trig_ConditionA(), Trig_ConditionB() ) ) then
return false
endif
return true
endfunction
function letsbowl_Actions takes nothing returns nothing
local unit pin = GetTriggerUnit()
local location targetloc2 = GetUnitLoc(pin)
local location targetloc = GetUnitLoc(udg_multifuncunit)
local real angle = AngleBetweenPoints(targetloc, targetloc2)
local timer t2 = CreateTimer()
local trigger letsbowlevenmore = CreateTrigger()
call TriggerRegisterUnitInRangeSimple( letsbowlevenmore, 90, pin )
call TriggerAddCondition( letsbowlevenmore, Condition( function Trig_letsbowlevenmore_Conditions ) )
call TriggerAddAction( letsbowlevenmore, function letsbowl_Actions )
call SetHandleHandle(t2, "pin", pin)
call SetHandleReal(t2, "angle", angle)
call TimerStart(t2, 0.01, true, function bashothers)
set pin = null
call RemoveLocation(targetloc2)
set targetloc2 = null
call PolledWait(0.5)
call TriggerClearActions(letsbowlevenmore)
call DestroyTrigger(letsbowlevenmore)
set letsbowlevenmore = null
endfunction
function Powerbash_Move takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit target = Powerbash_GetUnit(t)
local unit caster = Powerbash_GetUnit2(t)
local unit handletarget = Powerbash_GetUnit(t)
local real angle = Powerbash_GetAngle(t)
local integer level = GetHandleInt(t,"level")
local real movement = Move_Speed(handletarget)
local location targetloc = GetUnitLoc(target)
local location nextmove = PolarProjectionBJ(targetloc, movement, angle)
local integer trees = 0
local integer brake = GetHandleInt(t,"brake")
if brake==1 then
set movement = Move_Speed(handletarget)
set movement = movement * Powerbash_Brakedegree(level)
call SetHandleReal(handletarget,"movement",movement)
endif
set trees = CountDestructablesInCircle(targetloc, 150)
call UnitDamageTargetBJ( caster, target, ( I2R(trees) * Powerbash_Treedamage(level) ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
call EnumDestructablesInCircleBJ( 150.00, targetloc, function Tree_Killer )
call UnitDamageTargetBJ( caster, target, Powerbash_Movementdamage(level), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
call DestroyEffect(AddSpellEffectByIdLoc(Powerbash_SpellId(), EFFECT_TYPE_SPECIAL, targetloc) )
set nextmove = PolarProjectionBJ(targetloc, movement, angle)
call SetUnitPositionLoc( target, nextmove )
call RemoveLocation(targetloc)
call RemoveLocation(nextmove)
set t = null
set target = null
set targetloc = null
set nextmove = null
set caster = null
set handletarget = null
set trees = 0
endfunction
function Trig_Powerbash_Actions takes nothing returns nothing
local unit target = GetSpellTargetUnit()
local unit caster = GetTriggerUnit()
local unit handletarget = GetSpellTargetUnit()
local location a = GetUnitLoc(caster)
local location b = GetUnitLoc(target)
local real angle = AngleBetweenPoints(a, b)
local timer t = CreateTimer()
local integer level = GetUnitAbilityLevel(caster, GetSpellAbilityId() )
local real movement = Powerbash_Movement(level)
local integer brake = 0
local trigger letsbowl = CreateTrigger()
call TriggerRegisterUnitInRangeSimple( letsbowl, 90, target )
call TriggerAddAction( letsbowl, function letsbowl_Actions )
set udg_multifuncunit = target
call RemoveLocation(b)
call SetHandleHandle(t,"target",target)
call SetHandleHandle(t,"caster",caster)
call SetHandleReal(t,"angle", angle)
call SetHandleInt(t,"level",level)
call SetHandleReal(t,"movement",level)
call SetHandleReal(handletarget,"movement",movement)
call PauseUnitBJ( true, target )
call SetUnitFacingTimed( target, angle, 1 )
call UnitDamageTargetBJ( caster, target, Powerbash_Initialdamage(level), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
call TimerStart(t, 0.01, true, function Powerbash_Move)
call PolledWait(Powerbash_Time(level))
set brake = 1
call SetHandleInt(t,"brake",brake)
call PolledWait(Powerbash_Braketime(level))
call PauseUnitBJ( false, target )
call FlushHandleLocals(t)
call FlushHandleLocals(handletarget)
call DestroyTimer(t)
call IssuePointOrderLoc( target, "patrol", a ) // This is good for creeps or AOS
call RemoveLocation(a) // Spawnies. It makes "forgotten"
set target = null // Units behind trees impossible.
set caster = null
set a = null
set b = null
set t = null
set handletarget = null
call TriggerClearActions(letsbowl)
call DestroyTrigger(letsbowl)
set letsbowl = null
endfunction
//===========================================================================
function InitTrig_Powerbash takes nothing returns nothing
set gg_trg_Powerbash = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Powerbash, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Powerbash, Condition( function Trig_Powerbash_Conditions ) )
call TriggerAddAction( gg_trg_Powerbash, function Trig_Powerbash_Actions )
endfunction