Change rocket mechanics

This commit is contained in:
philipmi 2022-07-01 23:24:57 +02:00
parent 56f99fb271
commit 19c897cc98
5 changed files with 84 additions and 9 deletions

View file

@ -2,8 +2,8 @@ ctf_classes.default_class = "knight"
ctf_classes.register("knight", {
description = "Knight",
pros = { ">Skilled with swords", "> +50% health points" },
cons = { "> -10% speed" },
pros = { "* Skilled with swords", "* +50% health points" },
cons = { "* -10% speed" },
color = "#ccc",
properties = {
max_hp = 30,
@ -23,8 +23,8 @@ ctf_classes.register("knight", {
ctf_classes.register("shooter", {
description = "Sharp Shooter",
pros = { ">Skilled with ranged", "weapons and can", "craft/use sniper rifles"},
cons = { "> -20% health points" },
pros = { "* Skilled with ranged", "weapons and can", "craft/use sniper rifles"},
cons = { "* -20% health points" },
color = "#c60",
properties = {
allow_grapples = true,
@ -72,7 +72,7 @@ ctf_classes.register("shooter", {
ctf_classes.register("medic", {
description = "Medic",
pros = { ">x2 regen for nearby", "friendlies", ">Building supplies +", "Paxel", "> +10% speed" },
pros = { "* x2 regen for nearby", "friendlies", "* Building supplies +", "Paxel", "* +10% speed" },
cons = {},
color = "#0af",
properties = {
@ -156,8 +156,8 @@ ctf_classes.register("sniper", {
ctf_classes.register("rocketeer", {
description = "Rocketeer",
pros = { ">Can craft/use rockets" },
cons = { "> -25% health points" },
pros = { "* Can craft/use rockets", "Can't capture the flag" },
cons = { "* -25% health points" },
color = "#fa0",
properties = {
-- Disallow rocketeers from capturing flags - they're intended to be support
@ -167,7 +167,8 @@ ctf_classes.register("rocketeer", {
initial_stuff = {
"shooter_rocket:rocket_gun_loaded",
"shooter_rocket:rocket 4",
"ctf_classes:rocket",
"shooter_rocket:rocket 3",
},
additional_item_blacklist = {

View file

@ -11,6 +11,7 @@ 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")
dofile(minetest.get_modpath("ctf_classes") .. "/update_wear.lua")
minetest.register_on_joinplayer(function(player)

View file

@ -122,3 +122,9 @@ minetest.registered_entities["shooter_hook:hook"].on_step = function(self, dtime
return old_grapple_step(self, dtime, ...)
end
minetest.register_tool("ctf_classes:rocket", {
description = "Rocket",
stack_max = 1,
inventory_image = "shooter_rocket_inv.png",
})

View file

@ -0,0 +1,67 @@
-- ported from v3
local wear_timers = {}
ctf_classes.update_wear = {}
function ctf_classes.update_wear.find_item(pinv, item)
for pos, stack in pairs(pinv:get_list("main")) do
if stack:get_name() == item then
return pos, stack
end
end
end
function ctf_classes.update_wear.start_update(pname, item, step, down, finish_callback, cancel_callback)
if not wear_timers[pname] then wear_timers[pname] = {} end
if wear_timers[pname][item] then return end
wear_timers[pname][item] = {c=cancel_callback, t=minetest.after(1, function()
wear_timers[pname][item] = nil
local player = minetest.get_player_by_name(pname)
if player then
local pinv = player:get_inventory()
local pos, stack = ctf_classes.update_wear.find_item(pinv, item)
if pos then
local wear = stack:get_wear()
if down then
wear = math.max(0, wear - step)
else
wear = math.min(65534, wear + step)
end
stack:set_wear(wear)
pinv:set_stack("main", pos, stack)
if (down and wear > 0) or (not down and wear < 65534) then
ctf_classes.update_wear.start_update(pname, item, step, down, finish_callback, cancel_callback)
elseif finish_callback then
finish_callback()
end
end
end
end)}
end
function ctf_classes.update_wear.cancel_player_updates(pname)
if wear_timers[pname] then
for _, timer in pairs(wear_timers[pname]) do
if timer.c then
timer.c()
end
timer.t:cancel()
end
wear_timers[pname] = nil
end
end
minetest.register_on_dieplayer(function(player)
ctf_classes.update_wear.cancel_player_updates(player)
end)
minetest.register_on_leaveplayer(function(player)
ctf_classes.update_wear.cancel_player_updates(player)
end)

@ -1 +1 @@
Subproject commit 4733f7e6c792477a702aa172bed34df68e0c8e79
Subproject commit bb8775c3bbe48d77a7dbdbc4c08088500b6605a6