PDA

View Full Version : (Request) Adding concs to asti


aleXtric
01-15-2012, 09:01 AM
i want to add concs to asti for scouts and medics when they spawn. i have no idea how. heres the lua



-- ff_asti.lua

-----------------------------------------------------------------------------
-- includes
-----------------------------------------------------------------------------
IncludeScript("base_teamplay")
IncludeScript("base_id")
IncludeScript("base_location")
IncludeScript("base_respawnturret")

-----------------------------------------------------------------------------
-- overrides
-----------------------------------------------------------------------------
POINTS_PER_PERIOD = 5
NUM_PHASES = 3
FLAG_RETURN_TIME = 30


-----------------------------------------------------------------------------
-- locations
-----------------------------------------------------------------------------
location_ospawn = location_info:new({ text = "Attacker Spawn", team = NO_TEAM })
location_alley = location_info:new({ text = "Grenade Alley", team = NO_TEAM })
location_cp1 = location_info:new({ text = "Main Road - CP1", team = NO_TEAM })
location_uproad = location_info:new({ text = "Box Warehouse Road", team = NO_TEAM })
location_sroad = location_info:new({ text = "Asti Plaza Road", team = NO_TEAM })
location_cp2 = location_info:new({ text = "Asti Show Lounge - CP2", team = NO_TEAM })
location_froad = location_info:new({ text = "Grenade Factory Road", team = NO_TEAM })
location_cp3l = location_info:new({ text = "FF Building - Lower", team = NO_TEAM })
location_cp3 = location_info:new({ text = "FF Building - Upper - CP3", team = NO_TEAM })
location_box = location_info:new({ text = "Box Warehouse", team = NO_TEAM })
location_dspawn = location_info:new({ text = "Defense Spawn", team = NO_TEAM })

-----------------------------------------------------------------------------
-- backpacks
-----------------------------------------------------------------------------
astipack = genericbackpack:new({
health = 50,
armor = 50,
grenades = 25,
shells = 50,
nails = 50,
rockets = 25,
cells = 100,
respawntime = 10,
model = "models/items/backpack/backpack.mdl",
materializesound = "Item.Materialize",
touchsound = "Backpack.Touch",
notallowedmsg = "#FF_NOTALLOWEDPACK",
touchflags = {AllowFlags.kOnlyPlayers,AllowFlags.kBlue, AllowFlags.kRed}
})

function astipack:dropatspawn() return false
end

astigren = genericbackpack:new({
health = 50,
armor = 100,
grenades = 20,
shells = 50,
nails = 75,
rockets = 10,
cells = 100,
gren1 = 2,
gren2 = 1,
respawntime = 30,
model = "models/items/backpack/backpack.mdl",
materializesound = "Item.Materialize",
touchsound = "Backpack.Touch",
notallowedmsg = "#FF_NOTALLOWEDPACK",
touchflags = {AllowFlags.kOnlyPlayers,AllowFlags.kBlue, AllowFlags.kRed}
})
if dispensed >= 1 then
BroadCastMessageToPlayer( player, "Got grenades!" )
local backpack = CastToInfoScript(entity);
if (backpack ~= nil) then
backpack:EmitSound(self.touchsound);
backpack:Respawn(self.respawntime);
end
end

function astigren:dropatspawn() return false
end

-----------------------------------------------------------------------------
-- respawn turrets
-----------------------------------------------------------------------------
turret_a = base_respawnturret:new({ team = Attackers })
turret_d = base_respawnturret:new({ team = Defenders })

Crazycarl
01-15-2012, 09:49 PM
Add this anywhere, except inside an existing function

-- Give everyone a full resupply, but strip secondary grenades
function player_spawn( player_entity )
local player = CastToPlayer( player_entity )

player:AddHealth( 100 )
player:AddArmor( 300 )

player:AddAmmo( Ammo.kNails, 400 )
player:AddAmmo( Ammo.kShells, 400 )
player:AddAmmo( Ammo.kRockets, 400 )
player:AddAmmo( Ammo.kCells, 400 )
player:AddAmmo( Ammo.kDetpack, 1 )
player:AddAmmo( Ammo.kManCannon, 1 )

if player:GetClass() ~= Player.kScout and player:GetClass() ~= Player.kMedic then
player:RemoveAmmo( Ammo.kGren2, 4 )
end

if player:GetTeamId() == attackers then
UpdateObjectiveIcon( player, ATTACKERS_OBJECTIVE_ENTITY )
elseif player:GetTeamId() == defenders then
UpdateObjectiveIcon( player, DEFENDERS_OBJECTIVE_ENTITY )
end
end

Not tested, but that should do it.

aleXtric
01-16-2012, 11:32 PM
that didnt work:/

Crazycarl
01-16-2012, 11:57 PM
Squeeeeek!

squeek.
01-17-2012, 02:29 AM
Time to get fancy!

Add this to any part of the lua (very bottom would work):

-- save all the functions in a table with the same name as the Lua file
-- so we don't accidentally overwrite any saved functions in other files
local ff_asti_beta = {}

-- save the function in the table
ff_asti_beta.player_spawn = player_spawn

function player_spawn( player )
-- check to make sure the saved function is actually a function
if type(ff_asti_beta.player_spawn) == "function" then
-- call the saved function
ff_asti_beta.player_spawn( player )
end

if IsPlayer( player ) then
local player = CastToPlayer( player )
if player:GetClass() == Player.kScout then
player:AddAmmo( Ammo.kGren2, 3 )
elseif player:GetClass() == Player.kMedic then
player:AddAmmo( Ammo.kGren2, 2 )
end
end
end


This'll give medics 2 concs on spawn and scouts 3 and it doesn't overwrite the base_id player_spawn function, it just adds to it. I tested it and it should be working.

squeek.
01-17-2012, 02:30 AM
Crazycarl's solution works just as well, by the way. Don't know what you did wrong. Make sure to reload the map after you upload the new lua (ff_restartround works too).