Lua:ff miniturret
|
Spawn Turrets
ff_miniturret is the powerful ceiling-mounted gun that protects spawn rooms. Their behavior can be customized through lua. However, basic team-oriented turrets can be defined by placing the turret entity and naming it appropriately.
- respawnturret_blue
- respawnturret_red
- respawnturret_yellow
- respawnturret_green
The code for this functionality is located in includes/base_respawnturret.lua. Insert this line into your lua file:
IncludeScript("base_respawnturret")
Turrets are typically embedded into a ceiling, with just the bottom cap sticking out. Unlike TFC's turrets, they cannot be floor-mounted.
validtarget
ff_miniturret:validtarget(target_entity)
Respawn turrets will target players, sentries, and dispensers. Use this to define what is a valid target. Returning true makes the turret shoot at the entity in question. Within the scope of this callback, the keyword entity refers to the turret.
Example
-- Note: IsTeam1AlliedToTeam2 will return true if team1 is allied to team2 or -- if team1 is the same as team2 function base_respawnturret:validtarget( target_entity ) --local entity = GetEntity(ent_id) return (AreTeamsAllied(self.team, target_entity:GetTeamId()) == false) end
deploydelay
ff_miniturret:deploydelay(target_entity)
When a turret finds a valid target, it deploys after a two second delay. Use this callback to change this response time. Within the scope of this callback, the keyword entity refers to the turret.
Example
-- Turrets, by default, have a 2 second delay after they -- spot a target and before they're deployed (opened) function base_respawnturret:deploydelay( target_entity ) return 2.0 end