Fortress Forever

Go Back   Fortress Forever > Editing > Mapping > Lua

Reply
 
Thread Tools Display Modes
Old 04-02-2015, 07:54 AM   #1
FDA_Approved
Beta Tester
 
FDA_Approved's Avatar
 
Join Date: Nov 2011
Gametype: Capture the Flag
Posts Rated Helpful 293 Times
Lua request.

If any of you lua wizards would be so kind, there's a map I've been wanting to make for a while, and I believe some lua functionality was recently added that will make it fully functional.

I would need:

On spawn, buff health to 125%.

On kill, refill clips and buff health to 125%

It's going to be a map with multiple arenas, so I would also need some sort of functionality so that when you die in a certain arena you respawn at one of the random spawn points in that specific arena.

Am dumb plz help.
__________________
Currently equipped: Rad Scarf of liberating happiness.
FDA_Approved is offline   Reply With Quote


Old 04-02-2015, 04:50 PM   #2
R00Kie
Kawaii! ルーキー
Lua Team
Wiki Team
Fortress Forever Staff
 
R00Kie's Avatar
 
Join Date: Jan 2008
Location: Nowhere, Kansas
Class/Position: Random
Gametype: CTF
Affiliations: BiG, Kawaii!, MustacheBrigade, GoodFellas
Posts Rated Helpful 82 Times
Just fyi, the health tics down like the Medic over heal. You can increase the value of 1.25 if you want to start with more health. As far as the spawn points go I'm going to need more information about your map. You Can send me a PM when you get close to finishing.

Code:
function player_spawn( player )
	local player = CastToPlayer ( player )
	local MaxHealth = (player:GetMaxHealth() * 1.25) - player:GetMaxHealth()
	
	player:AddHealth(MaxHealth, true)
end

function player_killed( player, damageinfo )
	-- suicides have no damageinfo
	if not damageinfo then return end
	
	local player = CastToPlayer( player )
	local attacker_entity = damageinfo:GetAttacker()
	local attacker = CastToPlayer(attacker_entity)

	if not attacker then return end
	
	if IsPlayer( attacker ) then
		if player:GetId() ~= attacker:GetId() then
			local MaxHealth = (attacker:GetMaxHealth() * 1.25) - attacker:GetMaxHealth()
			
			attacker:ReloadClips()
			attacker:AddHealth(100, false)
			attacker:AddHealth(MaxHealth, true)
		end
	elseif IsSentrygun(attacker) then
	elseif IsDetpack(attacker) then
	elseif IsDispenser(attacker) then
	else
		return
	end	
end
__________________
Released: [ Island ] [ Rookie ] [ Limbo ] [ Sonic ] [ Tomb ] [ Skydive2 ] [ Bunkerwars ]
Beta: [ Argon ] [ Reflection ] [ Urbantag ]
Lua: [ game_rules ]

Last edited by R00Kie; 04-02-2015 at 04:55 PM.
R00Kie is offline   Reply With Quote


1 members found this post helpful.
Old 04-02-2015, 09:02 PM   #3
FDA_Approved
Beta Tester
 
FDA_Approved's Avatar
 
Join Date: Nov 2011
Gametype: Capture the Flag
Posts Rated Helpful 293 Times
Thank you very much. Yeah the overheal decay is a desired effect. I'll send you a pm soon.
__________________
Currently equipped: Rad Scarf of liberating happiness.
FDA_Approved is offline   Reply With Quote


Old 04-04-2015, 08:31 PM   #4
R00Kie
Kawaii! ルーキー
Lua Team
Wiki Team
Fortress Forever Staff
 
R00Kie's Avatar
 
Join Date: Jan 2008
Location: Nowhere, Kansas
Class/Position: Random
Gametype: CTF
Affiliations: BiG, Kawaii!, MustacheBrigade, GoodFellas
Posts Rated Helpful 82 Times
FDA, Here's the second part to the lua for spawn point control you asked for.
The starting spawn point should be named spawn0. All the others in different arenas should be named spawn1, spawn2, ect. The players can switch between arenas with the '!arena [number]' chat command. For example !arena 3 will put them in arena 3 and continue to spawn them there until they change their arena. If you have more or less than 6 arenas then change the ARENA_NUM variable to how many you have. If you have any issues, send me a PM.
Code:
player_table = {}
ARENA_NUM = 6 -- Increase this number if you want more spawn points.

function player_connected( player )
	player_table[player:GetId()] = { arena = 0 }
end

base_spawn = info_ff_teamspawn:new({ arena_number = 0, validspawn = function(self,player)
	return player:GetTeamId() == Team.kRed or player:GetTeamId() == Team.kBlue and self.arena_number == player_table[player:GetId()].arena
end })

-- For setting a spawnpoint Use spawn1, spawn2, ect.
-- Use Spawn0 as the inital spawn point.
for i = 0, ARENA_NUM do
	_G["spawn"..i] = base_spawn:new({ arena_number = i })
end

function player_onchat( player, chatstring )
	local player = CastToPlayer( player )

	-- string.gsub call removes all control characters (newlines, return carriages, etc)
	-- string.sub call removes the playername: part of the string, leaving just the message
	local message = string.sub( string.gsub( chatstring, "%c", "" ), string.len(player:GetName())+3 )
	
	for i = 1, ARENA_NUM do
		if message == "!arena "..i then
			ChatToPlayer(player, "Sending you to Arena "..tostring(i))
			player_table[player:GetId()].arena = i
			ApplyToPlayer(player, { AT.kRespawnPlayers })
			return false
		end
	end
	return true
end
__________________
Released: [ Island ] [ Rookie ] [ Limbo ] [ Sonic ] [ Tomb ] [ Skydive2 ] [ Bunkerwars ]
Beta: [ Argon ] [ Reflection ] [ Urbantag ]
Lua: [ game_rules ]
R00Kie is offline   Reply With Quote


2 members found this post helpful.
Old 04-04-2015, 09:22 PM   #5
FDA_Approved
Beta Tester
 
FDA_Approved's Avatar
 
Join Date: Nov 2011
Gametype: Capture the Flag
Posts Rated Helpful 293 Times
You're the best, very much appreciated.
__________________
Currently equipped: Rad Scarf of liberating happiness.
FDA_Approved is offline   Reply With Quote


Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 11:35 AM.


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