Fortress Forever

Go Back   Fortress Forever > Editing > Mapping > Lua

Reply
 
Thread Tools Display Modes
Old 12-04-2008, 02:33 AM   #1
Bridget
Banned
 
Bridget's Avatar
 
Join Date: Sep 2008
Class/Position: Soldier
Gametype: AVD
Affiliations: TALOS
Posts Rated Helpful 5 Times
Headshot reward lua?

Can someone conjure some lua code for me that awards a player's team 10 points if he or she makes a successful (resulting in death) headshot on an enemy?

EDIT: Preferably 10 points for a regular kill and 20 for a headshot?

Last edited by Bridget; 12-04-2008 at 02:41 AM.
Bridget is offline   Reply With Quote


Old 12-04-2008, 04:37 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.
This code is untested. It should give 20 team points per headshot (10 for regular kill, 10 bonus for headshots).

Code:
TEAM_POINTS_PER_KILL = 10
BONUS_TEAM_POINTS_PER_HEADSHOT = 10

player_onheadshot( shot_entity, shooter_entity )
	if IsPlayer(shooter_entity) then
		local player = CastToPlayer(shooter_entity)
		local team = player:GetTeam()
		team:AddScore(BONUS_TEAM_POINTS_PER_HEADSHOT)
	end
end

player_killed( player, damageinfo )
	-- Entity that is attacking
	local attacker = damageinfo:GetAttacker()

	-- If no attacker do nothing
	if not attacker then
		return
	end

	-- If attacker not a player do nothing
	if not IsPlayer(attacker) then 
		return
	end

	local playerAttacker = CastToPlayer(attacker)
	local weapon = damageinfo:GetInflictor():GetClassName()

	-- If attacked by sniper rifle, add points
	if weapon == "ff_weapon_sniperrifle" then
		local team = playerAttacker:GetTeam()
		-- Add score to team
		team:AddScore(TEAM_POINTS_PER_KILL)
	end
end
__________________
#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
squeek. 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:23 AM.


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