Lua:Map Location System

From Fortress Forever Wiki
Jump to navigationJump to search


Map Location System

The location system in Fortress Forever is used to show a player via the HUD what room/area they are currently in.

There are 2 parts to implementing a location system in a map:

  • trigger_ff_script entities in the .vmf
  • .lua file for the map

trigger_ff_script entities in the .vmf

In hammer create a brush and tie it to a trigger_ff_script entity. Give this new brush-entity a name like "location_my-specific-area-here".

Example Location Entity Names

location_red_ramproom
location_rocky_cliff
location_red_waterhole

You have now created a brush based location entity that when the player touches it will tell the player what location they are in.

Everytime a player touches a location entity (a trigger_ff_script named location_x where x is the location name) the game code checks to see if that player is already in location_x. If they are, nothing happens. If they aren't, then the HUD location display is changed to reflect the new location as well as the location information used in chats.

It's important to note that location entities really only need to be placed at the entrance and exit of an area as the player does not have to constantly be touching the location entity. Once the player touches a location entity they will be marked as being in that location until they touch a location entity with a different location name. You may also want to cover the spawn points with location entities so that the player immediately starts out in a location. Otherwise, when a player spawns their location is set to NULL until they touch a location entity.

.lua file for the map

Just like when using anything LUA related, you need a .lua file named the same as your map (ie: ff_dev_ctf.bsp has a lua file named ff_dev_ctf.lua).

In your maps lua file is where you define the actual location name you gave to the location entity in hammer. This is where you set the team who owns that area and the actual text that is displayed for this particular location. You also have to include the base location lua file in your map's lua file when wanting to use any locations.

Example .LUA File Utilizing Locations

-- Include the base location .lua file
IncludeScript( "base_location" );

-- Define a location
location_rocky_cliff = location_info:new({ text = "Rocky Cliff", team = NO_TEAM })

-- Define another location
location_red_waterhole = location_info:new({ text = "Water Hole", team = Team.kRed })

What that actually means... the 'text = "Water Hole"' part defines what will be shown for the location's name on the HUD and in chats. The 'team = Team.kRed' defines which team the location belongs to and determines the color the text is drawn in on the HUD.

Valid Teams

NO_TEAM     - for locations not belonging to any team
Team.kBlue   - for locations belonging to blue team
Team.kRed    - for locations belonging to red team
Team.kYellow - for locations belonging to yellow team
Team.kGreen  - for locations belonging to green team

Localization

TODO: yeah...

Pre-Defined Locations

"FF_LOCATION_ATTIC"		"Attic"
"FF_LOCATION_BASE"		"Base"
"FF_LOCATION_BALCONY"		"Balcony"
"FF_LOCATION_BATTLEMENTS"	"Battlements"
"FF_LOCATION_BUNKER"		"Bunker"
"FF_LOCATION_BUTTON"		"Button"
"FF_LOCATION_CAPPOINT"		"Cap Point"
"FF_LOCATION_ELEVATOR"		"Elevator"
"FF_LOCATION_FLAGROOM"		"Flag Room"
"FF_LOCATION_FRONTDOOR"		"Front Door"
"FF_LOCATION_LIFT"		"Lift"
"FF_LOCATION_LOFT"		"Loft"
"FF_LOCATION_PIT"		"Pit"
"FF_LOCATION_PLANK"		"Plank"
"FF_LOCATION_RAMP"		"Ramp"
"FF_LOCATION_RAMP_BOTTOM"	"Bottom Ramp"
"FF_LOCATION_RAMP_TOP"		"Top Ramp"
"FF_LOCATION_RAMPROOM"		"Ramp Room"
"FF_LOCATION_ROOF"		"Roof"
"FF_LOCATION_RESPAWN"		"Respawn"
"FF_LOCATION_SECURITY"		"Security"
"FF_LOCATION_SNIPER_PERCH"	"Sniper Perch"
"FF_LOCATION_SWITCH"		"Switch"
"FF_LOCATION_SPIRAL"		"Spiral"
"FF_LOCATION_T"			"T-Junction"
"FF_LOCATION_TRAIN_TUNNEL"	"Train Tunnel"
"FF_LOCATION_UNDERGROUND"	"Underground"
"FF_LOCATION_WATERROUTE"	"Water Route"
"FF_LOCATION_YARD"		"Yard"

"FF_LOCATION_ATTACKER_SPAWN"		"Attacker Spawn Area"
"FF_LOCATION_DEFENDER_SPAWN"		"Defender Spawn Area"
"FF_LOCATION_COMMAND_POINT_ONE"		"Command Point One"
"FF_LOCATION_COMMAND_POINT_TWO"		"Command Point Two"
"FF_LOCATION_COMMAND_POINT_THREE"	"Command Point Three"
"FF_LOCATION_COMMAND_POINT_FOUR"     	"Command Point Four"
"FF_LOCATION_COMMAND_POINT_FIVE"     	"Command Point Five"
"FF_LOCATION_COMMAND_POINT_SIX"     	"Command Point Six"
"FF_LOCATION_COMMAND_POINT_SEVEN"     	"Command Point Seven"
"FF_LOCATION_COMMAND_POINT_EIGHT"     	"Command Point Eight"
"FF_LOCATION_COMMAND_POINT_NINE"     	"Command Point Nine"
"FF_LOCATION_COMMAND_POINT_TEN"     	"Command Point Ten"
"FF_LOCATION_DETPACK_HOLE"		"Detpack Hole Area"

"FF_LOCATION_CP1_PATH"     		"Path to CP1"
"FF_LOCATION_CP2_PATH"     		"Path to CP2"
"FF_LOCATION_CP3_PATH"     		"Path to CP3"
"FF_LOCATION_CP4_PATH"     		"Path to CP4"
"FF_LOCATION_CP5_PATH"     		"Path to CP5"
"FF_LOCATION_CP6_PATH"     		"Path to CP6"
"FF_LOCATION_CP7_PATH"     		"Path to CP7"
"FF_LOCATION_CP8_PATH"     		"Path to CP8"
"FF_LOCATION_CP9_PATH"     		"Path to CP9"
"FF_LOCATION_CP10_PATH"     		"Path to CP10"

"FF_LOCATION_COMMAND_CENTER"     	"Command Center"
"FF_LOCATION_COMMAND_ROOM"	     	"Command Room"
"FF_LOCATION_CONTROL_CENTER"	     	"Control Center"
"FF_LOCATION_CONTROL_ROOM"	     	"Control Room"

"FF_LOCATION_CANAL"     		"Canal"
"FF_LOCATION_CATACOMBS"     		"Catacombs"
"FF_LOCATION_OUTSIDE_BASE"     		"Outside Base"