Quote:
Originally Posted by Dr.Satan
Ok...I didn't have time to test this, but this should be what your looking for:
Place this in your maps .lua
http://privatepaste.com/e61RxYBu3Y
Then on the top of the hill or whatever area you want, you just have to create a new trigger and name it "quadarea"
This should give them quad and resupply them periodically. But I might have missed something too (it's really early still)
|
That'll actually give everyone in the map quad damage if anyone is in the trigger.
Try this:
Code:
DAMAGE_BONUS = 4 -- Multiplies the player's damage by DAMAGE_BONUS when in the zone. 1 = Normal damage, 4 = Quad damage
RESUPPLY_IN_ZONE = true -- turns resupplying on/off
RESUPPLY_DELAY = 10 -- time between resupplies (if resupplying is on)
RELOAD_CLIPS = true -- periodically reloads all weapons when in the zone if set to true
quad_collection = Collection(); -- stores all players that have quad
-----------------------------------------------------------------------------
-- Damage event - Add Quad Damage
-----------------------------------------------------------------------------
function player_ondamage( player, damageinfo )
if not damageinfo then return end
-- Entity that is attacking
local attacker = damageinfo:GetAttacker()
-- If no attacker do nothing
if not attacker then return end
-- If attacker is a player
if IsPlayer(attacker) then
local playerAttacker = CastToPlayer(attacker)
-- If player is damaging self do nothing
if player:GetId() == playerAttacker:GetId() then return end
-- If the attacker isn't on the quad area do nothing
if not quad_collection:HasItem( playerAttacker ) then return end
-- if on the defending team
if playerAttacker:GetTeamId() == command_points[1].defending_team then
-- If all conditions are true, increase player's damage to 400% - Quad Damage
damageInfo:SetDamage(damageinfo:GetDamage() * DAMAGE_BONUS)
end
end
end
-- Fully resupply's the player's ammo
function fullresupply( player )
-- if on the defending team
if player:GetTeamId() == command_points[1].defending_team then
player:AddAmmo( Ammo.kNails, 300 )
player:AddAmmo( Ammo.kShells, 300 )
player:AddAmmo( Ammo.kRockets, 300 )
player:AddAmmo( Ammo.kCells, 300 )
end
end
-- Fully reload all weapons of a player
function fullreload( player )
-- if on the defending team
if player:GetTeamId() == command_points[1].defending_team then
ApplyToPlayer( player, { AT.kReloadClips } )
end
end
-----------------------------------------------------------------------------
-- Quad area
-- The area where the player is supposed to be holding
-----------------------------------------------------------------------------
quadarea = trigger_ff_script:new({ })
-- on touch, give quad
function quadarea:ontouch( trigger_entity )
if ( IsPlayer( trigger_entity ) ) then
local player = CastToPlayer( trigger_entity )
-- add to the quad collection
quad_collection:AddItem( player )
-- if resupplying is on, add schedule
if RESUPPLY_IN_ZONE then
AddSchedule("resupply_zone-"..player:GetId(), RESUPPLY_DELAY fullresupply, player)
end
if RELOAD_CLIPS then
AddSchedule("reload_zone-"..player:GetId(), 5, fullreload, player)
end
end
end
-- on endtouch, remove quad
function quadarea:onendtouch( trigger_entity )
if ( IsPlayer( trigger_entity ) ) then
local player = CastToPlayer( trigger_entity )
-- remove from the quad collection
zone_collection:RemoveItem( player )
-- if resupplying is on, add schedule
if RESUPPLY_IN_ZONE then
RemoveSchedule("resupply_zone-"..player:GetId())
end
if RELOAD_CLIPS then
RemoveSchedule("reload_zone-"..player:GetId())
end
end
end
-- when no one is in the zone, clear the collection
function quadarea:oninactive( )
-- remove everyone from the quad collection
zone_collection:RemoveAllItems()
end