Fortress Forever

Go Back   Fortress Forever > Editing > Mapping > Lua

Reply
 
Thread Tools Display Modes
Old 09-20-2010, 09:28 AM   #1
zE
Pew pew ze beams
 
zE's Avatar
 
Join Date: Jan 2008
Gametype: Gathers
Affiliations: pew pew
Posts Rated Helpful 11 Times
Quad Lua

Hi so im using base_quad lua but i need something diferent something like:

Blue team -> (Normal no quad) classes - Medic and Scout
Red team -> (Quad on) classes - Scout, Medic, soldier, Demo, Pyro, Engeneer
Green team -> Same as red
Yellow team -> (Normal no quad) classes - civilian only.

If anyone can help i apreciate D:

Last edited by zE; 09-20-2010 at 09:28 AM.
zE is offline   Reply With Quote


Old 09-20-2010, 08:38 PM   #2
Dexter
internet user
Fortress Forever Staff
 
Dexter's Avatar
 
Join Date: Jun 2007
Posts Rated Helpful 42 Times
Have you tried it yet and are having issues?
Or you want someone to do the team & class layout for you
Dexter is offline   Reply With Quote


Old 09-20-2010, 08:48 PM   #3
Dexter
internet user
Fortress Forever Staff
 
Dexter's Avatar
 
Join Date: Jun 2007
Posts Rated Helpful 42 Times
This will do the team stuff for u
Code:
IncludeScript("base_quad");
function startup()
	SetTeamName( Team.kBlue, "Normal no quad" )
	SetTeamName( Team.kRed, "Quad on" )
	SetTeamName( Team.kGreen, "Quad on 2" )
	SetTeamName( Team.kYellow, "Civilian only" )
	
	SetPlayerLimit(Team.kBlue, 0)
	SetPlayerLimit(Team.kRed, 0)
	SetPlayerLimit(Team.kYellow, 0)
	SetPlayerLimit(Team.kGreen, 0)
	
	local team = GetTeam( Team.kBlue )
	team:SetClassLimit( Player.kScout, 0 )
	team:SetClassLimit( Player.kMedic, 0 )
	
	team:SetClassLimit( Player.kHwguy, -1 )
	team:SetClassLimit( Player.kSpy, -1 )
	team:SetClassLimit( Player.kCivilian, -1 )
	team:SetClassLimit( Player.kSniper, -1 )	
	team:SetClassLimit( Player.kSoldier, -1 )
	team:SetClassLimit( Player.kDemoman, -1 )
	team:SetClassLimit( Player.kPyro, -1 )
	team:SetClassLimit( Player.kEngineer, -1 )
	
	local team = GetTeam( Team.kRed )
	team:SetClassLimit( Player.kScout, 0 )
	team:SetClassLimit( Player.kMedic, 0 )
	team:SetClassLimit( Player.kSoldier, 0 )
	team:SetClassLimit( Player.kDemoman, 0 )
	team:SetClassLimit( Player.kPyro, 0 )
	team:SetClassLimit( Player.kEngineer, 0 )
	
	team:SetClassLimit( Player.kHwguy, -1 )
	team:SetClassLimit( Player.kSpy, -1 )
	team:SetClassLimit( Player.kCivilian, -1 )
	team:SetClassLimit( Player.kSniper, -1 )	

	local team = GetTeam( Team.kGreen )
	team:SetClassLimit( Player.kScout, 0 )
	team:SetClassLimit( Player.kMedic, 0 )
	team:SetClassLimit( Player.kSoldier, 0 )
	team:SetClassLimit( Player.kDemoman, 0 )
	team:SetClassLimit( Player.kPyro, 0 )
	team:SetClassLimit( Player.kEngineer, 0 )
	
	team:SetClassLimit( Player.kHwguy, -1 )
	team:SetClassLimit( Player.kSpy, -1 )
	team:SetClassLimit( Player.kCivilian, -1 )
	team:SetClassLimit( Player.kSniper, -1 )	
	
	local team = GetTeam( Team.kYellow )
	team:SetClassLimit( Player.kCivilian, 0 )
	
	team:SetClassLimit( Player.kScout, -1 )
	team:SetClassLimit( Player.kMedic, -1)
	team:SetClassLimit( Player.kSoldier, -1 )
	team:SetClassLimit( Player.kDemoman, -1 )
	team:SetClassLimit( Player.kPyro, -1 )
	team:SetClassLimit( Player.kEngineer, -1 )
	team:SetClassLimit( Player.kHwguy, -1 )
	team:SetClassLimit( Player.kSpy, -1 )	
	team:SetClassLimit( Player.kSniper, -1 )
