Announcing end of killing spree

This commit is contained in:
sheldar 2018-02-11 17:33:42 +01:00
parent 5f51d9258b
commit 08abd022a6

View file

@ -3,7 +3,7 @@
Contributors: Contributors:
License: MIT License: MIT
Description: Script for killing spree sounds Description: Killing spree sounds and messages
]]-- ]]--
local modname = "killing-spree" local modname = "killing-spree"
@ -12,56 +12,48 @@ local version = "0.1"
local WORLDSPAWN_ENTITY = 1022 local WORLDSPAWN_ENTITY = 1022
local ENTITYNUM_NONE = 1023 local ENTITYNUM_NONE = 1023
local killingSprees = {}
local BROADCAST = -1 local BROADCAST = -1
local SPREE = 5 local SPREE = 5
local RAMPAGE = 10 local RAMPAGE = 10
local DOMINATION = 15 local DOMINATING = 15
local UNSTOPPABLE = 20 local UNSTOPPABLE = 20
local GODLIKE = 25 local GODLIKE = 25
local WICKED_SICK = 30 local WICKED_SICK = 30
local REAL_POTTER = 35 local REAL_POTTER = 35
-- local SPREE = 1
-- local RAMPAGE = 2
-- local DOMINATION = 3
-- local UNSTOPPABLE = 5
-- local GODLIKE = 5
-- local WICKED_SICK = 6
-- local REAL_POTTER = 7
local SPREE_ANNOUNCEMENTS = { local SPREE_ANNOUNCEMENTS = {
[SPREE] = { [SPREE] = {
sound = "/sound/misc/killing-spree.wav", sound = "/sound/misc/killingspree.wav",
message = "is on a killing spree!" message = "%s^7 is on a killing spree!"
}, },
[RAMPAGE] = { [RAMPAGE] = {
sound = "/sound/misc/rampage.wav", sound = "/sound/misc/rampage.wav",
message = "is on a rampage!!" message = "%s^7 is on a rampage!!"
}, },
[DOMINATION] = { [DOMINATING] = {
sound = "/sound/misc/domination.wav", sound = "/sound/misc/dominating.wav",
message = "is dominating!!" message = "%s^7 is dominating!!"
}, },
[UNSTOPPABLE] = { [UNSTOPPABLE] = {
sound = "/sound/misc/unstoppable.wav", sound = "/sound/misc/unstoppable.wav",
message = "is unstoppable!!!!" message = "%s^7 is unstoppable!!!!"
}, },
[GODLIKE] = { [GODLIKE] = {
sound = "/sound/misc/godlike.wav", sound = "/sound/misc/godlike.wav",
message = "is godlike!!!!!" message = "%s^7 is godlike!!!!!"
}, },
[WICKED_SICK] = { [WICKED_SICK] = {
sound = "/sound/misc/wicked-sick.wav", sound = "/sound/misc/wickedsick.wav",
message = "is wicked sick!!!!!!" message = "%s^7 is wicked sick!!!!!!"
}, },
[REAL_POTTER] = { [REAL_POTTER] = {
sound = "/sound/misc/real-potter.wav", sound = "/sound/misc/realpotter.wav",
message = "is real POTTER!!!!!!!" message = "%s^7 is real POTTER!!!!!!!"
},
} }
}
local killingSprees = {}
function et_InitGame() function et_InitGame()
et.RegisterModname(modname .. " " .. version) et.RegisterModname(modname .. " " .. version)
@ -95,9 +87,26 @@ function announceSpree(clientNumber, guid)
if announcement then if announcement then
local name = getName(clientNumber) local name = getName(clientNumber)
local message = string.format(announcement.message, name)
et.G_globalSound(announcement.sound); et.G_globalSound(announcement.sound)
et.trap_SendServerCommand(BROADCAST, "cpm \"" .. name .. " " .. announcement.message .. "\n\"") et.trap_SendServerCommand(BROADCAST, "cpm \"" .. message .. "\n\"")
end
end
function announceEndOfSpree(target, attacker)
local targetGuid = getGuid(target)
local spree = killingSprees[targetGuid]
if spree >= SPREE then
local message = string.format(
"%s^7 killing spree ended (^3%d^7), killed by %s^7!",
getName(target),
spree,
getName(attacker)
)
et.trap_SendServerCommand(BROADCAST, "cpm \"" .. message .. "\n\"")
end end
end end
@ -109,6 +118,8 @@ function et_Obituary(target, attacker, meansOfDeath)
local teamkill = targetTeam == attackerTeam local teamkill = targetTeam == attackerTeam
local killerIsNotPlayer = killer == WORLDSPAWN_ENTITY or killer == ENTITYNUM_NONE local killerIsNotPlayer = killer == WORLDSPAWN_ENTITY or killer == ENTITYNUM_NONE
announceEndOfSpree(target, attacker)
local targetGuid = getGuid(target) local targetGuid = getGuid(target)
killingSprees[targetGuid] = 0 killingSprees[targetGuid] = 0