.qc (dot qc) - the group for quake c coders of all denominations. If you make quake one mods and write code in quake c, join our group! I'll try to answer any quake c questions - please post your inquiry in the forums...
Posts | ||
---|---|---|
Rail trail in qc | Locked | |
Thread Options | ||
|
Aug 23 2011 Anchor | |
Promised code to generate a rail gun style trail with the darkplaces engine. This will probably work in any engine, but darkplaces will have the best looking effect. // variables for this segment local vector org, destination, v1, v2, vp; // set muzzle light, make punchangle for gun fire, also might want to use ammo up and play sounds here as well self.effects = self.effects | EF_MUZZLEFLASH; // origin - business end of gun pre-calculated for visible weapon effect org = self.origin + v_up * VWZ_RAILGUN + v_right * VWY_RAILGUN + v_forward * VWX_RAILGUN; // trace rail beam out traceline (org, org + v_forward*2048, TRUE, self); // initialize loop variables makevectors(self.v_angle); // loop to display particles - stops when entering a solid brush like a wall or blocking bsp model (doors, plats, etc.) while (i != CONTENT_SOLID) if (af < 10) af = af + 0.2; // particle trail inside spiral - standard quake particles, this could be refined to more approximate the q2 railgun if (random() < 0.2) particle (v1, v_forward * 30, 250, 2); // beambit makes the spiral, one every so many quake units e = chaos_spawn(MOVETYPE_FLY, SOLID_NOT, 0, 0, v1 + vp, v0, v0, v0, vp + self.velocity, "", "progs/beambit.spr", SUB_Remove, 0.5, SUB_Remove, SUB_Null, self, world); // count bits and set transparency in darkplaces if (e) // test code to track beam positioning - commented out for release code // code to advance spiral along - this sets a new quadrant of the spiral based on position j = j + aj; if (fabs(j) < 0.02 || fabs(k) < 0.02) // calculate distance forward (i is metric, v1 stores origin vector) to next particle - based on distance and particle count i = 2 + (1 / af) * 0.5; // find out if we are in a solid yet - this could be re-written to penetrate thin brushes like doors with an extra check! i = pointcontents(v1); // loop done - damage routine should follow this code // Arg...forum style is stripping the tab indents. They are there, you just cant see them. dur. Edited by: numbersix |
Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.