end
Dexter is offline   Reply With Quote


Old 09-20-2010, 10:45 PM   #4
zE
Pew pew ze beams
 
zE's Avatar
 
Join Date: Jan 2008
Gametype: Gathers
Affiliations: pew pew
Posts Rated Helpful 11 Times
Thks Dexter , but what i needed was something diferent, the default quad_lua allows only quad on red team and only soldier demoman and pyro classes, and i needed to add a green team to quad and also include engeneer as quad. But thks anyway.

Bri helped me with it and it goes like this:

-- base_quad.lua

----------------------------------------------------------------------
-- Quad icon
----------------------------------------------------------------------

hudicon = "hud_quad"
hudx = 5
hudy = 110
hudw = 48
hudh = 48
huda = 1
hudstatusicon = "hud_quad.vtf"

----------------------------------------------------------------------
-- Set hud icon at spawn
----------------------------------------------------------------------

function player_spawn( player_entity )
local player = CastToPlayer( player_entity )
local class = player:GetClass()
if class == Player.kSoldier or class == Player.kDemoman or class == Player.kMedic or class == Player.kEngineer or class == Player.kPyro then
if player:GetTeamId() ~= Team.kRed then
RemoveHudItem( player, hudstatusicon )
else
AddHudIcon(player, hudicon, hudstatusicon, hudx, hudy, hudw, hudh, huda)
end
else
RemoveHudItem( player, hudstatusicon )
end
end


----------------------------------------------------------------------
-- Remove hud icon if player changes to spectator
----------------------------------------------------------------------

function player_switchteam( player, currentteam, desiredteam )
if desiredteam == Team.kSpectator then
RemoveHudItem( player, hudstatusicon )
end
return true
end

----------------------------------------------------------------------
-- Set quad and invul when damage is taken by soldier and demoman and pyro
----------------------------------------------------------------------

function player_ondamage(player, damageinfo)
if player:GetTeamId() == Team.kRed or player:GetTeamId() == Team.kGreen then
local damage_force = damageinfo:GetDamageForce()
damageinfo:SetDamageForce(Vector(damage_force.x*4, damage_force.y*4, damage_force.z*4))
damageinfo:SetDamage(0)
end
end

Last edited by zE; 09-20-2010 at 10:47 PM.
zE is offline   Reply With Quote


Old 09-20-2010, 11:39 PM   #5
Dexter
internet user
Fortress Forever Staff
 
Dexter's Avatar
 
Join Date: Jun 2007
Posts Rated Helpful 42 Times
Oh ok oops!
Dexter is offline   Reply With Quote


Old 09-29-2010, 06:33 AM   #6
zE
Pew pew ze beams
 
zE's Avatar
 
Join Date: Jan 2008
Gametype: Gathers
Affiliations: pew pew
Posts Rated Helpful 11 Times
So basicly im still working on this lua, that bridget and squeek basicly did all , but im kinda bored of boring always the same dudes to help me with this, so if anyone knows plz help : D

The last lua crashed the server, so I had with help redo the last part.

PHP Code:
-----------------------------------------------------------------------
----------
Lua by Bridget and Squeek
-----------------------------------------------------------------------

---
HUD icons and Quad Power

settings 
= {
    
red_vtf        "quad.vtf",
    
red_quad    4,
    
blue_vtf    "blue.vtf",
    
blue_quad    1,
    
green_vtf    "easy.vtf",
    
green_quad    4,
    
yellow_vtf    "double.vtf",
    
yellow_quad    2
}

function 
returnInformation(team)
    
= {vtf="",quad=0}
    if 
team == Team.kRed     then    i["vtf"]=settings["red_vtf"];        i["quad"]=settings["red_quad"]             end
    
if team == Team.kBlue     then    i["vtf"]=settings["blue_vtf"];        i["quad"]=settings["blue_quad"]             end
    
if team == Team.kGreen     then     i["vtf"]=settings["green_vtf"];        i["quad"]=settings["green_quad"]         end
    
if team == Team.kYellow then     i["vtf"]=settings["yellow_vtf"];    i["quad"]=settings["yellow_quad"]        end
    
return i
end

---Remove Grenades and stuff at spawn

function player_spawn(player_entity)
    
local player CastToPlayer(player_entity)
    
    -- 
Ammo removal
    
if player:GetClass() == Player.kDemoman then
        player
:RemoveWeapon("ff_weapon_detpack")
        
player:RemoveAmmo(Ammo.kGren24)
    elseif 
