From d3911b9964f3dd221e9291d46912a88cbdb5d90a Mon Sep 17 00:00:00 2001 From: sheldar Date: Sat, 10 Feb 2018 21:06:59 +0100 Subject: [PATCH 1/7] Initial killing-spree script commit --- killing-spree/killing-spree.lua | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 killing-spree/killing-spree.lua diff --git a/killing-spree/killing-spree.lua b/killing-spree/killing-spree.lua new file mode 100644 index 0000000..1a4853e --- /dev/null +++ b/killing-spree/killing-spree.lua @@ -0,0 +1,9 @@ +--[[ + Author: Kewin Polok [Sheldar] + Contributors: + License: MIT + + Description: This script plays killing spree sounds +]]-- + +local version = "0.1" \ No newline at end of file From a4ec562ab9303484665f311eebf0b9dd19f6f0ff Mon Sep 17 00:00:00 2001 From: sheldar Date: Sun, 11 Feb 2018 14:24:07 +0100 Subject: [PATCH 2/7] Detecting deaths not related to killing spree --- killing-spree/killing-spree.lua | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/killing-spree/killing-spree.lua b/killing-spree/killing-spree.lua index 1a4853e..552470d 100644 --- a/killing-spree/killing-spree.lua +++ b/killing-spree/killing-spree.lua @@ -1,9 +1,32 @@ --[[ - Author: Kewin Polok [Sheldar] - Contributors: - License: MIT + Author: Kewin Polok [Sheldar] + Contributors: + License: MIT - Description: This script plays killing spree sounds + Description: Script for killing spree sounds ]]-- -local version = "0.1" \ No newline at end of file +local modname = "killing-spree" +local version = "0.1" + +local WORLDSPAWN_ENTITY = 1022 +local ENTITYNUM_NONE = 1023 + +function et_InitGame() + et.RegisterModname(modname .. " ".. version) +end + +function et_Obituary(target, attacker, meansOfDeath) + local targetTeam = et.gentity_get(target, "sess.sessionTeam") + local attackerTeam = et.gentity_get(attacker, "sess.sessionTeam") + + local suicide = target == attacker + local teamkill = targetTeam == attackerTeam + local killerIsNotPlayer = killer == WORLDSPAWN_ENTITY or killer == ENTITYNUM_NONE + + if suicide or teamkill or killerIsNotPlayer then + return + end +end + + From 2665ee88a48805cf92feac12ded23214554c8f46 Mon Sep 17 00:00:00 2001 From: sheldar Date: Sun, 11 Feb 2018 14:48:20 +0100 Subject: [PATCH 3/7] Counting sprees for players --- killing-spree/killing-spree.lua | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/killing-spree/killing-spree.lua b/killing-spree/killing-spree.lua index 552470d..37338a8 100644 --- a/killing-spree/killing-spree.lua +++ b/killing-spree/killing-spree.lua @@ -12,21 +12,45 @@ local version = "0.1" local WORLDSPAWN_ENTITY = 1022 local ENTITYNUM_NONE = 1023 +local killingSprees = {} + function et_InitGame() et.RegisterModname(modname .. " ".. version) end +function getTeam(clientNumber) + return et.gentity_get(clientNumber, "sess.sessionTeam") +end + +function getGuid(clientNumber) + return et.Info_ValueForKey( et.trap_GetUserinfo(clientNumber), "cl_guid") +end + +function et_ClientBegin(clientNumber) + local guid = getGuid(clientNumber) + + killingSprees[guid] = 0 +end + function et_Obituary(target, attacker, meansOfDeath) - local targetTeam = et.gentity_get(target, "sess.sessionTeam") - local attackerTeam = et.gentity_get(attacker, "sess.sessionTeam") + local targetTeam = getTeam(target) + local attackerTeam = getTeam(attacker) local suicide = target == attacker local teamkill = targetTeam == attackerTeam local killerIsNotPlayer = killer == WORLDSPAWN_ENTITY or killer == ENTITYNUM_NONE + + local targetGuid = getGuid(target) + killingSprees[targetGuid] = 0 if suicide or teamkill or killerIsNotPlayer then + et.G_Print("suicide or teamkill or killerIsNotPlayer\n") return end + + local attackerGuid = getGuid(attacker) + killingSprees[attackerGuid] = killingSprees[attackerGuid] + 1 + + et.G_Print("target " .. targetGuid .. " killed by " .. attackerGuid .. "\n") + et.G_Print("target spree " .. killingSprees[targetGuid] .. "\nattacker spree " .. killingSprees[attackerGuid] .. "\n") end - - From 6f57d11692823f04b11aeda4a57fc2c5f91db04d Mon Sep 17 00:00:00 2001 From: sheldar Date: Sun, 11 Feb 2018 14:57:47 +0100 Subject: [PATCH 4/7] Added spree levels, messages and sound names --- killing-spree/killing-spree.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/killing-spree/killing-spree.lua b/killing-spree/killing-spree.lua index 37338a8..1812c4e 100644 --- a/killing-spree/killing-spree.lua +++ b/killing-spree/killing-spree.lua @@ -14,6 +14,32 @@ local ENTITYNUM_NONE = 1023 local killingSprees = {} +local SPREE = 5 +local RAMPAGE = 10 +local DOMINATION = 15 +local UNSTOPPABLE = 20 +local GODLIKE = 25 +local WICKED_SICK = 30 +local REAL_POTTER = 35 + +local killingSpreeSounds = {} +killingSpreeSounds[SPREE] = "/sound/misc/killing-spree.wav" +killingSpreeSounds[RAMPAGE] = "/sound/misc/rampage.wav" +killingSpreeSounds[DOMINATION] = "/sound/misc/domination.wav" +killingSpreeSounds[UNSTOPPABLE] = "/sound/misc/unstoppable.wav" +killingSpreeSounds[GODLIKE] = "/sound/misc/godlike.wav" +killingSpreeSounds[WICKED_SICK] = "/sound/misc/wicked-sick.wav" +killingSpreeSounds[REAL_POTTER] = "/sound/misc/real-potter.wav" + +local killingSpreeMessages = {} +killingSpreeMessages[SPREE] = "is on a killing spree!" +killingSpreeMessages[RAMPAGE] = "is on a rampage!!" +killingSpreeMessages[DOMINATION] = "is dominating!!" +killingSpreeMessages[UNSTOPPABLE] = "is unstoppable!!!!" +killingSpreeMessages[GODLIKE] = "is godlike!!!!!" +killingSpreeMessages[WICKED_SICK] = "is wicked sick!!!!!!" +killingSpreeMessages[REAL_POTTER] = "is real POTTER!!!!!!!" + function et_InitGame() et.RegisterModname(modname .. " ".. version) end From 26db67507131da7dc0abe39f967c4bd85d334d15 Mon Sep 17 00:00:00 2001 From: sheldar Date: Sun, 11 Feb 2018 15:08:48 +0100 Subject: [PATCH 5/7] Announcement implementation --- killing-spree/killing-spree.lua | 65 ++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/killing-spree/killing-spree.lua b/killing-spree/killing-spree.lua index 1812c4e..da80d3e 100644 --- a/killing-spree/killing-spree.lua +++ b/killing-spree/killing-spree.lua @@ -14,6 +14,8 @@ local ENTITYNUM_NONE = 1023 local killingSprees = {} +local BROADCAST = -1 + local SPREE = 5 local RAMPAGE = 10 local DOMINATION = 15 @@ -22,23 +24,36 @@ local GODLIKE = 25 local WICKED_SICK = 30 local REAL_POTTER = 35 -local killingSpreeSounds = {} -killingSpreeSounds[SPREE] = "/sound/misc/killing-spree.wav" -killingSpreeSounds[RAMPAGE] = "/sound/misc/rampage.wav" -killingSpreeSounds[DOMINATION] = "/sound/misc/domination.wav" -killingSpreeSounds[UNSTOPPABLE] = "/sound/misc/unstoppable.wav" -killingSpreeSounds[GODLIKE] = "/sound/misc/godlike.wav" -killingSpreeSounds[WICKED_SICK] = "/sound/misc/wicked-sick.wav" -killingSpreeSounds[REAL_POTTER] = "/sound/misc/real-potter.wav" - -local killingSpreeMessages = {} -killingSpreeMessages[SPREE] = "is on a killing spree!" -killingSpreeMessages[RAMPAGE] = "is on a rampage!!" -killingSpreeMessages[DOMINATION] = "is dominating!!" -killingSpreeMessages[UNSTOPPABLE] = "is unstoppable!!!!" -killingSpreeMessages[GODLIKE] = "is godlike!!!!!" -killingSpreeMessages[WICKED_SICK] = "is wicked sick!!!!!!" -killingSpreeMessages[REAL_POTTER] = "is real POTTER!!!!!!!" +local SPREE_ANNOUNCEMENTS = { + [SPREE] = { + sound = "/sound/misc/killing-spree.wav", + message = "is on a killing spree!" + }, + [RAMPAGE] = { + sound = "/sound/misc/rampage.wav", + message = "is on a rampage!!" + }, + [DOMINATION] = { + sound = "/sound/misc/domination.wav", + message = "is dominating!!" + }, + [UNSTOPPABLE] = { + sound = "/sound/misc/unstoppable.wav", + message = "is unstoppable!!!!" + }, + [GODLIKE] = { + sound = "/sound/misc/godlike.wav", + message = "is godlike!!!!!" + }, + [WICKED_SICK] = { + sound = "/sound/misc/wicked-sick.wav", + message = "is wicked sick!!!!!!" + }, + [REAL_POTTER] = { + sound = "/sound/misc/real-potter.wav", + message = "is real POTTER!!!!!!!" + }, +} function et_InitGame() et.RegisterModname(modname .. " ".. version) @@ -52,12 +67,28 @@ function getGuid(clientNumber) return et.Info_ValueForKey( et.trap_GetUserinfo(clientNumber), "cl_guid") end +function getName(clientNumber) + return et.gentity_get(clientNumber, "pers.netname") +end + function et_ClientBegin(clientNumber) local guid = getGuid(clientNumber) killingSprees[guid] = 0 end +function announceSpree(clientNumber, guid) + local spree = killingSprees[guid] + local announcement = SPREE_ANNOUNCEMENTS[spree] + + if announcement then + local name = getName(clientNumber) + + et.G_globalSound(announcement.sound); + et.trap_SendServerCommand(BROADCAST, "cpm \"" .. name .. " " .. announcement.message .. "\n\"") + end +end + function et_Obituary(target, attacker, meansOfDeath) local targetTeam = getTeam(target) local attackerTeam = getTeam(attacker) From 5f51d9258beaef648d88b231dde028d791c1543d Mon Sep 17 00:00:00 2001 From: sheldar Date: Sun, 11 Feb 2018 15:17:29 +0100 Subject: [PATCH 6/7] Cleanup --- killing-spree/killing-spree.lua | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/killing-spree/killing-spree.lua b/killing-spree/killing-spree.lua index da80d3e..afb3de8 100644 --- a/killing-spree/killing-spree.lua +++ b/killing-spree/killing-spree.lua @@ -24,6 +24,14 @@ local GODLIKE = 25 local WICKED_SICK = 30 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 = { [SPREE] = { sound = "/sound/misc/killing-spree.wav", @@ -74,7 +82,11 @@ end function et_ClientBegin(clientNumber) local guid = getGuid(clientNumber) - killingSprees[guid] = 0 + local spree = killingSprees[guid] + + if not spree then + killingSprees[guid] = 0 + end end function announceSpree(clientNumber, guid) @@ -101,13 +113,11 @@ function et_Obituary(target, attacker, meansOfDeath) killingSprees[targetGuid] = 0 if suicide or teamkill or killerIsNotPlayer then - et.G_Print("suicide or teamkill or killerIsNotPlayer\n") return end local attackerGuid = getGuid(attacker) killingSprees[attackerGuid] = killingSprees[attackerGuid] + 1 - et.G_Print("target " .. targetGuid .. " killed by " .. attackerGuid .. "\n") - et.G_Print("target spree " .. killingSprees[targetGuid] .. "\nattacker spree " .. killingSprees[attackerGuid] .. "\n") + announceSpree(attacker, attackerGuid) end From 08abd022a694515610c4e2b4aeeacbcd6b94481f Mon Sep 17 00:00:00 2001 From: sheldar Date: Sun, 11 Feb 2018 17:33:42 +0100 Subject: [PATCH 7/7] Announcing end of killing spree --- killing-spree/killing-spree.lua | 67 +++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/killing-spree/killing-spree.lua b/killing-spree/killing-spree.lua index afb3de8..68a6453 100644 --- a/killing-spree/killing-spree.lua +++ b/killing-spree/killing-spree.lua @@ -3,7 +3,7 @@ Contributors: License: MIT - Description: Script for killing spree sounds + Description: Killing spree sounds and messages ]]-- local modname = "killing-spree" @@ -12,59 +12,51 @@ local version = "0.1" local WORLDSPAWN_ENTITY = 1022 local ENTITYNUM_NONE = 1023 -local killingSprees = {} - local BROADCAST = -1 local SPREE = 5 local RAMPAGE = 10 -local DOMINATION = 15 +local DOMINATING = 15 local UNSTOPPABLE = 20 local GODLIKE = 25 local WICKED_SICK = 30 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 = { [SPREE] = { - sound = "/sound/misc/killing-spree.wav", - message = "is on a killing spree!" + sound = "/sound/misc/killingspree.wav", + message = "%s^7 is on a killing spree!" }, [RAMPAGE] = { sound = "/sound/misc/rampage.wav", - message = "is on a rampage!!" + message = "%s^7 is on a rampage!!" }, - [DOMINATION] = { - sound = "/sound/misc/domination.wav", - message = "is dominating!!" + [DOMINATING] = { + sound = "/sound/misc/dominating.wav", + message = "%s^7 is dominating!!" }, [UNSTOPPABLE] = { sound = "/sound/misc/unstoppable.wav", - message = "is unstoppable!!!!" + message = "%s^7 is unstoppable!!!!" }, [GODLIKE] = { sound = "/sound/misc/godlike.wav", - message = "is godlike!!!!!" + message = "%s^7 is godlike!!!!!" }, [WICKED_SICK] = { - sound = "/sound/misc/wicked-sick.wav", - message = "is wicked sick!!!!!!" + sound = "/sound/misc/wickedsick.wav", + message = "%s^7 is wicked sick!!!!!!" }, [REAL_POTTER] = { - sound = "/sound/misc/real-potter.wav", - message = "is real POTTER!!!!!!!" - }, + sound = "/sound/misc/realpotter.wav", + message = "%s^7 is real POTTER!!!!!!!" + } } +local killingSprees = {} + function et_InitGame() - et.RegisterModname(modname .. " ".. version) + et.RegisterModname(modname .. " " .. version) end function getTeam(clientNumber) @@ -95,9 +87,26 @@ function announceSpree(clientNumber, guid) if announcement then local name = getName(clientNumber) + local message = string.format(announcement.message, name) - et.G_globalSound(announcement.sound); - et.trap_SendServerCommand(BROADCAST, "cpm \"" .. name .. " " .. announcement.message .. "\n\"") + et.G_globalSound(announcement.sound) + 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 @@ -109,6 +118,8 @@ function et_Obituary(target, attacker, meansOfDeath) local teamkill = targetTeam == attackerTeam local killerIsNotPlayer = killer == WORLDSPAWN_ENTITY or killer == ENTITYNUM_NONE + announceEndOfSpree(target, attacker) + local targetGuid = getGuid(target) killingSprees[targetGuid] = 0