@name Mike Dude's Missile Spawner
@inputs Array:array LastSpawned:entity
@outputs Missile:entity Fire
@persist Thrust


if (first() | duped())
{
    Thrust = 100000
}

interval(50)

if(opcounter()<= maxquota() - 100){
    for(IDX=1, Array:count()){
        Missile = Array[IDX,entity]
        ForwardVel = Missile:vel():dot(Missile:forward()) * Missile:forward()
        Missile:applyForce((Missile:forward() * Thrust + (-Missile:vel() + ForwardVel) + vec(0,0,36.3)) * Missile:mass())
    }
}

    ###Create a trail and play some sounds 1 time for each missile

if(changed(LastSpawned) & LastSpawned)
{
    entity():soundPlay(0, 0, "weapons/stinger_fire1.wav")
    LastSpawned:soundPlay(LastSpawned:id(), 0, "ambient/levels/citadel/portal_beam_shoot5.wav")
    LastSpawned:setTrails(10, 150, 2.5, "trails/smoke", vec(150, 150, 150), 225)
    LastSpawned:setMass(50000)
}
