Fortress Forever

Go Back   Fortress Forever > Editing > Mapping

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 10-15-2007, 12:04 AM   #1
Major Lee High
Retired Mapper
 
Major Lee High's Avatar
 
Join Date: Mar 2007
Location: Tulsa, OK
Posts Rated Helpful 1 Times
[LUA Help] Trigger Hurt, Momentary_Rot_Button HELP!!!

Things I got working.

func_rot_button works now. Toggles between teams.
toggled spawns, lever turns spawn on and off.

Things to Do (maybe).

Add Detpack points, had some probs with this so far.

Add ALERTS and hud icons for gas/warehouse events.

Things I still need help with.

Making Trigger_Hurt give the player that enables it with a button, the kills it gets. There is some LUA code about killer/attacker in the rocket arena include but I havent found a way to pass the killer along to the hurt. Also, no clue how to test this so atm im not working on it.

Momentary_Rot_button. While I have got func_rot_button working fine, momentary_rot_button does not work at all. I can get OnPressed and things to work fine in my LUA but, ALLOWED never gets called so i cant make it a team button. If I try to call the player in the OnPressed its always a nil value error no matter what I try to do. Any Ideas on this would be helpfull,

Edit

Redid the button part to see whats happening. Only OnPressed and OnFullyClosed are being called when I use it.

Heres what I got on the Momentary_Rot_Button atm

Code:
-----------------------------------------------------------------------------
-- Buildables
-----------------------------------------------------------------------------
momentary_rot_button = baseclass:new({})
function momentary_rot_button:allowed() return true end
function momentary_rot_button:onpressed() end
function momentary_rot_button:onunpressed() end
function momentary_rot_button:onfullyopen() end
function momentary_rot_button:onfullyclosed() end
function momentary_rot_button:onreachedposition() end

red_assaultramp_build = momentary_rot_button:new({ team = Team.kRed })

function red_assaultramp_build:Allowed() 
   		ConsoleToAll( "Allowed" )
end

function red_assaultramp_build:OnPressed()
		ConsoleToAll( "Pressed" )
end

function red_assaultramp_build:OnUnPressed()
		ConsoleToAll( "UnPressed" )
end

function red_assaultramp_build:OnFullyOpen()
		ConsoleToAll( "Fully Open" )
end

function red_assaultramp_build:OnFullyClosed()
		ConsoleToAll( "Fully Closed" )
end

function red_assaultramp_build:OnReachedPosition()
		ConsoleToAll( "Reached Postion" )
end


base_ramp_trigger = trigger_ff_script:new({ team = Team.kUnassigned })

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

		-- GetTemId() might not exist for buildables, they have their own seperate shit and it might be named differently
		if detpack:GetTeamId() ~= self.team then
			OutputEvent( self.team_name .. "_assaultramp", "Disable" )	
			OutputEvent( self.team_name .. "_assaultramp_trigger", "Disable" )		

		end
	end

	-- I think this is needed so grenades and other shit can blow up here. They won't fire the events, though.
	return EVENT_ALLOWED
end

red_assaultramp_trigger = base_ramp_trigger:new({ team = Team.kRed, team_name = "red" })
green_assaultramp_trigger = base_ramp_trigger:new({ team = Team.kGreen, team_name = "green" })
Basically what I'm doing with that, is BUILDING a wooden ramp with the button, which works great (pretty much ET buildable) and then allowing it to blow up with a detpack (also works fine). Problem is that I cant check team/class in the button lua, anyone can use it.


My current full LUA for Andever:

Code:
-- ff_andever.lua

-----------------------------------------------------------------------------
-- includes
-----------------------------------------------------------------------------

IncludeScript("base_ctf");
IncludeScript("base_location");
IncludeScript("base_respawnturret");

-----------------------------------------------------------------------------
-- global overrides
-----------------------------------------------------------------------------
POINTS_PER_CAPTURE = 10
FLAG_RETURN_TIME = 60

function startup()
	-- set up team limits on each team
	SetPlayerLimit(Team.kBlue, -1)
	SetPlayerLimit(Team.kRed, 0)
	SetPlayerLimit(Team.kYellow, -1)
	SetPlayerLimit(Team.kGreen, 0)

	-- CTF maps generally don't have civilians,
	-- so override in map LUA file if you want 'em
	local team = GetTeam(Team.kGreen)
	team:SetClassLimit(Player.kCivilian, -1)
	team:SetClassLimit( Player.kSpy, 0 )

	team = GetTeam(Team.kRed)
	team:SetClassLimit(Player.kCivilian, -1)
	team:SetClassLimit( Player.kSpy, 0 )	
	
end


