Fortress Forever

Fortress Forever (https://forums.fortress-forever.com/index.php)
-   Lua (https://forums.fortress-forever.com/forumdisplay.php?f=44)
-   -   Lua Requests (Lua Assistance Division) (https://forums.fortress-forever.com/showthread.php?t=14729)

TheWetMule 02-25-2008 11:56 PM

How 'bout TEAM specific teleports? I'd like to have Forward and Reverse teams on my concmap and I canney understand how to do it in FF.

No specifics, generic terms can be used for tele destinations and such, I'd love a basic outline though ;)

EDIT: Said class specific lewlz ;x

GambiT 02-26-2008 12:00 AM

use a "trigger_teleport"

TheWetMule 02-26-2008 12:10 AM

Team/class specific, I need, not just one teleport for everybody :)

squeek. 02-26-2008 12:21 AM

Re: TheWetMule
Code:

specific_tele = info_ff_script:new({ class = Player.kCivilian, team = Team.kUnassigned })

function specific_tele:allowed( touch_entity )
  if IsPlayer( touch_entity ) then
            local player = CastToPlayer( touch_entity )
            return player:GetTeamId() == self.team and player:GetClass() == self.class
  end
  return EVENT_DISALLOWED
end

blue_scout_tele = specific_tele:new({ class = Player.kScout, team = Team.kBlue })
red_demo_tele = specific_tele:new({ class= Player.kDemoman, team = Team.kRed })

Make the trigger_teleport's names match the bottom-most names (blue_scout_tele, red_demo_tele, etc).

GambiT 02-26-2008 12:22 AM

your the man squeek, you will be the first one i let play rock2!

squeek. 02-26-2008 12:24 AM

Quote:

Originally Posted by GambiT
your the man squeek, you will be the first one i let play rock2!

What's a #2 rock?

GambiT 02-26-2008 12:25 AM

8-ball what?

TheWetMule 02-26-2008 10:27 PM

Me luv you long tiem squeek

GambiT 02-27-2008 12:29 AM

2 dolla!

TheWetMule 03-01-2008 10:04 PM

Right, decided to put that nifty piece of code to the test, just want to clear up that I'm doing everything right.
  1. I make a trigger_teleport named blue_scout_tele
  2. I give it the destination I want it to teleport too

After I've done that, it should ONLY teleport blue scouts, not blue demomen or something? If so, it doesn't appear to be working! It teleports me regardless of class/team

DD` 03-01-2008 10:58 PM

Code:

specific_tele = info_ff_script:new({})

function specific_tele:allowed( touch_entity )
  if IsPlayer( touch_entity ) then
            local player = CastToPlayer( touch_entity )
            return player:GetTeamId() == self.team
  end
  return EVENT_DISALLOWED
end

blue_tele = specific_tele:new({ team = Team.kBlue })
red_tele = specific_tele:new({ team = Team.kRed })

tiny edit of squeeks code and I got it working for him the way he wanted it (team specific).

squeek. 03-01-2008 11:45 PM

Quote:

Originally Posted by DD`
tiny edit of squeeks code and I got it working for him the way he wanted it (team specific).

He wants team and class specific. My code was untested, I might have gotten something wrong. I'll test it and see what's wrong.

TheWetMule 03-02-2008 12:10 AM

No no, they worked seperately, just not together :P Don't worry, you did a grand job squeek.

EDIT: As in, scout teles only or team teles only, just not together.

TheWetMule 03-02-2008 05:10 PM

LOLDROUBLEPROAST

Anyway, got another one for you, is there a way to restock people ,constantly, no matter where they are without the use of mass trigger_ff_scripts :X?

squeek. 03-02-2008 08:41 PM

Quote:

Originally Posted by TheWetMule
LOLDROUBLEPROAST

Anyway, got another one for you, is there a way to restock people ,constantly, no matter where they are without the use of mass trigger_ff_scripts :X?

Yeah, give me a bit. Not totally sure if the tick() function is working or not.

TheWetMule 03-02-2008 09:05 PM

Not to seem like I'm forcing you into slave labour, but is there a way to make rockets/pipes/grenades/concs effect only the person that dropped them/used them?

squeek. 03-02-2008 09:16 PM

Quote:

Originally Posted by TheWetMule
Not to seem like I'm forcing you into slave labour, but is there a way to make rockets/pipes/grenades/concs effect only the person that dropped them/used them?

Rockets/Pipes would be rather easy... grenades as well (I think). Concs I'm not totally sure about.

squeek. 03-02-2008 10:10 PM

Quote:

Originally Posted by TheWetMule
Not to seem like I'm forcing you into slave labour, but is there a way to make rockets/pipes/grenades/concs effect only the person that dropped them/used them?

Code:

function player_onconc(player_entity, effector_entity)

        if IsPlayer( player_entity ) and IsPlayer( effector_entity ) then
                local player = CastToPlayer( player_entity )
                local playerEffector = CastToPlayer( effector_entity )
                if player:GetId() == playerEffector:GetId() then
                        return true
                end
        end
       
        return false
       
end

function player_ondamage( 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)

  -- If player is damaging self do nothing; else no damage/no push
  if player:GetId() == playerAttacker:GetId() then
        return
  else
        damageinfo:SetDamage(0)
        damageinfo:SetDamageForce(Vector( 0, 0, 0 ))
  end
 
end

The concs still push everyone around... but the effect is only added to the conc's owner; not sure if it's possible to stop the push. Rockets/pipes/nades (anything that does damage) works as intended, though.

squeek. 03-02-2008 10:32 PM

Quote:

Originally Posted by TheWetMule
Anyway, got another one for you, is there a way to restock people ,constantly, no matter where they are without the use of mass trigger_ff_scripts :X?

Add this to startup():
Code:

AddScheduleRepeating( "Restock", RESTOCK_ITERATION_TIME, restock )
And then here's the bulk of the code:
Code:

playerStateTable = {}
RESTOCK_ITERATION_TIME = 1

function player_spawn( player_id )

        local player = GetPlayer(player_id)
       
        -- Remove any players not on a team from table
        for playerx, recordx in pairs(playerStateTable) do
                ConsoleToAll("RECORD: "..playerStateTable[playerx].restock)
                local playert = GetPlayerByID( playerx )
                if (playert:GetTeamId() ~= Team.kRed) and (playert:GetTeamId() ~= Team.kBlue) and (playert:GetTeamId() ~= Team.kGreen) and (playert:GetTeamId() ~= Team.kYellow) then
                        playerStateTable[playerx] = nil
                end
        end
       
        -- add to table and set restock to 1
        playerStateTable[player:GetId()] = {restock = 1}
       
end


function restock()
        for playerx, recordx in pairs(playerStateTable) do
                if playerStateTable[playerx].restock == 1 then
                        local player = GetPlayerByID( playerx )
                        player:AddHealth( 400 )
                        player:AddArmor( 400 )
                        player:AddAmmo(Ammo.kCells, 400)
                        player:AddAmmo(Ammo.kShells, 400)
                        player:AddAmmo(Ammo.kNails, 400)
                        player:AddAmmo(Ammo.kRockets, 400)
                        player:AddAmmo(Ammo.kGren1, 400)
                        player:AddAmmo(Ammo.kGren2, 400)
                end
        end
end

This will restock every 1 second. Change RESTOCK_ITERATION_TIME if it's too long/too short.

TheWetMule 03-02-2008 10:59 PM

Wonderful, you're a genius Squeek, one little problem with the reload code though, I get the error

[SCRIPT] Error calling player_spawn ([string "maps\ddbbdd.lua"]:84: bad argument #1 to 'pairs' (table expected, got nil)) ent: NULL


All times are GMT. The time now is 05:03 AM.

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