Forum

This has been Bugging me...

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

This has been Bugging me...

Postby Mexicouger » Sun Jul 04, 2010 3:13 am

Well From redrums Charge code, I made it suitable for Prime. But I was wondering, if The velocity returns when self.charge returns to 0.
Look

/*
================
Blaster Firing
================
*/
Code: Select all
void() W_FireBlaster =
{

   local   entity plasma;
   blaster_flash();
   self.currentammo = self.ammo_blaster = self.ammo_blaster - 0;
   sound (self, CHAN_AUTO, "weapons/guncock.wav", 1, ATTN_NORM);
   self.punchangle_x = -2;

   plasma = spawn ();
   plasma.owner = self;
   plasma.movetype = MOVETYPE_FLYMISSILE;
   plasma.solid = SOLID_BBOX;
   plasma.classname = "missile";
      
// Set the speed of the Plasma

   makevectors (self.v_angle);
   plasma.velocity = aim(self, 1000);
   if (self.charge >= 10)   // Sets the Velocity for When charging the Blaster
      if (self.charge < 20)
        plasma.velocity = plasma.velocity * 4200;
   if (self.charge >= 20)
      if (self.charge < 30)
        plasma.velocity = plasma.velocity * 3700;
   if (self.charge >= 30)
      if (self.charge < 40)
        plasma.velocity = plasma.velocity * 3400;
   if (self.charge >= 40)
      if (self.charge < 50)
        plasma.velocity = plasma.velocity * 3100;
   if (self.charge >= 50)
      if (self.charge < 60)
        plasma.velocity = plasma.velocity * 2800;
   if (self.charge >= 60)
      if (self.charge < 70)
        plasma.velocity = plasma.velocity * 2500;
   if (self.charge >= 70)
        plasma.velocity = plasma.velocity * 2000;
   else
   plasma.velocity = plasma.velocity * 4500;

   plasma.angles = vectoangles(plasma.velocity);
   
   if (self.charge >= 10)   // Sets the Different Damages
      if (self.charge < 20)
        plasma.touch = BlasterTouch1;
   if (self.charge >= 40)
      if (self.charge < 50)
       plasma.touch = BlasterTouch2;
   if (self.charge >= 70)
        plasma.touch = BlasterTouch3;
   else
   plasma.touch = BlasterTouch;
   setmodel (plasma, "progs/blast.spr");
   if (self.charge >= 50 || self.charge >= 70)
   plasma.frame = 0;
   else
   plasma.frame = 2;

   setsize (plasma, '0 0 0', '0 0 0');      
   setorigin (plasma, self.origin + v_forward*10 + '0 0 16');
   
// set missile duration
   plasma.nextthink = time + 5;
   plasma.think = SUB_Remove;
   self.charge = 0;
};


Should I have a seperate code that Givees another entity the same charge as the player? Like it passes the charge level of the player onto the entity, and When the entity gets removed, then entity.charge = 0?

Like once self.charge = 0;, Does the velocity return to else or does it stay the same all the time? I am just wondering. Don't know if you quite understand my question. This is just a quick question, and I will delete this thread once it's answered.
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby DukeInstinct » Sun Jul 11, 2010 1:22 am

Your current code is always going to set the plasma.velocity to plasma.velocity * 4500 unless self.charge is more than 70.

You need to rewrite it like this:
Code: Select all
if(self.charge >= 70)
plasma.velocity = plasma.velocity * 2000;
else if (self.charge >= 60)
plasma.velocity = plasma.velocity * 2500;
else if (self.charge >= 50)
plasma.velocity = plasma.velocity * 2800;
else if (self.charge >= 40)
plasma.velocity = plasma.velocity * 3100;
else if (self.charge >= 30)
plasma.velocity = plasma.velocity * 3400;
else if (self.charge >= 20)
plasma.velocity = plasma.velocity * 3700;
else if (self.charge >= 10)
plasma.velocity = plasma.velocity * 4200;
else
plasma.velocity = plasma.velocity * 4500;


Code: Select all
if (self.charge >= 70)
plasma.touch = BlasterTouch3;
else if (self.charge >= 40 && self.charge < 50)
plasma.touch = BlasterTouch2;
else if (self.charge >= 10 && self.charge < 20)
plasma.touch = BlasterTouch1;
else
Plasma.touch = BlasterTouch;
Image
User avatar
DukeInstinct
 
Posts: 20
Joined: Sat Jul 10, 2010 11:20 pm
Location: DukeLand

Postby Spike » Sun Jul 11, 2010 2:23 am

beware the sv_maxvelocity cvar too!
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby Mexicouger » Sun Jul 11, 2010 10:25 pm

What's that cvar do. I am hitting nowhere near Maxvelocity for a Projectile.
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby ceriux » Mon Jul 12, 2010 5:25 pm

max velocity controls every things velocity you need to raise it. i had an issue with a sniper i was designing once.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest