Dissecting turrets

nbk

Newbie
Joined
Aug 20, 2004
Messages
135
Reaction score
1
I wrote this to be a slight(albeit extremely small) guide to turrets, with people adding things in. Thanks for any help anyone provides.

1. Open up npc_turret_floor.
2. Look at the different values

More noticeable ones would be the ammo type. Since I am reading through the files one by one, I can't see what it is linked too. Anyways, try modifying this variable to see what you can come up with.

Another would be m_flFieldOfView. The member variable is commented as field of view - Either how far it rotates, or how far it can "see"(or both).

Right below m_flFieldOfView are health/maxhealth.

I am not sure if this works. I am fairly sure that when you use the npc_create, it passes a reference to the string, which then goes through a case statement... mr_unanimouse, it would please me if you could help out a bit(with what is called with npc_create).

Also, I have not found a variable for the turrets being friendly/non-friendly. I have seen the function IRelationType(), and would possibly be it.



Thank you, qck. I just learned how to use that function(from you of course(LETC)). Also showed me a great use of inheritance :)
 
For friendly turrets I just wrote this tiny bit of code in after CNPC_FloorTurret in npc_turret_floor.cpp

Code:
//-----------------------------------------
// Purpose: Create a friendly floor turret 
// Created by: qckbeam
//-----------------------------------------
									

class CNPC_FloorTurretFriend : public CNPC_FloorTurret
{
	Class_T	Classify( void ) 
	{
		if( m_bEnabled ) 
			return CLASS_PLAYER_ALLY;

		return CLASS_NONE;
	}

};

LINK_ENTITY_TO_CLASS( npc_turret_floor_friend , CNPC_FloorTurretFriend );

//End qck edit

I'm sure there might be another way to do it, but this works quite well in my opinion.
 
qckbeam said:
For friendly turrets I just wrote this tiny bit of code in after CNPC_FloorTurret in npc_turret_floor.cpp
[...]

It works pretty good.. thanks! I was looking for -something- to make friendly turrets..

but.. it would still be nice to be able to make a friendly turret on an un-modded HL2. (for a few reasons, including that the SDK doesn't seem to be up to date with the actual HL2)

And there's one other thing, which isn't -huge- just annoying and also a curiosity... (it'd be interesting to figure it out..) the friendly turrets created aren't friendly to the in-game friendly turrets, and vice-versa.. Maybe you noticed already..? And know why..? :)

Oh well, thanks again for the cool code piece.. :)

- Notes
 
It could be something to do with the fact you can dynamically change the relationships of entities in hammer.

But, yeah, changing Classify is probably the most efficient way to make a friendly turret. Although, instead of creating a new class as shown above, it could be more interesting to have a variable that can be changed from outside triggers to choose its Classify type, so turrets can be made good/evil mid-game.

-Angry Lawyer
 
Back
Top