Compare commits

...

2 Commits

Author SHA1 Message Date
c55a8f8dcd posibility to configure blood or cry when attack or being under attack 2023-01-12 16:18:07 -04:00
5ba7c54408 Allow tool repairs on workbench mod coexits with game mechanish
* adapt the fix from the upstream by mt-sane
* becouse there is is also the anvil,
* This also fixes the problem with the vanishing of the tools
  when using the repair craft.
* closed https://github.com/Bremaweb/adventuretest/pull/26
* close #26
* close https://codeber.org/minenux/minetest-game-adventuretest/pulls/26
2023-01-12 13:49:29 -04:00
8 changed files with 71 additions and 16 deletions

View File

@ -33,6 +33,11 @@ of the inventory. also once in the game type `/m` and press
enter and you will get a crafting guide, equipping armor form enter and you will get a crafting guide, equipping armor form
and changing skin form. and changing skin form.
### Configuration
By default each interaction of attack causes blood, but you
can configure to make the enemy just cry with `enable_blood` to `false`
### Know issues ### Know issues
If yu got crash, somethigns you game get slow for movement, in singleplayer, If yu got crash, somethigns you game get slow for movement, in singleplayer,
@ -41,7 +46,6 @@ a block just stop it.
To solve, go into your world directory and delete the affects.txt To solve, go into your world directory and delete the affects.txt
and physics file. This happens sometimes when there is a crash. and physics file. This happens sometimes when there is a crash.
Adventuretest License Adventuretest License
------------------------------------------ ------------------------------------------
Copyright (C) 2013-2014 Brandon Bohannon <brandon@bremaweb.com> Copyright (C) 2013-2014 Brandon Bohannon <brandon@bremaweb.com>

View File

@ -33,6 +33,11 @@ of the inventory. also once in the game type `/m` and press
enter and you will get a crafting guide, equipping armor form enter and you will get a crafting guide, equipping armor form
and changing skin form. and changing skin form.
### Configuration
By default each interaction of attack causes blood, but you
can configure to make the enemy just cry with `enable_blood` to `false`
### Know issues ### Know issues
If yu got crash, somethigns you game get slow for movement, in singleplayer, If yu got crash, somethigns you game get slow for movement, in singleplayer,
@ -41,7 +46,6 @@ a block just stop it.
To solve, go into your world directory and delete the affects.txt To solve, go into your world directory and delete the affects.txt
and physics file. This happens sometimes when there is a crash. and physics file. This happens sometimes when there is a crash.
Adventuretest License Adventuretest License
------------------------------------------ ------------------------------------------
Copyright (C) 2013-2014 Brandon Bohannon <brandon@bremaweb.com> Copyright (C) 2013-2014 Brandon Bohannon <brandon@bremaweb.com>

View File

@ -5,6 +5,8 @@ enable_node_highlighting = true
debug_log_level = action debug_log_level = action
enable_blood = true
torches_enable_ceiling = false torches_enable_ceiling = false
torches_style = minetest torches_style = minetest

View File

@ -3,6 +3,11 @@ adventuretest = {}
adventuretest.seed = os.time() adventuretest.seed = os.time()
local enable_blood
if minetest.setting_get("enable_blood") ~= nil then
enable_blood = minetest.setting_getbool("enable_blood") or true
end
game_origin = nil game_origin = nil
if minetest.setting_get("game_origin") ~= nil then if minetest.setting_get("game_origin") ~= nil then
game_origin = minetest.string_to_pos(minetest.setting_get("game_origin")) game_origin = minetest.string_to_pos(minetest.setting_get("game_origin"))
@ -10,6 +15,9 @@ else
game_origin = {x=0,y=3,z=0} game_origin = {x=0,y=3,z=0}
end end
adventuretest.blood = enable_blood
dofile(minetest.get_modpath("adventuretest").."/functions.lua"); dofile(minetest.get_modpath("adventuretest").."/functions.lua");
dofile(minetest.get_modpath("adventuretest").."/register_functions.lua"); dofile(minetest.get_modpath("adventuretest").."/register_functions.lua");
dofile(minetest.get_modpath("adventuretest").."/privs.lua") dofile(minetest.get_modpath("adventuretest").."/privs.lua")

View File

