Fortress Forever

Fortress Forever (https://forums.fortress-forever.com/index.php)
-   Lua (https://forums.fortress-forever.com/forumdisplay.php?f=44)
-   -   (Request) Lua request. (https://forums.fortress-forever.com/showthread.php?t=25060)

FDA_Approved 04-02-2015 07:54 AM

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.

R00Kie 04-02-2015 04:50 PM

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


FDA_Approved 04-02-2015 09:02 PM

Thank you very much. Yeah the overheal decay is a desired effect. I'll send you a pm soon.

R00Kie 04-04-2015 08:31 PM

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


FDA_Approved 04-04-2015 09:22 PM

You're the best, very much appreciated.


All times are GMT. The time now is 08:20 PM.

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