I was wondering if anyone could help me modify a knock back system by triggerhappy.
Each time the knock back system moves a unit by an increment, I want the unit being moved to be dealt 5 damage by udg_hero[1].
udg_hero[1] is a unit array.
I tried inserting the code
In the loop containing I placed it after that code.
However I got some errors and was not sure how to progress.
The other thing I would like to do is before the unit is moved, check if the flying height is greater than 165 * cliff level @ the point it is being moved to.
1 Cliff level is about a flying height of 165. I don't want the unit to be able to be knocked up cliffs.
This I have no idea how to do.
The original code is below
Thanks for taking the time to read this.
Each time the knock back system moves a unit by an increment, I want the unit being moved to be dealt 5 damage by udg_hero[1].
udg_hero[1] is a unit array.
I tried inserting the code
JASS:
call UnitDamageTarget( udg_Hero[1], d.u, 5.00, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL )
In the loop containing I placed it after that code.
However I got some errors and was not sure how to progress.
The other thing I would like to do is before the unit is moved, check if the flying height is greater than 165 * cliff level @ the point it is being moved to.
1 Cliff level is about a flying height of 165. I don't want the unit to be able to be knocked up cliffs.
This I have no idea how to do.
The original code is below
JASS:
library UKS // Version 1.02
globals
private constant boolean SHOW_EFFECT = true
// Show effect on unit when he gets knockbacked
private constant boolean DESTROY = true
// Set to yes if you want to destroy doodads
private constant string EFFECT_POS = "origin"
// where on the unit to show the effect
private constant string EFFECT_GROUND = "Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl"
// The effect when a unit is knocked on ground
private constant string EFFECT_WATER = "Abilities\\Weapons\\WaterElementalMissile\\WaterElementalMissile.mdl"
// The effect when a unit is knocked on water
private constant real INTERVAL = 0.03
// How fast the timer will run periodicly
// End of Configurables. Necessary globals. \\
private timer TIMER = CreateTimer()
private integer COUNT = 0
endglobals
private struct UKSData
unit u
real speed
real dec
real ticksMax
real ticksCur
location l
static UKSData array List
static method create takes unit u1, location l1, real speed1, real dec returns UKSData
local UKSData d = UKSData.allocate()
local real dx = GetUnitX(u1) - GetLocationX(l1)
local real dy = GetUnitY(u1) - GetLocationY(l1)
set d.l = l1
set d.u = u1
set d.speed = speed1
set d.dec = dec
set d.ticksMax = SquareRoot(dx * dx + dy * dy)
set d.ticksCur = 0
set .List[COUNT] = d
return d
endmethod
method onDestroy takes nothing returns nothing
set .u = null
set .l = null
call RemoveLocation(.l)
endmethod
endstruct
private function DestructGroup takes nothing returns nothing
call KillDestructable(GetEnumDestructable())
endfunction
private function DestroyDestruct takes unit u returns nothing
local rect r
local real centerX = GetUnitX(u)
local real centerY = GetUnitY(u)
local real radius = 90
local location loc = GetUnitLoc(u)
if (radius >= 0) then
set bj_enumDestructableCenter = loc
set bj_enumDestructableRadius = radius
set r = Rect(centerX - radius, centerY - radius, centerX + radius, centerY + radius)
call EnumDestructablesInRect(r, filterEnumDestructablesInCircleBJ, function DestructGroup)
call RemoveRect(r)
call RemoveLocation(loc)
endif
set r = null
set loc = null
endfunction
private function MoveUnits takes nothing returns nothing
local integer i = 0
local UKSData d
local real x
local real y
local real x1
local real y1
local real dx
local real dy
local real d2
local group g = CreateGroup()
local boolexpr filter
loop
exitwhen i >= COUNT
set d = UKSData.List<i>
set x1 = GetUnitX(d.u)
set y1 = GetUnitY(d.u)
set dx = GetLocationX(d.l) - x1
set dy = GetLocationY(d.l) - y1
set d2 = SquareRoot(dx * dx + dy * dy)
set x = x1 + d.speed * dx / d2
set y = y1 + d.speed * dy / d2
call SetUnitX(d.u, x)
call SetUnitY(d.u, y)
if SHOW_EFFECT == true then
if IsTerrainPathable(x,y,PATHING_TYPE_FLOATABILITY) then
call DestroyEffect(AddSpecialEffectTarget(EFFECT_GROUND, d.u, EFFECT_POS))
elseif not IsTerrainPathable(x,y,PATHING_TYPE_WALKABILITY) then
call DestroyEffect(AddSpecialEffectTarget(EFFECT_WATER, d.u, EFFECT_POS))
endif
endif
if DESTROY == true then
call DestroyDestruct(d.u)
endif
set d.ticksCur = d.ticksCur + d.speed
if d.speed - d.dec >= 0.000 then
set d.speed = d.speed - d.dec
endif
if d.ticksCur >= d.ticksMax or d.ticksCur <= 1 or d.speed <= 1 then
set COUNT = COUNT - 1
set UKSData.List<i> = UKSData.List[COUNT]
set i = i - 1
if COUNT <= 0 then
call PauseTimer(TIMER)
set COUNT = 0
endif
call UKSData.destroy (d)
endif
set i = i + 1
endloop
set g = null
set filter = null
endfunction
public function KnockUnit takes unit u, location l, real speed, real decrement returns nothing
local UKSData d = UKSData.create(u,l,speed,decrement)
set COUNT = COUNT + 1
if COUNT == 1 then
call TimerStart(TIMER, INTERVAL, true, function MoveUnits)
endif
endfunction
endlibrary
</i></i>
Thanks for taking the time to read this.