04-27-2010, 02:08 AM | #1 |
Stuff Do-er
Lua Team
Wiki Team Fortress Forever Staff |
Jump Pad Triggers
Requested by zE. This code allows a trigger to act like a jump pad.
Names for the trigger can be: jumppad (Jump to activate, anyone can use) jumppad_nojump (Touch to activate, anyone can use) jumppad_blue (Jump to activate, blue team only) jumppad_red (Jump to activate, red team only) jumppad_yellow (Jump to activate, yellow team only) jumppad_green (Jump to activate, green team only) jumppad_nojump_blue (Touch to activate, blue team only) jumppad_nojump_red (Touch to activate, red team only) jumppad_nojump_yellow (Touch to activate, yellow team only) jumppad_nojump_green (Touch to activate, green team only) Code:
------------------------------------------ -- base_trigger_jumppad -- A trigger that emulates a jump pad ------------------------------------------ base_trigger_jumppad = trigger_ff_script:new({ teamonly = false, team = Team.kUnassigned, needtojump = true, push_horizontal = 1024, push_vertical = 512, notouchtime = 1, notouch = {} }) function base_trigger_jumppad:allowed( trigger_entity ) if IsPlayer( trigger_entity ) then local player = CastToPlayer( trigger_entity ) -- if jump needs to be pressed and it isn't, disallow if self.needtojump and not player:IsInJump() then return false; end -- if not able to touch, disallow if self.notouch[player:GetId()] then return false; end -- if team only and on the wrong team, disallow if self.teamonly and player:GetTeamId() ~= self.team then return false; end -- if haven't returned yet, allow return true; end return false; end function base_trigger_jumppad:ontrigger( trigger_entity ) if IsPlayer( trigger_entity ) then local player = CastToPlayer( trigger_entity ) -- get the direction the player is facing local facingdirection = player:GetAbsFacing() -- normalize just in case facingdirection:Normalize() -- calculate new velocity vector using the facing direction local newvelocity = Vector( facingdirection.x * self.push_horizontal, facingdirection.y * self.push_horizontal, self.push_vertical ) -- really hacky way to do this, but make sure the length of the horiz of the new velocity is correct -- the proper way to do it is to use the player's eyeangles right vector x Vector(0,0,1) local newvelocityhoriz = Vector( newvelocity.x, newvelocity.y, 0 ) while newvelocityhoriz:Length() < self.push_horizontal do newvelocityhoriz.x = newvelocityhoriz.x * 1.1 newvelocityhoriz.y = newvelocityhoriz.y * 1.1 end newvelocity.x = newvelocityhoriz.x newvelocity.y = newvelocityhoriz.y -- set player's velocity player:SetVelocity( newvelocity ) self:addnotouch(player:GetId(), self.notouchtime) end end function base_trigger_jumppad:addnotouch(player_id, duration) self.notouch[player_id] = duration AddSchedule("jumppad"..entity:GetId().."notouch-" .. player_id, duration, self.removenotouch, self, player_id) end function base_trigger_jumppad.removenotouch(self, player_id) self.notouch[player_id] = nil end -- standard definitions jumppad = base_trigger_jumppad:new({}) jumppad_nojump = base_trigger_jumppad:new({ needtojump = false }) -- teamonly definitions jumppad_blue = base_trigger_jumppad:new({ teamonly = true, team = Team.kBlue }) jumppad_red = base_trigger_jumppad:new({ teamonly = true, team = Team.kRed }) jumppad_green = base_trigger_jumppad:new({ teamonly = true, team = Team.kGreen }) jumppad_yellow = base_trigger_jumppad:new({ teamonly = true, team = Team.kYellow }) jumppad_nojump_blue = base_trigger_jumppad:new({ needtojump = false, teamonly = true, team = Team.kBlue }) jumppad_nojump_red = base_trigger_jumppad:new({ needtojump = false, teamonly = true, team = Team.kRed }) jumppad_nojump_green = base_trigger_jumppad:new({ needtojump = false, teamonly = true, team = Team.kGreen }) jumppad_nojump_yellow = base_trigger_jumppad:new({ needtojump = false, teamonly = true, team = Team.kYellow })
__________________
#FF.Pickup ยค Fortress-Forever pickups My Non-official Maps Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic Beta FF_Myth - FF_Redlight_Greenlight Sick of the people on the internet, always moanin'. They just moan. - Karl Pilkington Last edited by squeek.; 04-27-2010 at 02:11 AM. |
|
04-27-2010, 02:13 AM | #2 |
Pew pew ze beams
Join Date: Jan 2008
Gametype: Gathers Affiliations: pew pew Posts Rated Helpful 11 Times
|
Thks very much : ), the issue with regular push triggers is that they launch you only in one pre defined direction, while jumpads you can move in any direction, so ye this will help a lot in maping skill maps with push trigers.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|