Added Guns alongside other changes

This commit is contained in:
IamPyu 2024-12-28 20:13:36 -06:00
parent d438ec5f47
commit 55233863bd
16 changed files with 108 additions and 53 deletions

View File

@ -15,6 +15,7 @@ Game Changes:
- Cauldrons no longer drain its fuel.
- Instant Health potions can now be brewed.
- Added 3D model to players.
- Added guns
Bugfixes:

Binary file not shown.

View File

@ -6,17 +6,28 @@ local class = {
function class:on_step(dtime, moveresult)
local slowdown_speed = self._slowdown_speed or 0.98
local slowdown = self._slowdown
local godown = self._godown
if slowdown == nil then
slowdown = true
end
if godown == nil then
godown = false
end
if slowdown then
local vel = self.object:get_velocity()
vel = vector.multiply(vel, slowdown_speed)
self.object:set_velocity(vel)
end
if godown and not slowdown then
local vel = self.object:get_velocity()
vel.y = vel.y - (5 * dtime)
self.object:set_velocity(vel)
end
for _, v in pairs(moveresult.collisions) do
if v.type == "node" then
self._collided = true
@ -55,9 +66,12 @@ PyuTest.make_projectile = function (name, properties, options, functions)
}, options or {}), { __index = class }))
end
PyuTest.shoot_projectile_from_object = function(name, object, velocity)
PyuTest.shoot_projectile_from_object = function(name, object, velocity, offset)
local pos = object:get_pos()
pos = vector.offset(pos, 0, 1.3, 0)
if offset ~= nil then
pos = vector.offset(pos, offset.x, offset.y, offset.z)
end
local pvel = velocity or 30
@ -68,7 +82,7 @@ PyuTest.shoot_projectile_from_object = function(name, object, velocity)
local projectile = core.add_entity(pos, name)
projectile:set_velocity(vector.multiply(dir, pvel))
projectile:set_rotation(object:get_look_dir())
-- projectile:set_rotation(object:get_look_dir())
projectile:get_luaentity()._owner = object
return projectile

View File

@ -23,11 +23,11 @@ PyuTest.make_electricity_device("pyutest_electricity:heater_device", "Heater Dev
if core.get_item_group(n.name, "thawable") ~= 0 then
local def = core.registered_nodes[n.name]
local thaw_into = def.__thaw_into or "pyutest_blocks:water_source"
local thaw_into = def.__pyutest_thaw_into or "pyutest_blocks:water_source"
core.set_node(p, { name = thaw_into })
elseif core.get_item_group(n.name, "heatable") ~= 0 then
local def = core.registered_nodes[n.name]
local heat_into = def.__heat_into or "pyutest_blocks:lava_source"
local heat_into = def.__pyutest_heat_into or "pyutest_blocks:lava_source"
core.set_node(p, { name = heat_into })
end
end)

View File

@ -1 +1 @@
depends = pyutest_blocks,pyutest_cmds,pyutest_tools,pyutest_ores
depends = pyutest_blocks,pyutest_cmds,pyutest_tools,pyutest_ores,pyutest_mithril

View File

@ -0,0 +1,47 @@
PyuTest.make_gun = function(name, desc, texture, cooldown, damage)
local bullet_id = name .. "_bullet"
local cd = cooldown or 1
PyuTest.make_tool(name, desc, {
tool = 1,
gun = 1,
}, texture, {
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
PyuTest.shoot_projectile_from_object(bullet_id, user, 35)
core.sound_play("pyutest_shoot", {
pos = user:get_pos()
})
return itemstack
end,
})
PyuTest.make_projectile(bullet_id, {
visual_size = {x = 0.2, y = 0.2},
textures = {
"pyutest-bullet.png",
"pyutest-bullet.png",
"pyutest-bullet.png",
"pyutest-bullet.png",
"pyutest-bullet.png",
"pyutest-bullet.png",
}
}, {
_slowdown = false,
_godown = true,
}, {
on_hit_node = function(self, pos, node) end,
on_hit_object = function(self, object)
if not self._owner:is_valid() then
return
end
PyuTest.deal_damage(object, damage, {
type = "punch",
object = self._owner
})
end
})
end

View File

@ -0,0 +1,8 @@
local modpath = core.get_modpath(core.get_current_modname())
dofile(modpath .. "/api.lua")
PyuTest.make_gun("pyutest_guns:flintlock", "Flintlock",
"pyutest-flintlock.png", 2, 6)
PyuTest.make_gun("pyutest_guns:blunderbuss", "Blunderbuss", "pyutest-blunderbuss.png",
5, 12)

View File

@ -0,0 +1 @@
depends = pyutest_tools,pyutest_projectiles

View File

