Forum

Lightning gun -- help

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Postby Urre » Tue Apr 17, 2007 9:58 am

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
I was once a Quake modder
User avatar
Urre
 
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon

Postby Orion » Tue Apr 17, 2007 7:52 pm

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: 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?
User avatar
Orion
 
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil

Postby Sajt » Wed Apr 18, 2007 5:52 am

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

Postby Urre » Wed Apr 18, 2007 8:47 am

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.
I was once a Quake modder
User avatar
Urre
 
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon

Postby Gilgamesh » Wed Apr 18, 2007 1:07 pm

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
Gilgamesh
 
Posts: 67
Joined: Tue Oct 26, 2004 6:08 pm
Location: Brazil

Postby Urre » Wed Apr 18, 2007 1:50 pm

Gilgamesh: In the world of Quake, that is not a hack, and certainly not ugly :)

One's gotta do what one's gotta do!
I was once a Quake modder
User avatar
Urre
 
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon

Postby Orion » Wed Apr 18, 2007 2:08 pm

Solved, thanks!
User avatar
Orion
 
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil

Postby Entar » Wed Apr 18, 2007 3:34 pm

Gilgamesh: that's actually a pretty cool idea, imo.
User avatar
Entar
 
Posts: 439
Joined: Fri Nov 05, 2004 7:27 pm
Location: At my computer

Postby Gilgamesh » Wed Apr 18, 2007 4:05 pm

i feel better now :lol: :lol:
#EOP
Gilgamesh
 
Posts: 67
Joined: Tue Oct 26, 2004 6:08 pm
Location: Brazil

Postby Lardarse » Fri Apr 20, 2007 8:21 pm

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?
User avatar
Lardarse
 
Posts: 266
Joined: Sat Nov 05, 2005 1:58 pm
Location: Bristol, UK

Postby Gilgamesh » Fri Apr 20, 2007 9:34 pm

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! :cry: :cry: :cry: :cry:
#EOP
Gilgamesh
 
Posts: 67
Joined: Tue Oct 26, 2004 6:08 pm
Location: Brazil

Postby Orion » Tue May 08, 2007 8:16 pm

Hehe now the Quake2 parasite's beam works fine here :)
User avatar
Orion
 
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil

Previous

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest