Increase sword damage dealt by knights (#684)

* Extra sword damage for knights

* Make steel sword craftable
This commit is contained in:
LoneWolfHT 2020-10-13 08:42:41 -07:00 committed by GitHub
parent 037eb8ba96
commit 9666b03ea3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 1 deletions

View file

@ -2,12 +2,13 @@ ctf_classes.default_class = "knight"
ctf_classes.register("knight", {
description = "Knight",
pros = { "+50% health points" },
pros = { "Skilled with swords", "+50% health points" },
cons = { "-10% speed" },
color = "#ccc",
properties = {
max_hp = 30,
speed = 0.90,
melee_bonus = 1,
initial_stuff = {
"default:sword_steel",

View file

@ -7,6 +7,7 @@ dofile(minetest.get_modpath("ctf_classes") .. "/api.lua")
dofile(minetest.get_modpath("ctf_classes") .. "/gui.lua")
dofile(minetest.get_modpath("ctf_classes") .. "/medic.lua")
dofile(minetest.get_modpath("ctf_classes") .. "/ranged.lua")
dofile(minetest.get_modpath("ctf_classes") .. "/melee.lua")
dofile(minetest.get_modpath("ctf_classes") .. "/items.lua")
dofile(minetest.get_modpath("ctf_classes") .. "/flags.lua")
dofile(minetest.get_modpath("ctf_classes") .. "/classes.lua")

View file

@ -0,0 +1,13 @@
minetest.register_on_player_hpchange(function(player, hp_change, reason)
if reason.type ~= "punch" or not reason.object or not reason.object:is_player() then
return hp_change
end
local class = ctf_classes.get(reason.object)
if class.properties.melee_bonus and reason.object:get_wielded_item():get_name():find("sword") then
return hp_change - class.properties.melee_bonus
end
return hp_change
end, true)

View file

@ -7,6 +7,7 @@ local full_ores = {
}
local sword_materials = {
steel = "default:steel_ingot",
mese = "default:mese_crystal",
diamond = "default:diamond",
}