player:GetClass() == Player.kPyro then
            player
:RemoveAmmo(Ammo.kGren24)
    elseif 
player:GetClass() == Player.kEngineer then
        player
:RemoveAmmo(Ammo.kGren24)
    elseif 
player:GetClass() == Player.kMedic then
        player
:RemoveAmmo(Ammo.kGren14)
    elseif 
player:GetClass() == Player.kScout then
        player
:RemoveAmmo(Ammo.kManCannon1)
    
end

---Remove HUD icon     

    i 
returnInformation(player:GetTeamId())
    
RemoveHudItem(player"quad_icon");
    if 
i["quad"] > 1 then
        AddHudIcon
(playeri["vtf"], "quad_icon"511948480)
    
end
    
return true
end

function player_switchteam(playerold, new)
    
RemoveHudItem(player"quad_icon"); return true
end

---Quad and no damage except for trigger_hurt

function player_ondamageplayerdamageinfo )

    -- if 
no damageinfo do nothing
    
if not damageinfo then return end

    
-- remove all fall damage
    
if damageinfo:GetDamageType() == Damage.kFall then
        damageinfo
:SetDamage(0)
        return
    
end

    
-- Entity that is attacking
    local attacker 
damageinfo:GetAttacker()

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

    local player_attacker 
nil

    
-- get the attacking player
    
