this code is weird. you're overwriting mypos.z in the end. you're using VECTOR* and VECTOR kind of arbitrarily. you're using random(0)-0. you're mixing p.flags and set. you're not initializing p.lifespan.