@ -20,6 +20,12 @@ PyuTest.make_ore_and_item("pyutest_mithril:mithril", "Mithril", "shard", "Shard"
block_shiny = true,
})
PyuTest.make_item("pyutest_mithril:electricfied_mithril", "Electricfied Mithril", {
mineral = 1,
}, "pyutest-shard.png", {
color = "#82a8fe"
})
PyuTest.make_tool("pyutest_mithril:mithril_pickaxe", "Mithril Pickaxe", {
pickaxe = 1
}, "pyutest-mithril-pickaxe.png", {
@ -95,3 +101,12 @@ core.register_craft({
{ "pyutest_tools:basalt_stick" }
}
})
core.register_craft({
output = "pyutest_mithril:electrified_mithril",
recipe = {
"pyutest_ores:copper_ingot",
"pyutest_mithril:mithril_shard"
},
type = "shapeless"
})

View File

@ -1,5 +1,5 @@
PyuTest.registered_wood = {}
PyuTest.make_wood = function(id, desc, ltiles, btiles)
PyuTest.make_wood = function(id, desc, ltiles, btiles, lbtiles)
PyuTest.make_building_blocks(id .. "_log", desc .. " Log", ltiles, nil, {
choppy = PyuTest.BLOCK_NORMAL,
acid_vulnerable = 1,
@ -18,6 +18,16 @@ PyuTest.make_wood = function(id, desc, ltiles, btiles)
is_ground_content = false
})
PyuTest.make_building_blocks(id .. "_full_log", desc .. " Full Log", lbtiles or
{ltiles[3]}, nil, {
choppy = PyuTest.BLOCK_NORMAL,
acid_vulnerable = 1,
flammable = 1,
_pyutest_blast_resistance = 2
}, {
is_ground_content = false
})
local log_id = id .. "_log_block"
local planks_id = id .. "_wood_block"

View File

@ -1,9 +1,9 @@
PyuTest.chatcommand_entity_selector = function(caller, param)
local p_caller = core.get_player_by_name(caller)
-- if param == nil then
-- return {param}
-- end
if core.get_player_by_name(param) ~= nil then
return {param}
end
if param == "@self" or param == "@s" then
return {caller}
@ -69,7 +69,8 @@ PyuTest.parse_command_functions = function(runner, param)
local str = param
-- embed the output of command
str = str:gsub(".embed<([^%s]+)>", function(input)
str = str:gsub("$embed<([^%s]+)>", function(input)
core.log(input)
return PyuTest.execute_as(runner, input) or ""
end)

View File

@ -1 +1 @@
depends = unified_inventory,pyutest_blocks,pyutest_furniture,pyutest_ores,pyutest_wool,pyutest_wood,pyutest_flowers,pyutest_electricity
depends = unified_inventory,pyutest_blocks,pyutest_furniture,pyutest_ores,pyutest_wool,pyutest_wood,pyutest_flowers,pyutest_electricity,pyutest_guns,pyutest_mithril

View File

@ -9,8 +9,6 @@ PyuTest.register_overworld_biome("Plains", PyuTest.BIOME_TYPES.NORMAL, {
heat_point = 65,
humidity_point = 40,
weight = PyuTest.BIOME_WEIGHTS.large,
_pyutest_biome_flowering = true,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.NORMAL,
})
@ -25,8 +23,6 @@ PyuTest.register_overworld_biome("Forest", PyuTest.BIOME_TYPES.NORMAL, {
heat_point = 50,
humidity_point = 80,
weight = PyuTest.BIOME_WEIGHTS.big,
_pyutest_biome_flowering = true,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.LUSH,
})
@ -41,8 +37,6 @@ PyuTest.register_overworld_biome("BirchForest", PyuTest.BIOME_TYPES.NORMAL, {
heat_point = 50,
humidity_point = 84,
weight = PyuTest.BIOME_WEIGHTS.big,
_pyutest_biome_flowering = true,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.NORMAL,
})
@ -57,8 +51,6 @@ PyuTest.register_overworld_biome("OldGrowthBirchForest", PyuTest.BIOME_TYPES.NOR
heat_point = 50,
humidity_point = 87,
weight = PyuTest.BIOME_WEIGHTS.big,
_pyutest_biome_flowering = true,
_pyutest_biome_flowering_extra = true,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.NORMAL,
@ -75,8 +67,6 @@ PyuTest.register_overworld_biome("Meadow", PyuTest.BIOME_TYPES.NORMAL, {
heat_point = 50,
humidity_point = 83,
weight = PyuTest.BIOME_WEIGHTS.big,
_enable_beaches = false,
_pyutest_biome_flowering = true,
_pyutest_biome_flowering_extra = true,
@ -93,8 +83,6 @@ PyuTest.register_overworld_biome("CherryGrove", PyuTest.BIOME_TYPES.NORMAL, {
heat_point = 50,
humidity_point = 85,
weight = PyuTest.BIOME_WEIGHTS.small,
_enable_beaches = false,
_pyutest_biome_flowering = true,
_pyutest_biome_flowering_extra = true,
@ -115,8 +103,6 @@ PyuTest.register_overworld_biome("Desert", PyuTest.BIOME_TYPES.HOT, {
heat_point = 80,
humidity_point = 0,
weight = PyuTest.BIOME_WEIGHTS.vast,
_enable_beaches = false,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.DRY,
})
@ -131,7 +117,6 @@ PyuTest.register_overworld_biome("Savanna", PyuTest.BIOME_TYPES.WARM, {
heat_point = 75,
humidity_point = 0,
weight = PyuTest.BIOME_WEIGHTS.large,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.DRY,
})
@ -146,8 +131,6 @@ PyuTest.register_overworld_biome("MushroomFields", PyuTest.BIOME_TYPES.NORMAL, {
heat_point = 50,
humidity_point = 94,
weight = PyuTest.BIOME_WEIGHTS.tiny,
_enable_beaches = false,
_pyutest_fog_distance = 60,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.SWAMP,
@ -163,8 +146,6 @@ PyuTest.register_overworld_biome("LargeMushroomForest", PyuTest.BIOME_TYPES.NORM
heat_point = 50,
humidity_point = 95,
weight = PyuTest.BIOME_WEIGHTS.tiny,
_enable_beaches = false,
_pyutest_fog_distance = 60,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.SWAMP,
@ -180,8 +161,6 @@ PyuTest.register_overworld_biome("Swamp", PyuTest.BIOME_TYPES.WETLAND, {
heat_point = 50,
humidity_point = 100,
weight = PyuTest.BIOME_WEIGHTS.tiny,
_enable_beaches = false,
_pyutest_fog_distance = 60,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.SWAMP,
@ -198,8 +177,6 @@ PyuTest.register_overworld_biome("Taiga", PyuTest.BIOME_TYPES.CHILLY, {
heat_point = 20,
humidity_point = 72,
weight = PyuTest.BIOME_WEIGHTS.normal,
_pyutest_biome_flowering = true,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.DARK,
})
@ -214,7 +191,6 @@ PyuTest.register_overworld_biome("OldGrowthPineTaiga", PyuTest.BIOME_TYPES.CHILL
heat_point = 26,
humidity_point = 73,
weight = PyuTest.BIOME_WEIGHTS.large,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.DARK,
})
@ -228,8 +204,6 @@ PyuTest.register_overworld_biome("AspenForest", PyuTest.BIOME_TYPES.CHILLY, {
heat_point = 19,
humidity_point = 74,
weight = PyuTest.BIOME_WEIGHTS.small,
_pyutest_biome_flowering = true,
_pyutest_fog_distance = 60,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.ASPEN,
@ -245,8 +219,6 @@ PyuTest.register_overworld_biome("RedwoodForest", PyuTest.BIOME_TYPES.CHILLY, {
heat_point = 23,
humidity_point = 76,
weight = PyuTest.BIOME_WEIGHTS.small,
_pyutest_biome_flowering = true,
_pyutest_fog_distance = 60,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.DARK,
@ -262,8 +234,6 @@ PyuTest.register_overworld_biome("OminousForest", PyuTest.BIOME_TYPES.CHILLY, {
heat_point = 19,
humidity_point = 81,
weight = PyuTest.BIOME_WEIGHTS.tiny,
_pyutest_fog_distance = 45,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.MAGIC,
})
@ -283,7 +253,6 @@ PyuTest.register_overworld_biome("FrozenPlains", PyuTest.BIOME_TYPES.COLD, {
heat_point = 0,
humidity_point = 73,
weight = PyuTest.BIOME_WEIGHTS.large,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.SNOW,
})
@ -301,7 +270,6 @@ PyuTest.register_overworld_biome("SnowyForest", PyuTest.BIOME_TYPES.COLD, {
heat_point = 0,
humidity_point = 78,
weight = PyuTest.BIOME_WEIGHTS.large,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.SNOW,
})
@ -318,8 +286,6 @@ PyuTest.register_overworld_biome("IceSpikes", PyuTest.BIOME_TYPES.COLD, {
heat_point = 0,
humidity_point = 75,
weight = PyuTest.BIOME_WEIGHTS.large,
_enable_beaches = false,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.SNOW,
})
@ -337,8 +303,6 @@ PyuTest.register_overworld_biome("StonyPeaks", PyuTest.BIOME_TYPES.CHILLY, {
vertical_blend = 8,
weight = PyuTest.BIOME_WEIGHTS.large,
_enable_beaches = false,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.DRY,
})
@ -356,8 +320,6 @@ PyuTest.register_overworld_biome("FrozenPeaks", PyuTest.BIOME_TYPES.COLD, {
vertical_blend = 8,
weight = PyuTest.BIOME_WEIGHTS.large,
_enable_beaches = false,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.SNOW,
})
@ -374,8 +336,6 @@ PyuTest.register_overworld_biome("JaggedPeaks", PyuTest.BIOME_TYPES.COLD, {
vertical_blend = 8,
weight = PyuTest.BIOME_WEIGHTS.large,
_enable_beaches = false,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.SNOW,
})
@ -392,8 +352,6 @@ PyuTest.register_overworld_biome("Grove", PyuTest.BIOME_TYPES.COLD, {
vertical_blend = 8,
weight = PyuTest.BIOME_WEIGHTS.large,
_enable_beaches = false,
_pyutest_foliage_index = PyuTest.FOLIAGE_TYPES.SNOW,
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

BIN
textures/pyutest-bullet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B