function flaginfo( player_entity )
-- at the moment this is crappy workaround - simply displays the home icon
	local player = CastToPlayer( player_entity )

	-- copied from green_flag variables
	AddHudIcon( player, green_flag.hudstatusiconhome, ( green_flag.name.. "_h" ), green_flag.hudstatusiconx, green_flag.hudstatusicony, green_flag.hudstatusiconw, green_flag.hudstatusiconh, green_flag.hudstatusiconalign )
	AddHudIcon( player, red_flag.hudstatusiconhome, ( red_flag.name.. "_h" ), red_flag.hudstatusiconx, red_flag.hudstatusicony, red_flag.hudstatusiconw, red_flag.hudstatusiconh, red_flag.hudstatusiconalign )
	
	local flag = GetInfoScriptByName("green_flag")
	
	if flag:IsCarried() then
			AddHudIcon( player, green_flag.hudstatusiconcarried, ( green_flag.name.. "_h" ), green_flag.hudstatusiconx, green_flag.hudstatusicony, green_flag.hudstatusiconw, green_flag.hudstatusiconh, green_flag.hudstatusiconalign )
	elseif flag:IsDropped() then
			AddHudIcon( player, green_flag.hudstatusicondropped, ( green_flag.name.. "_h" ), green_flag.hudstatusiconx, green_flag.hudstatusicony, green_flag.hudstatusiconw, green_flag.hudstatusiconh, green_flag.hudstatusiconalign )
	end

	flag = GetInfoScriptByName("red_flag")
	
	if flag:IsCarried() then
			AddHudIcon( player, red_flag.hudstatusiconcarried, ( red_flag.name.. "_h" ), red_flag.hudstatusiconx, red_flag.hudstatusicony, red_flag.hudstatusiconw, red_flag.hudstatusiconh, red_flag.hudstatusiconalign )
	elseif flag:IsDropped() then
			AddHudIcon( player, red_flag.hudstatusicondropped, ( red_flag.name.. "_h" ), red_flag.hudstatusiconx, red_flag.hudstatusicony, red_flag.hudstatusiconw, red_flag.hudstatusiconh, red_flag.hudstatusiconalign )
	end
end


-----------------------------------------------------------------------------
-- Hurts
-----------------------------------------------------------------------------
hurt = trigger_ff_script:new({ team = Team.kUnassigned })
function hurt:allowed( allowed_entity )
	if IsPlayer( allowed_entity ) then
		local player = CastToPlayer( allowed_entity )
		if player:GetTeamId() == self.team then
			return EVENT_ALLOWED
		end
	end

	return EVENT_DISALLOWED
end

-- red lasers hurt green and vice-versa

green_laser_hurt_flag = hurt:new({ team = Team.kRed })
green_laser_hurt_button = hurt:new({ team = Team.kRed })

red_laser_hurt_flag = hurt:new({ team = Team.kGreen })
red_laser_hurt_button = hurt:new({ team = Team.kGreen })


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

base_grate_trigger = trigger_ff_script:new({ team = Team.kUnassigned, team_name = "neutral" })

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

		-- GetTemId() might not exist for buildables, they have their own seperate shit and it might be named differently
		if detpack:GetTeamId() ~= self.team then
			OutputEvent( self.team_name .. "_det_grate", "Kill" )
			
		end
	end

	-- I think this is needed so grenades and other shit can blow up here. They won't fire the events, though.
	return EVENT_ALLOWED
end

red_det_grate_trigger = base_grate_trigger:new({ team = Team.kRed, team_name = "red" })
green_det_grate_trigger = base_grate_trigger:new({ team = Team.kGreen, team_name = "green" })


-----------------------------------------------------------------------------
-- Locations
-----------------------------------------------------------------------------

location_greenbase = location_info:new({ text = "Inside Base", team = Team.kGreen })
location_greenwarehouse = location_info:new({ text = "Warehouse", team = Team.kGreen })
location_greenoutside = location_info:new({ text = "Outside Base", team = Team.kGreen })
location_greenflagbunker = location_info:new({ text = "Flag Bunker", team = Team.kGreen })
location_greensniper = location_info:new({ text = "Battlement", team = Team.kGreen })
location_greenbackway = location_info:new({ text = "Backway", team = Team.kGreen })
location_greenflag = location_info:new({ text = "Flag Room", team = Team.kGreen })

location_redbase = location_info:new({ text = "Inside Base", team = Team.kRed })
location_redwarehouse = location_info:new({ text = "Warehouse", team = Team.kRed })
location_redoutside = location_info:new({ text = "Outside Base", team = Team.kRed })
location_redflagbunker = location_info:new({ text = "Flag Bunker", team = Team.kRed })
location_redbattlement = location_info:new({ text = "Battlement", team = Team.kRed })
location_redbackway = location_info:new({ text = "Backway", team = Team.kRed })
location_redflagroom = location_info:new({ text = "Flag Room", team = Team.kRed })


