diff --git a/mobs/_kill_count.lua b/mobs/_kill_count.lua new file mode 100644 index 0000000..2b6585d --- /dev/null +++ b/mobs/_kill_count.lua @@ -0,0 +1,29 @@ +nssm.leaderboard = {} + +local function load_leaderboard() + -- TODO +end + +local function save_leaderboard() + -- TODO +end + +-- Globally accessible function +function __NSSM_kill_count(self, pos) + if self.cause_of_death and + self.cause_of_death.type == "punch" and + self.attack and + self.attack.is_player and + self.attack:is_player() + then + + local playername = self.attack:get_player_name() + local playerstats = nssm.leaderboard[playername] or {} + local killcount = playerstats[self.name] or 0 + + playerstats[self.name] = killcount + 1 + nssm.leaderboard[playername] = playerstats -- in case new stat + + minetest.log("action", playername.." defeated "..self.name) + end +end diff --git a/mobs/all_mobs.lua b/mobs/all_mobs.lua index 7390630..3b43bf6 100644 --- a/mobs/all_mobs.lua +++ b/mobs/all_mobs.lua @@ -1,3 +1,5 @@ +nssm:load("mobs/_kill_count.lua") + nssm:load("mobs/ant_queen.lua") nssm:load("mobs/ant_soldier.lua") nssm:load("mobs/ant_worker.lua") diff --git a/mobs/ant_queen.lua b/mobs/ant_queen.lua index 3ebb7a9..b66c001 100644 --- a/mobs/ant_queen.lua +++ b/mobs/ant_queen.lua @@ -101,5 +101,6 @@ mobs:register_mob("nssm:ant_queen", { end end end - end + end, + on_die= __NSSM_kill_count, }) diff --git a/mobs/ant_soldier.lua b/mobs/ant_soldier.lua index cbf3e2b..4f18f28 100644 --- a/mobs/ant_soldier.lua +++ b/mobs/ant_soldier.lua @@ -60,5 +60,6 @@ mobs:register_mob("nssm:ant_soldier", { run_end = 130, punch_start = 60, punch_end = 80, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/ant_worker.lua b/mobs/ant_worker.lua index e48afa4..4d8acbc 100644 --- a/mobs/ant_worker.lua +++ b/mobs/ant_worker.lua @@ -60,5 +60,6 @@ mobs:register_mob("nssm:ant_worker", { run_end = 160, punch_start = 50, punch_end = 70, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/black_widow.lua b/mobs/black_widow.lua index 93e6d0e..17c6d62 100644 --- a/mobs/black_widow.lua +++ b/mobs/black_widow.lua @@ -64,4 +64,5 @@ mobs:register_mob("nssm:black_widow", { do_custom = function(self) webber_ability(self, "nssm:web", 2) end, + on_die= __NSSM_kill_count, }) diff --git a/mobs/bloco.lua b/mobs/bloco.lua index 0aa759a..ba95b7d 100644 --- a/mobs/bloco.lua +++ b/mobs/bloco.lua @@ -61,5 +61,6 @@ mobs:register_mob("nssm:bloco", { run_end = 160, punch_start = 170, punch_end = 190, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/crab.lua b/mobs/crab.lua index 82f3fcb..1df8d1a 100644 --- a/mobs/crab.lua +++ b/mobs/crab.lua @@ -61,5 +61,6 @@ mobs:register_mob("nssm:crab", { run_end = 140, punch_start = 90, punch_end = 110, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/crocodile.lua b/mobs/crocodile.lua index 44e9a64..2c9008f 100644 --- a/mobs/crocodile.lua +++ b/mobs/crocodile.lua @@ -57,5 +57,6 @@ mobs:register_mob("nssm:crocodile", { punch_end = 220, --swim_start = 100, --swim_end = 140, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/daddy_long_legs.lua b/mobs/daddy_long_legs.lua index 33f569a..2ce100b 100644 --- a/mobs/daddy_long_legs.lua +++ b/mobs/daddy_long_legs.lua @@ -55,5 +55,6 @@ mobs:register_mob("nssm:daddy_long_legs", { run_end = 120, punch_start = 140, punch_end = 165, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/dolidrosaurus.lua b/mobs/dolidrosaurus.lua index fce4ec6..a16f8ad 100644 --- a/mobs/dolidrosaurus.lua +++ b/mobs/dolidrosaurus.lua @@ -54,5 +54,6 @@ mobs:register_mob("nssm:dolidrosaurus", { run_end = 180, punch_start = 190, punch_end = 220, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/duck.lua b/mobs/duck.lua index 996c381..3c1fdfa 100644 --- a/mobs/duck.lua +++ b/mobs/duck.lua @@ -59,6 +59,7 @@ mobs:register_mob("nssm:duck", { run_end = 40, punch_start = 40, punch_end = 60, - } + }, + on_die= __NSSM_kill_count, --pathfinding = 1, }) diff --git a/mobs/duckking.lua b/mobs/duckking.lua index 67d9f1d..b6a0b47 100644 --- a/mobs/duckking.lua +++ b/mobs/duckking.lua @@ -74,5 +74,6 @@ mobs:register_mob("nssm:duckking", { punch_end = 220, shoot_start = 160, shoot_end = 180, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/echidna.lua b/mobs/echidna.lua index d47eddc..453e92a 100644 --- a/mobs/echidna.lua +++ b/mobs/echidna.lua @@ -59,5 +59,6 @@ mobs:register_mob("nssm:echidna", { punch_end = 190, shoot_start = 200, shoot_end = 240, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/enderduck.lua b/mobs/enderduck.lua index dd4813f..ade786b 100644 --- a/mobs/enderduck.lua +++ b/mobs/enderduck.lua @@ -62,5 +62,6 @@ mobs:register_mob("nssm:enderduck", { run_end = 130, punch_start = 60, punch_end = 90, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/felucco.lua b/mobs/felucco.lua index e979bc9..96fb6ec 100644 --- a/mobs/felucco.lua +++ b/mobs/felucco.lua @@ -58,5 +58,6 @@ mobs:register_mob("nssm:felucco", { run_end = 160, punch_start = 200, punch_end = 240, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/flying_duck.lua b/mobs/flying_duck.lua index 1d3d22f..b88b853 100644 --- a/mobs/flying_duck.lua +++ b/mobs/flying_duck.lua @@ -59,5 +59,6 @@ mobs:register_mob("nssm:flying_duck", { run_end = 220, punch_start = 110, punch_end = 140, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/giant_sandworm.lua b/mobs/giant_sandworm.lua index eb5909c..2ca4449 100644 --- a/mobs/giant_sandworm.lua +++ b/mobs/giant_sandworm.lua @@ -56,4 +56,5 @@ mobs:register_mob("nssm:giant_sandworm", { punch_start = 150, punch_end = 180, }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/icelamander.lua b/mobs/icelamander.lua index 99924e6..ed4695f 100644 --- a/mobs/icelamander.lua +++ b/mobs/icelamander.lua @@ -73,4 +73,5 @@ mobs:register_mob("nssm:icelamander", { do_custom = function(self) midas_ability(self, "default:ice", self.run_velocity,1, 3) end, + on_die= __NSSM_kill_count, }) diff --git a/mobs/icesnake.lua b/mobs/icesnake.lua index 5cea35f..251817b 100644 --- a/mobs/icesnake.lua +++ b/mobs/icesnake.lua @@ -64,4 +64,5 @@ mobs:register_mob("nssm:icesnake", { do_custom = function(self) putting_ability(self, "default:ice", self.run_velocity) end, + on_die= __NSSM_kill_count, }) diff --git a/mobs/kraken.lua b/mobs/kraken.lua index 0c90f34..2b559ed 100644 --- a/mobs/kraken.lua +++ b/mobs/kraken.lua @@ -59,5 +59,6 @@ mobs:register_mob("nssm:kraken", { run_end = 100, punch_start = 120, punch_end = 150, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/larva.lua b/mobs/larva.lua index 92a9ee5..a349c57 100644 --- a/mobs/larva.lua +++ b/mobs/larva.lua @@ -83,5 +83,6 @@ mobs:register_mob("nssm:larva", { end return end - end + end, + on_die= __NSSM_kill_count, }) diff --git a/mobs/lava_titan.lua b/mobs/lava_titan.lua index b4e52c3..091c86f 100644 --- a/mobs/lava_titan.lua +++ b/mobs/lava_titan.lua @@ -89,6 +89,7 @@ mobs:register_mob("nssm:lava_titan", { -- For now deactivate - it places lava under it, sinks, then places lava under it, sinks, etc ... --putting_ability(self, "default:lava_source", self.run_velocity) end, + on_die= __NSSM_kill_count, --[[ custom_attack = function (self) -- digging_attack diff --git a/mobs/manticore.lua b/mobs/manticore.lua index 593ef6a..459929b 100644 --- a/mobs/manticore.lua +++ b/mobs/manticore.lua @@ -61,5 +61,6 @@ mobs:register_mob("nssm:manticore", { punch_end = 143, shoot_start =180, shoot_end=230, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/mantis.lua b/mobs/mantis.lua index 2850a9a..76d321b 100644 --- a/mobs/mantis.lua +++ b/mobs/mantis.lua @@ -61,5 +61,6 @@ mobs:register_mob("nssm:mantis", { punch_end = 140, punch2_start = 145, punch2_end = 165, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/mantis_beast.lua b/mobs/mantis_beast.lua index a3fd85c..bffa48b 100644 --- a/mobs/mantis_beast.lua +++ b/mobs/mantis_beast.lua @@ -59,5 +59,6 @@ mobs:register_mob("nssm:mantis_beast", { run_end = 110, punch_start = 140, punch_end = 165, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/masticone.lua b/mobs/masticone.lua index 813c857..d03c3cd 100644 --- a/mobs/masticone.lua +++ b/mobs/masticone.lua @@ -61,6 +61,8 @@ mobs:register_mob("nssm:masticone", { }, on_die = function(self, pos) self.object:remove() + __NSSM_kill_count(self,pos) + core.after(2, function() minetest.add_particlespawner({ amount = 200, diff --git a/mobs/mese_dragon.lua b/mobs/mese_dragon.lua index 7191462..9ecdb19 100644 --- a/mobs/mese_dragon.lua +++ b/mobs/mese_dragon.lua @@ -112,5 +112,6 @@ mobs:register_mob("nssm:mese_dragon", { end end end - end + end, + on_die= __NSSM_kill_count, }) diff --git a/mobs/moonheron.lua b/mobs/moonheron.lua index aa4d8df..c38be51 100644 --- a/mobs/moonheron.lua +++ b/mobs/moonheron.lua @@ -51,5 +51,6 @@ mobs:register_mob("nssm:moonheron", { run_end = 60, punch_start = 80, punch_end = 120, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/mordain.lua b/mobs/mordain.lua index 0a8d57d..2e43508 100644 --- a/mobs/mordain.lua +++ b/mobs/mordain.lua @@ -119,5 +119,6 @@ mobs:register_mob("nssm:mordain", { self.object:setpos(d) end) end - end + end, + on_die= __NSSM_kill_count, }) diff --git a/mobs/morde.lua b/mobs/morde.lua index 736b408..d2607a5 100644 --- a/mobs/morde.lua +++ b/mobs/morde.lua @@ -104,6 +104,7 @@ mobs:register_mob("nssm:morde", { local pos = self.object:getpos() self.object:remove() minetest.add_entity(pos, "nssm:mortick") + __NSSM_kill_count(self,pos) end, }) @@ -139,6 +140,7 @@ minetest.register_entity("nssm:mortick", { name == "default:lava_flowing" then self.object:remove() + __NSSM_kill_count(self,s) end --Find player to attack: diff --git a/mobs/morgre.lua b/mobs/morgre.lua index 546f81f..3d0fb47 100644 --- a/mobs/morgre.lua +++ b/mobs/morgre.lua @@ -53,5 +53,6 @@ mobs:register_mob("nssm:morgre", { run_end = 140, punch_start = 100, punch_end = 110, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/morgut.lua b/mobs/morgut.lua index 3ec3a0b..767a2be 100644 --- a/mobs/morgut.lua +++ b/mobs/morgut.lua @@ -183,5 +183,6 @@ mobs:register_mob("nssm:morgut", { end end self.object:remove() + __NSSM_kill_count(self, pos) end, }) diff --git a/mobs/morlu.lua b/mobs/morlu.lua index 404d0db..084d14a 100644 --- a/mobs/morlu.lua +++ b/mobs/morlu.lua @@ -240,5 +240,6 @@ mobs:register_mob("nssm:morlu", { end end self.object:remove() + __NSSM_kill_count(self,pos) end, }) diff --git a/mobs/morvalar.lua b/mobs/morvalar.lua index 1e2b421..6d23e76 100644 --- a/mobs/morvalar.lua +++ b/mobs/morvalar.lua @@ -837,6 +837,8 @@ mobs:register_mob("nssm:morvalar0", { on_die = function(self) local pos = self.object:getpos() self.object:remove() + __NSSM_kill_count(self, pos) + minetest.add_particlespawner({ amount = 500, time = 2, diff --git a/mobs/morvy.lua b/mobs/morvy.lua index cee0af4..5c6b32b 100644 --- a/mobs/morvy.lua +++ b/mobs/morvy.lua @@ -276,5 +276,6 @@ mobs:register_mob("nssm:morbat3", { run_end = 50, punch_start = 100, punch_end = 115, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/morwa.lua b/mobs/morwa.lua index 157b5bd..bd59abb 100644 --- a/mobs/morwa.lua +++ b/mobs/morwa.lua @@ -68,4 +68,5 @@ mobs:register_mob("nssm:morwa", { minetest.env:set_node(pos, {name="nssm:morwa_statue"}) end end, + on_die= __NSSM_kill_count, }) diff --git a/mobs/night_master.lua b/mobs/night_master.lua index 2af059b..e563dba 100644 --- a/mobs/night_master.lua +++ b/mobs/night_master.lua @@ -186,5 +186,6 @@ mobs:register_mob("nssm:night_master_1", { run_end = 50, punch_start = 130, punch_end = 160, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/octopus.lua b/mobs/octopus.lua index 603f954..a669aeb 100644 --- a/mobs/octopus.lua +++ b/mobs/octopus.lua @@ -118,4 +118,5 @@ mobs:register_mob("nssm:xgaloctopus", { replace_what = {"default:torch"}, replace_with = "default:water_source", replace_offset = 0, + on_die= __NSSM_kill_count, }) diff --git a/mobs/phoenix.lua b/mobs/phoenix.lua index 554b502..c6c9f63 100644 --- a/mobs/phoenix.lua +++ b/mobs/phoenix.lua @@ -64,5 +64,6 @@ mobs:register_mob("nssm:phoenix", { punch_end = 110, shoot_start = 80, shoot_end = 110, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/pumpboom.lua b/mobs/pumpboom.lua index 5942929..1dd8779 100644 --- a/mobs/pumpboom.lua +++ b/mobs/pumpboom.lua @@ -44,7 +44,8 @@ local function register_pumpboom(sizename, params) run_end = 97, punch_start = 70, punch_end = 80, - } + }, + on_die= __NSSM_kill_count, }) end diff --git a/mobs/pumpking.lua b/mobs/pumpking.lua index 5f55712..6dafefe 100644 --- a/mobs/pumpking.lua +++ b/mobs/pumpking.lua @@ -55,6 +55,8 @@ mobs:register_mob("nssm:pumpking", { }, on_die=function(self,pos) self.object:remove() + __NSSM_kill_count(self, pos) + minetest.after(0.2, function(pos) tnt.boom(pos, {damage_radius=5,radius=4,ignore_protection=false}) end, pos) diff --git a/mobs/sand_bloco.lua b/mobs/sand_bloco.lua index ef6a353..c8dff38 100644 --- a/mobs/sand_bloco.lua +++ b/mobs/sand_bloco.lua @@ -55,5 +55,6 @@ mobs:register_mob("nssm:sand_bloco", { run_end = 200, punch_start = 100, punch_end = 130, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/sandworm.lua b/mobs/sandworm.lua index f46249d..fa6b78b 100644 --- a/mobs/sandworm.lua +++ b/mobs/sandworm.lua @@ -61,4 +61,5 @@ mobs:register_mob("nssm:sandworm", { do_custom = function(self) digging_attack(self, "sand", self.run_velocity, {x=0, y=3, z=0}) end, + on_die= __NSSM_kill_count, }) diff --git a/mobs/scrausics.lua b/mobs/scrausics.lua index 3a23082..269b0ff 100644 --- a/mobs/scrausics.lua +++ b/mobs/scrausics.lua @@ -52,5 +52,6 @@ mobs:register_mob("nssm:scrausics", { run_end = 210, punch_start = 20, punch_end = 50, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/signosigno.lua b/mobs/signosigno.lua index 7957210..d3c4bcb 100644 --- a/mobs/signosigno.lua +++ b/mobs/signosigno.lua @@ -52,5 +52,6 @@ mobs:register_mob("nssm:signosigno", { run_end = 220, punch_start = 160, punch_end = 190, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/snow_biter.lua b/mobs/snow_biter.lua index 1ca3941..3c0d085 100644 --- a/mobs/snow_biter.lua +++ b/mobs/snow_biter.lua @@ -69,4 +69,5 @@ mobs:register_mob("nssm:snow_biter", { do_custom = function(self) putting_ability(self, "default:ice", self.run_velocity) end, + on_die= __NSSM_kill_count, }) diff --git a/mobs/spiderduck.lua b/mobs/spiderduck.lua index 47460a2..ab7a31a 100644 --- a/mobs/spiderduck.lua +++ b/mobs/spiderduck.lua @@ -70,5 +70,6 @@ mobs:register_mob("nssm:spiderduck", { punch_end = 46, shoot_start = 150, shoot_end = 200, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/stone_eater.lua b/mobs/stone_eater.lua index d83f16b..af790af 100644 --- a/mobs/stone_eater.lua +++ b/mobs/stone_eater.lua @@ -59,4 +59,5 @@ mobs:register_mob("nssm:stone_eater", { --digging_ability(self, "stone", self.run_velocity, {x=0, y=2, z=0}) digging_attack(self, "stone", self.run_velocity, {x=0, y=1, z=0}) end, + on_die= __NSSM_kill_count, }) diff --git a/mobs/swimming_duck.lua b/mobs/swimming_duck.lua index 7bda43a..55ae924 100644 --- a/mobs/swimming_duck.lua +++ b/mobs/swimming_duck.lua @@ -59,5 +59,6 @@ mobs:register_mob("nssm:swimming_duck", { run_end = 120, punch_start = 140, punch_end = 160, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/tarantula.lua b/mobs/tarantula.lua index ec2e4ff..04d4a51 100644 --- a/mobs/tarantula.lua +++ b/mobs/tarantula.lua @@ -141,5 +141,6 @@ mobs:register_mob("nssm:tarantula_propower", { run_end = 160, punch_start = 180, punch_end = 200, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/uloboros.lua b/mobs/uloboros.lua index 0a52615..bf5b051 100644 --- a/mobs/uloboros.lua +++ b/mobs/uloboros.lua @@ -64,4 +64,5 @@ mobs:register_mob("nssm:uloboros", { do_custom = function(self) webber_ability(self, "nssm:web", 2) end, + on_die= __NSSM_kill_count, }) diff --git a/mobs/werewolf.lua b/mobs/werewolf.lua index 367faf2..9b35e57 100644 --- a/mobs/werewolf.lua +++ b/mobs/werewolf.lua @@ -54,5 +54,6 @@ mobs:register_mob("nssm:werewolf", { run_end = 160, punch_start = 170, punch_end = 193, - } + }, + on_die= __NSSM_kill_count, }) diff --git a/mobs/white_werewolf.lua b/mobs/white_werewolf.lua index 35d5682..3f3d25d 100644 --- a/mobs/white_werewolf.lua +++ b/mobs/white_werewolf.lua @@ -54,5 +54,6 @@ mobs:register_mob("nssm:white_werewolf", { run_end = 160, punch_start = 170, punch_end = 193, - } + }, + on_die= __NSSM_kill_count, })