Difference between revisions of "Lua:Map Location System"

From Fortress Forever Wiki
Jump to navigationJump to search
(No difference)

Revision as of 04:01, 13 December 2007

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

include list of pre-defined areas