ctf_classes: Award points to medic for healing (#606)

This commit is contained in:
MinetestSam 2020-05-14 22:56:28 +05:30 committed by GitHub
parent eddd04168b
commit 1fda60bbbc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 3 deletions

View file

@ -16,7 +16,7 @@ globals = {
"ctf_colors", "hudkit", "default", "treasurer", "ChatCmdBuilder", "ctf_map",
"ctf_match", "ctf_stats", "ctf_treasure", "ctf_playertag", "chatplus", "irc",
"armor", "vote", "give_initial_stuff", "hud_score", "physics", "tsm_chests",
"armor", "shooter", "grenades", "ctf_classes"
"armor", "shooter", "grenades", "ctf_classes", "ctf_bandages"
}
read_globals = {

View file

@ -5,7 +5,7 @@ ctf_classes = {
dofile(minetest.get_modpath("ctf_classes") .. "/api.lua")
dofile(minetest.get_modpath("ctf_classes") .. "/gui.lua")
dofile(minetest.get_modpath("ctf_classes") .. "/regen.lua")
dofile(minetest.get_modpath("ctf_classes") .. "/medic.lua")
dofile(minetest.get_modpath("ctf_classes") .. "/ranged.lua")
dofile(minetest.get_modpath("ctf_classes") .. "/items.lua")
dofile(minetest.get_modpath("ctf_classes") .. "/flags.lua")

View file

@ -63,3 +63,37 @@ minetest.register_globalstep(function(delta)
regen_update()
end)
local bandage_on_use = minetest.registered_items["ctf_bandages:bandage"].on_use
minetest.override_item("ctf_bandages:bandage", {
on_use = function(stack, user, pointed_thing)
if pointed_thing.type ~= "object" then
return
end
local object = pointed_thing.ref
if not object:is_player() then
return
end
local pname = object:get_player_name()
local name = user:get_player_name()
if ctf.player(pname).team == ctf.player(name).team then
local hp = object:get_hp()
local limit = ctf_bandages.heal_percent * object:get_properties().hp_max
if hp > 0 and hp < limit then
local main, match = ctf_stats.player(name)
if main and match then
local reward = 5
main.score = main.score + reward
match.score = match.score + reward
hud_score.new(name, {
name = "ctf_stats:heal_score",
color = "0x00FF00",
value = reward
})
end
end
end
return bandage_on_use(stack, user, pointed_thing)
end
})

View file

@ -1,3 +1,3 @@
name = ctf_classes
depends = ctf, ctf_flag, ctf_colors, ctf_map_core, ctf_bandages, physics, shooter, hpregen, give_initial_stuff, dropondie, crafting
depends = ctf, ctf_flag, ctf_colors, ctf_map_core, ctf_stats, ctf_bandages, physics, shooter, hpregen, give_initial_stuff, dropondie, crafting
description = Adds classes, including knight, shooter, and medic