Forum

Spawning Model to Block Player Movement

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Spawning Model to Block Player Movement

Postby Ghost_Fang » Tue Jun 15, 2010 3:48 pm

I modified the grenade code to make a Halo 3 style deployable cover to block bullets and player movement. But as of right now it only blocks bullets. It is possible to spawn a model that'll block players too? I've tried all the SOLID_'s.

Code: Select all
void() W_FireGrenade =
{
   local   entity missile, mpuff;
   
   self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
   
   self.punchangle_x = -2;

   missile = spawn ();
   missile.owner = self;
   missile.movetype = MOVETYPE_STEP;
   missile.solid = SOLID_BBOX;
   missile.classname = "grenade";
      
// set missile speed   

   makevectors (self.v_angle);

   if (self.v_angle_x)
      missile.velocity = v_forward*500 + v_up * 00 + crandom()*v_right*10 + crandom()*v_up*10;
   else
   {
      missile.velocity = aim(self, 10000);
      missile.velocity = missile.velocity * 400;
      missile.velocity_z = 300;
   }
   
   
// set missile duration
   missile.nextthink = time + 2;
   missile.think = BecomeCover;

   setmodel (missile, "progs/d_cover.mdl");
   setsize (missile, '0 0 0', '0 0 0');      
   setorigin (missile, self.origin);
};




Code: Select all
void() BecomeCover =

{
   
   setmodel (self, "progs/cover.mdl");
   self.solid = SOLID_BBOX;
   self.movetype = MOVETYPE_STEP;
   setsize (self, VEC_HULL2_MIN, VEC_HULL2_MAX);
   self.nextthink = time + 15;
   self.think = BecomeExplosion;
   setorigin (self, self.origin);
};





One More thing, I deleted the
"missile.angles = vectoangles(missile.velocity);"
part of the code because if you looked up and threw it, the spawned the model facing up, and every other direction etc. But now no matter what way you face it spawns in the same direction, how would i change the missile angles to affect X & Y but not Z (if you know what i mean) so you can throw it and it only copies the direction you were facing but ignores if you were facing up or down.
Ghost_Fang
 
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am

Postby Sajt » Tue Jun 15, 2010 5:53 pm

missile.angles = '0 1 0' * vectoyaw(missile.velocity);

or just

missile.angles = '0 1 0' * playerentity.angles_y;
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 Dr. Shadowborg » Tue Jun 15, 2010 6:22 pm

Also, to make it block the player too, you need to switch the owner from the player to the world, or something.

i.e. in BecomeCover(); add a self.owner = world;

Beware though, you'll have to do some stuff to keep it from getting the player stuck inside of it if he's too close.
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1110
Joined: Sat Oct 16, 2004 3:34 pm

Postby Mexicouger » Tue Jun 15, 2010 7:27 pm

So you started working on this eh Ghost? Nice man. It isn't as complex as I thought It would be however. Good Luck.
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby Sajt » Wed Jun 16, 2010 12:31 am

Increasing the bbox suddenly (without doing any checks to see if it is now intersecting something) scares me. The entity should drop out of the world, or trigger satanic unsticking code, or something when you do that.
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 Ghost_Fang » Fri Jun 18, 2010 5:44 pm

Thanks Dr. Shadowborg worked perfectly.
Ghost_Fang
 
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest