diff --git a/[gamemodes]/[deathmatch]/deathmatch/client/hud.lua b/[gamemodes]/[deathmatch]/deathmatch/client/hud.lua
index ae1229e3a..be363ede8 100644
--- a/[gamemodes]/[deathmatch]/deathmatch/client/hud.lua
+++ b/[gamemodes]/[deathmatch]/deathmatch/client/hud.lua
@@ -1,5 +1,3 @@
--- TODO: long term - implement new UI resembling original game design
--- more code cleanup?
local SCREEN_WIDTH, SCREEN_HEIGHT = guiGetScreenSize()
--
@@ -25,6 +23,7 @@ end
_hud.loadingScreen.update = function()
_hud.loadingScreen.mapInfoText:text(_mapTitle..(_mapAuthor and ("\n by ".._mapAuthor) or ""))
end
+
-- score display
_hud.scoreDisplay = {}
_hud.scoreDisplay.roundInfoText = dxText:create("", 0, 0, false, "bankgothic", 1)
@@ -48,6 +47,7 @@ _hud.scoreDisplay.update = function()
.."\nRank: "..getElementData(localPlayer, "Rank").."/"..#getElementsByType("player")
)
end
+
-- respawn screen
_hud.respawnScreen = {}
-- respawn counter (You will respawn in x seconds)
@@ -65,6 +65,7 @@ _hud.respawnScreen.startCountdown = function()
_hud.respawnScreen.respawnCounter:text("Wasted")
end
end
+
-- end screen
_hud.endScreen = {}
-- announcement text (x has won the round!)
diff --git a/[gamemodes]/[deathmatch]/deathmatch/client/main.lua b/[gamemodes]/[deathmatch]/deathmatch/client/main.lua
index f5df1bca3..b514199bc 100644
--- a/[gamemodes]/[deathmatch]/deathmatch/client/main.lua
+++ b/[gamemodes]/[deathmatch]/deathmatch/client/main.lua
@@ -1,7 +1,7 @@
--
--- startDeathmatchClient: initializes the deathmatch client
+-- startGamemodeClient: initializes the gamemode client
--
-local function startDeathmatchClient()
+local function startGamemodeClient()
-- add scoreboard columns
exports.scoreboard:scoreboardAddColumn("Score")
exports.scoreboard:scoreboardAddColumn("Rank")
@@ -13,27 +13,25 @@ local function startDeathmatchClient()
if getElementData(resourceRoot, "gameState") == GAME_IN_PROGRESS then
setCameraMatrix(unpack(calculateLoadingCameraMatrix()))
end
- -- inform server we are ready to play
- triggerServerEvent("onDeathmatchPlayerReady", localPlayer)
end
-addEventHandler("onClientResourceStart", resourceRoot, startDeathmatchClient)
+addEventHandler("onClientResourceStart", resourceRoot, startGamemodeClient)
--
--- stopDeathmatchClient: cleans up the deathmatch client
+-- stopGamemodeClient: cleans up the gamemode client
--
-local function stopDeathmatchClient()
+local function stopGamemodeClient()
-- remove scoreboard columns
exports.scoreboard:scoreboardRemoveColumn("Score")
exports.scoreboard:scoreboardRemoveColumn("Rank")
-- hide scoreboard
exports.scoreboard:setScoreboardForced(false)
end
-addEventHandler("onClientResourceStop", resourceRoot, stopDeathmatchClient)
+addEventHandler("onClientResourceStop", resourceRoot, stopGamemodeClient)
--
--- startDeathmatchMap: triggered when a deathmatch map starts
+-- startGamemodeMap: triggered when a gamemode map starts
--
-local function startDeathmatchMap(mapTitle, mapAuthor, fragLimit, respawnTime)
+local function startGamemodeMap(mapTitle, mapAuthor, fragLimit, respawnTime)
-- apply the loading camera matrix - used to stream-in map elements
setCameraMatrix(unpack(calculateLoadingCameraMatrix()))
-- hide end screen and scoreboard
@@ -48,13 +46,13 @@ local function startDeathmatchMap(mapTitle, mapAuthor, fragLimit, respawnTime)
_hud.loadingScreen:update()
_hud.loadingScreen:setVisible(true)
end
-addEvent("onClientDeathmatchMapStart", true)
-addEventHandler("onClientDeathmatchMapStart", resourceRoot, startDeathmatchMap)
+addEvent("onClientGamemodeMapStart", true)
+addEventHandler("onClientGamemodeMapStart", resourceRoot, startGamemodeMap)
--
--- stopDeathmatchMap: triggered when a deathmatch map stops
+-- stopGamemodeMap: triggered when a gamemode map stops
--
-local function stopDeathmatchMap()
+local function stopGamemodeMap()
-- clear stored map data
_mapTitle = nil
_mapAuthor = nil
@@ -63,13 +61,13 @@ local function stopDeathmatchMap()
-- hide loading text
_hud.loadingScreen:setVisible(false)
end
-addEvent("onClientDeathmatchMapStop", true)
-addEventHandler("onClientDeathmatchMapStop", resourceRoot, stopDeathmatchMap)
+addEvent("onClientGamemodeMapStop", true)
+addEventHandler("onClientGamemodeMapStop", resourceRoot, stopGamemodeMap)
--
--- startDeathmatchRound: triggered when a round begins
+-- startGamemodeRound: triggered when a round begins
--
-local function startDeathmatchRound()
+local function startGamemodeRound()
-- attach player wasted handler
addEventHandler("onClientPlayerWasted", localPlayer, _hud.respawnScreen.startCountdown)
-- attach element data change handler
@@ -82,13 +80,13 @@ local function startDeathmatchRound()
_hud.scoreDisplay:update()
_hud.scoreDisplay:setVisible(true)
end
-addEvent("onClientDeathmatchRoundStart", true)
-addEventHandler("onClientDeathmatchRoundStart", resourceRoot, startDeathmatchRound)
+addEvent("onClientGamemodeRoundStart", true)
+addEventHandler("onClientGamemodeRoundStart", resourceRoot, startGamemodeRound)
--
--- stopDeathmatchRound: triggered when a round ends
+-- stopGamemodeRound: triggered when a round ends
--
-local function stopDeathmatchRound(winner, draw, aborted)
+local function stopGamemodeRound(winner, draw, aborted)
-- remove player wasted handler and hide respawn screen if active
removeEventHandler("onClientPlayerWasted", localPlayer, _hud.respawnScreen.startCountdown)
_hud.respawnScreen.setVisible(false)
@@ -110,8 +108,8 @@ local function stopDeathmatchRound(winner, draw, aborted)
_hud.endScreen:setVisible(true)
exports.scoreboard:setScoreboardForced(true)
end
-addEvent("onClientDeathmatchRoundEnd", true)
-addEventHandler("onClientDeathmatchRoundEnd", resourceRoot, stopDeathmatchRound)
+addEvent("onClientGamemodeRoundEnd", true)
+addEventHandler("onClientGamemodeRoundEnd", resourceRoot, stopGamemodeRound)
--
-- elementDataChange: triggered when element data changes - used to track score changes
diff --git a/[gamemodes]/[deathmatch]/deathmatch/meta.xml b/[gamemodes]/[deathmatch]/deathmatch/meta.xml
index d02b3c2a0..fb1d35f7e 100644
--- a/[gamemodes]/[deathmatch]/deathmatch/meta.xml
+++ b/[gamemodes]/[deathmatch]/deathmatch/meta.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/[gamemodes]/[deathmatch]/deathmatch/server/main.lua b/[gamemodes]/[deathmatch]/deathmatch/server/main.lua
index d9eac1c9c..9fbab16f1 100644
--- a/[gamemodes]/[deathmatch]/deathmatch/server/main.lua
+++ b/[gamemodes]/[deathmatch]/deathmatch/server/main.lua
@@ -10,9 +10,9 @@ local defaults = {
}
--
--- startDeathmatchMode: initializes the deathmatch gamemode
+-- startGamemodeMode: initializes the gamemode
--
-local function startDeathmatchMode()
+local function startGamemode()
-- update game state
setElementData(resourceRoot, "gameState", GAME_WAITING)
-- set default player state on gamemode start (clients will report in when ready)
@@ -20,24 +20,24 @@ local function startDeathmatchMode()
_playerStates[player] = PLAYER_JOINED
end
end
-addEventHandler("onGamemodeStart", resourceRoot, startDeathmatchMode)
+addEventHandler("onGamemodeStart", resourceRoot, startGamemode)
--
--- stopDeathmatchMode: cleans up the deathmatch gamemode
+-- stopGamemodeMode: cleans up the gamemode
--
-local function stopDeathmatchMode()
+local function stopGamemode()
-- cleanup player score data, make sure scoreboard isn't forced
for _, player in ipairs(getElementsByType("player")) do
removeElementData(player, "Score")
removeElementData(player, "Rank")
end
end
-addEventHandler("onGamemodeStop", resourceRoot, stopDeathmatchMode)
+addEventHandler("onGamemodeStop", resourceRoot, stopGamemode)
--
--- startDeathmatchMap: initializes a deathmatch map
+-- startGamemodeMap: initializes a gamemode map
--
-local function startDeathmatchMap(resource)
+local function startGamemodeMap(resource)
-- load map settings
_mapResource = resource
local resourceName = getResourceName(resource)
@@ -46,7 +46,7 @@ local function startDeathmatchMap(resource)
_respawnTime = (tonumber(get(resourceName..".respawn_time")) and math.floor(tonumber(get(resourceName..".respawn_time"))) or defaults.respawnTime)*1000
-- use a default frag and time limit if both are zero (infinite)
if _fragLimit == 0 and _timeLimit == 0 then
- outputDebugString("deathmatch: map frag_limit and time_limit both disabled; using default values", 2)
+ outputDebugString("Gamemode: map frag_limit and time_limit both disabled; using default values", 2)
_fragLimit = defaults.fragLimit
_timeLimit = defaults.timeLimit
end
@@ -70,18 +70,18 @@ local function startDeathmatchMap(resource)
-- inform all ready players that the game is about to start
for player, state in pairs(_playerStates) do
if state == PLAYER_READY then
- triggerClientEvent(player, "onClientDeathmatchMapStart", resourceRoot, _mapTitle, _mapAuthor, _fragLimit, _respawnTime)
+ triggerClientEvent(player, "onClientGamemodeMapStart", resourceRoot, _mapTitle, _mapAuthor, _fragLimit, _respawnTime)
end
end
-- schedule round to begin
setTimer(beginRound, CAMERA_LOAD_DELAY, 1)
end
-addEventHandler("onGamemodeMapStart", root, startDeathmatchMap)
+addEventHandler("onGamemodeMapStart", root, startGamemodeMap)
--
--- stopDeathmatchMap: cleans up a deathmatch map
+-- stopGamemodeMap: cleans up a gamemode map
--
-local function stopDeathmatchMap(resource)
+local function stopGamemodeMap(resource)
-- end the round
endRound(false, false, true)
-- update game state
@@ -89,11 +89,11 @@ local function stopDeathmatchMap(resource)
-- inform all clients that the map was stopped
for player, state in pairs(_playerStates) do
if state ~= PLAYER_JOINED then
- triggerClientEvent(player, "onClientDeathmatchMapStop", resourceRoot)
+ triggerClientEvent(player, "onClientGamemodeMapStop", resourceRoot)
end
end
end
-addEventHandler("onGamemodeMapStop", root, stopDeathmatchMap)
+addEventHandler("onGamemodeMapStop", root, stopGamemodeMap)
--
-- calculatePlayerRanks: calculates player ranks
diff --git a/[gamemodes]/[deathmatch]/deathmatch/server/player.lua b/[gamemodes]/[deathmatch]/deathmatch/server/player.lua
index bd53dea4e..569630954 100644
--- a/[gamemodes]/[deathmatch]/deathmatch/server/player.lua
+++ b/[gamemodes]/[deathmatch]/deathmatch/server/player.lua
@@ -25,31 +25,30 @@ end
addEventHandler("onPlayerQuit", root, processPlayerQuit)
--
--- deathmatchPlayerReady: triggered when a client is ready to play
+-- gamemodePlayerReady: triggered when a client is ready to play
--
-- triggered by the client post-onClientResourceStart
- function deathmatchPlayerReady()
+ function gamemodePlayerReady()
-- inform client of current game state by triggering certain events
local gameState = getElementData(resourceRoot, "gameState")
if gameState == GAME_STARTING then
- triggerClientEvent(client, "onClientDeathmatchMapStart", resourceRoot, _mapTitle, _mapAuthor, _fragLimit, _respawnTime)
+ triggerClientEvent(source, "onClientGamemodeMapStart", resourceRoot, _mapTitle, _mapAuthor, _fragLimit, _respawnTime)
elseif gameState == GAME_IN_PROGRESS then
- triggerClientEvent(client, "onClientDeathmatchMapStart", resourceRoot, _mapTitle, _mapAuthor, _fragLimit, _respawnTime)
- triggerClientEvent(client, "onClientDeathmatchRoundStart", resourceRoot)
- spawnDeathmatchPlayer(client)
+ triggerClientEvent(source, "onClientGamemodeMapStart", resourceRoot, _mapTitle, _mapAuthor, _fragLimit, _respawnTime)
+ triggerClientEvent(source, "onClientGamemodeRoundStart", resourceRoot)
+ spawnGamemodePlayer(source)
elseif gameState == GAME_FINISHED then
- triggerClientEvent(client, "onClientDeathmatchRoundEnd", resourceRoot, false, false)
+ triggerClientEvent(source, "onClientGamemodeRoundEnd", resourceRoot, false, false)
end
-- update player state
- _playerStates[client] = PLAYER_READY
+ _playerStates[source] = PLAYER_READY
end
-addEvent("onDeathmatchPlayerReady", true)
-addEventHandler("onDeathmatchPlayerReady", root, deathmatchPlayerReady)
+addEventHandler("onPlayerResourceStart", root, gamemodePlayerReady)
--
--- spawnDeathmatchPlayer: spawns a player in deathmatch mode
+-- spawnGamemodePlayer: spawns a player in Gamemode mode
--
-function spawnDeathmatchPlayer(player)
+function spawnGamemodePlayer(player)
if not isElement(player) then
return
end
@@ -105,6 +104,6 @@ function processPlayerWasted(totalAmmo, killer, killerWeapon, bodypart)
calculatePlayerRanks()
-- set timer to respawn player
if _respawnTime > 0 then
- _respawnTimers[source] = setTimer(spawnDeathmatchPlayer, _respawnTime, 1, source)
+ _respawnTimers[source] = setTimer(spawnGamemodePlayer, _respawnTime, 1, source)
end
end
diff --git a/[gamemodes]/[deathmatch]/deathmatch/server/round.lua b/[gamemodes]/[deathmatch]/deathmatch/server/round.lua
index 930edd4ea..778f48e7e 100644
--- a/[gamemodes]/[deathmatch]/deathmatch/server/round.lua
+++ b/[gamemodes]/[deathmatch]/deathmatch/server/round.lua
@@ -17,8 +17,8 @@ function beginRound()
setElementData(players[i], "Score", 0)
setElementData(players[i], "Rank", "-")
if _playerStates[players[i]] == PLAYER_READY then
- spawnDeathmatchPlayer(players[i])
- triggerClientEvent(players[i], "onClientDeathmatchRoundStart", resourceRoot)
+ spawnGamemodePlayer(players[i])
+ triggerClientEvent(players[i], "onClientGamemodeRoundStart", resourceRoot)
end
end
end
@@ -63,7 +63,7 @@ function endRound(winner, draw, aborted)
-- update player state
_playerStates[players[i]] = PLAYER_READY
-- inform client round is over
- triggerClientEvent(players[i], "onClientDeathmatchRoundEnd", resourceRoot, winner, draw, aborted)
+ triggerClientEvent(players[i], "onClientGamemodeRoundEnd", resourceRoot, winner, draw, aborted)
end
end
-- don't cycle the map if the round was aborted (map resource was stopped)