Big problem with NPC 3rd person weapon code..

Discuss programming in the QuakeC language.
Post Reply
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Big problem with NPC 3rd person weapon code..

Post by drm_wayne »

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;

};
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

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

Post by Spike »

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?
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

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

Post by drm_wayne »

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
Post Reply