Category:Buildable functions

From Fortress Forever Wiki
Jump to navigationJump to search


Mapping for FF
The Basics

Setting up Hammer
Getting Started With Lua
Releasing a map

FF-specific Entities

Lua location system

Map Templates
FF Lua Documentation

Entity Typing
Entity Collections

Commands
Callbacks

These are functions that can be applied to machines built by players, such as sentry guns.

Usage

CFFBuildableObject:function(parameters)

or

CFFSentryGun:function(parameters)

or

CFFDispener:function(parameters)

Probably mancannons and detpacks would apply here as well

Example

function player_killed ( player_victim, damageinfo )

	-- if no damageinfo do nothing
	if not damageinfo then return end

	-- Entity that is attacking
	local attacker = damageinfo:GetAttacker()
  
	-- If no attacker do nothing
	if not attacker then return end

	elseif IsSentrygun(attacker) then
		attacker = CastToSentrygun(attacker)
		--attacker now refers to a CFFSentryGun object;
		--we can do sentry specific stuff, as well as general buildable stuff.
		player_attacker = attacker:GetOwner()
		--We now know who owns the sentry who killed this player
	end
end

CFFBuildableObject -- The basic form of buildable

Command Description
GetTeamId() returns teamid of the buildable.
GetOwner() returns the player that built it. Not sure if this is a player object or entity.
GetTeam() returns the team of the buildable.

CFFSentryGun -- Sentrygun is a type of buildable, and inherits all of the above.

Command Description
GetLevel() Returns the level of the sentry.
SetLevel(int level) sets the level (does not play upgrade sounds)
Upgrade() upgrades to the next level.
Repair(int cells) adds health based on the number of cells
AddAmmo(int shells, int rockets) adds ammo
RocketPosition() returns the Vector position of where rockets are fired from.
MuzzlePosition() returns the Vector position of where bullets are fired from
GetRockets() number of rockets the SG has
GetShells() number of shells the SG has
GetHealth() amount of health the SG has
SetRockets(int rockets)
SetShells(int shells)
SetHealth(int health)
GetMaxRockets()
GetMaxShells()
GetMaxHealth()
SetFocusPoint(Vector point) sets where the SG wants to look
GetEnemy() gets the target of the SG (CBaseEntity)
SetEnemy(CBaseEntity enemy)
GetVecAiming() gets the direction vector of the SG's current aim direction
GetVecGoal() gets the direction vector of the SG's goal aim direction
Shoot() makes the SG shoot one shell
ShootRocket() makes the SG shoot one rocket

This category currently contains no pages or media.