if IsPlayer(attackerthen
        attacker 
CastToPlayer(attacker)
        
player_attacker attacker
    
elseif IsSentrygun(attackerthen
        attacker 
CastToSentrygun(attacker)
        
player_attacker attacker:GetOwner()
    elseif 
IsDetpack(attackerthen
        attacker 
CastToDetpack(attacker)
        
player_attacker attacker:GetOwner()
    elseif 
IsDispenser(attackerthen
        attacker 
CastToDispenser(attacker)
        
player_attacker attacker:GetOwner()
    else
        return
    
end

    
-- if still no attacking player after all thatforget about it
    
if not player_attacker then return end

    
-- If attacker is also the victim (self damage)
    if 
player:GetId() == player_attacker:GetId() then
        
-- change push force
        local damage_force 
damageinfo:GetDamageForce()
        
returnInformation(player:GetTeamId())
        
damageinfo:SetDamageForce(Vector(damage_force.x*i["quad"], damage_force.y*i["quad"], damage_force.z*i["quad"]))
        -- 
set damage to zero
        damageinfo
:SetDamage(0)
        return
    
end

    
-- for everyone else, use attacker's quad force
    -- change push force
    local damage_force = damageinfo:GetDamageForce()
    i = returnInformation(player_attacker:GetTeamId())
    damageinfo:SetDamageForce(Vector(damage_force.x*i["quad"], damage_force.y*i["quad"], damage_force.z*i["quad"]))
    -- set damage to zero
    damageinfo:SetDamage(0)
    
    if player:GetTeamId() == Team.kGreen then Resupply(player) end
 
end

--- Auto reload Green Team on damage

function player_ondamage( player_entity, damageinfo )
    if IsPlayer(player_entity) then
        local player = CastToPlayer(player_entity)
        if player:GetTeamId() == Team.kGreen then ApplyToPlayer(player, { AT.kReloadClips }) end
    end
end 
But im having an issue with the last part -- Auto reload for Green Team on damage
That code like that makes the quad do damage, and I dont want damage : <, im sure its that part of code of it that does it because I tested it with it and wihout it : D

Last edited by zE; 09-29-2010 at 06:45 AM.
zE is offline   Reply With Quote


Old 09-29-2010, 10:20 AM   #7
Bridget
Banned
 
Bridget's Avatar
 
Join Date: Sep 2008
Class/Position: Soldier
Gametype: AVD
Affiliations: TALOS
Posts Rated Helpful 5 Times
Code:
-----------------------------------------------------------------------
----------Lua by Bridget and Squeek
-----------------------------------------------------------------------

---HUD icons and Quad Power

settings = {
    red_vtf        = "quad.vtf",
    red_quad    = 4,
    blue_vtf    = "blue.vtf",
    blue_quad    = 1,
    green_vtf    = "easy.vtf",
    green_quad    = 4,
    yellow_vtf    = "double.vtf",
    yellow_quad    = 2
}

function returnInformation(team)
    i = {vtf="",quad=0}
    if team == Team.kRed     then    i["vtf"]=settings["red_vtf"];        i["quad"]=settings["red_quad"]             end
    if team == Team.kBlue     then    i["vtf"]=settings["blue_vtf"];        i["quad"]=settings["blue_quad"]             end
    if team == Team.kGreen     then     i["vtf"]=settings["green_vtf"];        i["quad"]=settings["green_quad"]         end
    if team == Team.kYellow then     i["vtf"]=settings["yellow_vtf"];    i["quad"]=settings["yellow_quad"]        end
    return i
end

---Remove Grenades and stuff at spawn

function player_spawn(player_entity)
    local player = CastToPlayer(player_entity)
    
    -- Ammo removal
    if player:GetClass() == Player.kDemoman then
        player:RemoveWeapon("ff_weapon_detpack")
        player:RemoveAmmo(Ammo.kGren2, 4)
    elseif player:GetClass() == Player.kPyro then
            player:RemoveAmmo(Ammo.kGren2, 4)
    elseif player:GetClass() == Player.kEngineer then
        player:RemoveAmmo(Ammo.kGren2, 4)
    elseif player:GetClass() == Player.kMedic then
        player:RemoveAmmo(Ammo.kGren1, 4)
    elseif player:GetClass() == Player.kScout then
        player:RemoveAmmo(Ammo.kManCannon, 1)
    end

---Remove HUD icon     

    i = returnInformation(player:GetTeamId())
    RemoveHudItem(player, "quad_icon");
    if i["quad"] > 1 then
        AddHudIcon(player, i["vtf"], "quad_icon", 5, 119, 48, 48, 0)
    end
    return true
end

function player_switchteam(player, old, new)
    RemoveHudItem(player, "quad_icon"); return true
end

---Quad and no damage except for trigger_hurt

function player_ondamage( player, damageinfo )

    -- if no damageinfo do nothing
    if not damageinfo then return end

    -- remove all fall damage
    if damageinfo:GetDamageType() == Damage.kFall then
        damageinfo:SetDamage(0)
        return
    end

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

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

    local player_attacker = nil

    -- get the attacking player
    if IsPlayer(attacker) then
        attacker = CastToPlayer(attacker)
        player_attacker = attacker
    elseif IsSentrygun(attacker) then
        attacker = CastToSentrygun(attacker)
        player_attacker = attacker:GetOwner()
    elseif IsDetpack(attacker) then
        attacker = CastToDetpack(attacker)
        player_attacker = attacker:GetOwner()
    elseif IsDispenser(attacker) then
        attacker = CastToDispenser(attacker)
        player_attacker = attacker:GetOwner()
    else
        return
    end

    -- if still no attacking player after all that, forget about it
    if not player_attacker then return end

    -- If attacker is also the victim (self damage)
    if player:GetId() == player_attacker:GetId() then
        -- change push force
        local damage_force = damageinfo:GetDamageForce()
        i = returnInformation(player:GetTeamId())
        damageinfo:SetDamageForce(Vector(damage_force.x*i["quad"], damage_force.y*i["quad"], damage_force.z*i["quad"]))
        -- set damage to zero
        damageinfo:SetDamage(0)
        return
    end

    -- for everyone else, use attackers quad force
    -- change push force
    local damage_force = damageinfo:GetDamageForce()
    i = returnInformation(player_attacker:GetTeamId())
    damageinfo:SetDamageForce(Vector(damage_force.x*i["quad"], damage_force.y*i["quad"], damage_force.z*i["quad"]))
    -- set damage to zero
    damageinfo:SetDamage(0)
    
    if player:GetTeamId() == Team.kGreen then ApplyToPlayer(player, {AT.kReloadClips}) end
 
end
Bridget is offline   Reply With Quote


Old 09-29-2010, 09:27 PM   #8
zE
Pew pew ze beams
 
zE's Avatar
 
Join Date: Jan 2008
Gametype: Gathers
Affiliations: pew pew
Posts Rated Helpful 11 Times
That last lua makes the auto reload in green doest work : \
zE is offline   Reply With Quote


Old 09-30-2010, 09:58 PM   #9
zE
Pew pew ze beams
 
zE's Avatar
 
Join Date: Jan 2008
Gametype: Gathers
Affiliations: pew pew
Posts Rated Helpful 11 Times
Double post ftl

Last edited by zE; 09-30-2010 at 10:38 PM.
zE is offline   Reply With Quote


Old 09-30-2010, 10:38 PM   #10
zE
Pew pew ze beams
 
zE's Avatar
 
Join Date: Jan 2008
Gametype: Gathers
Affiliations: pew pew
Posts Rated Helpful 11 Times
Working now : D Bri fixed it ftw
zE 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 01:30 PM.


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