Browse Source

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
master
sys4-fr 1 year ago
parent
commit
5abfe9569c
2 changed files with 28 additions and 25 deletions
  1. +1
    -0
      depends.txt
  2. +27
    -25
      yeti.lua

+ 1
- 0
depends.txt View File

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

+ 27
- 25
yeti.lua 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

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

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,
-- 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

on_use = mobs_shoot_snowball
})
-- 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
mobs:alias_mob("mobs:yeti", "pmobs:yeti")

Loading…
Cancel
Save