Page 1 of 1

Adding a timer to a map

Posted: Sun Oct 19, 2008 6:03 pm
by jedimaster745
how to i add an automatic timer to conquest mode for my map? if its possible, please tell me. thanks

Re: Adding a timer to a map

Posted: Sun Oct 19, 2008 6:36 pm
by [RDH]Zerted
A timer to do what? The scripting guide documentation has info on timers.

Re: Adding a timer to a map

Posted: Sun Oct 19, 2008 6:44 pm
by jedimaster745
a timer as in like, a countdown until the next map starts. like in hunt where you can choose how long you want the played map to last until the next map starts.

Re: Adding a timer to a map

Posted: Sun Oct 19, 2008 8:41 pm
by elfie
jedimaster745 wrote:a timer as in like, a countdown until the next map starts. like in hunt where you can choose how long you want the played map to last until the next map starts.
I put a timer in one of my maps. I don't know what you mean by a countdown though. If you mean timer like the timer tells you how much time is left in the map then that is done through the lua. I did it to my map, so I know it is possible. There is a topic on it in this forum so use the search function.

EDIT: I found it. It was in the ObjectiveTDM.lua I think. Here it is if you want to look at it:
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

ScriptCB_DoFile("Objective")

--=============================
-- ObjectiveTDM
-- Handles the logic for a team deathmatch game
-- Aaaactually, this has morphed into the Hunt gametype (at the last minute, hence the lack of name-change), but only in multiplayer/instant-action mode
--=============================
ObjectiveTDM = Objective:New
{
-- external values
pointsPerKillATT = 1,
pointsPerKillDEF = 1,

isCelebrityDeathmatch = false, -- exactly what it sounds like.
isUberMode = false, -- ditto
uberScoreLimit = 400, -- score limit for, get this, uber mode
}

function ObjectiveTDM:GetGameTimeLimit()
if ( self.isCelebrityDeathmatch or self.isUberMode) then
return 0
else
return 960
end
end

function ObjectiveTDM:GameOptionsTimeLimitUp()
local team1pts = GetTeamPoints(1)
local team2pts = GetTeamPoints(2)
if ( team1pts > team2pts ) then
MissionVictory(1)
elseif ( team1pts < team2pts ) then
MissionVictory(2)
else
--tied, so victory for both
MissionVictory({1,2})
end
end

function ObjectiveTDM:Start()
if ( self.isCelebrityDeathmatch == true ) then
ScriptCB_SetNumBots(ScriptCB_GetASSNumBots())
end

--===============================
-- Initialization logic
--===============================
--initialize the base objective data first
Objective.Start(self)

if self.multiplayerRules then
ShowTeamPoints(self.teamATT, true)
ShowTeamPoints(self.teamDEF, true)

SetReinforcementCount(self.teamATT, -1)
SetReinforcementCount(self.teamDEF, -1)

SetTeamPoints(self.teamATT, 0)
SetTeamPoints(self.teamDEF, 0)
if ( self.isCelebrityDeathmatch ) then
ScriptCB_ShowHuntScoreLimit(2)
elseif ( self.isUberMode ) then
ScriptCB_ShowHuntScoreLimit(3)
ScriptCB_SetUberScoreLimit(self.uberScoreLimit)
else
ScriptCB_ShowHuntScoreLimit(1)
end
end


--set AI goals
self.AIGoals = {}
if self.AIGoalWeight > 0.0 then
table.insert(self.AIGoals, AddAIGoal(self.teamATT, "Deathmatch", 100*self.AIGoalWeight))
table.insert(self.AIGoals, AddAIGoal(self.teamDEF, "Deathmatch", 100*self.AIGoalWeight))
end

--=======================================
-- Event responses
--=======================================

--when used in multiplayer, TDM will count points upwards until a score limit is reached
if self.multiplayerRules then
local eventResponseCharacterDeath = OnCharacterDeath(
function(character, killer)
if not killer then return end --no points for suicides

local victimTeam = GetCharacterTeam(character)
local killerTeam = GetCharacterTeam(killer)

if victimTeam == killerTeam then return end --no points for killing guys on your team

if killerTeam == self.teamATT then
AddTeamPoints(killerTeam, self.pointsPerKillATT)
elseif killerTeam == self.teamDEF then
AddTeamPoints(killerTeam, self.pointsPerKillDEF)
end

if GetTeamPoints(killerTeam) >= 250 then
self:Complete(killerTeam)
ReleaseCharacterDeath(eventResponseCharacterDeath)
end
end
)
end

end