Thread: (Request) Speed boost lua
View Single Post
Old 12-17-2014, 12:43 AM   #2
squeek.
Stuff Do-er
Lua Team
Wiki Team
Fortress Forever Staff
 
squeek.'s Avatar
 
Join Date: Mar 2007
Location: Northern California
Class/Position: Rallygun Shooter
Gametype: Conc tag (you just wait)
Affiliations: Mustache Brigade
Posts Rated Helpful 352 Times
Send a message via AIM to squeek.
There are many ways to approach this. Here are two:

1) Give each trigger a different name. This is what I do in my ricochet map:
Code:
base_jump = trigger_ff_script:new({ pushx = 0, pushy = 0, pushz = 0 })

function base_jump:ontouch( trigger_entity )
	if IsPlayer( trigger_entity ) then
		local player = CastToPlayer( trigger_entity )
		
		player:SetVelocity( Vector( self.pushx, self.pushy, self.pushz ) )
		entity:EmitSound("ricochet.triggerjump")
	end
end

-- standard
jump_standard_north = base_jump:new({ pushx = 0, pushy = 700, pushz = 400 })
jump_standard_east = base_jump:new({ pushx = 700, pushy = 0, pushz = 400 })
jump_standard_south = base_jump:new({ pushx = 0, pushy = -700, pushz = 400 })
jump_standard_west = base_jump:new({ pushx = -700, pushy = 0, pushz = 400 })

-- etc...
2) Add a named info_target (or any point entity) and use that to get the direction of the velocity. Untested code to give you a general idea:
Code:
local base_launch_towards_target = trigger_ff_script:new({ horiz_push = 0, vert_push = 0, target = "" })

function base_launch_towards_target:ontouch( trigger_entity )
	if IsPlayer( trigger_entity ) then
		local player = CastToPlayer( trigger_entity )
		local target = GetEntityByName( self.target )

		if not target then return end

		local dir = target:GetOrigin() - player:GetOrigin()
		-- zero out the z value so that only horizontal direction matters
		dir.z = 0
		dir:Normalize()
		
		player:SetVelocity( Vector(dir.x * self.horiz_push, dir.y * self.horiz_push, self.vert_push) )
	end
end

player_launch = base_launch_towards_target:new({ horiz_push = 1000, vert_push = 500, target="target_name" })
in this example, you'd name the info_target entity "target_name"

EDIT: Didn't think the target code through; made some minor adjustments so that the vertical push is constant rather than influenced by the difference in height between the player and the target
__________________
#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.; 12-17-2014 at 05:00 AM.
squeek. is offline   Reply With Quote


2 members found this post helpful.