- Joined
- Apr 1, 2010
- Messages
- 289
well, here is my projectile system, it has a few bugs, and it doesn't recycle projectiles (yet) and it bugs up occasionally(my test map illustrates the bug, just test it and cast flame strike somewhere) some of the pigs stop moving while others keep moving, but it can have over 600 projectiles out at a time without lagging, except from creating 600 units. (to test simple remove the wait out of the cast trigger.)
please test.
currently my projectiles do nothing more then tell you that they hit something running they could easily do so.
could someone make projectile recycling system please?
edit: posting code
Basic creation(note, i am using a gui trigger for this with a wall of custom text and i thought this would be easier to read.
please test.
currently my projectiles do nothing more then tell you that they hit something running they could easily do so.
could someone make projectile recycling system please?
edit: posting code
JASS:
function Trig_MS_Actions takes nothing returns nothing
local integer i = 0
local boolean e
loop
set i = i+1
exitwhen i > udg_MS_Max
set e = false
loop
set udg_MS_Life[i] = udg_MS_Life[i]-.03
if udg_MS_Life[i] > 0 then
set e = true
call SetUnitX(udg_MS_U[i],GetUnitX(udg_MS_U[i])+udg_MS_X[i])
call SetUnitY(udg_MS_U[i],GetUnitY(udg_MS_U[i])+udg_MS_Y[i])
else
call SetUnitUserData(udg_MS_U[udg_MS_Max],i)
call SetUnitUserData(udg_MS_U[i],0)
call DisableTrigger(LoadTriggerHandle(udg_MS,0,GetHandleId(udg_MS_U[i])))
set udg_MS_X[i] = udg_MS_X[udg_MS_Max]
set udg_MS_Y[i] = udg_MS_Y[udg_MS_Max]
set udg_MS_Life[i] = udg_MS_Life[udg_MS_Max]
set udg_MS_Max = udg_MS_Max-1
set udg_MS_U[i] = udg_MS_U[udg_MS_Max]
endif
exitwhen e == true or udg_MS_Max == 0
endloop
endloop
if udg_MS_Max == 0 then
call DisableTrigger(gg_trg_MS)
endif
endfunction
//========================================================================
function InitTrig_MS takes nothing returns nothing
set gg_trg_MS = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_MS, 0.03 )
call TriggerAddAction( gg_trg_MS, function Trig_MS_Actions )
endfunction
JASS:
function Collision takes nothing returns nothing
set udg_MS_Collision = 0
set udg_MS_CollisionUnit = LoadUnitHandle(udg_MS,0,GetHandleId(GetTriggeringTrigger()))
set udg_MS_CollidingU = GetTriggerUnit()
set udg_MS_Collision = 1
call DisplayTimedTextToForce( GetPlayersAll(), 1.00, "Colliding")
endfunction
JASS:
local unit c = GetTriggerUnit()
local real f = GetUnitFacing(c)
local real s = 10
local real x = GetUnitX(c)
local real y = GetUnitY(c)
set udg_MS_Max = udg_MS_Max+1
set udg_T = CreateTrigger()
set udg_MS_U[udg_MS_Max] = CreateUnit(GetTriggerPlayer(),'h000',x,y,f)
call TriggerRegisterUnitInRangeSimple( udg_T,120, udg_MS_U[udg_MS_Max] )
call TriggerAddAction(udg_T,function Collision)
call SaveTriggerHandle(udg_MS,0,GetHandleId(udg_MS_U[udg_MS_Max]),udg_T)
call SaveUnitHandle(udg_MS,0,GetHandleId(udg_T),udg_MS_U[udg_MS_Max])
set udg_MS_Y[udg_MS_Max]=((Sin(f*3.141592/180))*s)
set udg_MS_X[udg_MS_Max]=((Cos(f*3.141593/180))*s)
set udg_MS_Life[udg_MS_Max] = 5
call SetUnitUserData(udg_MS_U[udg_MS_Max],udg_MS_Max)
set c = null
Attachments
Last edited: