Forum

Big problem with NPC 3rd person weapon code..

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Big problem with NPC 3rd person weapon code..

Postby drm_wayne » Thu May 02, 2013 4:23 am

I added a code to spawn a 3rd person gun to a singleplayer enemy, it works but sometiems the weapon gets
also attached to my grenades and shell ejection (???)...
Anybody can help me??

Heres the code..

Code: Select all
void() npc_mp40update =
{

   if(self.owner.classname == "npc_soldier")
   setmodel (self, "progs/visual/vis_mp40.mdl");

   self.angles = self.owner.angles;
   self.origin = self.owner.origin;
   self.think = npc_mp40update;
   self.nextthink = time + 0.01;
   self.frame = self.owner.frame;

};

void() SpawnNPCWeapon =
{
   local   entity gun;
   
   
   gun = spawn ();
   gun.owner = self;   
   gun.movetype = MOVETYPE_NONE;
   gun.solid = SOLID_NOT;
   gun.classname = "Third Person Weapon";
   setorigin (gun, self.origin);
   gun.angles = self.angles;
   gun.frame = self.owner.frame;
   self.gunnumber = self.gunnumber + 1;
   if(self.gunnumber > 1)         //Do we already have one?
      gun.think = SUB_Remove;      //Then go away
   else
      gun.think = npc_mp40update;
   gun.nextthink = time+ 0.01;

};
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: Big problem with NPC 3rd person weapon code..

Postby Spike » Thu May 02, 2013 5:46 am

do you remove the 3rd-person weapon when its owner dies? or does it linger on other things like projectiles that simply use the same entity slot as its owner?
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Big problem with NPC 3rd person weapon code..

Postby drm_wayne » Thu May 02, 2013 11:18 am

Spike wrote:do you remove the 3rd-person weapon when its owner dies? or does it linger on other things like projectiles that simply use the same entity slot as its owner?


Currently the dead body and the gun gets removed (they sink in the ground)....
But it seems to happen after i walk over the dead bodies... lol xD
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest