Lightning gun -- help
Moderator: InsideQC Admins
27 posts
• Page 2 of 2 • 1, 2
Should I do a while loop? I've done a little different, but in large corridors the lightning is going infinity, and doing packet overflows.
So, what's the way to fix? If I put an (if (fwd > dist) return;), will have a runaway loop error?
- Code: Select all
void(vector org, string bolt, float tracedist) ParseBeam =
{
local entity beam;
local float fwd, avel, dist;
fwd = 0;
avel = 10000;
makevectors (self.v_angle);
traceline (org, org + v_forward*tracedist, TRUE, self);
dist = vlen(tracedist*trace_fraction);
while (fwd < dist)
{
fwd = fwd + 32;
avel = avel * 2;
beam = spawn ();
beam.owner = self;
beam.movetype = MOVETYPE_FLY;
beam.effects = EF_DIMLIGHT;
makevectors (self.v_angle);
beam.avelocity_z = avel;
beam.angles_x = self.v_angle_x * -1;
beam.angles_y = self.v_angle_y;
beam.angles_z = self.v_angle_z;
beam.nextthink = time + 0.1;
beam.think = SUB_Remove;
setmodel (beam, bolt);
setsize (beam, '0 0 0', '0 0 0');
setorigin (beam, org + v_forward*fwd);
}
};
So, what's the way to fix? If I put an (if (fwd > dist) return;), will have a runaway loop error?
-

Orion - Posts: 476
- Joined: Fri Jan 12, 2007 6:32 pm
- Location: Brazil
- Code: Select all
dist = vlen(tracedist*trace_fraction);
Shouldn't the compiler give an error on that? :O Just use dist = tracedist * trace_fraction;[/code]
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
Just a tip: in one of my mods (TecnoX) i had a similar idea.
I needed to make a laser beam effect (skinnable), and to avoid spawning too many entities and causing packet overflows, i did an UGLY hack: the mdl used had about 10 frames, stretched to a given length (frame 1 had 16 "quake units", frame 2 had 32 units, frame 3 had 64...).
With this in mind, the algorithm checks the required beam length and used the biggest model frame, spawning a minimum amount of entities, avoiding packet overflows.
I needed to make a laser beam effect (skinnable), and to avoid spawning too many entities and causing packet overflows, i did an UGLY hack: the mdl used had about 10 frames, stretched to a given length (frame 1 had 16 "quake units", frame 2 had 32 units, frame 3 had 64...).
With this in mind, the algorithm checks the required beam length and used the biggest model frame, spawning a minimum amount of entities, avoiding packet overflows.
#EOP
- Gilgamesh
- Posts: 67
- Joined: Tue Oct 26, 2004 6:08 pm
- Location: Brazil
-

Entar - Posts: 439
- Joined: Fri Nov 05, 2004 7:27 pm
- Location: At my computer
Gilgamesh wrote:Just a tip: in one of my mods (TecnoX) i had a similar idea.
I needed to make a laser beam effect (skinnable), and to avoid spawning too many entities and causing packet overflows, i did an UGLY hack: the mdl used had about 10 frames, stretched to a given length (frame 1 had 16 "quake units", frame 2 had 32 units, frame 3 had 64...).
With this in mind, the algorithm checks the required beam length and used the biggest model frame, spawning a minimum amount of entities, avoiding packet overflows.
Very clever. I assume that you had different coloured skins as well...
Any chance you could share the model?
-

Lardarse - Posts: 266
- Joined: Sat Nov 05, 2005 1:58 pm
- Location: Bristol, UK
I can search for it (it's from qexpo 2003), but is just the enforcer laser with many skins, and stretched.
EDIT: Found it. Good news: found the full mod, and it still works! Bad news: i lost ALL source code, and frikqcc throws an error when i try to decompile it!

EDIT: Found it. Good news: found the full mod, and it still works! Bad news: i lost ALL source code, and frikqcc throws an error when i try to decompile it!
#EOP
- Gilgamesh
- Posts: 67
- Joined: Tue Oct 26, 2004 6:08 pm
- Location: Brazil
27 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest
