Difference between revisions of "Map Template:Security"

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

Revision as of 06:51, 29 August 2009


Introduction

This is how to set up security doors and lasers in a map. The doors, lasers, trigger_hurt's, lights and sounds are all controlled by two logic relays. The relays are triggered by the lua.  

Entities

  • red_sec (trigger_ff_script): Trigger which deactivates security when touched.
  • red_secdown_relay (logic_relay): This relay gets fired when security gets deactivated.
  • red_secup_relay (logic_relay): This relay gets fired when security reactivates.

Lua Script

-- security_test.lua
IncludeScript("base");
IncludeScript("base_ctf");

-- security is active to start
redsecurity = true

red_sec = trigger_ff_script:new()

function red_sec:ontouch( touch_entity )
	ConsoleToAll("moooo?")
	if IsPlayer( touch_entity ) then
		local player = CastToPlayer( touch_entity )
		-- can only be deactivated by blue players
		if player:GetTeamId() == Team.kBlue then
			ConsoleToAll("caaaa")
			if redsecurity then
				ConsoleToAll("ummm")
				redsecurity = false
				AddSchedule("secup10red",50,secup10red)
				AddSchedule("secupred",60,secupred)
				OutputEvent("red_secdown_relay", "Trigger" )
				BroadCastMessage("Red Security Deactivated for 60 Seconds")
				SpeakAll( "SD_REDDOWN" )
				RemoveHudItemFromAll( "red-sec-up" )
				AddHudIconToAll( "hud_secdown.vtf", "red-sec-down", 60, 25, 16, 16, 3 )
			end
		end
	end
end

function secupred()
	-- This function reactivates security
	redsecurity = true
	OutputEvent("red_secup_relay", "Trigger" )
	BroadCastMessage("Red Security Online")
	SpeakAll( "SD_REDUP" )
	RemoveHudItemFromAll( "red-sec-down" )
	AddHudIconToAll( "hud_secup_red.vtf", "red-sec-up", 60, 25, 16, 16, 3 )
end

function secup10red()
	-- Give a 10 second warning that security will reactivate
	BroadCastMessage("Red Security Online in 10 Seconds")
end