Hey this is concerning your recent missile system.
Is there a way to pass information to the struct that implements MissileStruct?
I want to make it so on impact, I can check if a unit is an enemy and deal damage. But I don't know how to do that with your Missile.
edit: wait, can I do this
local MyStruct mag
local Missile m
// misile stuf..
//
mag = m.data
mag.cast = .cast
mag.damage = 50.
MyStruct.Launch(m)
edit 2: so I've tried this, and it kinda works - but like a third of the time I'm getting null instances when I try to refer to them back in my MissileStruct struct. This is what I'm doing to be more specific
// This is the stuff inside my MissileStruct struct.
// But sometimes I get null instance on mis.data,
// so if I print the caster's name it comes out blank or whatever
// and the caster gets hit by the missile because the filter returns true.
static method onCollide takes Missile mis, unit hitTarget returns boolean
local thistype this = mis.data
if IsUnitEnemy(hitTarget, GetOwningPlayer(.cast)) and GetWidgetLife(hitTarget)>.405 and not IsUnitType(hitTarget, UNIT_TYPE_DEAD) then
call .explodeMissile(hitTarget)
return true
endif
return false
endmethod
// This is what I do to create missile and set variables.
set mis = Missile.create(.ix, .iy, MISSILE_Z, Atan2(yy, xx), dist, MISSILE_Z)
set mis.speed = .speed
set mis.model = MISSILE_FX
set mis.arc = .10
set mis.scale = .scale
set mis.collision = .collisionAoe
set mag = mis.data
set mag.cast = .cast
set mag.dmg = .dmg
set mag.splash = .splashDmg
set mag.aoe = .splashAoe
set mag.sx = rx
set mag.sy = ry
set mag.explode = true
call Magnum.launch(mis)