Inside3D!
     

Lightning gun -- help
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
Urre



Joined: 05 Nov 2004
Posts: 1073
Location: Sweden

PostPosted: Tue Apr 17, 2007 9:58 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Orion



Joined: 12 Jan 2007
Posts: 413
Location: Brazil

PostPosted: Tue Apr 17, 2007 7:52 pm    Post subject: Reply with quote

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
View user's profile Send private message
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Wed Apr 18, 2007 5:52 am    Post subject: Reply with quote

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
View user's profile Send private message
Urre



Joined: 05 Nov 2004
Posts: 1073
Location: Sweden

PostPosted: Wed Apr 18, 2007 8:47 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Gilgamesh



Joined: 26 Oct 2004
Posts: 67
Location: Brazil

PostPosted: Wed Apr 18, 2007 1:07 pm    Post subject: Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
Urre



Joined: 05 Nov 2004
Posts: 1073
Location: Sweden

PostPosted: Wed Apr 18, 2007 1:50 pm    Post subject: Reply with quote

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

One's gotta do what one's gotta do!
_________________
Look out for Twigboy
Back to top
View user's profile Send private message Visit poster's website
Orion



Joined: 12 Jan 2007
Posts: 413
Location: Brazil

PostPosted: Wed Apr 18, 2007 2:08 pm    Post subject: Reply with quote

Solved, thanks!
_________________
There's no signature here. Stop looking for one.
Back to top
View user's profile Send private message
Entar



Joined: 05 Nov 2004
Posts: 422
Location: At my computer

PostPosted: Wed Apr 18, 2007 3:34 pm    Post subject: Reply with quote

Gilgamesh: that's actually a pretty cool idea, imo.
_________________
woh... feelin woozy... too much cider...
http://entar.quakedev.com
games fascination - My Game Development Blog/Journal
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Gilgamesh



Joined: 26 Oct 2004
Posts: 67
Location: Brazil

PostPosted: Wed Apr 18, 2007 4:05 pm    Post subject: Reply with quote

i feel better now Laughing Laughing
_________________
#EOP
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Lardarse



Joined: 05 Nov 2005
Posts: 243
Location: Bristol, UK

PostPosted: Fri Apr 20, 2007 8:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
Gilgamesh



Joined: 26 Oct 2004
Posts: 67
Location: Brazil

PostPosted: Fri Apr 20, 2007 9:34 pm    Post subject: Reply with quote

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! Crying or Very sad Crying or Very sad Crying or Very sad Crying or Very sad
_________________
#EOP
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Orion



Joined: 12 Jan 2007
Posts: 413
Location: Brazil

PostPosted: Tue May 08, 2007 8:16 pm    Post subject: Reply with quote

Hehe now the Quake2 parasite's beam works fine here Smile
_________________
There's no signature here. Stop looking for one.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group