DevTest: Add more test weapons and armorball modes (#11870)

Co-authored-by: sfan5 <sfan5@live.de>
This commit is contained in:
Wuzzy 2022-04-24 21:48:50 +00:00 committed by GitHub
parent b55d7cd45a
commit 77325b92fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 129 additions and 34 deletions

@ -279,50 +279,135 @@ minetest.register_tool("basetools:sword_wood", {
}) })
minetest.register_tool("basetools:sword_stone", { minetest.register_tool("basetools:sword_stone", {
description = "Stone Sword".."\n".. description = "Stone Sword".."\n"..
"Damage: fleshy=4", "Damage: fleshy=5",
inventory_image = "basetools_stonesword.png", inventory_image = "basetools_stonesword.png",
tool_capabilities = { tool_capabilities = {
full_punch_interval = 1.0, full_punch_interval = 1.0,
max_drop_level=0, max_drop_level=0,
damage_groups = {fleshy=4}, damage_groups = {fleshy=5},
} }
}) })
minetest.register_tool("basetools:sword_steel", { minetest.register_tool("basetools:sword_steel", {
description = "Steel Sword".."\n".. description = "Steel Sword".."\n"..
"Damage: fleshy=6", "Damage: fleshy=10",
inventory_image = "basetools_steelsword.png", inventory_image = "basetools_steelsword.png",
tool_capabilities = { tool_capabilities = {
full_punch_interval = 1.0, full_punch_interval = 1.0,
max_drop_level=1, max_drop_level=1,
damage_groups = {fleshy=6}, damage_groups = {fleshy=10},
}
})
minetest.register_tool("basetools:sword_titanium", {
description = "Titanium Sword".."\n"..
"Damage: fleshy=100",
inventory_image = "basetools_titaniumsword.png",
tool_capabilities = {
full_punch_interval = 1.0,
max_drop_level=1,
damage_groups = {fleshy=100},
}
})
minetest.register_tool("basetools:sword_blood", {
description = "Blood Sword".."\n"..
"Damage: fleshy=1000",
inventory_image = "basetools_bloodsword.png",
tool_capabilities = {
full_punch_interval = 1.0,
max_drop_level=1,
damage_groups = {fleshy=1000},
}
})
-- Max. damage sword
minetest.register_tool("basetools:sword_mese", {
description = "Mese Sword".."\n"..
"Damage: fleshy=32767, fiery=32767, icy=32767".."\n"..
"Full Punch Interval: 0.0s",
inventory_image = "basetools_mesesword.png",
tool_capabilities = {
full_punch_interval = 0.0,
max_drop_level=1,
damage_groups = {fleshy=32767, fiery=32767, icy=32767},
} }
}) })
-- Fire/Ice sword: Deal damage to non-fleshy damage groups -- Fire/Ice sword: Deal damage to non-fleshy damage groups
minetest.register_tool("basetools:sword_fire", { minetest.register_tool("basetools:sword_fire", {
description = "Fire Sword".."\n".. description = "Fire Sword".."\n"..
"Damage: icy=6", "Damage: icy=10",
inventory_image = "basetools_firesword.png", inventory_image = "basetools_firesword.png",
tool_capabilities = { tool_capabilities = {
full_punch_interval = 1.0, full_punch_interval = 1.0,
max_drop_level=0, max_drop_level=0,
damage_groups = {icy=6}, damage_groups = {icy=10},
} }
}) })
minetest.register_tool("basetools:sword_ice", { minetest.register_tool("basetools:sword_ice", {
description = "Ice Sword".."\n".. description = "Ice Sword".."\n"..
"Damage: fiery=6", "Damage: fiery=10",
inventory_image = "basetools_icesword.png", inventory_image = "basetools_icesword.png",
tool_capabilities = { tool_capabilities = {
full_punch_interval = 1.0, full_punch_interval = 1.0,
max_drop_level=0, max_drop_level=0,
damage_groups = {fiery=6}, damage_groups = {fiery=10},
} }
}) })
minetest.register_tool("basetools:sword_elemental", {
description = "Elemental Sword".."\n"..
"Damage: fiery=10, icy=10",
inventory_image = "basetools_elementalsword.png",
tool_capabilities = {
full_punch_interval = 1.0,
max_drop_level=0,
damage_groups = {fiery=10, icy=10},
}
})
-- Healing weapons: heal HP
minetest.register_tool("basetools:dagger_heal", {
description = "Healing Dagger".."\n"..
"Heal: fleshy=1".."\n"..
"Full Punch Interval: 0.5s",
inventory_image = "basetools_healdagger.png",
tool_capabilities = {
full_punch_interval = 0.5,
damage_groups = {fleshy=-1},
}
})
minetest.register_tool("basetools:sword_heal", {
description = "Healing Sword".."\n"..
"Heal: fleshy=10",
inventory_image = "basetools_healsword.png",
tool_capabilities = {
full_punch_interval = 1.0,
damage_groups = {fleshy=-10},
}
})
minetest.register_tool("basetools:sword_heal_super", {
description = "Super Healing Sword".."\n"..
"Heal: fleshy=32768, fiery=32768, icy=32768",
inventory_image = "basetools_superhealsword.png",
tool_capabilities = {
full_punch_interval = 1.0,
damage_groups = {fleshy=-32768, fiery=-32768, icy=-32768},
}
})
-- --
-- Dagger: Low damage, fast punch interval -- Dagger: Low damage, fast punch interval
-- --
minetest.register_tool("basetools:dagger_wood", {
description = "Wooden Dagger".."\n"..
"Damage: fleshy=1".."\n"..
"Full Punch Interval: 0.5s",
inventory_image = "basetools_wooddagger.png",
tool_capabilities = {
full_punch_interval = 0.5,
max_drop_level=0,
damage_groups = {fleshy=1},
}
})
minetest.register_tool("basetools:dagger_steel", { minetest.register_tool("basetools:dagger_steel", {
description = "Steel Dagger".."\n".. description = "Steel Dagger".."\n"..
"Damage: fleshy=2".."\n".. "Damage: fleshy=2".."\n"..
@ -343,7 +428,7 @@ for i=1, #uses do
minetest.register_tool("basetools:pick_uses_"..string.format("%05d", u), { minetest.register_tool("basetools:pick_uses_"..string.format("%05d", u), {
description = u.."-Uses Pickaxe".."\n".. description = u.."-Uses Pickaxe".."\n"..
"Digs cracky=3", "Digs cracky=3",
inventory_image = "basetools_steelpick.png^[colorize:"..color..":127", inventory_image = "basetools_usespick.png^[colorize:"..color..":127",
tool_capabilities = { tool_capabilities = {
max_drop_level=0, max_drop_level=0,
groupcaps={ groupcaps={
@ -355,7 +440,7 @@ for i=1, #uses do
minetest.register_tool("basetools:sword_uses_"..string.format("%05d", u), { minetest.register_tool("basetools:sword_uses_"..string.format("%05d", u), {
description = u.."-Uses Sword".."\n".. description = u.."-Uses Sword".."\n"..
"Damage: fleshy=1", "Damage: fleshy=1",
inventory_image = "basetools_woodsword.png^[colorize:"..color..":127", inventory_image = "basetools_usessword.png^[colorize:"..color..":127",
tool_capabilities = { tool_capabilities = {
damage_groups = {fleshy=1}, damage_groups = {fleshy=1},
punch_attack_uses = u, punch_attack_uses = u,

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

@ -4,10 +4,19 @@
local phasearmor = { local phasearmor = {
[0]={icy=100}, [0]={icy=100},
[1]={fiery=100}, [1]={fiery=100},
[2]={fleshy=100}, [2]={icy=100, fiery=100},
[3]={immortal=1}, [3]={fleshy=-100},
[4]={punch_operable=1}, [4]={fleshy=1},
[5]={fleshy=10},
[6]={fleshy=50},
[7]={fleshy=100},
[8]={fleshy=200},
[9]={fleshy=1000},
[10]={fleshy=32767},
[11]={immortal=1},
[12]={punch_operable=1},
} }
local max_phase = 12
minetest.register_entity("testentities:armorball", { minetest.register_entity("testentities:armorball", {
initial_properties = { initial_properties = {
@ -21,7 +30,7 @@ minetest.register_entity("testentities:armorball", {
initial_sprite_basepos = {x=0, y=0}, initial_sprite_basepos = {x=0, y=0},
}, },
_phase = 2, _phase = 7,
on_activate = function(self, staticdata) on_activate = function(self, staticdata)
minetest.log("action", "[testentities] armorball.on_activate") minetest.log("action", "[testentities] armorball.on_activate")
@ -32,10 +41,21 @@ minetest.register_entity("testentities:armorball", {
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
-- Change armor group and sprite -- Change armor group and sprite
self._phase = self._phase + 1 self._phase = self._phase + 1
if self._phase >= 5 then if self._phase >= max_phase + 1 then
self._phase = 0 self._phase = 0
end end
self.object:set_sprite({x=0, y=self._phase}) self.object:set_sprite({x=0, y=self._phase})
self.object:set_armor_groups(phasearmor[self._phase]) self.object:set_armor_groups(phasearmor[self._phase])
end, end,
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)
if not puncher then
return
end
local name = puncher:get_player_name()
if not name then
return
end
minetest.chat_send_player(name, "time_from_last_punch="..string.format("%.3f", time_from_last_punch).."; damage="..tostring(damage))
end,
}) })

Binary file not shown.

Before

Width:  |  Height:  |  Size: 561 B

After

Width:  |  Height:  |  Size: 1.3 KiB

@ -1,17 +1,7 @@
local full_description = "Colorful Pickaxe\nThe best pick." local full_description = "Description Test Item\nFor testing item decription"
minetest.register_tool("unittests:colorful_pick", { minetest.register_tool("unittests:description_test", {
description = full_description, description = full_description,
inventory_image = "basetools_mesepick.png", inventory_image = "unittests_description_test.png",
tool_capabilities = {
full_punch_interval = 1.0,
max_drop_level=3,
groupcaps={
cracky={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3},
crumbly={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3},
snappy={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}
},
damage_groups = {fleshy=4},
},
}) })
minetest.register_chatcommand("item_description", { minetest.register_chatcommand("item_description", {
@ -30,18 +20,18 @@ local function test_short_desc()
return ItemStack(item):get_short_description() return ItemStack(item):get_short_description()
end end
local stack = ItemStack("unittests:colorful_pick") local stack = ItemStack("unittests:description_test")
assert(stack:get_short_description() == "Colorful Pickaxe") assert(stack:get_short_description() == "Description Test Item")
assert(get_short_description("unittests:colorful_pick") == "Colorful Pickaxe") assert(get_short_description("unittests:description_test") == "Description Test Item")
assert(minetest.registered_items["unittests:colorful_pick"].short_description == nil) assert(minetest.registered_items["unittests:description_test"].short_description == nil)
assert(stack:get_description() == full_description) assert(stack:get_description() == full_description)
assert(stack:get_description() == minetest.registered_items["unittests:colorful_pick"].description) assert(stack:get_description() == minetest.registered_items["unittests:description_test"].description)
stack:get_meta():set_string("description", "Hello World") stack:get_meta():set_string("description", "Hello World")
assert(stack:get_short_description() == "Hello World") assert(stack:get_short_description() == "Hello World")
assert(stack:get_description() == "Hello World") assert(stack:get_description() == "Hello World")
assert(get_short_description(stack) == "Hello World") assert(get_short_description(stack) == "Hello World")
assert(get_short_description("unittests:colorful_pick") == "Colorful Pickaxe") assert(get_short_description("unittests:description_test") == "Description Test Item")
stack:get_meta():set_string("short_description", "Foo Bar") stack:get_meta():set_string("short_description", "Foo Bar")
assert(stack:get_short_description() == "Foo Bar") assert(stack:get_short_description() == "Foo Bar")

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B