Obj sentrygun: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
 
 Tip:Mini-sentries can be created by copying the following VScript code to a .nut file and assigning it under the
Tip:Mini-sentries can be created by copying the following VScript code to a .nut file and assigning it under the 
 Note:Values higher than 2 are accepted (need to be typed in with SmartEdit off), with the limit being 90. With higher levels, the objects gain more health/damage/recharge speed.
Note:Values higher than 2 are accepted (need to be typed in with SmartEdit off), with the limit being 90. With higher levels, the objects gain more health/damage/recharge speed.
		
	
|  (→Inputs) |  (Rewrite Template:Lang to Template:LanguageBar (This action was performed by a bot.)) | ||
| (30 intermediate revisions by 19 users not shown) | |||
| Line 1: | Line 1: | ||
| {{ | {{TF2 topicon}} | ||
| {{LanguageBar|title=obj_sentrygun}} | |||
| {{CD|CObjectSentrygun|file1=tf_obj_sentrygun.cpp}} | |||
| {{this is a|model entity|name=obj_sentrygun|game=Team Fortress 2}} | |||
| [[File:TF2 Sentries.PNG|thumb|400px|right|Sentry Guns in TF2 at levels 1, 2 and 3.]] | |||
| ==Entity Description== | ==Entity Description== | ||
| Used to place a  | Used to place a {{tfwiki|Sentry Gun}} in your map. The Sentry Gun is a defensive building that puts heavy fire on any enemies that come into range. The Sentry Gun has a range of 1100 Hammer Units from its origin. | ||
| {{tip|Mini-sentries can be created by copying the following [[VScript]] code to a .nut file and assigning it under the <code>Entity Scripts</code> | |||
| <source lang=js> | |||
| function Precache() | |||
| { | |||
| 	NetProps.SetPropBool(self, "m_bMiniBuilding", true); | |||
| } | |||
| function OnPostSpawn() | |||
| { | |||
| 	self.SetModelScale(0.75, 0.0); | |||
| 	self.SetSkin(self.GetSkin() + 2); | |||
| } | |||
| </source> | |||
| }} | |||
| ==Keyvalues== | |||
| {{KV Targetname}} | |||
| {{KV TFObject}} | |||
| ==  | ==Flags== | ||
| {{Fl TFBaseObject}} | |||
| {{fl|4|Upgradable}} | |||
| {{fl|8|Infinite Ammo}} | |||
| ==  | ==Inputs== | ||
| {{I TFObject}} | |||
| ==Outputs== | |||
| {{O TFObject}} | |||
Latest revision as of 17:19, 18 July 2025

 
|  Class hierarchy | 
|---|
| CObjectSentrygun | 
|  tf_obj_sentrygun.cpp | 
obj_sentrygun  is a   model entity  available in  Team Fortress 2.
 Team Fortress 2.
Entity Description
Used to place a  Sentry Gun in your map. The Sentry Gun is a defensive building that puts heavy fire on any enemies that come into range. The Sentry Gun has a range of 1100 Hammer Units from its origin.
 Sentry Gun in your map. The Sentry Gun is a defensive building that puts heavy fire on any enemies that come into range. The Sentry Gun has a range of 1100 Hammer Units from its origin.
 Tip:Mini-sentries can be created by copying the following VScript code to a .nut file and assigning it under the
Tip:Mini-sentries can be created by copying the following VScript code to a .nut file and assigning it under the Entity Scripts
function Precache()
{
	NetProps.SetPropBool(self, "m_bMiniBuilding", true);
}
function OnPostSpawn()
{
	self.SetModelScale(0.75, 0.0);
	self.SetSkin(self.GetSkin() + 2);
}
Keyvalues
- Name (targetname) <string>[ Edit ]
- The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentnameortarget).
 Also displayed in Hammer's 2D views and Entity Report.See also: Generic Keyvalues, Inputs and Outputs available to all entities
TFObject:
- Team (TeamNum) <choices>
- Team
- 2 : Red
- 3 : Blue
 
- Starting Upgrade Level (defaultupgrade) <choices>
- Object spawns in the selected level.
- 0 : Level 1
- 1 : Level 2
- 2 : Level 3
 
 Note:Values higher than 2 are accepted (need to be typed in with SmartEdit off), with the limit being 90. With higher levels, the objects gain more health/damage/recharge speed.
Note:Values higher than 2 are accepted (need to be typed in with SmartEdit off), with the limit being 90. With higher levels, the objects gain more health/damage/recharge speed.- SolidToPlayer (SolidToPlayer) <choices>
- Object is solid or non-solid to players. !FGD
- 1 : Solid
- 0 : Non-solid
 
Flags
BaseObject:
- Invulnerable : [2] Bug:Invulnerable buildings can still be stunned with the Bug:Invulnerable buildings can still be stunned with the Sapper or completely destroyed with the Sapper or completely destroyed with the Red-Tape Recorder. Red-Tape Recorder.
- Upgradable : [4]
- Infinite Ammo : [8]
Inputs
TFObject:
- SetHealth <integer>
- Sets the current and maximum health. If the object is upgraded, the health will scale according to the new value.
 Bug:Crashes if set to 0.  [todo tested in ?] Bug:Crashes if set to 0.  [todo tested in ?]
- AddHealth <integer>
- Increase the current health of the object. Does not surpass maximum health. Does not destroy the building if set at 0.
- RemoveHealth <integer>
- Decrease current health of the object. Destroys the object if the health hits 0.
- SetSolidToPlayer <boolean>
- Sets the object to be solid or non-solid to players. 0 - non-solid, 1 - solid. !FGD
 Note:The builder of the building will always be solid to the object. Note:The builder of the building will always be solid to the object.
- SetBuilder
- Sets the builder of the object to the !activator.
- Show
- Makes the building visible and re-enables it.
- Hide
- Makes the building invisible and disables it.
 Bug:Does not hide the obj_dispenser screen. A workaround is to fire the Bug:Does not hide the obj_dispenser screen. A workaround is to fire the- SetInactive(or- SetActive) on the vgui_screen entity, although it will apply to all buildings. [todo tested in ?]
- Enable
- Enable the object.
 Note:Using Note:Using- Enableafter using the- Hideinput will enable the building and keep it invisible.
 Bug: Bug:- Enablewill reset the upgrade level on the object. Use the- Showinput instead, which properly re-enables the object. [todo tested in ?]
- Disable
- Disable the object.
Outputs
TFObject:
- OnDestroyed
- Sent when object dies.
- OnDamaged
- Sent when hurt. Works with !activator.
























