Fortress Forever

Go Back   Fortress Forever > Editing > Mapping > Lua

Reply
 
Thread Tools Display Modes
Old 02-03-2014, 12:17 AM   #1
[TALOS]Smoke
 
Join Date: Jul 2012
Location: Killeen, Tx, USA
Class/Position: Demo Defense
Gametype: Capture the Flag
Affiliations: [TALOS]
Posts Rated Helpful 3 Times
please help

I'm about done with the map, I'm having a few issues with the lua and hoping maybe someone can help. Here's a list of what's broke:
-Teams can det their own gens (shouldn't)
-Teams can repair enemy gens (also shouldn't)
-Security icon goes down when gen is detted/and when button is pushed yet comes back up after a respawn even if they're both down still.
-I'm not using the gen fire and it really doesn't affect anything, but it's clutter in the lua.
Thanks!!

Code:
-----------------------------------------------------------------------------------------------------------------------------
-- INCLUDES
-----------------------------------------------------------------------------------------------------------------------------

IncludeScript("base_shutdown");
IncludeScript("base_location");

SECURITY_LENGTH = 40

-----------------------------------------------------------------------------------------------------------------------------
-- LOCATIONS
-----------------------------------------------------------------------------------------------------------------------------

location_blue_flag	= location_info:new({ text = "Flag Room", team = Team.kBlue })
location_blue_uhall	= location_info:new({ text = "Flag Room Upper Hallway", team = Team.kBlue })
location_blue_lflaghall	= location_info:new({ text = "Flag Room Lower Hallway", team = Team.kBlue })
location_blue_fronthall	= location_info:new({ text = "Front Hallway", team = Team.kBlue })
location_blue_security	= location_info:new({ text = "Security Area", team = Team.kBlue })
location_blue_capbridge	= location_info:new({ text = "Capture Point Bridge", team = Team.kBlue })
location_blue_cappoint	= location_info:new({ text = "Capture Point", team = Team.kBlue })
location_blue_liftroom	= location_info:new({ text = "Lift Room", team = Team.kBlue })
location_blue_waccess	= location_info:new({ text = "Water Access", team = Team.kBlue })
location_blue_tower	= location_info:new({ text = "Tower", team = Team.kBlue })
location_blue_secret	= location_info:new({ text = "Secret Tunnel", team = Team.kBlue })
location_blue_water	= location_info:new({ text = "Water Area", team = Team.kBlue })
location_blue_fspawn	= location_info:new({ text = "Front Spawn", team = Team.kBlue })
location_blue_mspawn	= location_info:new({ text = "Main Spawn", team = Team.kBlue })
location_blue_gen	= location_info:new({ text = "Generator Room", team = Team.kBlue })
location_blue_maint	= location_info:new({ text = "Maintenance Hall", team = Team.kBlue })
location_blue_tele	= location_info:new({ text = "Tele Room", team = Team.kBlue })

location_red_flag	= location_info:new({ text = "Flag Room", team = Team.kRed })
location_red_uhall	= location_info:new({ text = "Flag Room Upper Hallway", team = Team.kRed })
location_red_window	= location_info:new({ text = "Security Window", team = Team.kRed })
location_red_security	= location_info:new({ text = "Security Area", team = Team.kRed })
location_red_capbridge	= location_info:new({ text = "Capture Point Bridge", team = Team.kRed })
location_red_courtyard	= location_info:new({ text = "Main Courtyard", team = Team.kRed })
location_red_liftroom	= location_info:new({ text = "Lift Room", team = Team.kRed })
location_red_secside	= location_info:new({ text = "Security Side", team = Team.kRed })
location_red_frontdoor	= location_info:new({ text = "Front Door", team = Team.kRed })
location_red_waccess	= location_info:new({ text = "Water Access", team = Team.kRed })
location_red_mspawn	= location_info:new({ text = "Main Spawn", team = Team.kRed })
location_red_secret	= location_info:new({ text = "Secret Tunnel", team = Team.kRed })
location_red_fspawn	= location_info:new({ text = "Front Spawn", team = Team.kRed })
location_red_gen	= location_info:new({ text = "Generator Room", team = Team.kRed })
location_red_maint	= location_info:new({ text = "Maintenance Hall", team = Team.kRed })
location_red_tower	= location_info:new({ text = "Tower", team = Team.kRed })
location_red_tele	= location_info:new({ text = "Tele Room", team = Team.kRed })
location_red_fronthall	= location_info:new({ text = "Front Hallway", team = Team.kRed })

location_yard		= location_info:new({ text = "Yard", team = Team.kUnassigned })

-----------------------------------------------------------------------------
-- Spy doors
-----------------------------------------------------------------------------

specdoor = trigger_ff_script:new({ team = Team.kUnassigned, allowdisguised=true, alarm })

function specdoor:allowed(allowed_entity)
    if IsPlayer(allowed_entity) then
        local player = CastToPlayer(allowed_entity)
	if (player:GetTeamId() == self.team) or (self.allowdisguised and player:IsDisguised() and player:GetDisguisedTeam() == self.team) then
            return EVENT_ALLOWED
        end
    end
    return EVENT_DISALLOWED
end

function specdoor:ontouch(touch_entity)
    if IsPlayer(touch_entity) then
        local player = CastToPlayer(touch_entity)
        if player:IsDisguised() and player:GetTeamId() ~= self.team and player:GetDisguisedTeam() == self.team then
        OutputEvent(self.alarm, "PlaySound")
        end
    end
end

blue_gendoor = specdoor:new({ team = Team.kBlue, alarm = "blue_spy_alert" })
red_gendoor = specdoor:new({ team = Team.kRed, alarm = "red_spy_alert" })
blue_teledoor = specdoor:new({ team = Team.kBlue, alarm = "blue_spy_alert1" })
red_teledoor = specdoor:new({ team = Team.kRed, alarm = "red_spy_alert1" })

-----------------------------------------------------------------------------
--  PACKS
-----------------------------------------------------------------------------
	hall_genpack = genericbackpack:new({
	health = 25,
	armor = 10,
	
	grenades = 0,
	nails = 100,
	shells = 25,
	rockets = 15,
	cells = 25,
	
	gren1 = 0,
	gren2 = 0,
	
	respawntime = 8,
	model = "models/items/backpack/backpack.mdl",
	materializesound = "Item.Materialize",
	touchsound = "Backpack.Touch",
	botgoaltype = Bot.kBackPack_Ammo
})
	genpack = genericbackpack:new({
	health = 50,
	armor = 25,
	
	grenades = 0,
	nails = 400,
	shells = 400,
	rockets = 400,
	cells = 400,
	
	gren1 = 0,
	gren2 = 0,
	
	respawntime = 2,
	model = "models/items/backpack/backpack.mdl",
	materializesound = "Item.Materialize",
	touchsound = "Backpack.Touch",
	botgoaltype = Bot.kBackPack_Ammo
})
function genpack:dropatspawn() return false end
blue_genpack = genpack:new({ touchflags = { AllowFlags.kOnlyPlayers, AllowFlags.kBlue } })
red_genpack = genpack:new({ touchflags = { AllowFlags.kOnlyPlayers, AllowFlags.kRed } })

function genpack:dropatspawn() return false end
blue_hall_genpack = hall_genpack:new({ touchflags = { AllowFlags.kOnlyPlayers, AllowFlags.kBlue } })
red_hall_genpack = hall_genpack:new({ touchflags = { AllowFlags.kOnlyPlayers, AllowFlags.kRed } })


-- grenade backpack
grenpack = grenadebackpack:new({ gren1 = 4, gren2 = 4 })
SNIPER_LIMIT = 1;

-----------------------------------------------------------------------------
-- No Annoyances
-----------------------------------------------------------------------------
noannoyances = trigger_ff_script:new({})
 
function noannoyances:onbuild( build_entity )
        return EVENT_DISALLOWED
end
 
function noannoyances:onexplode( explode_entity )
        if IsGrenade( explode_entity ) then
                return EVENT_DISALLOWED
        end
        return EVENT_DISALLOWED
end
 
function noannoyances:oninfect( infect_entity )
        return EVENT_DISALLOWED
end
 
no_annoyances = noannoyances

-----------------------------------------------------------------------------
-- SPAWNS
-----------------------------------------------------------------------------

red_o_only = function(self,player) return ((player:GetTeamId() == Team.kRed) and ((player:GetClass() == Player.kScout) or (player:GetClass() == Player.kMedic) or (player:GetClass() == Player.kSpy) or (player:GetClass() == Player.kEngineer))) end
red_d_only = function(self,player) return ((player:GetTeamId() == Team.kRed) and (((player:GetClass() == Player.kScout) == false) and ((player:GetClass() == Player.kMedic) == false) and ((player:GetClass() == Player.kSpy) == false) and ((player:GetClass() == Player.kEngineer) == false))) end

red_ospawn = { validspawn = red_o_only }
red_dspawn = { validspawn = red_d_only }

blue_o_only = function(self,player) return ((player:GetTeamId() == Team.kBlue) and ((player:GetClass() == Player.kSoldier) or (player:GetClass() == Player.kMedic) or (player:GetClass() == Player.kSpy) or (player:GetClass() == Player.kEngineer))) end
blue_d_only = function(self,player) return ((player:GetTeamId() == Team.kBlue) and (((player:GetClass() == Player.kScout) == false) and ((player:GetClass() == Player.kMedic) == false) and ((player:GetClass() == Player.kSpy) == false))) end

blue_ospawn = { validspawn = blue_o_only }
blue_dspawn = { validspawn = blue_d_only }

SNIPER_LIMIT = 1;

-----------------------------------------------------------------------------
-- Grates
-----------------------------------------------------------------------------

base_grate_trigger = trigger_ff_script:new({ })

function base_grate_trigger:onexplode( explosion_entity )
	if IsDetpack( explosion_entity ) then
		local detpack = CastToDetpack( explosion_entity )

		if detpack:GetTeamId() ~= self.team then
			OutputEvent( self.team_name .. "_grate", "Kill" )
			OutputEvent( self.team_name .. "_grate_wall", "Kill" )
			if self.team_name == "red" then BroadCastMessage("#FF_RED_GRATEBLOWN") end
			if self.team_name == "blue" then BroadCastMessage("#FF_BLUE_GRATEBLOWN") end
		end
	end

	return EVENT_ALLOWED
end

red_grate_trigger = base_grate_trigger:new({ team = Team.kRed, team_name = "red" })
blue_grate_trigger = base_grate_trigger:new({ team = Team.kBlue, team_name = "blue" })

-----------------------------------------------------------------------------
-- Generators Destroy
-----------------------------------------------------------------------------

red_gen_trigger = trigger_ff_script:new({ })
redfire = 0

function red_gen_trigger:onexplode( trigger_entity  ) 
	if IsDetpack( trigger_entity ) then 
		if redgenup == 1 then
		redsecstatus = 0
           	OutputEvent( "red_logicdown", "Trigger" )
           	BroadCastMessage("#FF_RED_GENBLOWN")
	   	OutputEvent( "red_gen_doorhack", "Open")
          	RemoveHudItemFromAll( "red-sec-up" )
		AddHudIconToAll( "hud_secdown.vtf", "red-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
      

            redgenup = 0
            end
	end 
	return EVENT_ALLOWED
end
function red_gen_trigger:allowed( trigger_entity ) return EVENT_DISALLOWED 
end



blue_gen_trigger = trigger_ff_script:new({ })
bluefire = 0

function blue_gen_trigger:onexplode( trigger_entity  ) 
	if IsDetpack( trigger_entity ) then 
            if bluegenup == 1 then
	    bluesecstatus = 0
	    OutputEvent( "blue_logicdown", "Trigger" )
	    BroadCastMessage("#FF_BLUE_GENBLOWN")
	    OutputEvent( "blue_gen_doorhack", "Open")
            RemoveHudItemFromAll( "blue-sec-up" )
            AddHudIconToAll( "hud_secdown.vtf", "blue-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )

            bluegenup = 0
            end
	end 
	return EVENT_ALLOWED
end
function blue_gen_trigger:allowed( trigger_entity ) return EVENT_DISALLOWED 
end

-----------------------------------------------------------------------------
-- Generators Repair
-----------------------------------------------------------------------------

red_gen_repair_trigger = func_button:new({})
red_gen_repair_trigger_script = trigger_ff_script:new()
redspannerclang = 0
redgenup = 1
redclangcntr = 0

function red_gen_repair_trigger_script:ontouch( touch_entity )
	if IsPlayer( touch_entity ) then
		local player = CastToPlayer( touch_entity )
			if player:GetActiveWeaponName() == "ff_weapon_spanner" then
				redspannerclang = 1
				if redfire == 1 then
					DisplayMessage( player, "#HINT_BURNINGGENERATOR" )
				end
			end
	end
end

function red_gen_repair_trigger_script:onendtouch()
	redspannerclang = 0
end

function red_gen_repair_trigger:ondamage()
	if redspannerclang == 1 then
		if redgenup == 0 then
             	if redfire == 0 then
      	 	OutputEvent( "redspannerhit", "PlaySound" )
             	redclangcntr = redclangcntr + 1
                if redclangcntr > 4 then
                redclangcntr = 0             
                BroadCastMessage("#FF_RED_GEN_OK")
                OutputEvent( "red_logicup", "Trigger" )
		redsecstatus=1
		CloseDoor("red_gen_doorhack")
		redspannerclang = 0
                redgenup = 1
		secupred()
                     end
			end
		 end
      end
	return EVENT_DISALLOWED
end



blue_gen_repair_trigger = func_button:new({})
blue_gen_repair_trigger_script = trigger_ff_script:new()
bluespannerclang = 0
bluegenup = 1
blueclangcntr = 0


function blue_gen_repair_trigger_script:ontouch( touch_entity )
	if IsPlayer( touch_entity ) then
		local player = CastToPlayer( touch_entity )
			if player:GetActiveWeaponName() == "ff_weapon_spanner" then
				bluespannerclang = 1
				if bluefire == 1 then
					DisplayMessage( player, "#HINT_BURNINGGENERATOR" )
				end
			end
	end
end

function blue_gen_repair_trigger_script:onendtouch()
	bluespannerclang = 0
end

function blue_gen_repair_trigger:ondamage()
	if bluespannerclang == 1 then
		 if bluegenup == 0 then
             	if bluefire == 0 then
		OutputEvent( "bluespannerhit", "PlaySound" )
             	blueclangcntr = blueclangcntr + 1
                     if blueclangcntr > 4 then
                     blueclangcntr = 0             
                     BroadCastMessage("#FF_BLUE_GEN_OK")
		     OutputEvent( "blue_logicup", "Trigger" )
		     bluesecstatus=1
		     CloseDoor("blue_gen_doorhack")
		     bluespannerclang = 0
                     bluegenup = 1
			secupblue()
                     end
			end
             end
      end
	return EVENT_DISALLOWED
end


-----------------------------------------------------------------------------
--  SECURITY
-----------------------------------------------------------------------------

red_sec = trigger_ff_script:new()
blue_sec = trigger_ff_script:new()
bluesecstatus = 1
redsecstatus = 1

sec_iconx = 60
sec_icony = 30
sec_iconw = 16
sec_iconh = 16

function red_sec:ontouch( touch_entity )
	if IsPlayer( touch_entity ) then
		local player = CastToPlayer( touch_entity )
		if player:GetTeamId() == Team.kBlue then
			if redsecstatus == 1 then
				redsecstatus = 0
				AddSchedule("secup10red", SECURITY_LENGTH - 10, secup10red)
				AddSchedule("beginclosered", SECURITY_LENGTH - 6, beginclosered)
				AddSchedule("secupred",SECURITY_LENGTH,secupred)
				OutputEvent( "red_logicdown", "Trigger" )
				BroadCastMessage("#FF_RED_SEC_40")
				SpeakAll( "SD_REDDOWN" )
				RemoveHudItemFromAll( "red-sec-up" )
				AddHudIconToAll( "hud_secdown.vtf", "red-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
			end
		end
	end
end

function blue_sec:ontouch( touch_entity )
	if IsPlayer( touch_entity ) then
		local player = CastToPlayer( touch_entity )
		if player:GetTeamId() == Team.kRed then
			if bluesecstatus == 1 then
				bluesecstatus = 0
				AddSchedule("secup10blue", SECURITY_LENGTH - 10, secup10blue)
				AddSchedule("begincloseblue", SECURITY_LENGTH - 6, begincloseblue)
				AddSchedule("secupblue",SECURITY_LENGTH,secupblue)
				OutputEvent( "blue_logicdown", "Trigger" )
				BroadCastMessage("#FF_BLUE_SEC_40")
				SpeakAll( "SD_BLUEDOWN" )
				RemoveHudItemFromAll( "blue-sec-up" )
				AddHudIconToAll( "hud_secdown.vtf", "blue-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
			end
		end
	end
end

function secupred()
   	if redgenup == 0 then return false end
	redsecstatus = 1
	BroadCastMessage("#FF_RED_SEC_ON")
	SpeakAll( "SD_REDUP" )
	RemoveHudItemFromAll( "red-sec-down" )
	AddHudIconToAll( "hud_secup_red.vtf", "red-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
end

function begincloseblue()
	if bluegenup == 0 then return false end
	OutputEvent( "blue_logicup", "Trigger" )
end

function beginclosered()
	if redgenup == 0 then return false end
	OutputEvent( "red_logicup", "Trigger" )
end

function secupblue()
    	if bluegenup == 0 then return false end
	bluesecstatus = 1
	BroadCastMessage("#FF_BLUE_SEC_ON")
	SpeakAll( "SD_BLUEUP" )
	RemoveHudItemFromAll( "blue-sec-down" )
	AddHudIconToAll( "hud_secup_blue.vtf", "blue-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
end

function secup10red()
	if redgenup == 0 then return false end
	BroadCastMessage("#FF_RED_SEC_10")
end

function secup10blue()
	if bluegenup == 0 then return false end
	BroadCastMessage("#FF_BLUE_SEC_10")
end

Last edited by GeoKill----->; 02-03-2014 at 01:56 PM. Reason: code format and getting rid of emoticons
[TALOS]Smoke is offline   Reply With Quote


Old 02-03-2014, 05:34 PM   #2
ddm999
worst ff player eu
 
Join Date: Jun 2012
Location: South Yorks., England
Class/Position: o - no, d - scout
Gametype: IvDZ
Posts Rated Helpful 18 Times
All problems should be fixed.
  • Generator detpack triggers check a detpack's team after figuring out it's a detpack
  • The detpack triggers themselves use a modified version of the security triggers to minimize conflicts (and you'll get the speech from security disables when a generator is detonated)
  • Generator repair scripts check a players team before letting them repair
  • flaginfo function added
  • redfire / bluefire globals removed

Your problem with the security icons was everytime you spawned, it would call flaginfo, which is last overwritten in base_shutdown, which tries to find buttons for your security system (no-one uses buttons, so everyone copies the aardvark stuff generally). The buttons don't exist, so it just resorts to putting the security online icons there.

Code:
-----------------------------------------------------------------------------------------------------------------------------
-- INCLUDES
-----------------------------------------------------------------------------------------------------------------------------

IncludeScript("base_shutdown");
IncludeScript("base_location");

SECURITY_LENGTH = 40

-----------------------------------------------------------------------------------------------------------------------------
-- LOCATIONS
-----------------------------------------------------------------------------------------------------------------------------

location_blue_flag	= location_info:new({ text = "Flag Room", team = Team.kBlue })
location_blue_uhall	= location_info:new({ text = "Flag Room Upper Hallway", team = Team.kBlue })
location_blue_lflaghall	= location_info:new({ text = "Flag Room Lower Hallway", team = Team.kBlue })
location_blue_fronthall	= location_info:new({ text = "Front Hallway", team = Team.kBlue })
location_blue_security	= location_info:new({ text = "Security Area", team = Team.kBlue })
location_blue_capbridge	= location_info:new({ text = "Capture Point Bridge", team = Team.kBlue })
location_blue_cappoint	= location_info:new({ text = "Capture Point", team = Team.kBlue })
location_blue_liftroom	= location_info:new({ text = "Lift Room", team = Team.kBlue })
location_blue_waccess	= location_info:new({ text = "Water Access", team = Team.kBlue })
location_blue_tower	= location_info:new({ text = "Tower", team = Team.kBlue })
location_blue_secret	= location_info:new({ text = "Secret Tunnel", team = Team.kBlue })
location_blue_water	= location_info:new({ text = "Water Area", team = Team.kBlue })
location_blue_fspawn	= location_info:new({ text = "Front Spawn", team = Team.kBlue })
location_blue_mspawn	= location_info:new({ text = "Main Spawn", team = Team.kBlue })
location_blue_gen	= location_info:new({ text = "Generator Room", team = Team.kBlue })
location_blue_maint	= location_info:new({ text = "Maintenance Hall", team = Team.kBlue })
location_blue_tele	= location_info:new({ text = "Tele Room", team = Team.kBlue })

location_red_flag	= location_info:new({ text = "Flag Room", team = Team.kRed })
location_red_uhall	= location_info:new({ text = "Flag Room Upper Hallway", team = Team.kRed })
location_red_window	= location_info:new({ text = "Security Window", team = Team.kRed })
location_red_security	= location_info:new({ text = "Security Area", team = Team.kRed })
location_red_capbridge	= location_info:new({ text = "Capture Point Bridge", team = Team.kRed })
location_red_courtyard	= location_info:new({ text = "Main Courtyard", team = Team.kRed })
location_red_liftroom	= location_info:new({ text = "Lift Room", team = Team.kRed })
location_red_secside	= location_info:new({ text = "Security Side", team = Team.kRed })
location_red_frontdoor	= location_info:new({ text = "Front Door", team = Team.kRed })
location_red_waccess	= location_info:new({ text = "Water Access", team = Team.kRed })
location_red_mspawn	= location_info:new({ text = "Main Spawn", team = Team.kRed })
location_red_secret	= location_info:new({ text = "Secret Tunnel", team = Team.kRed })
location_red_fspawn	= location_info:new({ text = "Front Spawn", team = Team.kRed })
location_red_gen	= location_info:new({ text = "Generator Room", team = Team.kRed })
location_red_maint	= location_info:new({ text = "Maintenance Hall", team = Team.kRed })
location_red_tower	= location_info:new({ text = "Tower", team = Team.kRed })
location_red_tele	= location_info:new({ text = "Tele Room", team = Team.kRed })
location_red_fronthall	= location_info:new({ text = "Front Hallway", team = Team.kRed })

location_yard		= location_info:new({ text = "Yard", team = Team.kUnassigned })

-----------------------------------------------------------------------------
-- Spy doors
-----------------------------------------------------------------------------

specdoor = trigger_ff_script:new({ team = Team.kUnassigned, allowdisguised=true, alarm })

function specdoor:allowed(allowed_entity)
    if IsPlayer(allowed_entity) then
        local player = CastToPlayer(allowed_entity)
	if (player:GetTeamId() == self.team) or (self.allowdisguised and player:IsDisguised() and player:GetDisguisedTeam() == self.team) then
            return EVENT_ALLOWED
        end
    end
    return EVENT_DISALLOWED
end

function specdoor:ontouch(touch_entity)
    if IsPlayer(touch_entity) then
        local player = CastToPlayer(touch_entity)
        if player:IsDisguised() and player:GetTeamId() ~= self.team and player:GetDisguisedTeam() == self.team then
        OutputEvent(self.alarm, "PlaySound")
        end
    end
end

blue_gendoor = specdoor:new({ team = Team.kBlue, alarm = "blue_spy_alert" })
red_gendoor = specdoor:new({ team = Team.kRed, alarm = "red_spy_alert" })
blue_teledoor = specdoor:new({ team = Team.kBlue, alarm = "blue_spy_alert1" })
red_teledoor = specdoor:new({ team = Team.kRed, alarm = "red_spy_alert1" })

-----------------------------------------------------------------------------
--  PACKS
-----------------------------------------------------------------------------
	hall_genpack = genericbackpack:new({
	health = 25,
	armor = 10,
	
	grenades = 0,
	nails = 100,
	shells = 25,
	rockets = 15,
	cells = 25,
	
	gren1 = 0,
	gren2 = 0,
	
	respawntime = 8,
	model = "models/items/backpack/backpack.mdl",
	materializesound = "Item.Materialize",
	touchsound = "Backpack.Touch",
	botgoaltype = Bot.kBackPack_Ammo
})
	genpack = genericbackpack:new({
	health = 50,
	armor = 25,
	
	grenades = 0,
	nails = 400,
	shells = 400,
	rockets = 400,
	cells = 400,
	
	gren1 = 0,
	gren2 = 0,
	
	respawntime = 2,
	model = "models/items/backpack/backpack.mdl",
	materializesound = "Item.Materialize",
	touchsound = "Backpack.Touch",
	botgoaltype = Bot.kBackPack_Ammo
})
function genpack:dropatspawn() return false end
blue_genpack = genpack:new({ touchflags = { AllowFlags.kOnlyPlayers, AllowFlags.kBlue } })
red_genpack = genpack:new({ touchflags = { AllowFlags.kOnlyPlayers, AllowFlags.kRed } })

function genpack:dropatspawn() return false end
blue_hall_genpack = hall_genpack:new({ touchflags = { AllowFlags.kOnlyPlayers, AllowFlags.kBlue } })
red_hall_genpack = hall_genpack:new({ touchflags = { AllowFlags.kOnlyPlayers, AllowFlags.kRed } })


-- grenade backpack
grenpack = grenadebackpack:new({ gren1 = 4, gren2 = 4 })
SNIPER_LIMIT = 1;

-----------------------------------------------------------------------------
-- No Annoyances
-----------------------------------------------------------------------------
noannoyances = trigger_ff_script:new({})
 
function noannoyances:onbuild( build_entity )
        return EVENT_DISALLOWED
end
 
function noannoyances:onexplode( explode_entity )
        if IsGrenade( explode_entity ) then
                return EVENT_DISALLOWED
        end
        return EVENT_DISALLOWED
end
 
function noannoyances:oninfect( infect_entity )
        return EVENT_DISALLOWED
end
 
no_annoyances = noannoyances

-----------------------------------------------------------------------------
-- SPAWNS
-----------------------------------------------------------------------------

red_o_only = function(self,player) return ((player:GetTeamId() == Team.kRed) and ((player:GetClass() == Player.kScout) or (player:GetClass() == Player.kMedic) or (player:GetClass() == Player.kSpy) or (player:GetClass() == Player.kEngineer))) end
red_d_only = function(self,player) return ((player:GetTeamId() == Team.kRed) and (((player:GetClass() == Player.kScout) == false) and ((player:GetClass() == Player.kMedic) == false) and ((player:GetClass() == Player.kSpy) == false) and ((player:GetClass() == Player.kEngineer) == false))) end

red_ospawn = { validspawn = red_o_only }
red_dspawn = { validspawn = red_d_only }

blue_o_only = function(self,player) return ((player:GetTeamId() == Team.kBlue) and ((player:GetClass() == Player.kSoldier) or (player:GetClass() == Player.kMedic) or (player:GetClass() == Player.kSpy) or (player:GetClass() == Player.kEngineer))) end
blue_d_only = function(self,player) return ((player:GetTeamId() == Team.kBlue) and (((player:GetClass() == Player.kScout) == false) and ((player:GetClass() == Player.kMedic) == false) and ((player:GetClass() == Player.kSpy) == false))) end

blue_ospawn = { validspawn = blue_o_only }
blue_dspawn = { validspawn = blue_d_only }

SNIPER_LIMIT = 1;

-----------------------------------------------------------------------------
-- Grates
-----------------------------------------------------------------------------

base_grate_trigger = trigger_ff_script:new({ })

function base_grate_trigger:onexplode( explosion_entity )
	if IsDetpack( explosion_entity ) then
		local detpack = CastToDetpack( explosion_entity )

		if detpack:GetTeamId() ~= self.team then
			OutputEvent( self.team_name .. "_grate", "Kill" )
			OutputEvent( self.team_name .. "_grate_wall", "Kill" )
			if self.team_name == "red" then BroadCastMessage("#FF_RED_GRATEBLOWN") end
			if self.team_name == "blue" then BroadCastMessage("#FF_BLUE_GRATEBLOWN") end
		end
	end

	return EVENT_ALLOWED
end

red_grate_trigger = base_grate_trigger:new({ team = Team.kRed, team_name = "red" })
blue_grate_trigger = base_grate_trigger:new({ team = Team.kBlue, team_name = "blue" })

-----------------------------------------------------------------------------
-- Generators Destroy
-----------------------------------------------------------------------------

red_gen_trigger = trigger_ff_script:new({ })

function red_gen_trigger:onexplode( trigger_entity  ) 
	if IsDetpack( trigger_entity ) then
	if CastToDetpack( trigger_entity ):GetTeamId() == Team.kBlue then
		if redsecstatus == 1 then
			redsecstatus = 0
			RemoveSchedule("secup10red")
			RemoveSchedule("beginclosered")
			RemoveSchedule("secupred")
			OutputEvent( "red_logicdown", "Trigger" )
			OpenDoor("red_gen_doorhack")
			BroadCastMessage("#FF_RED_GENBLOWN")
			SpeakAll( "SD_REDDOWN" )
			RemoveHudItemFromAll( "red-sec-up" )
			AddHudIconToAll( "hud_secdown.vtf", "red-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
		end
	end
	end
	return EVENT_ALLOWED
end
function red_gen_trigger:allowed( trigger_entity ) return EVENT_DISALLOWED 
end



blue_gen_trigger = trigger_ff_script:new({ })

function blue_gen_trigger:onexplode( trigger_entity  ) 
	if IsDetpack( trigger_entity ) then
	if CastToDetpack( trigger_entity ):GetTeamId() == Team.kRed then
		if redsecstatus == 1 then
			redsecstatus = 0
			RemoveSchedule("secup10blue")
			RemoveSchedule("begincloseblue")
			RemoveSchedule("secupblue")
			OutputEvent( "blue_logicdown", "Trigger" )
			OpenDoor("blue_gen_doorhack")
			BroadCastMessage("#FF_BLUE_GENBLOWN")
			SpeakAll( "SD_BLUEDOWN" )
			RemoveHudItemFromAll( "blue-sec-up" )
			AddHudIconToAll( "hud_secdown.vtf", "blue-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
		end
	end
	end
	return EVENT_ALLOWED
end
function blue_gen_trigger:allowed( trigger_entity ) return EVENT_DISALLOWED 
end

-----------------------------------------------------------------------------
-- Generators Repair
-----------------------------------------------------------------------------

red_gen_repair_trigger = func_button:new({})
red_gen_repair_trigger_script = trigger_ff_script:new()
redspannerclang = 0
redgenup = 1
redclangcntr = 0

function red_gen_repair_trigger_script:ontouch( touch_entity )
	if IsPlayer( touch_entity ) then
		local player = CastToPlayer( touch_entity )
		if player:GetActiveWeaponName() == "ff_weapon_spanner" and player:GetTeamId() == Team.kRed then
			redspannerclang = 1
		end
	end
end

function red_gen_repair_trigger_script:onendtouch()
	redspannerclang = 0
end

function red_gen_repair_trigger:ondamage()
	if redspannerclang == 1 then
		if redgenup == 0 then
			OutputEvent( "redspannerhit", "PlaySound" )
			redclangcntr = redclangcntr + 1
            if redclangcntr > 4 then
                redclangcntr = 0             
                BroadCastMessage("#FF_RED_GEN_OK")
                OutputEvent( "red_logicup", "Trigger" )
				redsecstatus = 1
				CloseDoor("red_gen_doorhack")
				redspannerclang = 0
				redgenup = 1
				secupred()
				end
			end
		end
	end
	return EVENT_DISALLOWED
end



blue_gen_repair_trigger = func_button:new({})
blue_gen_repair_trigger_script = trigger_ff_script:new()
bluespannerclang = 0
bluegenup = 1
blueclangcntr = 0


function blue_gen_repair_trigger_script:ontouch( touch_entity )
	if IsPlayer( touch_entity ) then
		local player = CastToPlayer( touch_entity )
			if player:GetActiveWeaponName() == "ff_weapon_spanner" and player:GetTeamId() == Team.kBlue then
				bluespannerclang = 1
			end
	end
end

function blue_gen_repair_trigger_script:onendtouch()
	bluespannerclang = 0
end

function blue_gen_repair_trigger:ondamage()
	if bluespannerclang == 1 then
		 if bluegenup == 0 then
			OutputEvent( "bluespannerhit", "PlaySound" )
			blueclangcntr = blueclangcntr + 1
			if blueclangcntr > 4 then
				blueclangcntr = 0             
				BroadCastMessage("#FF_BLUE_GEN_OK")
				OutputEvent( "blue_logicup", "Trigger" )
				bluesecstatus=1
				CloseDoor("blue_gen_doorhack")
				bluespannerclang = 0
				bluegenup = 1
				secupblue()
			end
		end
	end
	return EVENT_DISALLOWED
end


-----------------------------------------------------------------------------
--  SECURITY
-----------------------------------------------------------------------------

red_sec = trigger_ff_script:new()
blue_sec = trigger_ff_script:new()
bluesecstatus = 1
redsecstatus = 1

sec_iconx = 60
sec_icony = 30
sec_iconw = 16
sec_iconh = 16

function red_sec:ontouch( touch_entity )
	if IsPlayer( touch_entity ) then
		local player = CastToPlayer( touch_entity )
		if player:GetTeamId() == Team.kBlue then
			if redsecstatus == 1 then
				redsecstatus = 0
				AddSchedule("secup10red", SECURITY_LENGTH - 10, secup10red)
				AddSchedule("beginclosered", SECURITY_LENGTH - 6, beginclosered)
				AddSchedule("secupred",SECURITY_LENGTH,secupred)
				OutputEvent( "red_logicdown", "Trigger" )
				BroadCastMessage("#FF_RED_SEC_40")
				SpeakAll( "SD_REDDOWN" )
				RemoveHudItemFromAll( "red-sec-up" )
				AddHudIconToAll( "hud_secdown.vtf", "red-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
			end
		end
	end
end

function blue_sec:ontouch( touch_entity )
	if IsPlayer( touch_entity ) then
		local player = CastToPlayer( touch_entity )
		if player:GetTeamId() == Team.kRed then
			if bluesecstatus == 1 then
				bluesecstatus = 0
				AddSchedule("secup10blue", SECURITY_LENGTH - 10, secup10blue)
				AddSchedule("begincloseblue", SECURITY_LENGTH - 6, begincloseblue)
				AddSchedule("secupblue",SECURITY_LENGTH,secupblue)
				OutputEvent( "blue_logicdown", "Trigger" )
				BroadCastMessage("#FF_BLUE_SEC_40")
				SpeakAll( "SD_BLUEDOWN" )
				RemoveHudItemFromAll( "blue-sec-up" )
				AddHudIconToAll( "hud_secdown.vtf", "blue-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
			end
		end
	end
end

function secupred()
	redsecstatus = 1
	BroadCastMessage("#FF_RED_SEC_ON")
	SpeakAll( "SD_REDUP" )
	RemoveHudItemFromAll( "red-sec-down" )
	AddHudIconToAll( "hud_secup_red.vtf", "red-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
end

function begincloseblue()
	OutputEvent( "blue_logicup", "Trigger" )
end

function beginclosered()
	OutputEvent( "red_logicup", "Trigger" )
end

function secupblue()
	bluesecstatus = 1
	BroadCastMessage("#FF_BLUE_SEC_ON")
	SpeakAll( "SD_BLUEUP" )
	RemoveHudItemFromAll( "blue-sec-down" )
	AddHudIconToAll( "hud_secup_blue.vtf", "blue-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
end

function secup10red()
	BroadCastMessage("#FF_RED_SEC_10")
end

function secup10blue()
	BroadCastMessage("#FF_BLUE_SEC_10")
end

function flaginfo( player_entity )
	flaginfo_base(player_entity) --see base_teamplay.lua

	local player = CastToPlayer( player_entity )
	
	RemoveHudItem( player, "red-sec-down" )
	RemoveHudItem( player, "blue-sec-down" )
	RemoveHudItem( player, "red-sec-up" )
	RemoveHudItem( player, "blue-sec-up" )

		if bluesecstatus == 1 then
			AddHudIcon( player, "hud_secup_blue.vtf", "blue-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
		else
			AddHudIcon( player, "hud_secdown.vtf", "blue-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
		end

		if redsecstatus == 1 then
			AddHudIcon( player, "hud_secup_red.vtf", "red-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
		else
			AddHudIcon( player, "hud_secdown.vtf", "red-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
		end
end
Lemme know if you find any problems.
__________________
gg ff not ded
ff very much alive
ddm999 is offline   Reply With Quote


1 members found this post helpful.
Old 02-03-2014, 08:20 PM   #3
[TALOS]Smoke
 
Join Date: Jul 2012
Location: Killeen, Tx, USA
Class/Position: Demo Defense
Gametype: Capture the Flag
Affiliations: [TALOS]
Posts Rated Helpful 3 Times
Quote:
Originally Posted by ddm999 View Post
Your problem with the security icons was everytime you spawned, it would call flaginfo, which is last overwritten in base_shutdown, which tries to find buttons for your security system (no-one uses buttons, so everyone copies the aardvark stuff generally). The buttons don't exist, so it just resorts to putting the security online icons there.
Ok, I fixed a couple of things. Everything else seems to be working properly except the gen repair functions. I'm still trying to figure out why. Here's the gen parts after I fixed the errors.

Code:
----------------------------------------------------------------
-- Generators Destroy
----------------------------------------------------------------

red_gen_trigger = trigger_ff_script:new({ })

function red_gen_trigger:onexplode( trigger_entity  ) 
	if IsDetpack( trigger_entity ) then
	if CastToDetpack( trigger_entity ):GetTeamId() == Team.kBlue then
		if redgenup == 1 then
			redsecstatus = 0
			RemoveSchedule("secup10red")
			RemoveSchedule("beginclosered")
			RemoveSchedule("secupred")
			OutputEvent( "red_logicdown", "Trigger" )
			OpenDoor("red_gen_doorhack")
			BroadCastMessage("#FF_RED_GENBLOWN")
			SpeakAll( "SD_REDDOWN" )
			RemoveHudItemFromAll( "red-sec-up" )
			AddHudIconToAll( "hud_secdown.vtf", "red-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
		end
	end
	end
	return EVENT_ALLOWED
end
function red_gen_trigger:allowed( trigger_entity ) return EVENT_DISALLOWED 
end



blue_gen_trigger = trigger_ff_script:new({ })

function blue_gen_trigger:onexplode( trigger_entity  ) 
	if IsDetpack( trigger_entity ) then
	if CastToDetpack( trigger_entity ):GetTeamId() == Team.kRed then
		if bluegenup == 1 then
			bluesecstatus = 0
			RemoveSchedule("secup10blue")
			RemoveSchedule("begincloseblue")
			RemoveSchedule("secupblue")
			OutputEvent( "blue_logicdown", "Trigger" )
			OpenDoor("blue_gen_doorhack")
			BroadCastMessage("#FF_BLUE_GENBLOWN")
			SpeakAll( "SD_BLUEDOWN" )
			RemoveHudItemFromAll( "blue-sec-up" )
			AddHudIconToAll( "hud_secdown.vtf", "blue-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
		end
	end
	end
	return EVENT_ALLOWED
end
function blue_gen_trigger:allowed( trigger_entity ) return EVENT_DISALLOWED 
end

-----------------------------------------------------------------------------
-- Generators Repair
-----------------------------------------------------------------------------

red_gen_repair_trigger = func_button:new({})
red_gen_repair_trigger_script = trigger_ff_script:new()
redspannerclang = 0
redgenup = 1
redclangcntr = 0

function red_gen_repair_trigger_script:ontouch( touch_entity )
	if IsPlayer( touch_entity ) then
		local player = CastToPlayer( touch_entity )
		if player:GetActiveWeaponName() == "ff_weapon_spanner" and player:GetTeamId() == Team.kRed then
			redspannerclang = 1
		end
	end
end

function red_gen_repair_trigger_script:onendtouch()
	redspannerclang = 0
end

function red_gen_repair_trigger:ondamage()
	if redspannerclang == 1 then
		if redgenup == 0 then
			OutputEvent( "redspannerhit", "PlaySound" )
			ConsoleToAll("hitting gen")
			redclangcntr = redclangcntr + 1
            if redclangcntr > 4 then
                redclangcntr = 0             
                BroadCastMessage("#FF_RED_GEN_OK")
                OutputEvent( "red_logicup", "Trigger" )
				redsecstatus = 1
				CloseDoor("red_gen_doorhack")
				redspannerclang = 0
				redgenup = 1
				secupred()
				end
			end
		end
	return EVENT_DISALLOWED
end



blue_gen_repair_trigger = func_button:new({})
blue_gen_repair_trigger_script = trigger_ff_script:new()
bluespannerclang = 0
bluegenup = 1
blueclangcntr = 0


function blue_gen_repair_trigger_script:ontouch( touch_entity )
	if IsPlayer( touch_entity ) then
		local player = CastToPlayer( touch_entity )
			if player:GetActiveWeaponName() == "ff_weapon_spanner" and player:GetTeamId() == Team.kBlue then
				bluespannerclang = 1
			end
	end
end

function blue_gen_repair_trigger_script:onendtouch()
	bluespannerclang = 0
end

function blue_gen_repair_trigger:ondamage()
	if bluespannerclang == 1 then
		 if bluegenup == 0 then
			ConsoleToAll("hitting gen")
			OutputEvent( "bluespannerhit", "PlaySound" )
			blueclangcntr = blueclangcntr + 1
			if blueclangcntr > 4 then
				blueclangcntr = 0             
				BroadCastMessage("#FF_BLUE_GEN_OK")
				OutputEvent( "blue_logicup", "Trigger" )
				bluesecstatus=1
				CloseDoor("blue_gen_doorhack")
				bluespannerclang = 0
				bluegenup = 1
				secupblue()
			end
		end
	end
	return EVENT_DISALLOWED
end

Last edited by [TALOS]Smoke; 02-03-2014 at 08:26 PM.
[TALOS]Smoke is offline   Reply With Quote


Old 02-03-2014, 10:32 PM   #4
ddm999
worst ff player eu
 
Join Date: Jun 2012
Location: South Yorks., England
Class/Position: o - no, d - scout
Gametype: IvDZ
Posts Rated Helpful 18 Times
You need to put 'redgenup = 0' and 'bluegenup = 0' in 'red_gen_trigger:onexplode' and 'blue_gen_trigger:onexplode'.

The repair things think the generator hasn't actually detonated without them, so you can't repair.

(I assume you aren't getting those consoletoall's you added)
__________________
gg ff not ded
ff very much alive

Last edited by ddm999; 02-03-2014 at 10:32 PM.
ddm999 is offline   Reply With Quote


Old 02-04-2014, 12:38 AM   #5
[TALOS]Smoke
 
Join Date: Jul 2012
Location: Killeen, Tx, USA
Class/Position: Demo Defense
Gametype: Capture the Flag
Affiliations: [TALOS]
Posts Rated Helpful 3 Times
Sweet, it's working now! All I have to do is optimize the map and fix the location brushes.
[TALOS]Smoke is offline   Reply With Quote


Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:38 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.