hieu2525
Mr & Ms Pac-Man
- 23/3/09
- 111
- 0
Cho em hỏi, em có 1 spell khi cast nó sẽ đẩy mọi unit ra xung quanh mình nhưng nó lại đẩy xuyên núi doodad nên em ko biết làm cách nào, xin mọi người giúp dùm em 

Mã:
scope RejuvenationCyclone initializer OnInit
globals
private constant integer SPELL_ID = 'A07I'
//this is the spell ID (under the view tab, check view raw data and find your spell to get this)
private constant boolean MOVE_TO_MAX = false
//if true this will move units to max range and not past it
private constant boolean IGNORE_UNIT_PATHING = false
//if true this push will ignore unit pathing
private constant boolean IGNORE_PATHING = false
//if this is true the push will ignore pathing period
private constant real DURATION = 0.5
//this is the max duration of the push, when set to 0 it will be instant
private constant real INTERVAL = 0.02
//CAN NOT BE 0.00, this is the interval at which the push is issued, frequency relates directly with smoothness and lag
private constant boolean STUN = true
//set to false if you dont want the units to be stunned
private timer RCLLTIMER = CreateTimer() //DO NOT CHANGE
endglobals
struct RCLL extends array
unit pushTarget
real changeX
real changeY
integer changeCount
integer next
integer previous
static integer array recycleList
static integer lastRecycled = 0
static integer listSize = 0
private static method Allocate takes nothing returns thistype
local integer i = RCLL.recycleList[0]
if (i == 0) then
set RCLL.listSize = RCLL.listSize + 1
return RCLL.listSize
endif
set RCLL.recycleList[0] = RCLL.recycleList[i]
set RCLL.recycleList[i] = 0
return i
endmethod
static method linkUnit takes unit u, real x, real y returns nothing
local thistype this = thistype.Allocate()
set this.pushTarget = u
set this.changeX = x
set this.changeY = y
set this.changeCount = 0
set this.next = 0
set this.previous = thistype[0].previous
set thistype[thistype[0].previous].next = this
set thistype[0].previous = this
endmethod
static method removeLink takes integer i returns nothing
set thistype[thistype[i].previous].next = thistype[i].next
set thistype[thistype[i].next].previous = thistype[i].previous
set thistype.recycleList[thistype.lastRecycled] = i
set thistype.lastRecycled = i
set thistype.recycleList[i] = 0
endmethod
endstruct
private function Core takes nothing returns nothing
local integer i = RCLL[0].next
local location a
local real x
local real y
loop
if RCLL[0].next == 0 then
call PauseTimer(RCLLTIMER)
endif
exitwhen i == 0
if IGNORE_UNIT_PATHING == true then
call SetUnitPathing(RCLL[i].pushTarget, false)
elseif IGNORE_PATHING == true then
call SetUnitPathing(RCLL[i].pushTarget, false)
endif
if STUN then
call PauseUnit(RCLL[i].pushTarget, true)
endif
set a = GetUnitLoc(RCLL[i].pushTarget)
set x = GetLocationX(a)
set y = GetLocationY(a)
call SetUnitX(RCLL[i].pushTarget, RCLL[i].changeX + x)
call SetUnitY(RCLL[i].pushTarget, RCLL[i].changeY + y)
if IGNORE_PATHING == false then
if IGNORE_UNIT_PATHING == false then
call SetUnitPathing(RCLL[i].pushTarget, true)
endif
endif
set RCLL[i].changeCount = RCLL[i].changeCount + 1
if RCLL[i].changeCount == R2I(DURATION / INTERVAL) then
if IGNORE_PATHING or IGNORE_UNIT_PATHING then
call SetUnitPathing(RCLL[i].pushTarget, true)
endif
if STUN then
call PauseUnit(RCLL[i].pushTarget, false)
endif
call RCLL.removeLink(i)
endif
set a = null
set i = RCLL[i].next
endloop
endfunction
private function GroupFilter takes nothing returns boolean
local boolean bool
set bool = not IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE)
set bool = bool and not IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING)
set bool = bool and not IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL)
set bool = bool and not IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE)
set bool = bool and not IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD)
return bool
endfunction
private function OnInitActions takes nothing returns boolean
local real rx
local real ry
local group g = CreateGroup()
local unit u
local real x = GetUnitX(GetTriggerUnit())
local real y = GetUnitY(GetTriggerUnit())
local real bx
local real by
local real r
if GetSpellAbilityId() == SPELL_ID then
call GroupEnumUnitsInRange(g, x, y, 450, Filter(function GroupFilter))
loop
set u = FirstOfGroup(g)
exitwhen (u == null)
if IsUnitEnemy(u,GetOwningPlayer(GetTriggerUnit())) then
set bx = GetUnitX(u)
set by = GetUnitY(u)
set r = bj_RADTODEG * Atan2(by - y, bx - x)
if (MOVE_TO_MAX == true) then
set rx = bx + 450 * Cos(r * bj_DEGTORAD)
set ry = by + 450 * Sin(r * bj_DEGTORAD)
elseif (MOVE_TO_MAX == false) then
set rx = x + 450 * Cos(r * bj_DEGTORAD)
set ry = y + 450 * Sin(r * bj_DEGTORAD)
endif
set rx = ((rx - x) /(DURATION / INTERVAL))
set ry = ((ry - y)/(DURATION / INTERVAL))
call RCLL.linkUnit(u, rx, ry)
elseif (IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(u)) == true) then
call SetUnitState(u, UNIT_STATE_LIFE, (GetUnitState(u, UNIT_STATE_LIFE) + 100.0 + (75.0 * GetUnitAbilityLevel(GetTriggerUnit(), SPELL_ID))))
endif
call GroupRemoveUnit(g, u)
endloop
call TimerStart(RCLLTIMER, INTERVAL, true, function Core)
endif
call DestroyGroup(g)
set g = null
set u = null
return true
endfunction
private function OnInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Filter(function OnInitActions))
set t = null
endfunction
endscope


.


sao hum nay mình nói nhiều vậy
và 1 cái bất tiện nữa là nếu thằng kia nó cast con chim wa TR bên cạnh thì nạn ks chửi nhau sẽ lại rộn lên 