-----------------------------------------------------------------------------
-- Spawns
-----------------------------------------------------------------------------

togglespawn = info_ff_teamspawn:new({ team = Team.kUnassigned, toggledoff = false })

function toggle_allowedmethod(self, player_entity)

	if (IsPlayer(player_entity) == false) then
		return false
	end

	local player = CastToPlayer( player_entity )
	local teamId = player:GetTeamId()
	
	return (teamId == self.team and self.toggledoff == false)
end

greenspawn_w = togglespawn:new({ team = Team.kGreen, validspawn = toggle_allowedmethod })
greenspawn_f = togglespawn:new({ team = Team.kGreen, validspawn = toggle_allowedmethod })

redspawn_w = togglespawn:new({ team = Team.kRed, validspawn = toggle_allowedmethod })
redspawn_f = togglespawn:new({ team = Team.kRed, validspawn = toggle_allowedmethod })


-----------------------------------------------------------------------------
-- Warehouse Levers
-----------------------------------------------------------------------------

func_rot_button = baseclass:new({})
function func_rot_button:allowed() return true end
function func_rot_button:onuse() end

function func_rot_button:allowed( touch_entity ) 
   if IsPlayer( touch_entity ) then 
             local player = CastToPlayer( touch_entity ) 
             return player:GetTeamId() == self.team 
   end 

        return EVENT_DISALLOWED 
end 


green_warehouse_lever_rot = func_rot_button:new({ team = Team.kRed })

function green_warehouse_lever_rot:OnIn( trigger_entity ) 

	greenspawn_w.toggledoff = true
	self.team = Team.kGreen

	local player = CastToPlayer( trigger_entity )
    player:AddFortPoints( 100, "Warehouse Spawn Disabled" )

end 

function green_warehouse_lever_rot:OnOut( trigger_entity ) 

	greenspawn_w.toggledoff = false
	self.team = Team.kRed
	
	local player = CastToPlayer( trigger_entity )
    player:AddFortPoints( 250, "Warehouse Spawn Enabled" )

end 



red_warehouse_lever_rot = func_rot_button:new({ team = Team.kGreen })

function red_warehouse_lever_rot:OnIn( trigger_entity ) 

	redspawn_w.toggledoff = true
	self.team = Team.kRed

	local player = CastToPlayer( trigger_entity )
    player:AddFortPoints( 100, "Warehouse Spawn Disabled" )
    
end 

function red_warehouse_lever_rot:OnOut( trigger_entity ) 

	redspawn_w.toggledoff = false
	self.team = Team.kGreen
	
	local player = CastToPlayer( trigger_entity )
    player:AddFortPoints( 250, "Warehouse Spawn Enabled" )

end


-----------------------------------------------------------------------------
-- Gas Chambers
-----------------------------------------------------------------------------

green_gasbutton = func_rot_button:new({ team = Team.kRed })

function green_gasbutton:allowed( touch_entity ) 
   if IsPlayer( touch_entity ) then 
             local player = CastToPlayer( touch_entity ) 
             return player:GetTeamId() == self.team 
   end 

        return EVENT_DISALLOWED 
end

function green_gasbutton:OnIn( trigger_entity )

	greenspawn_f.toggledoff = true 
	
	local player = CastToPlayer( trigger_entity )
    player:AddFortPoints( 150, "Gas Chamber Enabled" )

end 

function green_gasbutton:OnOut() 

	greenspawn_f.toggledoff = false

end 


red_gasbutton = func_rot_button:new({ team = Team.kGreen })

function red_gasbutton:allowed( touch_entity ) 
   if IsPlayer( touch_entity ) then 
             local player = CastToPlayer( touch_entity ) 
             return player:GetTeamId() == self.team 
   end 

        return EVENT_DISALLOWED 
end

function red_gasbutton:OnIn( trigger_entity ) 

	redspawn_f.toggledoff = true 
	
	local player = CastToPlayer( trigger_entity )
    player:AddFortPoints( 150, "Gas Chamber Enabled" )

end 

function red_gasbutton:OnOut() 

	redspawn_f.toggledoff = false 

end 



-----------------------------------------------------------------------------
-- Testing
-----------------------------------------------------------------------------

Last edited by Major Lee High; 10-29-2007 at 08:26 AM. Reason: update
Major Lee High is offline   Reply With Quote


 


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 02:38 PM.


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