Compare commits
70 Commits
master
...
master_old
Author | SHA1 | Date | |
---|---|---|---|
|
b4b71f5dc8 | ||
|
edb0a24809 | ||
|
3e007b1ea6 | ||
|
02c8bea45e | ||
|
d74dfde51a | ||
|
e2fe01a10b | ||
|
1fc949bf99 | ||
|
47185f48c8 | ||
|
ea4e576ee6 | ||
|
43855a6e6b | ||
|
9f061a533c | ||
|
523492b1a4 | ||
|
692b36ba59 | ||
|
0e173ccefb | ||
|
ae9c9c32dc | ||
|
9046b0fad7 | ||
|
ff01e876f5 | ||
|
da35fb58ac | ||
|
4db155bd9b | ||
|
428b88bdda | ||
|
2603c721d2 | ||
|
592e247c1c | ||
|
a4d47e7e6b | ||
|
9739add50c | ||
|
5eb1de1627 | ||
|
3497f917f9 | ||
|
88794f7a8f | ||
|
6b94bef75e | ||
|
394465e515 | ||
|
a003553309 | ||
|
3f12094bdf | ||
|
f26ca5c2b9 | ||
|
87dec04c58 | ||
|
41bf1ae241 | ||
|
b271747df7 | ||
|
d12f80d1f3 | ||
|
1d9c2ed3c5 | ||
|
e96d9da420 | ||
|
6b8a1b7f82 | ||
|
da60a0f9ab | ||
|
fe42ca01db | ||
|
21d78e0b65 | ||
|
3a3de549bf | ||
|
58b239b4ae | ||
|
c905656ec8 | ||
|
ea3ab21024 | ||
|
23477fb85f | ||
|
a73dc9aa39 | ||
|
a5025cdfb8 | ||
|
439646417a | ||
|
1f04669a68 | ||
|
05670a46c7 | ||
|
af4f5219f1 | ||
|
43bfded8b2 | ||
|
517c7afd06 | ||
|
40f0c24552 | ||
|
e2badd6a6f | ||
|
58d9d44c35 | ||
|
3d06833867 | ||
|
0b7e8b89c6 | ||
|
beaff3d886 | ||
|
a52acac435 | ||
|
c0a53e2340 | ||
|
f838db1cef | ||
|
c789f39247 | ||
|
d9602eef55 | ||
|
58ac8ed83c | ||
|
b1c3a5a590 | ||
|
de7cd62f17 | ||
|
9d4581ec5b |
8
CHANGES.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
1.0
|
||||||
|
- Forked & renamed from Rui's original "creeper" mod.
|
||||||
|
- Updated for Minetest 5.x API.
|
||||||
|
- Changed to MIT license.
|
||||||
|
- Ported to Creatures Revived (cmer) engine.
|
||||||
|
- Spawn on more types of nodes.
|
||||||
|
- Spawn on "nether:rack" if nether mod available.
|
13
LICENSE.md
@ -1,13 +0,0 @@
|
|||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
||||||
Version 2, December 2004
|
|
||||||
|
|
||||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim or modified
|
|
||||||
copies of this license document, and changing it is allowed as long
|
|
||||||
as the name is changed.
|
|
||||||
|
|
||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
||||||
|
|
||||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
|
21
LICENSE.txt
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright © 2021 Jordan Irwin (AntumDeluge)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
55
README.md
@ -1,8 +1,51 @@
|
|||||||
# creeper
|
## Sneeker mod for Minetest
|
||||||
Adds some explosive nuisance.
|
|
||||||
|
|
||||||
## Forum Topic
|
---
|
||||||
- https://forum.minetest.net/viewtopic.php?t=11891
|
### Description:
|
||||||
|
|
||||||
## License
|
An explosive nuisance for [Minetest](http://minetest.net/).
|
||||||
- **Code:** WTFPL
|
|
||||||
|
![screenshot](screenshot.png)
|
||||||
|
|
||||||
|
---
|
||||||
|
### Licensing:
|
||||||
|
|
||||||
|
- **Code:** [MIT](LICENSE.txt)
|
||||||
|
- Original by Rui: WTFPL
|
||||||
|
|
||||||
|
---
|
||||||
|
### Usage:
|
||||||
|
|
||||||
|
Settings:
|
||||||
|
- ***sneeker.spawn_chance***
|
||||||
|
- Sets possibility for spawn.
|
||||||
|
- type: int
|
||||||
|
- default: 10000
|
||||||
|
- ***sneeker.spawn_interval***
|
||||||
|
- Sets frequency of spawn chance.
|
||||||
|
- type: int
|
||||||
|
- default: 240 (4 minutes)
|
||||||
|
- ***sneeker.spawn_minlight***
|
||||||
|
- Sets the minimum light that a node must have for spawn to occur.
|
||||||
|
- type: int
|
||||||
|
- default: 0
|
||||||
|
- ***sneeker.spawn_maxlight***
|
||||||
|
- Sets the maximum light that a node can have for spawn to occur.
|
||||||
|
- type: int
|
||||||
|
- default: 9
|
||||||
|
- ***sneeker.spawn_minheight***
|
||||||
|
- Sets the maximum light that a node can have for spawn to occur.
|
||||||
|
- type: int
|
||||||
|
- default: -31000
|
||||||
|
- ***sneeker.spawn_maxheight***
|
||||||
|
- Sets the lowest position at which sneeker can spawn.
|
||||||
|
- type: int
|
||||||
|
- default 31000
|
||||||
|
|
||||||
|
---
|
||||||
|
### Links:
|
||||||
|
|
||||||
|
- [Original forum thread](https://forum.minetest.net/viewtopic.php?t=11891)
|
||||||
|
- [Git repo](https://github.com/AntumMT/mod-sneeker)
|
||||||
|
- [Changelog](CHANGES.txt)
|
||||||
|
- [TODO](TODO.txt)
|
||||||
|
5
TODO.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
TODO:
|
||||||
|
- fix walk logic to stop before exploding
|
||||||
|
- fix sound playthrough
|
||||||
|
- remove unused setting "sneeker.spawn_cap"
|
13
functions.lua
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
-- Functions for sneeker mod
|
||||||
|
|
||||||
|
|
||||||
|
-- Spawns a sneeker entity
|
||||||
|
function sneeker.spawn(pos)
|
||||||
|
core.add_entity(pos, sneeker.mob_name)
|
||||||
|
sneeker.log("debug", "Spawned entity \"" .. sneeker.mob_name .. "\" at " .. tostring(pos.x) .. "," .. tostring(pos.y))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Retrieves pos coordinates in string value
|
||||||
|
function sneeker.get_pos_string(pos)
|
||||||
|
return "x=" .. tostring(pos.x) .. ", y=" .. tostring(pos.y) .. ", z=" .. tostring(pos.z)
|
||||||
|
end
|
408
init.lua
@ -1,45 +1,83 @@
|
|||||||
creeper = {}
|
|
||||||
|
sneeker = {}
|
||||||
|
sneeker.modname = core.get_current_modname()
|
||||||
|
sneeker.modpath = core.get_modpath(sneeker.modname)
|
||||||
|
|
||||||
|
dofile(sneeker.modpath .. "/settings.lua")
|
||||||
|
|
||||||
|
sneeker.log = function(lvl, msg)
|
||||||
|
if lvl == "debug" and not sneeker.debug then return end
|
||||||
|
|
||||||
|
if not msg then
|
||||||
|
msg = lvl
|
||||||
|
lvl = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
msg = "[" .. sneeker.modname .. "] " .. msg
|
||||||
|
if lvl == "debug" then
|
||||||
|
msg = "[DEBUG] " .. msg
|
||||||
|
end
|
||||||
|
|
||||||
|
if not lvl then
|
||||||
|
core.log(msg)
|
||||||
|
else
|
||||||
|
core.log(lvl, msg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
sneeker.log("debug", "Debugging is on")
|
||||||
|
|
||||||
|
|
||||||
|
if core.settings:get_bool("log_mods") then
|
||||||
|
core.log("action", "Loading mod \"" .. sneeker.modname .. "\" ...")
|
||||||
|
end
|
||||||
|
|
||||||
|
sneeker.mob_name = "sneeker:sneeker"
|
||||||
|
local old_spawnegg_name = "sneeker:spawnegg"
|
||||||
|
|
||||||
|
local scripts = {
|
||||||
|
"functions",
|
||||||
|
"tnt_function",
|
||||||
|
--"spawn",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, script in ipairs(scripts) do
|
||||||
|
dofile(sneeker.modpath .. "/" .. script .. ".lua")
|
||||||
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
-- DISABLED!!!
|
local function jump(self, pos, direction)
|
||||||
do return end
|
|
||||||
--]]
|
|
||||||
|
|
||||||
dofile(minetest.get_modpath("creeper").."/tnt_function.lua")
|
|
||||||
dofile(minetest.get_modpath("creeper").."/spawn.lua")
|
|
||||||
|
|
||||||
local function jump(self,pos,direction)
|
|
||||||
local velocity = self.object:get_velocity()
|
local velocity = self.object:get_velocity()
|
||||||
if minetest.registered_nodes[minetest.get_node(pos).name].climbable then
|
if core.registered_nodes[core.get_node(pos).name].climbable then
|
||||||
self.object:set_velocity({x=velocity.x,y=4,z=velocity.z})
|
self.object:set_velocity({x=velocity.x, y=4, z=velocity.z})
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local spos = {x=pos.x+direction.x,y=pos.y,z=pos.z+direction.z}
|
local spos = {x=pos.x+direction.x, y=pos.y, z=pos.z+direction.z}
|
||||||
local node = minetest.get_node_or_nil(spos)
|
local node = core.get_node_or_nil(spos)
|
||||||
spos.y = spos.y+1
|
spos.y = spos.y+1
|
||||||
local node2 = minetest.get_node_or_nil(spos)
|
local node2 = core.get_node_or_nil(spos)
|
||||||
local def,def2 = {}
|
local def, def2 = {}
|
||||||
if node and node.name then
|
if node and node.name then
|
||||||
def = minetest.registered_items[node.name]
|
def = core.registered_items[node.name]
|
||||||
end
|
end
|
||||||
if node2 and node2.name then
|
if node2 and node2.name then
|
||||||
def2 = minetest.registered_items[node2.name]
|
def2 = core.registered_items[node2.name]
|
||||||
end
|
end
|
||||||
if def and def.walkable
|
if def and def.walkable
|
||||||
and def2 and not def2.walkable
|
and def2 and not def2.walkable
|
||||||
and def.drawtype ~= "fencelike" then
|
and def.drawtype ~= "fencelike" then
|
||||||
self.object:set_velocity({
|
self.object:set_velocity({
|
||||||
x=velocity.x*2.2,
|
x = velocity.x*2.2,
|
||||||
y=self.jump_height,
|
y = self.jump_height,
|
||||||
z=velocity.z*2.2
|
z = velocity.z*2.2
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function random_turn(self)
|
local function random_turn(self)
|
||||||
if self.turn_timer > math.random(2,5) then
|
if self.turn_timer > math.random(2, 5) then
|
||||||
local select_turn = math.random(1,3)
|
local select_turn = math.random(1, 3)
|
||||||
if select_turn == 1 then
|
if select_turn == 1 then
|
||||||
self.turn = "left"
|
self.turn = "left"
|
||||||
elseif select_turn == 2 then
|
elseif select_turn == 2 then
|
||||||
@ -55,10 +93,10 @@ end
|
|||||||
local def = {
|
local def = {
|
||||||
hp_max = 20,
|
hp_max = 20,
|
||||||
physical = true,
|
physical = true,
|
||||||
collisionbox = {-0.25,-0.7,-0.25, 0.25,0.8,0.25},
|
collisionbox = {-0.25, -0.7, -0.25, 0.25, 0.8, 0.25},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "character.b3d",
|
mesh = "character.b3d",
|
||||||
textures = {"creeper.png"},
|
textures = {"sneeker.png"},
|
||||||
makes_footstep_sound = false,
|
makes_footstep_sound = false,
|
||||||
|
|
||||||
-- Original
|
-- Original
|
||||||
@ -73,40 +111,145 @@ local def = {
|
|||||||
animation_speed = 30,
|
animation_speed = 30,
|
||||||
knockback_level = 2
|
knockback_level = 2
|
||||||
}
|
}
|
||||||
|
]]
|
||||||
|
|
||||||
def.on_activate = function(self,staticdata)
|
local sneeker_on_activate = function(self, staticdata)
|
||||||
|
--[[
|
||||||
self.yaw = 0
|
self.yaw = 0
|
||||||
self.anim = 1
|
self.anim = 1
|
||||||
|
]]
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
self.visualx = 1
|
self.visualx = 1
|
||||||
|
--[[
|
||||||
self.jump_timer = 0
|
self.jump_timer = 0
|
||||||
self.turn_timer = 0
|
self.turn_timer = 0
|
||||||
self.turn_speed = 0
|
self.turn_speed = 0
|
||||||
|
]]
|
||||||
self.powered = false
|
self.powered = false
|
||||||
|
--[[
|
||||||
self.knockback = false
|
self.knockback = false
|
||||||
self.state = math.random(1,2)
|
self.state = math.random(1, 2)
|
||||||
self.old_y = self.object:get_pos().y
|
self.old_y = self.object:get_pos().y
|
||||||
|
]]
|
||||||
|
|
||||||
local data = minetest.deserialize(staticdata)
|
local data = core.deserialize(staticdata)
|
||||||
if data and type(data) == "table" then
|
if data and type(data) == "table" then
|
||||||
if data.powered == true then
|
if data.powered == true then
|
||||||
self.powered = true
|
self.powered = true
|
||||||
self.object:set_properties({textures = {"creeper_powered.png"}})
|
self.object:set_properties({textures = {"sneeker_powered.png"}})
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if math.random(0,20) == 20 then
|
if math.random(0, 20) == 20 then
|
||||||
self.powered = true
|
self.powered = true
|
||||||
self.object:set_properties({textures = {"creeper_powered.png"}})
|
self.object:set_properties({textures = {"sneeker_powered.png"}})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function isnan(n)
|
local function isnan(n)
|
||||||
return tostring(n) == tostring((-1)^.5)
|
return tostring(n) == tostring((-1)^.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
def.on_step = function(self, dtime)
|
local sneeker_on_step = function(self, dtime)
|
||||||
|
if self.stunned then return false end
|
||||||
|
|
||||||
|
local pos = self.object:get_pos()
|
||||||
|
local inside = core.get_objects_inside_radius(pos, 10)
|
||||||
|
local velocity = self.object:get_velocity()
|
||||||
|
|
||||||
|
self.timer = self.timer+0.01
|
||||||
|
|
||||||
|
if self.mode == "follow" and self.visualx < 2 then
|
||||||
|
if not self.hiss then
|
||||||
|
core.sound_play("sneeker_hiss", {pos=pos, gain=1.5, max_hear_distance=2*64})
|
||||||
|
end
|
||||||
|
self.visualx = self.visualx+0.05
|
||||||
|
self.object:set_properties({
|
||||||
|
visual_size = {x=self.visualx, y=1}
|
||||||
|
})
|
||||||
|
self.hiss = true
|
||||||
|
elseif self.visualx > 1 then
|
||||||
|
self.visualx = self.visualx-0.05
|
||||||
|
self.object:set_properties({
|
||||||
|
visual_size = {x=self.visualx, y=1}
|
||||||
|
})
|
||||||
|
self.hiss = false
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, object in ipairs(inside) do
|
||||||
|
if object:is_player() then
|
||||||
|
self.mode = "follow"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.mode == "follow" then
|
||||||
|
local inside_2 = core.get_objects_inside_radius(pos, 2)
|
||||||
|
|
||||||
|
-- boom
|
||||||
|
if #inside_2 ~= 0 then
|
||||||
|
for _, object in ipairs(inside_2) do
|
||||||
|
if object:is_player() and object:get_hp() ~= 0 then
|
||||||
|
if self.visualx >= 2 then
|
||||||
|
self.object:remove()
|
||||||
|
sneeker.boom(pos, self.powered)
|
||||||
|
core.sound_play("sneeker_explode", {pos=pos, gain=1.5, max_hear_distance=2*64})
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #inside > 0 then
|
||||||
|
for _, object in ipairs(inside) do
|
||||||
|
if object:is_player() and object:get_hp() ~= 0 then
|
||||||
|
if #inside_2 > 0 then
|
||||||
|
for _, object in ipairs(inside_2) do
|
||||||
|
-- Stop move
|
||||||
|
if object:is_player() then
|
||||||
|
--[[
|
||||||
|
if self.anim ~= ANIM_STAND then
|
||||||
|
self.object:set_animation({x=animation.stand_START, y=animation.stand_END}, anim_speed, 0)
|
||||||
|
self.anim = ANIM_STAND
|
||||||
|
end
|
||||||
|
]]
|
||||||
|
--self.object:set_velocity({x=0, y=velocity.y, z=0})
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- follow player
|
||||||
|
local ppos = object:get_pos()
|
||||||
|
self.vec = {x=ppos.x-pos.x, y=ppos.y-pos.y, z=ppos.z-pos.z}
|
||||||
|
self.yaw = math.atan(self.vec.z/self.vec.x)+math.pi^2
|
||||||
|
if ppos.x > pos.x then
|
||||||
|
self.yaw = self.yaw+math.pi
|
||||||
|
end
|
||||||
|
self.yaw = self.yaw-2
|
||||||
|
self.object:set_yaw(self.yaw)
|
||||||
|
self.direction = {x=math.sin(self.yaw)*-1, y=0, z=math.cos(self.yaw)}
|
||||||
|
|
||||||
|
local direction = self.direction
|
||||||
|
local dir_x = direction.x*2.5
|
||||||
|
local dir_y = velocity.y
|
||||||
|
local dir_z = direction.z*2.5
|
||||||
|
|
||||||
|
if not isnan(dir_x) and not isnan(dir_y) and not isnan(dir_z) then
|
||||||
|
self.object:set_velocity({x=direction.x*2.5, y=velocity.y, z=direction.z*2.5})
|
||||||
|
else
|
||||||
|
sneeker.log("warning", "Found NaN")
|
||||||
|
for k, v in ipairs({x=dir_x, y=dir_y, z=dir_z}) do
|
||||||
|
if isnan(v) then
|
||||||
|
sneeker.log("warning", "\"" .. k .. "\" is not a number: " .. tostring(v))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
if self.knockback then
|
if self.knockback then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -116,7 +259,7 @@ def.on_step = function(self, dtime)
|
|||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
local yaw = self.object:get_yaw()
|
local yaw = self.object:get_yaw()
|
||||||
local inside = minetest.get_objects_inside_radius(pos,10)
|
local inside = core.get_objects_inside_radius(pos, 10)
|
||||||
local walk_speed = self.walk_speed
|
local walk_speed = self.walk_speed
|
||||||
local animation = self.animation
|
local animation = self.animation
|
||||||
local anim_speed = self.animation_speed
|
local anim_speed = self.animation_speed
|
||||||
@ -127,7 +270,7 @@ def.on_step = function(self, dtime)
|
|||||||
self.jump_timer = self.jump_timer+0.01
|
self.jump_timer = self.jump_timer+0.01
|
||||||
|
|
||||||
if not self.chase
|
if not self.chase
|
||||||
and self.timer > math.random(2,5) then
|
and self.timer > math.random(2, 5) then
|
||||||
if math.random() > 0.8 then
|
if math.random() > 0.8 then
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
else
|
else
|
||||||
@ -146,24 +289,24 @@ def.on_step = function(self, dtime)
|
|||||||
|
|
||||||
if self.chase and self.visualx < 2 then
|
if self.chase and self.visualx < 2 then
|
||||||
if self.hiss == false then
|
if self.hiss == false then
|
||||||
minetest.sound_play("creeper_hiss",{pos=pos,gain=1.5,max_hear_distance=2*64})
|
core.sound_play("sneeker_hiss", {pos=pos, gain=1.5, max_hear_distance=2*64})
|
||||||
end
|
end
|
||||||
self.visualx = self.visualx+0.05
|
self.visualx = self.visualx+0.05
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
visual_size = {x=self.visualx,y=1}
|
visual_size = {x=self.visualx, y=1}
|
||||||
})
|
})
|
||||||
self.hiss = true
|
self.hiss = true
|
||||||
elseif self.visualx > 1 then
|
elseif self.visualx > 1 then
|
||||||
self.visualx = self.visualx-0.05
|
self.visualx = self.visualx-0.05
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
visual_size = {x=self.visualx,y=1}
|
visual_size = {x=self.visualx, y=1}
|
||||||
})
|
})
|
||||||
self.hiss = false
|
self.hiss = false
|
||||||
end
|
end
|
||||||
|
|
||||||
self.chase = false
|
self.chase = false
|
||||||
|
|
||||||
for _,object in ipairs(inside) do
|
for _, object in ipairs(inside) do
|
||||||
if object:is_player() then
|
if object:is_player() then
|
||||||
self.state = "chase"
|
self.state = "chase"
|
||||||
end
|
end
|
||||||
@ -171,7 +314,7 @@ def.on_step = function(self, dtime)
|
|||||||
|
|
||||||
if self.state == "stand" then
|
if self.state == "stand" then
|
||||||
if self.anim ~= ANIM_STAND then
|
if self.anim ~= ANIM_STAND then
|
||||||
self.object:set_animation({x=animation.stand_START,y=animation.stand_END},anim_speed,0)
|
self.object:set_animation({x=animation.stand_START, y=animation.stand_END}, anim_speed, 0)
|
||||||
self.anim = ANIM_STAND
|
self.anim = ANIM_STAND
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -179,19 +322,19 @@ def.on_step = function(self, dtime)
|
|||||||
|
|
||||||
if velocity.x ~= 0
|
if velocity.x ~= 0
|
||||||
or velocity.z ~= 0 then
|
or velocity.z ~= 0 then
|
||||||
self.object:set_velocity({x=0,y=velocity.y,z=0})
|
self.object:set_velocity({x=0, y=velocity.y, z=0})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.state == "walk" then
|
if self.state == "walk" then
|
||||||
if self.anim ~= ANIM_WALK then
|
if self.anim ~= ANIM_WALK then
|
||||||
self.object:set_animation({x=animation.walk_START,y=animation.walk_END},anim_speed,0)
|
self.object:set_animation({x=animation.walk_START, y=animation.walk_END}, anim_speed, 0)
|
||||||
self.anim = ANIM_WALK
|
self.anim = ANIM_WALK
|
||||||
end
|
end
|
||||||
|
|
||||||
self.direction = {x=math.sin(yaw)*-1,y=-10,z=math.cos(yaw)}
|
self.direction = {x=math.sin(yaw)*-1, y=-10, z=math.cos(yaw)}
|
||||||
if self.direction then
|
if self.direction then
|
||||||
self.object:set_velocity({x=self.direction.x*walk_speed,y=velocity.y,z=self.direction.z*walk_speed})
|
self.object:set_velocity({x=self.direction.x*walk_speed, y=velocity.y, z=self.direction.z*walk_speed})
|
||||||
end
|
end
|
||||||
|
|
||||||
random_turn(self)
|
random_turn(self)
|
||||||
@ -200,10 +343,10 @@ def.on_step = function(self, dtime)
|
|||||||
|
|
||||||
if self.turn_timer > 1 then
|
if self.turn_timer > 1 then
|
||||||
local direction = self.direction
|
local direction = self.direction
|
||||||
local npos = {x=pos.x+direction.x,y=pos.y+0.2,z=pos.z+direction.z}
|
local npos = {x=pos.x+direction.x, y=pos.y+0.2, z=pos.z+direction.z}
|
||||||
if velocity.x == 0 or velocity.z == 0
|
if velocity.x == 0 or velocity.z == 0
|
||||||
or minetest.registered_nodes[minetest.get_node(npos).name].walkable then
|
or core.registered_nodes[core.get_node(npos).name].walkable then
|
||||||
local select_turn = math.random(1,2)
|
local select_turn = math.random(1, 2)
|
||||||
if select_turn == 1 then
|
if select_turn == 1 then
|
||||||
self.turn = "left"
|
self.turn = "left"
|
||||||
elseif select_turn == 2 then
|
elseif select_turn == 2 then
|
||||||
@ -216,79 +359,67 @@ def.on_step = function(self, dtime)
|
|||||||
|
|
||||||
-- Jump
|
-- Jump
|
||||||
if self.jump_timer > 0.2 then
|
if self.jump_timer > 0.2 then
|
||||||
jump(self,pos,self.direction)
|
jump(self, pos, self.direction)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.state == "chase" then
|
if self.state == "chase" then
|
||||||
if self.anim ~= ANIM_WALK then
|
if self.anim ~= ANIM_WALK then
|
||||||
self.object:set_animation({x=animation.walk_START,y=animation.walk_END},anim_speed,0)
|
self.object:set_animation({x=animation.walk_START, y=animation.walk_END}, anim_speed, 0)
|
||||||
self.anim = ANIM_WALK
|
self.anim = ANIM_WALK
|
||||||
end
|
end
|
||||||
|
|
||||||
self.turn = "straight"
|
self.turn = "straight"
|
||||||
|
|
||||||
local inside_2 = minetest.get_objects_inside_radius(pos,2)
|
local inside_2 = core.get_objects_inside_radius(pos, 2)
|
||||||
|
|
||||||
-- Boom
|
-- Boom
|
||||||
if #inside_2 ~= 0 then
|
if #inside_2 ~= 0 then
|
||||||
for _,object in ipairs(inside_2) do
|
for _, object in ipairs(inside_2) do
|
||||||
if object:is_player() and object:get_hp() ~= 0 then
|
if object:is_player() and object:get_hp() ~= 0 then
|
||||||
self.chase = true
|
self.chase = true
|
||||||
if self.visualx >= 2 then
|
if self.visualx >= 2 then
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
creeper.boom(pos,self.powered)
|
sneeker.boom(pos, self.powered)
|
||||||
minetest.sound_play("creeper_explode",{pos=pos,gain=1.5,max_hear_distance=2*64})
|
core.sound_play("sneeker_explode", {pos=pos, gain=1.5, max_hear_distance=2*64})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if #inside ~= 0 then
|
if #inside ~= 0 then
|
||||||
for _,object in ipairs(inside) do
|
for _, object in ipairs(inside) do
|
||||||
if object:is_player() and object:get_hp() ~= 0 then
|
if object:is_player() and object:get_hp() ~= 0 then
|
||||||
if #inside_2 ~= 0 then
|
if #inside_2 ~= 0 then
|
||||||
for _,object in ipairs(inside_2) do
|
for _, object in ipairs(inside_2) do
|
||||||
-- Stop move
|
-- Stop move
|
||||||
if object:is_player() then
|
if object:is_player() then
|
||||||
if self.anim ~= ANIM_STAND then
|
if self.anim ~= ANIM_STAND then
|
||||||
self.object:set_animation({x=animation.stand_START,y=animation.stand_END},anim_speed,0)
|
self.object:set_animation({x=animation.stand_START, y=animation.stand_END}, anim_speed, 0)
|
||||||
self.anim = ANIM_STAND
|
self.anim = ANIM_STAND
|
||||||
end
|
end
|
||||||
self.object:set_velocity({x=0,y=velocity.y,z=0})
|
self.object:set_velocity({x=0, y=velocity.y, z=0})
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ppos = object:get_pos()
|
local ppos = object:get_pos()
|
||||||
self.vec = {x=ppos.x-pos.x,y=ppos.y-pos.y,z=ppos.z-pos.z}
|
self.vec = {x=ppos.x-pos.x, y=ppos.y-pos.y, z=ppos.z-pos.z}
|
||||||
self.yaw = math.atan(self.vec.z/self.vec.x)+math.pi^2
|
self.yaw = math.atan(self.vec.z/self.vec.x)+math.pi^2
|
||||||
if ppos.x > pos.x then
|
if ppos.x > pos.x then
|
||||||
self.yaw = self.yaw+math.pi
|
self.yaw = self.yaw+math.pi
|
||||||
end
|
end
|
||||||
self.yaw = self.yaw-2
|
self.yaw = self.yaw-2
|
||||||
self.object:set_yaw(self.yaw)
|
self.object:set_yaw(self.yaw)
|
||||||
self.direction = {x=math.sin(self.yaw)*-1,y=0,z=math.cos(self.yaw)}
|
self.direction = {x=math.sin(self.yaw)*-1, y=0, z=math.cos(self.yaw)}
|
||||||
|
|
||||||
local direction = self.direction
|
local direction = self.direction
|
||||||
|
self.object:set_velocity({x=direction.x*2.5, y=velocity.y, z=direction.z*2.5})
|
||||||
-- FIXME: hack
|
|
||||||
local can_set = true
|
|
||||||
for _, c in ipairs({direction.x*2.5, direction.z*2.5}) do
|
|
||||||
if isnan(c) then
|
|
||||||
can_set = false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if can_set then
|
|
||||||
self.object:set_velocity({x=direction.x*2.5,y=velocity.y,z=direction.z*2.5})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Jump
|
-- Jump
|
||||||
if self.jump_timer > 0.2 then
|
if self.jump_timer > 0.2 then
|
||||||
jump(self,pos,direction)
|
jump(self, pos, direction)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -298,63 +429,132 @@ def.on_step = function(self, dtime)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Swim
|
-- Swim
|
||||||
local node = minetest.get_node(pos)
|
local node = core.get_node(pos)
|
||||||
if minetest.get_item_group(node.name,"water") ~= 0 then
|
if core.get_item_group(node.name, "water") ~= 0 then
|
||||||
self.object:set_acceleration({x=0,y=1,z=0})
|
self.object:set_acceleration({x=0, y=1, z=0})
|
||||||
local velocity = self.object:get_velocity()
|
local velocity = self.object:get_velocity()
|
||||||
if self.object:get_velocity().y > 5 then
|
if self.object:get_velocity().y > 5 then
|
||||||
self.object:set_velocity({x=0,y=velocity.y-velocity.y/2,z=0})
|
self.object:set_velocity({x=0, y=velocity.y-velocity.y/2, z=0})
|
||||||
else
|
else
|
||||||
self.object:set_velocity({x=0,y=velocity.y+1,z=0})
|
self.object:set_velocity({x=0, y=velocity.y+1, z=0})
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self.object:set_acceleration({x=0,y=-10,z=0})
|
self.object:set_acceleration({x=0, y=-10, z=0})
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
end
|
end
|
||||||
|
|
||||||
def.on_punch = function(self,puncher,time_from_last_punch,tool_capabilities,dir)
|
--[[
|
||||||
|
def.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||||
if self.knockback == false then
|
if self.knockback == false then
|
||||||
local knockback_level = self.knockback_level
|
local knockback_level = self.knockback_level
|
||||||
self.object:set_velocity({x=dir.x*knockback_level,y=3,z=dir.z*knockback_level})
|
self.object:set_velocity({x=dir.x*knockback_level, y=3, z=dir.z*knockback_level})
|
||||||
self.knockback = true
|
self.knockback = true
|
||||||
minetest.after(0.6,function()
|
core.after(0.6, function()
|
||||||
self.knockback = false
|
self.knockback = false
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
if self.object:get_hp() < 1 then
|
if self.object:get_hp() < 1 then
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
local x = 1/math.random(1,5)*dir.x
|
local x = 1/math.random(1, 5)*dir.x
|
||||||
local z = 1/math.random(1,5)*dir.z
|
local z = 1/math.random(1, 5)*dir.z
|
||||||
local p = {x=pos.x+x,y=pos.y,z=pos.z+z}
|
local p = {x=pos.x+x, y=pos.y, z=pos.z+z}
|
||||||
local node = minetest.get_node_or_nil(p)
|
local node = core.get_node_or_nil(p)
|
||||||
if node == nil or not node.name or node.name ~= "air" then
|
if node == nil or not node.name or node.name ~= "air" then
|
||||||
p = pos
|
p = pos
|
||||||
end
|
end
|
||||||
local obj = minetest.add_item(p, {name="tnt:gunpowder",count=math.random(0,2)})
|
local obj = core.add_item(p, {name="tnt:gunpowder", count=math.random(0, 2)})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
|
|
||||||
def.get_staticdata = function(self)
|
local sneeker_get_staticdata = function(self)
|
||||||
return minetest.serialize({
|
return core.serialize({
|
||||||
powered = self.powered
|
powered = self.powered
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_entity("creeper:creeper",def)
|
--core.register_entity(sneeker.mob_name, def)
|
||||||
|
|
||||||
minetest.register_craftitem("creeper:spawnegg",{
|
|
||||||
description = "Creeper Spawn Egg",
|
local spawn_nodes = {
|
||||||
inventory_image = "creeper_spawnegg.png",
|
"default:dirt",
|
||||||
stack_max = 64,
|
"default:dirt_with_grass",
|
||||||
on_place = function(itemstack,placer,pointed_thing)
|
"default:dry_dirt_with_dry_grass",
|
||||||
if pointed_thing.type == "node" then
|
"default:desert_sand",
|
||||||
local pos = pointed_thing.above
|
"default:sand",
|
||||||
pos.y = pos.y+1
|
"default:stone",
|
||||||
minetest.add_entity(pos,"creeper:creeper")
|
"default:desert_stone",
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
}
|
||||||
itemstack:take_item()
|
|
||||||
end
|
if core.global_exists("nether") then
|
||||||
return itemstack
|
table.insert(spawn_nodes, "nether:rack")
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
local drops = nil
|
||||||
|
if core.global_exists("tnt") then
|
||||||
|
drops = {
|
||||||
|
{"tnt:gunpowder", {min=1, max=2}, chance=0.66},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
cmer.register_mob({
|
||||||
|
name = sneeker.mob_name,
|
||||||
|
stats = {
|
||||||
|
hp = 20,
|
||||||
|
lifetime = 15 * 60, -- 15 minutes
|
||||||
|
can_jump = 5,
|
||||||
|
has_kockback = true,
|
||||||
|
sneaky = true,
|
||||||
|
},
|
||||||
|
modes = {
|
||||||
|
idle = {chance=0.3, moving_speed=0,},
|
||||||
|
walk = {chance=0.7, moving_speed=1.5,},
|
||||||
|
follow = {chance=0.0, moving_speed=1.5,},
|
||||||
|
inflate = {chance=0.0, moving_speed=0,},
|
||||||
|
},
|
||||||
|
model = {
|
||||||
|
mesh = "character.b3d",
|
||||||
|
textures = {"sneeker.png"},
|
||||||
|
collisionbox = {-0.25, -0.7, -0.25, 0.25, 0.8, 0.25},
|
||||||
|
rotation = 270.0,
|
||||||
|
animations = {
|
||||||
|
idle = {start=0, stop=79, speed=30,},
|
||||||
|
walk = {start=168, stop=187, speed=30,},
|
||||||
|
follow = {start=168, stop=187, speed=30,},
|
||||||
|
inflate = {start=0, stop=79, speed=30,},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
sounds = {},
|
||||||
|
drops = drops,
|
||||||
|
spawning = {
|
||||||
|
abm_nodes = {
|
||||||
|
spawn_on = spawn_nodes,
|
||||||
|
},
|
||||||
|
abm_interval = sneeker.spawn_interval,
|
||||||
|
abm_chance = sneeker.spawn_chance,
|
||||||
|
max_number = 1,
|
||||||
|
number = 1,
|
||||||
|
time_range = {min=0, max=23999},
|
||||||
|
light = {min=sneeker.spawn_minlight, max=sneeker.spawn_maxlight},
|
||||||
|
height_limit = {min=sneeker.spawn_minheight, max=sneeker.spawn_maxheight},
|
||||||
|
},
|
||||||
|
on_step = sneeker_on_step,
|
||||||
|
on_activate = sneeker_on_activate,
|
||||||
|
get_staticdata = sneeker_get_staticdata,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if core.global_exists("asm") then
|
||||||
|
asm.addEgg({
|
||||||
|
name = "sneeker",
|
||||||
|
inventory_image = "sneeker_spawnegg.png",
|
||||||
|
spawn = "sneeker:sneeker",
|
||||||
|
})
|
||||||
|
|
||||||
|
core.register_alias(old_spawnegg_name, "spawneggs:sneeker")
|
||||||
|
|
||||||
|
if core.registered_items["tnt:tnt"] then
|
||||||
|
asm.addEggRecipe("sneeker", "tnt:tnt")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
9
mod.conf
@ -1,5 +1,6 @@
|
|||||||
name = creeper
|
name = sneeker
|
||||||
title = Creeper
|
title = Sneeker
|
||||||
description = Adds some explosive nuisance.
|
description = An explosive nuisance.
|
||||||
author = Rui
|
author = Rui
|
||||||
depends = default, tnt
|
depends = cmer, default, tnt
|
||||||
|
optional_depends = asm_spawneggs, nether
|
||||||
|
53
settings.lua
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
-- Settings for sneeker mod
|
||||||
|
|
||||||
|
|
||||||
|
sneeker.time_min = 60
|
||||||
|
|
||||||
|
sneeker.debug = core.settings:get_bool("enable_debug_mods", false)
|
||||||
|
|
||||||
|
--- Sets maximum number of spawns that can exist in world at one time.
|
||||||
|
--
|
||||||
|
-- @setting sneeker.spawn_cap
|
||||||
|
sneeker.spawn_cap = tonumber(core.settings:get("sneeker.spawn_cap")) or 10
|
||||||
|
|
||||||
|
--- Sets possibility for spawn.
|
||||||
|
--
|
||||||
|
-- Inverted value (e.g. 10000 = 1/10000).
|
||||||
|
--
|
||||||
|
-- @setting sneeker.spawn_chance
|
||||||
|
sneeker.spawn_chance = tonumber(core.settings:get("sneeker.spawn_chance")) or 10000
|
||||||
|
|
||||||
|
--- Sets frequency of spawn chance.
|
||||||
|
--
|
||||||
|
-- Default 240 is equivalent to 4 minutes (60 * 4).
|
||||||
|
--
|
||||||
|
-- @setting sneeker.spawn_interval
|
||||||
|
sneeker.spawn_interval = tonumber(core.settings:get("sneeker.spawn_interval")) or sneeker.time_min * 4
|
||||||
|
|
||||||
|
--- Sets the minimum light that a node must have for spawn to occur.
|
||||||
|
--
|
||||||
|
-- Default: 0
|
||||||
|
--
|
||||||
|
-- @setting sneeker.spawn_minlight
|
||||||
|
sneeker.spawn_minlight = tonumber(core.settings:get("sneeker.spawn_minlight")) or 0
|
||||||
|
|
||||||
|
--- Sets the maximum light that a node can have for spawn to occur.
|
||||||
|
--
|
||||||
|
-- Default: 9
|
||||||
|
--
|
||||||
|
-- @setting sneeker.spawn_maxlight
|
||||||
|
sneeker.spawn_maxlight = tonumber(core.settings:get("sneeker.spawn_maxlight")) or 9
|
||||||
|
|
||||||
|
--- Sets the lowest position at which sneeker can spawn.
|
||||||
|
--
|
||||||
|
-- Default: -31000
|
||||||
|
--
|
||||||
|
-- @setting sneeker.spawn_minheight
|
||||||
|
sneeker.spawn_minheight = tonumber(core.settings:get("sneeker.spawn_minheight")) or -31000
|
||||||
|
|
||||||
|
--- Sets the highest position at which sneeker can spawn.
|
||||||
|
--
|
||||||
|
-- Default: 31000
|
||||||
|
--
|
||||||
|
-- @setting sneeker.spawn_maxheight
|
||||||
|
sneeker.spawn_maxheight = tonumber(core.settings:get("sneeker.spawn_maxheight")) or 31000
|
23
settingtypes.txt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Sets maximum number of spawns that can exist in world.
|
||||||
|
sneeker.spawn_cap (Sneeker maximum spawns) int 10
|
||||||
|
|
||||||
|
# Sets possibility for spawn.
|
||||||
|
sneeker.spawn_chance (Sneeker spawn chance) int 10000
|
||||||
|
|
||||||
|
# Sets frequency of spawn chance. Default 240 is equivalent to 4 minutes (60 * 4).
|
||||||
|
sneeker.spawn_interval (Sneeker spawn interval) int 240
|
||||||
|
|
||||||
|
# Sets the minimum light that a node must have for spawn to occur.
|
||||||
|
sneeker.spawn_minlight (Sneeker min light for spawn) int 0
|
||||||
|
|
||||||
|
# Sets the maximum light that a node can have for spawn to occur.
|
||||||
|
sneeker.spawn_maxlight (Sneeker max light for spawn) int 9
|
||||||
|
|
||||||
|
# Sets the lowest position at which sneeker can spawn.
|
||||||
|
sneeker.spawn_minheight (Sneeker min spawn height) int -31000
|
||||||
|
|
||||||
|
# Sets the highest position at which sneeker can spawn.
|
||||||
|
sneeker.spawn_maxheight (Sneeker max spawn height) int 31000
|
||||||
|
|
||||||
|
# Logs extra debug messages.
|
||||||
|
enable_debug_mods (Enable debugging messages) bool false
|
82
spawn.lua
@ -1,32 +1,84 @@
|
|||||||
minetest.register_abm({
|
|
||||||
nodenames = {"default:dirt_with_grass","default:stone"},
|
local time_hr = sneeker.time_min * 60
|
||||||
|
local time_day = time_hr * 24
|
||||||
|
|
||||||
|
-- Display spawn chance as percentage in log
|
||||||
|
local spawn_chance_percent = math.floor(1 / sneeker.spawn_chance * 100)
|
||||||
|
if spawn_chance_percent < 1 then
|
||||||
|
spawn_chance_percent = "Less than 1%"
|
||||||
|
else
|
||||||
|
spawn_chance_percent = tostring(spawn_chance_percent) .. "%"
|
||||||
|
end
|
||||||
|
|
||||||
|
sneeker.log("Spawn cap: " .. tostring(sneeker.spawn_cap))
|
||||||
|
sneeker.log("Spawn chance: " .. spawn_chance_percent)
|
||||||
|
sneeker.log("Spawn interval: " .. tostring(sneeker.spawn_interval) .. " (" .. tostring(sneeker.spawn_interval/60) .. " minute(s))")
|
||||||
|
sneeker.log("Maximum light value for spawn: " .. tostring(sneeker.spawn_maxlight))
|
||||||
|
|
||||||
|
local spawn_nodes = {"default:dirt_with_grass", "default:stone"}
|
||||||
|
if core.global_exists("nether") then
|
||||||
|
table.insert(spawn_nodes, "nether:rack")
|
||||||
|
end
|
||||||
|
|
||||||
|
core.register_abm({
|
||||||
|
nodenames = spawn_nodes,
|
||||||
neighbors = {"air"},
|
neighbors = {"air"},
|
||||||
interval = 30,
|
interval = spawn_interval,
|
||||||
chance = 9000,
|
chance = spawn_chance,
|
||||||
action = function(pos, node, _, active_object_count_wider)
|
action = function(pos, node, _, active_object_count_wider)
|
||||||
if active_object_count_wider > 5 then
|
if active_object_count_wider > 5 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Check light value of node
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
if not minetest.get_node_light(pos) then
|
local node_light = core.get_node_light(pos)
|
||||||
|
|
||||||
|
-- Debugging spawning
|
||||||
|
sneeker.log("debug", "Node light level at " .. sneeker.get_pos_string(pos) .. ": " .. tostring(node_light))
|
||||||
|
|
||||||
|
-- Node light level
|
||||||
|
if not node_light or node_light > spawn_maxlight then
|
||||||
|
sneeker.log("debug", "Node not dark enough for spawn")
|
||||||
|
return
|
||||||
|
elseif node_light < spawn_minlight then
|
||||||
|
sneeker.log("debug", "Node too dark for spawn")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.get_node_light(pos) > 5 then
|
|
||||||
|
-- Spawn range
|
||||||
|
if spawn_minheight ~= nil and pos.y < spawn_minheight then
|
||||||
|
sneeker.log("debug", "Position is too low for spawn")
|
||||||
|
return
|
||||||
|
elseif pos.y > spawn_maxheight then
|
||||||
|
sneeker.log("debug", "Position is too high for spawn")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.get_node_light(pos) < -1 then
|
|
||||||
return
|
-- Node must be touching air
|
||||||
end
|
if core.get_node(pos).name ~= "air" then
|
||||||
if pos.y > 31000 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if minetest.get_node(pos).name ~= "air" then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
if minetest.get_node(pos).name ~= "air" then
|
if core.get_node(pos).name ~= "air" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
minetest.add_entity(pos,"creeper:creeper")
|
|
||||||
|
-- Get total count of sneekers in world
|
||||||
|
local count = 0
|
||||||
|
for I in pairs(core.luaentities) do
|
||||||
|
if core.luaentities[I].name == sneeker.mob_name then
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
sneeker.log("debug", "Current active spawns: " .. tostring(count) .. "/" .. tostring(spawn_cap))
|
||||||
|
|
||||||
|
if count >= spawn_cap then
|
||||||
|
sneeker.log("debug", "Max spawns reached")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
sneeker.spawn(pos)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
Before Width: | Height: | Size: 353 B After Width: | Height: | Size: 353 B |
Before Width: | Height: | Size: 355 B After Width: | Height: | Size: 355 B |
Before Width: | Height: | Size: 139 B After Width: | Height: | Size: 139 B |
Before Width: | Height: | Size: 249 B After Width: | Height: | Size: 249 B |
@ -1,14 +1,15 @@
|
|||||||
|
|
||||||
-- From TNT
|
-- From TNT
|
||||||
local cid_data = {}
|
local cid_data = {}
|
||||||
local radius = tonumber(minetest.setting_get("tnt_radius") or 3)
|
local radius = tonumber(core.settings:get("tnt_radius") or 3)
|
||||||
local large_radius = 5
|
local large_radius = 5
|
||||||
local loss_prob = {
|
local loss_prob = {
|
||||||
["default:cobble"] = 3,
|
["default:cobble"] = 3,
|
||||||
["default:dirt"] = 4,
|
["default:dirt"] = 4,
|
||||||
}
|
}
|
||||||
minetest.after(0, function()
|
core.after(0, function()
|
||||||
for name, def in pairs(minetest.registered_nodes) do
|
for name, def in pairs(core.registered_nodes) do
|
||||||
cid_data[minetest.get_content_id(name)] = {
|
cid_data[core.get_content_id(name)] = {
|
||||||
name = name,
|
name = name,
|
||||||
drops = def.drops,
|
drops = def.drops,
|
||||||
flammable = def.groups.flammable,
|
flammable = def.groups.flammable,
|
||||||
@ -34,7 +35,7 @@ local function eject_drops(drops, pos, radius)
|
|||||||
item:set_count(count)
|
item:set_count(count)
|
||||||
end
|
end
|
||||||
rand_pos(pos, drop_pos, radius)
|
rand_pos(pos, drop_pos, radius)
|
||||||
local obj = minetest.add_item(drop_pos, item)
|
local obj = core.add_item(drop_pos, item)
|
||||||
if obj then
|
if obj then
|
||||||
obj:get_luaentity().collect = true
|
obj:get_luaentity().collect = true
|
||||||
obj:set_acceleration({x=0, y=-10, z=0})
|
obj:set_acceleration({x=0, y=-10, z=0})
|
||||||
@ -62,7 +63,7 @@ local function add_drop(drops, item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function destroy(drops, pos, cid)
|
local function destroy(drops, pos, cid)
|
||||||
if minetest.is_protected(pos, "") then
|
if core.is_protected(pos, "") then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local def = cid_data[cid]
|
local def = cid_data[cid]
|
||||||
@ -70,9 +71,9 @@ local function destroy(drops, pos, cid)
|
|||||||
def.on_blast(vector.new(pos), 1)
|
def.on_blast(vector.new(pos), 1)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
minetest.remove_node(pos)
|
core.remove_node(pos)
|
||||||
if def then
|
if def then
|
||||||
local node_drops = minetest.get_node_drops(def.name, "")
|
local node_drops = core.get_node_drops(def.name, "")
|
||||||
for _, item in ipairs(node_drops) do
|
for _, item in ipairs(node_drops) do
|
||||||
add_drop(drops, item)
|
add_drop(drops, item)
|
||||||
end
|
end
|
||||||
@ -98,7 +99,7 @@ end
|
|||||||
local function entity_physics(pos, radius)
|
local function entity_physics(pos, radius)
|
||||||
-- Make the damage radius larger than the destruction radius
|
-- Make the damage radius larger than the destruction radius
|
||||||
radius = radius * 2
|
radius = radius * 2
|
||||||
local objs = minetest.get_objects_inside_radius(pos, radius)
|
local objs = core.get_objects_inside_radius(pos, radius)
|
||||||
for _, obj in pairs(objs) do
|
for _, obj in pairs(objs) do
|
||||||
local obj_pos = obj:get_pos()
|
local obj_pos = obj:get_pos()
|
||||||
local obj_vel = obj:get_velocity()
|
local obj_vel = obj:get_velocity()
|
||||||
@ -115,7 +116,7 @@ local function entity_physics(pos, radius)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function add_effects(pos, radius)
|
local function add_effects(pos, radius)
|
||||||
minetest.add_particlespawner({
|
core.add_particlespawner({
|
||||||
amount = 128,
|
amount = 128,
|
||||||
time = 1,
|
time = 1,
|
||||||
minpos = vector.subtract(pos, radius / 2),
|
minpos = vector.subtract(pos, radius / 2),
|
||||||
@ -128,7 +129,7 @@ local function add_effects(pos, radius)
|
|||||||
maxexptime = 3,
|
maxexptime = 3,
|
||||||
minsize = 8,
|
minsize = 8,
|
||||||
maxsize = 16,
|
maxsize = 16,
|
||||||
texture = "creeper_smoke.png",
|
texture = "sneeker_smoke.png",
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -146,16 +147,16 @@ local function explode(pos, radius)
|
|||||||
local drops = {}
|
local drops = {}
|
||||||
local p = {}
|
local p = {}
|
||||||
|
|
||||||
local c_air = minetest.get_content_id("air")
|
local c_air = core.get_content_id("air")
|
||||||
local c_tnt = nil
|
local c_tnt = nil
|
||||||
if minetest.settings:get_bool("enable_tnt", false) then
|
if core.settings:get_bool("enable_tnt", false) then
|
||||||
c_tnt = minetest.get_content_id("tnt:tnt")
|
c_tnt = core.get_content_id("tnt:tnt")
|
||||||
end
|
end
|
||||||
|
|
||||||
local c_tnt_burning = minetest.get_content_id("tnt:tnt_burning")
|
local c_tnt_burning = core.get_content_id("tnt:tnt_burning")
|
||||||
local c_gunpowder = minetest.get_content_id("tnt:gunpowder")
|
local c_gunpowder = core.get_content_id("tnt:gunpowder")
|
||||||
local c_gunpowder_burning = minetest.get_content_id("tnt:gunpowder_burning")
|
local c_gunpowder_burning = core.get_content_id("tnt:gunpowder_burning")
|
||||||
local c_boom = minetest.get_content_id("tnt:boom")
|
local c_boom = core.get_content_id("tnt:boom")
|
||||||
|
|
||||||
for z = -radius, radius do
|
for z = -radius, radius do
|
||||||
for y = -radius, radius do
|
for y = -radius, radius do
|
||||||
@ -184,14 +185,14 @@ local function explode(pos, radius)
|
|||||||
return drops
|
return drops
|
||||||
end
|
end
|
||||||
|
|
||||||
function creeper.boom(pos,large)
|
function sneeker.boom(pos, large)
|
||||||
local radius = radius
|
local radius = radius
|
||||||
if large then
|
if large then
|
||||||
radius = large_radius
|
radius = large_radius
|
||||||
end
|
end
|
||||||
minetest.sound_play("creeper_explode", {pos=pos, gain=1.5, max_hear_distance=2*64})
|
core.sound_play("sneeker_explode", {pos=pos, gain=1.5, max_hear_distance=2*64})
|
||||||
minetest.set_node(pos, {name="tnt:boom"})
|
core.set_node(pos, {name="tnt:boom"})
|
||||||
minetest.get_node_timer(pos):start(0.5)
|
core.get_node_timer(pos):start(0.5)
|
||||||
local drops = explode(pos, radius)
|
local drops = explode(pos, radius)
|
||||||
entity_physics(pos, radius)
|
entity_physics(pos, radius)
|
||||||
eject_drops(drops, pos, radius)
|
eject_drops(drops, pos, radius)
|
||||||
|