Added proper crafting recipies, adjusted damage, fixed some bugs, crash causes, moved settings to settingtypes, changed drop chance

master
stub 2017-12-03 00:19:04 +03:00
parent 4c1e1b0960
commit 1d0a85d30a
11 changed files with 150 additions and 159 deletions

View File

@ -1,8 +1,12 @@
## Throwing mod reloaded
#### This is another fork of throwing mod for minetest by Echoes91, which was further improved by MinetestForFun team.
* Keep in mind that this fork is still WIP and many survival-related things are not yet implemented (normal craft schematics, normal weapon wear, etc)
#### New Stuff
## Throwing reloaded
## This is another fork of throwing mod for minetest by Echoes91, which was further improved by MinetestForFun team.
## Requirements
* Minetest 0.4.16+
#### Optionally requires:
* Vines from plantlife pack (rope arrow)
* Lightning (lightning arrow)
* Moreores (mithril arrow)
## New Stuff
* Rewrote code related to damage, which causes mobs to respond to your attacks
* Returned velocity-based damage
* Increased base velocity of all bows and crossbows
@ -13,17 +17,14 @@
* Rewrote tnt arrow, that now has cosmetic effect of an explosion and AoE damage, but no actual node destruction
* Added particle effects and sounds to all arrows, usual arrows produce particles and sound on impact, teleport arrows make particles like teleporters from telemosaic mod, etc
* New textures for teleport, lightning, fireworks, and mithril arrows
* Various code optimizations, fixes and improvements (replaced use of some deprecated and obsolete functions, though I'm still improving the code)
#### Balance
* Bows and crossbows are craftable from common materials, but in big quantities (since I hardly see any usage for diamonds or gold in actual bows and crossbows)
* Instead of bows having linear quality progressions, various bows offer various perks, for example small wooden bow takes least amount of wood to craft and can be drawn easily, but it gives little amount of velocity to the arrow. Same goes to
the steel bow, it takes a lot of iron to craft and gives an excellent velocity, but takes a lot of time to draw. That also applies to crossbows, repeater crossbow shoots very fast but with quite weak starting velocity
#### Credits
* Settings moved to minetest.conf, configurable either in minetest advanced options (in mods section) or in minetest.conf
* Various code optimizations, fixes and improvements
## Credits
* Original copyright and resources belongs to MinetestForFun team, Echoes91, PilzAdam and Jeija.
* Teleport texture: made by tacomexmex for his fork of telemosaic mod
* TNT particles and sounds: minetest dev team
* Compound bow and repeater crossbow, lightning, rope, teleport, mithril and green firework arrow textures are licenced under CC-BY 3.0 (link can be found later in this section)
* Sourcecode: LGPLv2.1 (see http://www.gnu.org/licenses/lgpl-2.1.html)
* Graphics & sounds: CC-BY 3.0 (see http://creativecommons.org/licenses/by/3.0/legalcode)
* All graphics & sounds resources from original mod: CC-BY 3.0 (see http://creativecommons.org/licenses/by/3.0/legalcode)

View File

@ -1,32 +1,35 @@
-- Bows
DISABLE_WOODEN_BOW = false
DISABLE_LONGBOW = false
DISABLE_COMPOSITE_BOW = false
DISABLE_STEEL_BOW = false
DISABLE_COMPOUND_BOW = false
DISABLE_WOODEN_BOW = minetest.settings:get("DISABLE_WOODEN_BOW") or false
DISABLE_LONGBOW = minetest.settings:get("DISABLE_LONGBOW") or false
DISABLE_COMPOSITE_BOW = minetest.settings:get("DISABLE_COMPOSITE_BOW") or false
DISABLE_STEEL_BOW = minetest.settings:get("DISABLE_STEEL_BOW") or false
DISABLE_COMPOUND_BOW = minetest.settings:get("DISABLE_COMPOUND_BOW") or false
-- Crossbows
DISABLE_CROSSBOW = false
DISABLE_REPEATING_CROSSBOW = false
DISABLE_ARBALEST = false
DISABLE_AUTOMATED_ARBALEST = false
DISABLE_CROSSBOW = minetest.settings:get("DISABLE_CROSSBOW") or false
DISABLE_REPEATING_CROSSBOW = minetest.settings:get("DISABLE_REPEATING_CROSSBOW") or false
DISABLE_ARBALEST = minetest.settings:get("DISABLE_ARBALEST") or false
DISABLE_AUTOMATED_ARBALEST = minetest.settings:get("DISABLE_AUTOMATED_ARBALEST") or false
-- Special Arrows
DISABLE_TELEPORT_ARROW = false
DISABLE_DIG_ARROW = false
DISABLE_TNT_ARROW = false
DISABLE_TORCH_ARROW = false
DISABLE_ROPE_ARROW = false
DISABLE_LIGHTNING_ARROW = false
DISABLE_TELEPORT_ARROW = minetest.settings:get("DISABLE_TELEPORT_ARROW") or false
DISABLE_DIG_ARROW = minetest.settings:get("DISABLE_DIG_ARROW") or false
DISABLE_TNT_ARROW = minetest.settings:get("DISABLE_TNT_ARROW") or false
DISABLE_TORCH_ARROW = minetest.settings:get("DISABLE_TORCH_ARROW ") or false
DISABLE_ROPE_ARROW = minetest.settings:get("DISABLE_ROPE_ARROW") or false
DISABLE_LIGHTNING_ARROW = minetest.settings:get("DISABLE_LIGHTNING_ARROW") or false
-- Fireworks arrows
DISABLE_FIREWORKS_BLUE_ARROW = false
DISABLE_FIREWORKS_RED_ARROW = false
DISABLE_FIREWORKS_GREEN_ARROW = false
DISABLE_FIREWORKS_BLUE_ARROW = minetest.settings:get("DISABLE_FIREWORKS_BLUE_ARROW") or false
DISABLE_FIREWORKS_RED_ARROW = minetest.settings:get("DISABLE_FIREWORKS_RED_ARROW") or false
DISABLE_FIREWORKS_GREEN_ARROW = minetest.settings:get("DISABLE_FIREWORKS_GREEN_ARROW") or false
-- Normal arrows
DISABLE_STONE_ARROW = false
DISABLE_STEEL_ARROW = false
DISABLE_OBSIDIAN_ARROW = false
DISABLE_DIAMOND_ARROW = false
DISABLE_MITHRIL_ARROW = false
DISABLE_STONE_ARROW = minetest.settings:get("DISABLE_STONE_ARROW") or false
DISABLE_STEEL_ARROW = minetest.settings:get("DISABLE_STEEL_ARROW") or false
DISABLE_OBSIDIAN_ARROW = minetest.settings:get("DISABLE_OBSIDIAN_ARROW") or false
DISABLE_DIAMOND_ARROW = minetest.settings:get("DISABLE_DIAMOND_ARROW") or false
DISABLE_MITHRIL_ARROW = minetest.settings:get("DISABLE_MITHRIL_ARROW") or false
-- Other
THROWING_RECOVERY_CHANCE = minetest.settings:get("THROWING_RECOVERY_CHANCE") or 0.5

View File

@ -31,23 +31,25 @@ minetest.register_node("throwing:arrow_dig_box", {
local function addEffect(pos, node)
minetest.sound_play("default_dug_node", {pos=pos, gain=1, max_hear_distance=2*64})
texture=minetest.registered_nodes[node.name].tiles[1]
minetest.add_particlespawner({
amount = 16,
time = 0.1,
minpos = pos,
maxpos = pos,
minvel = {x = -5, y = -5, z = -5},
maxvel = {x = 5, y = 5, z = 5},
minacc = {x = 0, y = -8, z = 0},
maxacc = {x = 0, y = -8, z = 0},
minexptime = 0.8,
maxexptime = 2.0,
minsize = 4,
maxsize = 6,
texture = texture,
collisiondetection = true,
})
if minetest.registered_nodes[node.name].tiles~=nil then
texture=minetest.registered_nodes[node.name].tiles[1]
minetest.add_particlespawner({
amount = 16,
time = 0.1,
minpos = pos,
maxpos = pos,
minvel = {x = -5, y = -5, z = -5},
maxvel = {x = 5, y = 5, z = 5},
minacc = {x = 0, y = -8, z = 0},
maxacc = {x = 0, y = -8, z = 0},
minexptime = 0.8,
maxexptime = 2.0,
minsize = 4,
maxsize = 6,
texture = texture,
collisiondetection = true,
})
end
end
local THROWING_ARROW_ENTITY={
@ -72,8 +74,10 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
for k, obj in pairs(objs) do
if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then
if throwing_touch(pos, obj:getpos()) then
if math.random(0,100) % 1.1 == 0 then -- chance to drop
minetest.add_item(pos, "throwing:arrow_dig")
if math.random() < THROWING_RECOVERY_CHANCE then
minetest.add_item(pos, 'throwing:arrow_dig')
else
minetest.add_item(pos, 'default:stick')
end
self.object:remove()
return
@ -91,7 +95,13 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
and node.diggable ~= false then
addEffect(pos, node)
minetest.dig_node(pos)
minetest.add_item(pos, node.name)
--minetest.add_item(pos, node.name)
else
if math.random() < THROWING_RECOVERY_CHANCE then
minetest.add_item(pos, 'throwing:arrow_dig')
else
minetest.add_item(pos, 'default:stick')
end
end
self.object:remove()
return

View File

@ -1,6 +1,6 @@
local function throwing_register_fireworks(color, color2, desc)
minetest.register_craftitem("throwing:arrow_fireworks_" .. color, {
description = desc .. "fireworks arrow",
description = desc .. " Fireworks Arrow",
inventory_image = "throwing_arrow_fireworks_" .. color .. ".png",
})
@ -145,14 +145,14 @@ local function throwing_register_fireworks(color, color2, desc)
minetest.register_entity("throwing:arrow_fireworks_" .. color .. "_entity", THROWING_ARROW_ENTITY)
minetest.register_craft({
output = 'throwing:arrow_fireworks_' .. color .. ,
output = 'throwing:arrow_fireworks_' .. color,
recipe = {
{'default:stick', 'group:coal', 'dye:' .. color},
}
})
minetest.register_craft({
output = 'throwing:arrow_fireworks_' .. color .. ,
output = 'throwing:arrow_fireworks_' .. color,
recipe = {
{'dye:' .. color, 'group:coal', 'default:stick'},
}

View File

@ -17,13 +17,6 @@ throwing_arrows = {
dofile(minetest.get_modpath("throwing").."/defaults.lua")
local input = io.open(minetest.get_modpath("throwing").."/throwing.conf", "r")
if input then
dofile(minetest.get_modpath("throwing").."/throwing.conf")
input:close()
input = nil
end
dofile(minetest.get_modpath("throwing").."/functions.lua")
dofile(minetest.get_modpath("throwing").."/tools.lua")

View File

@ -41,23 +41,25 @@ local THROWING_ARROW_ENTITY={
}
local function addEffect(pos, node)
minetest.sound_play("default_dug_metal", {pos=pos, gain=1, max_hear_distance=2*64})
texture=minetest.registered_nodes[node.name].tiles[1]
minetest.add_particlespawner({
amount = 16,
time = 0.1,
minpos = pos,
maxpos = pos,
minvel = {x = -5, y = -5, z = -5},
maxvel = {x = 5, y = 5, z = 5},
minacc = {x = 0, y = -8, z = 0},
maxacc = {x = 0, y = -8, z = 0},
minexptime = 0.8,
maxexptime = 2.0,
minsize = 4,
maxsize = 6,
texture = texture,
collisiondetection = true,
})
if minetest.registered_nodes[node.name].tiles~=nil then
texture=minetest.registered_nodes[node.name].tiles[1]
minetest.add_particlespawner({
amount = 16,
time = 0.1,
minpos = pos,
maxpos = pos,
minvel = {x = -5, y = -5, z = -5},
maxvel = {x = 5, y = 5, z = 5},
minacc = {x = 0, y = -8, z = 0},
maxacc = {x = 0, y = -8, z = 0},
minexptime = 0.8,
maxexptime = 2.0,
minsize = 4,
maxsize = 6,
texture = texture,
collisiondetection = true,
})
end
end
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
@ -80,11 +82,8 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
full_punch_interval=1.0,
damage_groups={fleshy=damage},
}, nil)
local toughness = 0.9
if math.random() < toughness then
if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15)
minetest.add_item(pos, 'throwing:arrow_torch')
end
if math.random() < THROWING_RECOVERY_CHANCE then
minetest.add_item(pos, 'throwing:arrow_rope')
else
minetest.add_item(pos, 'default:stick')
end
@ -108,12 +107,11 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
addEffect(self.lastpos, node)
minetest.place_node(self.lastpos, {name="vines:rope_block"})
else
local toughness = 0.9
if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_rope')
else
minetest.add_item(self.lastpos, 'default:stick')
end
if math.random() < THROWING_RECOVERY_CHANCE then
minetest.add_item(pos, 'throwing:arrow_rope')
else
minetest.add_item(pos, 'default:stick')
end
end
self.object:remove()
return

29
settingtypes.txt Normal file
View File

@ -0,0 +1,29 @@
DISABLE_WOODEN_BOW (Disable Wooden Bow) bool false
DISABLE_LONGBOW (Disable Longbow) bool false
DISABLE_COMPOSITE_BOW (Disable Composite Bow) bool false
DISABLE_STEEL_BOW (Disable Steel Bow) bool false
DISABLE_COMPOUND_BOW (Disable Compound Bow) bool false
DISABLE_CROSSBOW (Disable Crossbow) bool false
DISABLE_REPEATING_CROSSBOW (Disable Repeating Crossbow) bool false
DISABLE_ARBALEST (Disable Arbalest) bool false
DISABLE_AUTOMATED_ARBALEST (Disable Automated Arbalest) bool false
DISABLE_TELEPORT_ARROW (Disable Teleport Arrow) bool false
DISABLE_DIG_ARROW (Disable Dig Arrow) bool false
DISABLE_TNT_ARROW (Disable TNT Arrow) bool false
DISABLE_TORCH_ARROW (Disable Torch Arrow) bool false
DISABLE_ROPE_ARROW (Disable Rope Arrow) bool false
DISABLE_LIGHTNING_ARROW (Disable Lightning Arrow) bool false
DISABLE_FIREWORKS_BLUE_ARROW (Disable Blue Fireworks) bool false
DISABLE_FIREWORKS_RED_ARROW (Disable Red Fireworks) bool false
DISABLE_FIREWORKS_GREEN_ARROW (Disable Green Fireworks) bool false
DISABLE_STONE_ARROW (Disable Stone Arrow) bool false
DISABLE_STEEL_ARROW (Disable Steel Arrow) bool false
DISABLE_OBSIDIAN_ARROW (Disable Obsidian Arrow) bool false
DISABLE_DIAMOND_ARROW (Disable Diamond Arrow) bool false
DISABLE_MITHRIL_ARROW (Disable Mithril Arrow) bool false
THROWING_RECOVERY_CHANCE (Arrow Recovery Chance) float 0.3

View File

@ -1,6 +1,6 @@
function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
function throwing_register_arrow_standard (kind, desc, eq, craft)
minetest.register_craftitem("throwing:arrow_" .. kind, {
description = desc .. " arrow",
description = desc .. " Arrow",
inventory_image = "throwing_arrow_" .. kind .. ".png",
})
@ -84,10 +84,8 @@ end
damage_groups={fleshy=damage},
}, nil)
minetest.sound_play("default_dug_metal", {pos=objpos, gain=1, max_hear_distance=2*64})
if math.random() < toughness then
if math.random(0,100) % 2 == 0 then
minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind)
end
if math.random() < THROWING_RECOVERY_CHANCE then
minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind)
else
minetest.add_item(self.lastpos, 'default:stick')
end
@ -103,7 +101,7 @@ end
and not string.find(node.name, 'flowers:')
and not string.find(node.name, 'fire:') then
add_effects(self.lastpos, node)
if math.random() < toughness then
if math.random() < THROWING_RECOVERY_CHANCE then
minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind)
else
minetest.add_item(self.lastpos, 'default:stick')
@ -135,21 +133,21 @@ end
end
if not DISABLE_STONE_ARROW then
throwing_register_arrow_standard ('stone', 'Stone', 5, 0.10, 'group:stone')
throwing_register_arrow_standard ('stone', 'Stone', 5, 'group:stone')
end
if not DISABLE_STEEL_ARROW then
throwing_register_arrow_standard ('steel', 'Steel', 10, 0.80, 'default:steel_ingot')
throwing_register_arrow_standard ('steel', 'Steel', 10, 'default:steel_ingot')
end
if not DISABLE_OBSIDIAN_ARROW then
throwing_register_arrow_standard ('obsidian', 'Obsidian', 15, 0.20, 'default:obsidian')
throwing_register_arrow_standard ('obsidian', 'Obsidian', 15, 'default:obsidian')
end
if not DISABLE_DIAMOND_ARROW then
throwing_register_arrow_standard ('diamond', 'Diamond', 20, 0.40, 'default:diamond')
throwing_register_arrow_standard ('diamond', 'Diamond', 20, 'default:diamond')
end
if minetest.get_modpath('moreores') and not DISABLE_MITHRIL_ARROW then
throwing_register_arrow_standard ('mithril', 'Mithril', 30, 0.86, 'moreores:mithril_ingot')
throwing_register_arrow_standard ('mithril', 'Mithril', 30, 'moreores:mithril_ingot')
end

View File

@ -1,33 +0,0 @@
-- Bows
DISABLE_WOODEN_BOW = false
DISABLE_LONGBOW = false
DISABLE_COMPOSITE_BOW = false
DISABLE_STEEL_BOW = false
DISABLE_COMPOUND_BOW = false
-- Crossbows
DISABLE_CROSSBOW = false
DISABLE_REPEATING_CROSSBOW = false
DISABLE_ARBALEST = false
DISABLE_AUTOMATED_ARBALEST = false
-- Special Arrows
DISABLE_TELEPORT_ARROW = false
DISABLE_DIG_ARROW = false
DISABLE_TNT_ARROW = false
DISABLE_TORCH_ARROW = false
DISABLE_ROPE_ARROW = false
DISABLE_LIGHTNING_ARROW = false
-- Fireworks arrows
DISABLE_FIREWORKS_BLUE_ARROW = false
DISABLE_FIREWORKS_RED_ARROW = false
DISABLE_FIREWORKS_GREEN_ARROW = false
-- Normal arrows
DISABLE_STONE_ARROW = false
DISABLE_STEEL_ARROW = false
DISABLE_OBSIDIAN_ARROW = false
DISABLE_DIAMOND_ARROW = false
DISABLE_MITHRIL_ARROW = false

View File

@ -1,5 +1,5 @@
minetest.register_craftitem("throwing:arrow_tnt", {
description = "TNT arrow",
description = "TNT Arrow",
inventory_image = "throwing_arrow_tnt.png",
})
@ -95,14 +95,9 @@ end
local function boom(pos)
minetest.sound_play("tnt_explode", {pos=pos, gain=1, max_hear_distance=2*64})
if minetest.get_node(pos).name == 'air' or minetest.get_node(pos).name == 'throwing:firework_trail' then
minetest.add_node(pos, {name="throwing:firework_boom"})
minetest.get_node_timer(pos):start(0.2)
end
add_effects(pos, 10)
end
-- Back to the arrow
local function damageInRadius(damage, puncher, pos, radius)
local targs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, radius)
for k, targ in pairs(targs) do
@ -116,6 +111,7 @@ local function damageInRadius(damage, puncher, pos, radius)
}, nil)
end
end
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
self.timer=self.timer+dtime
local newpos = self.object:getpos()
@ -149,7 +145,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
if self.player and minetest.get_player_by_name(self.player) then
puncher = minetest.get_player_by_name(self.player)
end
damageInRadius(30, puncher, pos, 8)
damageInRadius(20, puncher, pos, 8)
effectsTexture(pos, node)
boom(pos)
self.object:remove()
@ -163,7 +159,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
if self.player and minetest.get_player_by_name(self.player) then
puncher = minetest.get_player_by_name(self.player)
end
damageInRadius(30, puncher, pos, 8)
damageInRadius(20, puncher, pos, 8)
effectsTexture(pos, node)
boom(pos)
self.object:remove()
@ -175,19 +171,18 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z}
end
minetest.register_entity("throwing:arrow_tnt_entity", THROWING_ARROW_ENTITY)
minetest.register_craft({
output = 'throwing:arrow_tnt',
recipe = {
{'default:stick', 'tnt:tnt', 'default:bronze_ingot'},
{'default:stick', 'group:coal', 'default:bronze_ingot'},
}
})
minetest.register_craft({
output = 'throwing:arrow_tnt',
recipe = {
{'default:bronze_ingot', 'tnt:tnt', 'default:stick'},
{'default:bronze_ingot', 'group:coal', 'default:stick'},
}
})

View File

@ -84,10 +84,8 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
damage_groups={fleshy=damage},
}, nil)
local toughness = 0.9
if math.random() < toughness then
if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15)
minetest.add_item(pos, 'throwing:arrow_torch')
end
if math.random() < THROWING_RECOVERY_CHANCE then
minetest.add_item(pos, 'throwing:arrow_torch')
else
minetest.add_item(pos, 'default:stick')
end
@ -119,12 +117,11 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
end
add_effects(self.lastpos, node)
else
local toughness = 0.9
if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_torch')
else
minetest.add_item(self.lastpos, 'default:stick')
end
if math.random() < THROWING_RECOVERY_CHANCE then
minetest.add_item(pos, 'throwing:arrow_torch')
else
minetest.add_item(pos, 'default:stick')
end
end
self.object:remove()
return