View previous topic :: View next topic |
Author |
Message |
Urre

Joined: 05 Nov 2004 Posts: 1073 Location: Sweden
|
Posted: Tue Apr 17, 2007 9:58 am Post subject: |
|
|
You could easily add it to that code by simply first checking the length of the trace (blah = vlen(tracelength*trace_fraction)), and just do a check for (if (fwd > blah) return;) to stop spawning them _________________ Look out for Twigboy |
|
Back to top |
|
 |
Orion

Joined: 12 Jan 2007 Posts: 413 Location: Brazil
|
Posted: Tue Apr 17, 2007 7:52 pm Post subject: |
|
|
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.
Code: |
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? _________________ There's no signature here. Stop looking for one. |
|
Back to top |
|
 |
Sajt
Joined: 16 Oct 2004 Posts: 1026
|
Posted: Wed Apr 18, 2007 5:52 am Post subject: |
|
|
Code: | 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. |
|
Back to top |
|
 |
Urre

Joined: 05 Nov 2004 Posts: 1073 Location: Sweden
|
Posted: Wed Apr 18, 2007 8:47 am Post subject: |
|
|
It should give an error, since tracedist is a float. I was assuming it'd be a vector when I gave the suggestion, so yeah change it to what Sajt said. _________________ Look out for Twigboy |
|
Back to top |
|
 |
Gilgamesh
Joined: 26 Oct 2004 Posts: 67 Location: Brazil
|
Posted: Wed Apr 18, 2007 1:07 pm Post subject: |
|
|
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. _________________ #EOP |
|
Back to top |
|
 |
Urre

Joined: 05 Nov 2004 Posts: 1073 Location: Sweden
|
Posted: Wed Apr 18, 2007 1:50 pm Post subject: |
|
|
Gilgamesh: In the world of Quake, that is not a hack, and certainly not ugly
One's gotta do what one's gotta do! _________________ Look out for Twigboy |
|
Back to top |
|
 |
Orion

Joined: 12 Jan 2007 Posts: 413 Location: Brazil
|
Posted: Wed Apr 18, 2007 2:08 pm Post subject: |
|
|
Solved, thanks! _________________ There's no signature here. Stop looking for one. |
|
Back to top |
|
 |
Entar

Joined: 05 Nov 2004 Posts: 422 Location: At my computer
|
|
Back to top |
|
 |
Gilgamesh
Joined: 26 Oct 2004 Posts: 67 Location: Brazil
|
Posted: Wed Apr 18, 2007 4:05 pm Post subject: |
|
|
i feel better now  _________________ #EOP |
|
Back to top |
|
 |
Lardarse

Joined: 05 Nov 2005 Posts: 243 Location: Bristol, UK
|
Posted: Fri Apr 20, 2007 8:21 pm Post subject: |
|
|
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? |
|
Back to top |
|
 |
Gilgamesh
Joined: 26 Oct 2004 Posts: 67 Location: Brazil
|
Posted: Fri Apr 20, 2007 9:34 pm Post subject: |
|
|
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!  _________________ #EOP |
|
Back to top |
|
 |
Orion

Joined: 12 Jan 2007 Posts: 413 Location: Brazil
|
Posted: Tue May 08, 2007 8:16 pm Post subject: |
|
|
Hehe now the Quake2 parasite's beam works fine here  _________________ There's no signature here. Stop looking for one. |
|
Back to top |
|
 |
|