- Joined
- Feb 6, 2014
- Messages
- 2,466
It would be great if this had some benchmarks.
GetRecycleUnit vs CreateUnit
GetRecycleUnit vs CreateUnit
Updated with that change, and set the dummy owner to Player 13 instead of 15. If I am not mistaken, Player 13 is Neutral Extra. That player can cast both positive and negative buffs on the same target.
function GetRecycledMissile takes real x, real y, @real z@, real facing returns unit
I thought the ability should be removed before we can modify the fly height.
Btw, what do you think about adding delay parameter to RecycleMissile function? So that we can choose to remove the dummy immediately or not.
GetRecycledMissile takes real x, real y, real z, real facing
// Runs in createEx.
//! textmacro MISSILE_RESET_ALL_MEMBERS
set path = null
set speed = 0.
set acceleration = 0.
set distance = 0.
set dist = 0
set dist = 0.
set height = 0.
set turn = 0.
set open = 0.
set collision = 0.
set collisionType = 0
set stackSize = 0
set scaling = 1.
set wantDestroy = false
set recycle = false
//! endtextmacro
// Launches a dummy of your choice.
static method createEx takes unit missileDummy, real impactX, real impactY, real impactZ returns thistype
local thistype this = thistype.allocateNode()
local real originX = GetUnitX(missileDummy)
local real originY = GetUnitY(missileDummy)
local real originZ = GetUnitFlyHeight(missileDummy)
//
//! runtextmacro MISSILE_RESET_ALL_MEMBERS()
//
set origin = MissilePosition.create(originX, originY, originZ)
set impact = MissilePosition.create(impactX, impactY, impactZ)
call MissilePosition.link(origin, impact)
set posX = originX
set posY = originY
set x = originX
set y = originY
set z = originZ
set angle = origin.angle
set dummy = missileDummy
call SetUnitFlyHeight(missileDummy, originZ, 0.)
call SaveUnitHandle(HASH, this, GetHandleId(missileDummy), missileDummy)
//
static if LIBRARY_ErrorMessage then
debug call ThrowWarning(GetUnitTypeId(missileDummy) == 0, "Missile", "createEx", "missileDummy", this, "Invalid missile dummy unit ( null )!")
endif
debug set launched = false
return this
endmethod
// Wrapper to createEx
static method create takes real x, real y, real z, real angle, real distance, real impactZ returns thistype
local real impactX = x + distance*Cos(angle)
local real impactY = y + distance*Sin(angle)
// Get the dummy unit.
//! runtextmacro MISSILE_GET_DUMMY_FROM_LIBRARY()
endmethod
static if LIBRARY_MissileRecycler then
return createEx(GetRecycledMissile(x, y, z, angle*bj_RADTODEG), impactX, impactY, impactZ) // TOLD YOU SO - this function seems to me as an example of using simple create unit event
The vast majority of performance bottlenecks in missile systems is from checking for collisions; the number of possible collisions to check scales strongly with W (number of walled surfaces or targets to collide with) and M (number of existing missiles) since each needs to be checked against everything else. Specifically (W+M)! which can be fucking massive.(I dunno, it seems it has no one and missile recycle might help it to improve perfomance)
thx you. I'm still curious how to use your system anywayMissileRecycler is designed only to work with Vexorian/Anitarf/InFrane's dummy.mdx model file, so usually you just have one dummy unit type for that. I don't know about BPower's Missile enough to advise further.
function GetRecycledMissile
takes real x, real y, real z, real facing
returns unit
function RecycleMissile
takes unit u
returns nothing
Thx you. I'm kinda confused how tricky dummy recycling is. That has been said that system uses indexed angles, configuravle via ANG... Oh my gosh I cant undestand it, I have read an instruction 2 times already.The purpose of the system is to both recycle units as well as to allow their facing angle to be correct (not always perfectly) when it spawns, making it good for arrow projectiles but irrelevant for something that doesn't have a direction (such as phoenix fire).
If you are getting cases where the missiles are getting overloaded and killed/created too often, you can increase the constant variable ANG_STORAGE_MAX to something higher than 12 depending on how many of those dummies are exceeding the limit.