Skip to content

Commit

Permalink
Remove mods: Arrows, Throwing, Lottthrowing (closes #921)
Browse files Browse the repository at this point in the history
Lord Archery: add all axes (closes #1867, #1868)
Lord Archery: move all arrows, bows etc. to the new archery engine (closes #1523, #1863)
Lord Archery: mobs are now using new archery engine
Lord Archery: added crafts
Lord Archery: mobs are now aggroed on hit (closes #1874)
  • Loading branch information
Doloment authored and alek13 committed Dec 30, 2024
1 parent 97113ab commit a11ccbe
Show file tree
Hide file tree
Showing 133 changed files with 856 additions and 1,702 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/luacheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Check Cyclomatic Complexity
run: |
$HOME/.luarocks/bin/luacheck . --max-cyclomatic-complexity 10 \
--globals lottachievements races throwing \
--globals lottachievements races \
--exclude-files \
mods/_minetest_game/ \
mods/lord/_overwrites/MTG/default/ \
Expand All @@ -43,9 +43,7 @@ jobs:
mods/lord/Blocks/protector_lott/ \
mods/lord/Blocks/signs_lib/ \
mods/lord/Blocks/technic_chests/ \
mods/lord/Entities/throwing/ \
mods/lord/Entities/npc/ \
mods/lord/Entities/lottthrowing/ \
mods/lord/Entities/lottmobs/ \
mods/lord/Game/lottachievements/ \
mods/lord/Game/lord_classes/ \
Expand Down
7 changes: 6 additions & 1 deletion mods/_various/mobs/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,7 @@ local do_states = function(self, dtime)
-- calculate distance from mob and enemy
local s = self.object:get_pos()
local p = self.attack:get_pos() or s
local shoot_dir = vector.normalize(vector.add(vector.subtract(p, s), vector.new(0, 2, 0)))
local dist = get_distance(p, s)

-- stop attacking if player or out of range
Expand Down Expand Up @@ -1782,7 +1783,11 @@ local do_states = function(self, dtime)
z = vec.z,
}

throwing.shoot(self.object, "entity", self.arrow, p, dir, 0.5)
local arrow = ItemStack(self.arrow)

minetest.sound_play(arrow:get_definition()["_sound_on_release"], { object = self.object })
local aim_variety = random(-2, 2) * 0.1
archery.projectile_shoot(self.object, arrow, 0.6 + aim_variety, shoot_dir)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion mods/_various/mobs/mod.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name = mobs
depends = default, lordlib, throwing, factions, lord_classes
depends = default, lordlib, factions, lord_classes
4 changes: 3 additions & 1 deletion mods/lord/Core/archery/src/archery/processor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ controls.on_release(function(player, key, hold_time)
local new_stack = ItemStack(table.copy(stack:to_table()))

local uses = api.reg_from_archery_item(new_stack:get_name()).definition.uses
new_stack:add_wear(65535/uses)
if uses then
new_stack:add_wear(65535/uses)
end

local projectile_item = archery.get_throwables()[stack:get_name()].entity_name
if projectile_item and api.projectile_shoot(player, new_stack, power) then
Expand Down
29 changes: 20 additions & 9 deletions mods/lord/Core/archery/src/archery/processor/processing_api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,33 @@ local function calculate_power(stack, hold_time, no_hold)
return power
end

--- @param player Player a player that shoots the projectile
--- @param projectile_stack temStack itemstack with item to shoot
--- @param hold_time number the time the player was holding CONTROL_CHARGE down
local function projectile_shoot(player, projectile_stack, power)

local look_dir = player:get_look_dir()
local player_pos = player:get_pos()
local projectile_pos = vector.new(player_pos.x, player_pos.y + 1.5, player_pos.z)
--- @param shooter Object|Player a player that shoots the projectile
--- @param projectile_stack ItemStack itemstack with item to shoot
--- @param power number power multiplier
--- @param forced_direction vector forced shooting direction (normalized vector)
--- @param forced_start_position vector forced position to spawn the projectile on
local function projectile_shoot(shooter, projectile_stack, power, forced_direction, forced_start_position)
local shooter_pos = shooter:get_pos()
local yaw = shooter:get_yaw()
local look_dir = forced_direction
local projectile_pos = forced_start_position

if shooter and shooter:is_player() then
look_dir = look_dir or shooter:get_look_dir()
projectile_pos = forced_start_position or vector.new(shooter_pos.x, shooter_pos.y + 1.5, shooter_pos.z)
elseif shooter then
look_dir = look_dir or vector.new(-math.sin(yaw), 0.25, math.cos(yaw))
projectile_pos = forced_start_position or vector.new(shooter_pos.x, shooter_pos.y, shooter_pos.z)
end

local projectile_item = projectile_stack:get_name()

local projectile_reg = projectiles.get_projectiles()[projectile_item]

local projectile_entity = minetest.add_entity(projectile_pos, projectile_reg.entity_name)
projectile_entity:add_velocity(vector.multiply(look_dir, projectile_reg.entity_reg.max_speed * power))
projectile_entity:set_acceleration(vector.new(0, -GRAVITY, 0))
projectile_entity:get_luaentity()._shooter = player
projectile_entity:get_luaentity()._shooter = shooter
projectile_entity:get_luaentity()._projectile_stack = projectile_stack
projectile_entity:get_luaentity()._remove_on_object_hit = projectile_reg.entity_reg.remove_on_object_hit
projectile_entity:get_luaentity()._rotation_formula = projectile_reg.entity_reg.rotation_formula
Expand Down
64 changes: 44 additions & 20 deletions mods/lord/Core/archery/src/archery/public_api.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--local S_tt = minetest.get_translator("tt_base")
local api = require("archery.processor.processing_api")

local registered_bows = {}
local registered_crossbows = {}
Expand Down Expand Up @@ -100,7 +100,7 @@ local function register_crossbow(name, reg)
minetest.register_tool(name, {
range = def.range or 3,
description = def.description,
wield_scale = wield_scale,
wield_scale = def.wield_scale or wield_scale,
inventory_image = def.inventory_image .. ".png",
wield_image = def.inventory_image .. ".png",
groups = table.merge({ allow_hold_abort = 1 }, def.groups),
Expand Down Expand Up @@ -165,23 +165,42 @@ local function register_throwable(name, reg)
local def = reg.definition
local wield_scale = { x = 2, y = 2, z = 0.75, }

minetest.register_tool(name, {
range = def.range or 3,
description = def.description,
wield_scale = def.wield_scale or wield_scale,
inventory_image = def.inventory_image .. ".png",
wield_image = def.inventory_image .. ".png",
groups = def.groups,
tool_capabilities = def.tool_capabilities,
touch_interaction = def.touch_interaction or {
pointed_nothing = "short_dig_long_place",
pointed_node = "long_dig_short_place",
pointed_object = "short_dig_long_place",
},
_original_state = name,
_sound_on_release = def.sound_on_release,
_used_projectiles = def.used_projectiles,
})
if reg.definition.just_an_item == true then
minetest.register_craftitem(name, {
range = def.range or 3,
description = def.description,
wield_scale = def.wield_scale or wield_scale,
inventory_image = def.inventory_image .. ".png",
wield_image = def.inventory_image .. ".png",
groups = def.groups,
touch_interaction = def.touch_interaction or {
pointed_nothing = "short_dig_long_place",
pointed_node = "long_dig_short_place",
pointed_object = "short_dig_long_place",
},
_original_state = name,
_sound_on_release = def.sound_on_release,
_used_projectiles = name,
})
else
minetest.register_tool(name, {
range = def.range or 3,
description = def.description,
wield_scale = def.wield_scale or wield_scale,
inventory_image = def.inventory_image .. ".png",
wield_image = def.inventory_image .. ".png",
groups = def.groups,
tool_capabilities = def.tool_capabilities,
touch_interaction = def.touch_interaction or {
pointed_nothing = "short_dig_long_place",
pointed_node = "long_dig_short_place",
pointed_object = "short_dig_long_place",
},
_original_state = name,
_sound_on_release = def.sound_on_release,
_used_projectiles = def.used_projectiles,
})
end

local stages = {}
stages[0] = name
Expand All @@ -206,6 +225,8 @@ local function register_throwable(name, reg)
}
end

--WIP:
--[[
local function link_existing_throwable(name, reg)
local stages = {}
stages[0] = name
Expand All @@ -228,12 +249,15 @@ local function link_existing_throwable(name, reg)
},
}
end
]]

return {
register_bow = register_bow,
projectile_shoot = api.projectile_shoot,
register_crossbow = register_crossbow,
register_throwable = register_throwable,
link_existing_throwable = link_existing_throwable,
--WIP:
--link_existing_throwable = link_existing_throwable,
get_bows = function() return registered_bows end,
get_crossbows = function() return registered_crossbows end,
get_throwables = function() return registered_throwables end,
Expand Down
46 changes: 36 additions & 10 deletions mods/lord/Core/legacy/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ minetest.register_alias("lord_homedecor:slab_Roofing", "stairs:slab_roofing")
minetest.register_alias("lord_homedecor:slab_grate", "stairs:slab_grate")
minetest.register_alias("lord_homedecor:slab_hardwood", "stairs:slab_hardwood")

minetest.register_alias("lottthrowing:bolt_fire", "lottthrowing:bolt")
minetest.register_alias("lottpotion:bolt", "lottthrowing:bolt")
minetest.register_alias("lottthrowing:bolt_fire", "lord_projectiles:steel_bolt")
minetest.register_alias("lottpotion:bolt", "lord_projectiles:steel_bolt")

minetest.register_alias("lottplants:anemones_fake", "lottplants:anemones")
minetest.register_alias("lottplants:asphodel_fake", "lottplants:asphodel")
Expand Down Expand Up @@ -253,15 +253,41 @@ end
minetest.register_alias("lottweapons:elven_sword", "tools:sword_elven")
minetest.register_alias("lottweapons:orc_sword", "tools:sword_orc")

minetest.register_alias("lottthrowing:arrow", "arrows:arrow_steel")
minetest.register_alias("lottthrowing:arrow_mithril", "arrows:arrow_mithril")
minetest.register_alias("lottthrowing:bolt", "arrows:bolt_steel")
minetest.register_alias("lottthrowing:bolt_mithril", "arrows:bolt_mithril")
minetest.register_alias("lottthrowing:arrow", "lord_projectiles:steel_arrow")
minetest.register_alias("lottthrowing:arrow_mithril", "lord_projectiles:mithril_arrow")
minetest.register_alias("lottthrowing:bolt", "lord_projectiles:steel_bolt")
minetest.register_alias("lottthrowing:bolt_mithril", "lord_projectiles:mithril_bolt")

minetest.register_alias("arrows:arrow_steel", "lord_projectiles:steel_arrow")
minetest.register_alias("arrows:arrow_mithril", "lord_projectiles:mithril_arrow")
minetest.register_alias("arrows:bolt_steel", "lord_projectiles:steel_bolt")
minetest.register_alias("arrows:bolt_mithril", "lord_projectiles:mithril_bolt")

minetest.register_alias("lottthrowing:axe_dwarf", "lord_projectiles:mithril_bolt")
minetest.register_alias("lottthrowing:axe_elf", "lord_projectiles:galvorn_bolt")
minetest.register_alias("lottthrowing:axe_steel", "lord_projectiles:steel_bolt")
minetest.register_alias("lottthrowing:axe_galvorn", "lord_projectiles:galvorn_bolt")

minetest.register_alias("arrows:axe_dwarf", "lord_projectiles:mithril_bolt")
minetest.register_alias("arrows:axe_elf", "lord_projectiles:galvorn_bolt")
minetest.register_alias("arrows:axe_steel", "lord_projectiles:steel_bolt")
minetest.register_alias("arrows:axe_galvorn", "lord_projectiles:galvorn_bolt")

minetest.register_alias("lottthrowing:bow_wood", "lord_archery:apple_wood_bow")
minetest.register_alias("lottthrowing:bow_wood_alder", "lord_archery:alder_wood_bow")
minetest.register_alias("lottthrowing:bow_wood_birch", "lord_archery:birch_wood_bow")
minetest.register_alias("lottthrowing:bow_wood_lebethron", "lord_archery:lebethron_wood_bow")
minetest.register_alias("lottthrowing:bow_wood_mallorn", "lord_archery:mallorn_wood_bow")

minetest.register_alias("lottthrowing:crossbow_galvorn", "lord_archery:galvorn_crossbow")
minetest.register_alias("lottthrowing:crossbow_gold", "lord_archery:gold_crossbow")
minetest.register_alias("lottthrowing:crossbow_magical", "lord_archery:mithril_crossbow")
minetest.register_alias("lottthrowing:crossbow_mithril", "lord_archery:mithril_crossbow")
minetest.register_alias("lottthrowing:crossbow_silver", "lord_archery:silver_crossbow")
minetest.register_alias("lottthrowing:crossbow_steel", "lord_archery:steel_crossbow")
minetest.register_alias("lottthrowing:crossbow_tin", "lord_archery:tin_crossbow")
minetest.register_alias("lottthrowing:crossbow_wood", "lord_archery:wooden_crossbow")

minetest.register_alias("lottthrowing:axe_dwarf", "arrows:axe_dwarf")
minetest.register_alias("lottthrowing:axe_elf", "arrows:axe_elf")
minetest.register_alias("lottthrowing:axe_steel", "arrows:axe_steel")
minetest.register_alias("lottthrowing:axe_galvorn", "arrows:axe_galvorn")

minetest.register_alias("fire:campfire", "campfire:campfire")
minetest.register_alias("fire:fireplace", "campfire:fireplace")
Expand Down
5 changes: 5 additions & 0 deletions mods/lord/Core/legacy/textures/legacy_textures
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Used for entities that were spawned in older versions

'lord_archery_apple_wood_bow.png' as 'lottthrowing_bow_wood.png'
'lord_archery_steel_crossbow.png' as 'lottthrowing_crossbow_steel.png'
'lord_archery_mallorn_wood_bow.png' as 'lottthrowing_bow_wood_mallorn.png'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions mods/lord/Core/projectiles/src/projectiles/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,68 @@ local function register_projectile(name, reg, not_register_item)
}, def))
end

local flame_node = function(pos)
local n = minetest.get_node(pos).name
local node_desc = minetest.registered_nodes[n]
if node_desc == nil then
minetest.log("error", "Attempt to flame unknown node: "..n..
" ("..pos.x..","..pos.y..","..pos.z..")")
return
end

if node_desc.groups == nil then
node_desc.groups = {}
end

if node_desc.groups.forbidden == nil then
local in_nazgul_area = nazgul_area.position_in_nazgul_area(pos)

if node_desc.groups.flammable or math.random(1, 100) <= 30 then
if n == "air" or not in_nazgul_area then
minetest.set_node(pos, { name = "fire:basic_flame" })
end
else
if not in_nazgul_area then
minetest.remove_node(pos)
end
end
end
end

local flame_area = function(p1, p2)
for y = p1.y, p2.y do
for z = p1.z, p2.z do
minetest.punch_node({ x = p1.x - 1, y = y, z = z })
minetest.punch_node({ x = p2.x + 1, y = y, z = z })
end
end

for x = p1.x, p2.x do
for z = p1.z, p2.z do
minetest.punch_node({ x = x, y = p1.y - 1, z = z })
minetest.punch_node({ x = x, y = p2.y + 1, z = z })
end
end

for x = p1.x, p2.x do
for y = p1.y, p2.y do
minetest.punch_node({ x = x, y = y, z = p1.z - 1 })
minetest.punch_node({ x = x, y = y, z = p2.z + 1 })
end
end

for x = p1.x, p2.x do
for y = p1.y, p2.y do
for z = p1.z, p2.z do
flame_node(vector.new(x, y, z))
end
end
end
end


return {
flame_area = flame_area,
register_projectile = register_projectile,
get_projectiles = function() return registered_projectiles end,
}
Loading

0 comments on commit a11ccbe

Please sign in to comment.