Désactive le lancé de boule de neige si le mod snow est detecté

Le mod snow implémente déjà cette fonctionnalité et de bien meilleure manière
This commit is contained in:
sys4-fr 2018-11-07 20:49:17 +01:00
parent 2dfcf120c1
commit 5abfe9569c
2 changed files with 28 additions and 27 deletions

View File

@ -2,3 +2,4 @@ default
mobs
maptools?
zombie?
snow?

View File

@ -79,34 +79,34 @@ mobs:register_arrow("pmobs:snowball", {
})
-- snowball throwing item
if not minetest.get_modpath("snow") then
local snowball_GRAVITY=9
local snowball_VELOCITY=19
local snowball_GRAVITY=9
local snowball_VELOCITY=19
-- shoot snowball
local mobs_shoot_snowball=function (item, player, pointed_thing)
local playerpos=player:getpos()
local obj=minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, "pmobs:snowball")
local dir=player:get_look_dir()
obj:get_luaentity().velocity = snowball_VELOCITY -- needed for api internal timing
obj:setvelocity({x=dir.x*snowball_VELOCITY, y=dir.y*snowball_VELOCITY, z=dir.z*snowball_VELOCITY})
obj:setacceleration({x=dir.x*-3, y=-snowball_GRAVITY, z=dir.z*-3})
item:take_item()
return item
end
-- shoot snowball
local mobs_shoot_snowball=function (item, player, pointed_thing)
local playerpos=player:getpos()
local obj=minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, "pmobs:snowball")
local dir=player:get_look_dir()
obj:get_luaentity().velocity = snowball_VELOCITY -- needed for api internal timing
obj:setvelocity({x=dir.x*snowball_VELOCITY, y=dir.y*snowball_VELOCITY, z=dir.z*snowball_VELOCITY})
obj:setacceleration({x=dir.x*-3, y=-snowball_GRAVITY, z=dir.z*-3})
item:take_item()
return item
-- override default snow to shoot snowballs
minetest.override_item("default:snow", {
--Disable placement prediction for snow.
node_placement_prediction = "",
on_construct = function(pos)
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") > 0 then
minetest.set_node({x=pos.x, y=pos.y-1, z=pos.z}, {name="default:dirt_with_snow"})
end
end,
on_use = mobs_shoot_snowball
})
end
-- override default snow to shoot snowballs
minetest.override_item("default:snow", {
--Disable placement prediction for snow.
node_placement_prediction = "",
on_construct = function(pos)
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") > 0 then
minetest.set_node({x=pos.x, y=pos.y-1, z=pos.z}, {name="default:dirt_with_snow"})
end
end,
on_use = mobs_shoot_snowball
})
mobs:alias_mob("mobs:yeti", "pmobs:yeti")