Fortress Forever

Go Back   Fortress Forever > Editing > Mapping > Lua

Reply
 
Thread Tools Display Modes
Old 12-17-2014, 12:33 AM   #1
KubeDawg
Nade Whore
Server Owner
Beta Tester
 
KubeDawg's Avatar
 
Join Date: Sep 2007
Location: Oklahoma
Class/Position: Scout/Soldier
Gametype: CTF/TDM
Affiliations: blunt. Moto
Posts Rated Helpful 128 Times
Speed boost lua

For the purposes of my new map, I want to create a boost/lift that shoots people from the corners of my map upwards and towards the center. So a 45 degree angle horizontally and depending on what works best, somewhere between 45-75 degrees vertically.

I've been using this code until now:
Code:
base_jump = trigger_ff_script:new({ pushz = 0, pushx = 0 })

function base_jump:ontouch( trigger_entity )
	if IsPlayer( trigger_entity ) then
		local player = CastToPlayer( trigger_entity )
		local playerVel = player:GetVelocity()
		playerVel.z = self.pushz
		playerVel.x = self.pushx
		player:SetVelocity( playerVel )
	end
end
player_launch = base_jump:new({ pushz = 0, pushx = 1000 })
But it appears I cannot control the direction it pushes the player in. If I set pushz to 1000 and pushx to 0, it flings me straight up in the air. If I do the opposite with pushx 1000 and pushz 0, it flings me in one single direction. So if I have it in each corner of my map, one will push me to the right, another straight forward, another backwards and one to the left. Is there a way to control the direction of the horizontal and vertical direction with lua?
__________________
Moto's Funhouse | Dallas, TX - 74.91.114.247:27015

ff_plunder - Complete
KubeDawg is offline   Reply With Quote


Old 12-17-2014, 01: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 06:00 AM.
squeek. is offline   Reply With Quote


2 members found this post helpful.
Old 12-17-2014, 05:54 AM   #3
KubeDawg
Nade Whore
Server Owner
Beta Tester
 
KubeDawg's Avatar
 
Join Date: Sep 2007
Location: Oklahoma
Class/Position: Scout/Soldier
Gametype: CTF/TDM
Affiliations: blunt. Moto
Posts Rated Helpful 128 Times
awesome! thanks
__________________
Moto's Funhouse | Dallas, TX - 74.91.114.247:27015

ff_plunder - Complete
KubeDawg is offline   Reply With Quote


Old 12-21-2014, 12:22 PM   #4
Headz
 
Headz's Avatar
 
Join Date: Mar 2013
Location: England
Posts Rated Helpful 81 Times
mmm or use a trigger_push brush and set angles/speed ?
new map moto ?
__________________
Compile error:
Leaf portal saw into Cluster Phuck
Headz is offline   Reply With Quote


Old 12-21-2014, 02:06 PM   #5
KubeDawg
Nade Whore
Server Owner
Beta Tester
 
KubeDawg's Avatar
 
Join Date: Sep 2007
Location: Oklahoma
Class/Position: Scout/Soldier
Gametype: CTF/TDM
Affiliations: blunt. Moto
Posts Rated Helpful 128 Times
That doesn't seem to work Headz. Plus, then I have to deal with the speed clamping errors (which can be removed via a plugin, but still)
__________________
Moto's Funhouse | Dallas, TX - 74.91.114.247:27015

ff_plunder - Complete
KubeDawg 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 10:46 AM.


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