@ -216,10 +216,13 @@ end
adventuretest.register_pl_hook(default.player_globalstep,0) adventuretest.register_pl_hook(default.player_globalstep,0)
if minetest.register_on_punchplayer ~= nil then if minetest.register_on_punchplayer ~= nil then
local enable_blood = adventuretest.blood
local texture_blood_cry = "mobs_blood_blue.png"
if enable_blood then texture_blood_cry = "mobs_blood.png" end
minetest.register_on_punchplayer( function(player, hitter, time_from_last_punch, tool_capabilities, dir) minetest.register_on_punchplayer( function(player, hitter, time_from_last_punch, tool_capabilities, dir)
local name = player:get_player_name() local name = player:get_player_name()
process_weapon(hitter,time_from_last_punch,tool_capabilities) process_weapon(hitter,time_from_last_punch,tool_capabilities)
blood_particles(player:getpos(),0.5,27,"mobs_blood.png") blood_particles(player:getpos(),0.5,27,texture_blood_cry)
if player_anim[name] == "lay" or player_anim[name] == "sit" then if player_anim[name] == "lay" or player_anim[name] == "sit" then
player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0}) player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
local sleep_hud = pd.get(name,"sleep_hud") local sleep_hud = pd.get(name,"sleep_hud")

View File

@ -1,5 +1,9 @@
mobs = {} mobs = {}
local enable_blood = adventuretest.blood
local texture_blood_cry = "mobs_blood_blue.png"
if enable_blood then texture_blood_dry = "mobs_blood.png" end
dofile(minetest.get_modpath("mobs").."/step.lua") dofile(minetest.get_modpath("mobs").."/step.lua")
mobs.mob_list = { npc={}, barbarian={}, monster={}, animal={}, npc_special={}} mobs.mob_list = { npc={}, barbarian={}, monster={}, animal={}, npc_special={}}
@ -58,7 +62,7 @@ function mobs:register_mob(name, def)
knock_back = def.knock_back or 3, knock_back = def.knock_back or 3,
blood_offset = def.blood_offset or 0, blood_offset = def.blood_offset or 0,
blood_amount = def.blood_amount or 15, blood_amount = def.blood_amount or 15,
blood_texture = def.blood_texture or "mobs_blood.png", blood_texture = texture_blood_cry,
rewards = def.rewards or nil, rewards = def.rewards or nil,
stationary = def.stationary or false, stationary = def.stationary or false,
activity_level = def.activity_level or 10, activity_level = def.activity_level or 10,

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -89,21 +89,51 @@ local function inventory_set(player, size)
end end
local function on_craft(itemstack,player,old_craftgrid,craft_inv) local function on_craft(itemstack,player,old_craftgrid,craft_inv)
if itemstack:get_definition().skill ~= nil then
local name = player:get_player_name() local name = player:get_player_name()
local probability = skills.get_probability(name,SKILL_CRAFTING,itemstack:get_definition().skill) if not name then return nil end
local rangeLow = ( probability - 10 ) / 100
probability = probability / 100 local craftItemDef = itemstack:get_definition()
local wear = math.floor(50000 - ( 50000 * math.random(rangeLow,probability) )) if not craftItemDef then return nil end
itemstack:add_wear(wear)
local i = skills.add_skill_exp(name,SKILL_CRAFTING,1) local craftItemSkill = craftItemDef.skill
local ii = skills.add_skill_exp(name,itemstack:get_definition().skill,1) if not craftItemSkill then return nil end
if i or ii then
if craftItemDef.type == "tool" then
local isSameItem = true
local itemCount = 0
local craftedItemName = craftItemDef.name
for _,recipeStack in ipairs(old_craftgrid) do
local recipeItemName = recipeStack:get_name()
if recipeItemName ~= "" then
itemCount = itemCount + 1
if itemCount > 2 then break end
if recipeItemName ~= craftedItemName then
isSameItem = false
break
end
end
end
if isSameItem and itemCount == 2 then
-- Yes we can ... repair
return nil
end
end
local probability = skills.get_probability(name, SKILL_CRAFTING, craftItemSkill)
local rangeLow = math.max(( probability - 10 ) / 100, 0.0)
probability = probability / 100
local wear = math.floor(50000 - ( 50000 * math.random(rangeLow,probability) ))
itemstack:add_wear(wear)
local craftItemDefw = itemstack:get_definition()
local craftItemSkillw = craftItemDefw.skill
-- local i = skills.add_skill_exp(name,SKILL_CRAFTING,1)
local ii = skills.add_skill_exp(name,craftItemSkillw,1)
if ii then
minetest.chat_send_player(name,"Your skills are increasing!") minetest.chat_send_player(name,"Your skills are increasing!")
end end
return itemstack return itemstack
end
return nil
end end
minetest.register_on_craft(on_craft) minetest.register_on_craft(on_craft)