Compare commits
77 Commits
mobs
...
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 | ||
|
84f6c2f3c9 | ||
|
6c46f8bf7e | ||
|
45b0bf5f08 | ||
|
6efa22caf4 | ||
|
b88e4357f9 | ||
|
cc9cb71090 | ||
|
a89eb699c9 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +0,0 @@
|
|||||||
## Eclipse project files & directories
|
|
||||||
.project
|
|
||||||
.settings
|
|
8
CHANGES.txt
Normal file
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.
|
@@ -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.
|
|
134
LICENSE.txt
134
LICENSE.txt
@@ -1,121 +1,21 @@
|
|||||||
Creative Commons Legal Code
|
The MIT License (MIT)
|
||||||
|
|
||||||
CC0 1.0 Universal
|
Copyright © 2021 Jordan Irwin (AntumDeluge)
|
||||||
|
|
||||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
the Software without restriction, including without limitation the rights to
|
||||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
so, subject to the following conditions:
|
||||||
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
|
||||||
HEREUNDER.
|
|
||||||
|
|
||||||
Statement of Purpose
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
The laws of most jurisdictions throughout the world automatically confer
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
exclusive Copyright and Related Rights (defined below) upon the creator
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
and subsequent owner(s) (each and all, an "owner") of an original work of
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
authorship and/or a database (each, a "Work").
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
Certain owners wish to permanently relinquish those rights to a Work for
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
the purpose of contributing to a commons of creative, cultural and
|
SOFTWARE.
|
||||||
scientific works ("Commons") that the public can reliably and without fear
|
|
||||||
of later claims of infringement build upon, modify, incorporate in other
|
|
||||||
works, reuse and redistribute as freely as possible in any form whatsoever
|
|
||||||
and for any purposes, including without limitation commercial purposes.
|
|
||||||
These owners may contribute to the Commons to promote the ideal of a free
|
|
||||||
culture and the further production of creative, cultural and scientific
|
|
||||||
works, or to gain reputation or greater distribution for their Work in
|
|
||||||
part through the use and efforts of others.
|
|
||||||
|
|
||||||
For these and/or other purposes and motivations, and without any
|
|
||||||
expectation of additional consideration or compensation, the person
|
|
||||||
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
|
||||||
is an owner of Copyright and Related Rights in the Work, voluntarily
|
|
||||||
elects to apply CC0 to the Work and publicly distribute the Work under its
|
|
||||||
terms, with knowledge of his or her Copyright and Related Rights in the
|
|
||||||
Work and the meaning and intended legal effect of CC0 on those rights.
|
|
||||||
|
|
||||||
1. Copyright and Related Rights. A Work made available under CC0 may be
|
|
||||||
protected by copyright and related or neighboring rights ("Copyright and
|
|
||||||
Related Rights"). Copyright and Related Rights include, but are not
|
|
||||||
limited to, the following:
|
|
||||||
|
|
||||||
i. the right to reproduce, adapt, distribute, perform, display,
|
|
||||||
communicate, and translate a Work;
|
|
||||||
ii. moral rights retained by the original author(s) and/or performer(s);
|
|
||||||
iii. publicity and privacy rights pertaining to a person's image or
|
|
||||||
likeness depicted in a Work;
|
|
||||||
iv. rights protecting against unfair competition in regards to a Work,
|
|
||||||
subject to the limitations in paragraph 4(a), below;
|
|
||||||
v. rights protecting the extraction, dissemination, use and reuse of data
|
|
||||||
in a Work;
|
|
||||||
vi. database rights (such as those arising under Directive 96/9/EC of the
|
|
||||||
European Parliament and of the Council of 11 March 1996 on the legal
|
|
||||||
protection of databases, and under any national implementation
|
|
||||||
thereof, including any amended or successor version of such
|
|
||||||
directive); and
|
|
||||||
vii. other similar, equivalent or corresponding rights throughout the
|
|
||||||
world based on applicable law or treaty, and any national
|
|
||||||
implementations thereof.
|
|
||||||
|
|
||||||
2. Waiver. To the greatest extent permitted by, but not in contravention
|
|
||||||
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
|
||||||
irrevocably and unconditionally waives, abandons, and surrenders all of
|
|
||||||
Affirmer's Copyright and Related Rights and associated claims and causes
|
|
||||||
of action, whether now known or unknown (including existing as well as
|
|
||||||
future claims and causes of action), in the Work (i) in all territories
|
|
||||||
worldwide, (ii) for the maximum duration provided by applicable law or
|
|
||||||
treaty (including future time extensions), (iii) in any current or future
|
|
||||||
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
|
||||||
including without limitation commercial, advertising or promotional
|
|
||||||
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
|
||||||
member of the public at large and to the detriment of Affirmer's heirs and
|
|
||||||
successors, fully intending that such Waiver shall not be subject to
|
|
||||||
revocation, rescission, cancellation, termination, or any other legal or
|
|
||||||
equitable action to disrupt the quiet enjoyment of the Work by the public
|
|
||||||
as contemplated by Affirmer's express Statement of Purpose.
|
|
||||||
|
|
||||||
3. Public License Fallback. Should any part of the Waiver for any reason
|
|
||||||
be judged legally invalid or ineffective under applicable law, then the
|
|
||||||
Waiver shall be preserved to the maximum extent permitted taking into
|
|
||||||
account Affirmer's express Statement of Purpose. In addition, to the
|
|
||||||
extent the Waiver is so judged Affirmer hereby grants to each affected
|
|
||||||
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
|
||||||
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
|
||||||
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
|
||||||
maximum duration provided by applicable law or treaty (including future
|
|
||||||
time extensions), (iii) in any current or future medium and for any number
|
|
||||||
of copies, and (iv) for any purpose whatsoever, including without
|
|
||||||
limitation commercial, advertising or promotional purposes (the
|
|
||||||
"License"). The License shall be deemed effective as of the date CC0 was
|
|
||||||
applied by Affirmer to the Work. Should any part of the License for any
|
|
||||||
reason be judged legally invalid or ineffective under applicable law, such
|
|
||||||
partial invalidity or ineffectiveness shall not invalidate the remainder
|
|
||||||
of the License, and in such case Affirmer hereby affirms that he or she
|
|
||||||
will not (i) exercise any of his or her remaining Copyright and Related
|
|
||||||
Rights in the Work or (ii) assert any associated claims and causes of
|
|
||||||
action with respect to the Work, in either case contrary to Affirmer's
|
|
||||||
express Statement of Purpose.
|
|
||||||
|
|
||||||
4. Limitations and Disclaimers.
|
|
||||||
|
|
||||||
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
|
||||||
surrendered, licensed or otherwise affected by this document.
|
|
||||||
b. Affirmer offers the Work as-is and makes no representations or
|
|
||||||
warranties of any kind concerning the Work, express, implied,
|
|
||||||
statutory or otherwise, including without limitation warranties of
|
|
||||||
title, merchantability, fitness for a particular purpose, non
|
|
||||||
infringement, or the absence of latent or other defects, accuracy, or
|
|
||||||
the present or absence of errors, whether or not discoverable, all to
|
|
||||||
the greatest extent permissible under applicable law.
|
|
||||||
c. Affirmer disclaims responsibility for clearing rights of other persons
|
|
||||||
that may apply to the Work or any use thereof, including without
|
|
||||||
limitation any person's Copyright and Related Rights in the Work.
|
|
||||||
Further, Affirmer disclaims responsibility for obtaining any necessary
|
|
||||||
consents, permissions or other rights required for any use of the
|
|
||||||
Work.
|
|
||||||
d. Affirmer understands and acknowledges that Creative Commons is not a
|
|
||||||
party to this document and has no duty or obligation with respect to
|
|
||||||
this CC0 or use of the Work.
|
|
||||||
|
54
README.md
54
README.md
@@ -1,17 +1,51 @@
|
|||||||
# Sneeker mobile mod for Minetest
|
## Sneeker mod for Minetest
|
||||||
|
|
||||||
Adds some explosive nuisance.
|
---
|
||||||
|
### Description:
|
||||||
|
|
||||||
## Forum Topic
|
An explosive nuisance for [Minetest](http://minetest.net/).
|
||||||
|
|
||||||
- Original thread: https://forum.minetest.net/viewtopic.php?t=11891
|

|
||||||
|
|
||||||
## License
|
---
|
||||||
|
### Licensing:
|
||||||
|
|
||||||
- **Code:**
|
- **Code:** [MIT](LICENSE.txt)
|
||||||
- Original by Rui: [WTFPL][lic.wtfpl]
|
- Original by Rui: WTFPL
|
||||||
- AntumDeluge: [CC0][lic.cc0]
|
|
||||||
|
|
||||||
|
---
|
||||||
|
### Usage:
|
||||||
|
|
||||||
[lic.cc0]: LICENSE.txt
|
Settings:
|
||||||
[lic.wtfpl]: LICENSE-wtfpl.txt
|
- ***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
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"
|
@@ -1,4 +0,0 @@
|
|||||||
default
|
|
||||||
mobs?
|
|
||||||
spawneggs?
|
|
||||||
tnt?
|
|
@@ -1 +0,0 @@
|
|||||||
Adds some explosive nuisance.
|
|
@@ -1,30 +1,13 @@
|
|||||||
-- Functions for sneeker mod
|
-- Functions for sneeker mod
|
||||||
|
|
||||||
|
|
||||||
local log_mods = core.settings:get_bool('log_mods')
|
|
||||||
|
|
||||||
|
|
||||||
-- Displays a message in log output
|
|
||||||
function sneeker.log(message)
|
|
||||||
if log_mods then
|
|
||||||
core.log('action', '[' .. sneeker.modname .. '] ' .. message)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Displays a message in log output only if 'sneeker.debug' is set to 'true'
|
|
||||||
function sneeker.log_debug(message)
|
|
||||||
if sneeker.debug then
|
|
||||||
sneeker.log('DEBUG: ' .. message)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Spawns a sneeker entity
|
-- Spawns a sneeker entity
|
||||||
function sneeker.spawn(pos)
|
function sneeker.spawn(pos)
|
||||||
core.add_entity(pos, sneeker.mob_name)
|
core.add_entity(pos, sneeker.mob_name)
|
||||||
sneeker.log_debug('Spawned entity "' .. sneeker.mob_name .. '" at ' .. tostring(pos.x) .. ',' .. tostring(pos.y))
|
sneeker.log("debug", "Spawned entity \"" .. sneeker.mob_name .. "\" at " .. tostring(pos.x) .. "," .. tostring(pos.y))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Retrieves pos coordinates in string value
|
-- Retrieves pos coordinates in string value
|
||||||
function sneeker.get_pos_string(pos)
|
function sneeker.get_pos_string(pos)
|
||||||
return 'x=' .. tostring(pos.x) .. ', y=' .. tostring(pos.y) .. ', z=' .. tostring(pos.z)
|
return "x=" .. tostring(pos.x) .. ", y=" .. tostring(pos.y) .. ", z=" .. tostring(pos.z)
|
||||||
end
|
end
|
||||||
|
944
init.lua
944
init.lua
@@ -1,384 +1,560 @@
|
|||||||
-- Original code by Rui: WTFPL
|
|
||||||
|
sneeker = {}
|
||||||
|
sneeker.modname = core.get_current_modname()
|
||||||
sneeker = {}
|
sneeker.modpath = core.get_modpath(sneeker.modname)
|
||||||
sneeker.modname = core.get_current_modname()
|
|
||||||
sneeker.modpath = core.get_modpath(sneeker.modname)
|
dofile(sneeker.modpath .. "/settings.lua")
|
||||||
|
|
||||||
if core.settings:get_bool('log_mods') then
|
sneeker.log = function(lvl, msg)
|
||||||
core.log('action', 'Loading mod "' .. sneeker.modname .. '" ...')
|
if lvl == "debug" and not sneeker.debug then return end
|
||||||
end
|
|
||||||
|
if not msg then
|
||||||
dofile(sneeker.modpath .. '/settings.lua')
|
msg = lvl
|
||||||
dofile(sneeker.modpath .. '/functions.lua')
|
lvl = nil
|
||||||
|
end
|
||||||
sneeker.log_debug('Debugging is on')
|
|
||||||
|
msg = "[" .. sneeker.modname .. "] " .. msg
|
||||||
sneeker.mob_name = sneeker.modname .. ':' .. sneeker.modname
|
if lvl == "debug" then
|
||||||
sneeker.spawnegg_name = sneeker.modname .. ':spawnegg'
|
msg = "[DEBUG] " .. msg
|
||||||
|
end
|
||||||
local scripts = {
|
|
||||||
'tnt_function',
|
if not lvl then
|
||||||
'spawn',
|
core.log(msg)
|
||||||
}
|
else
|
||||||
|
core.log(lvl, msg)
|
||||||
for I in pairs(scripts) do
|
end
|
||||||
dofile(sneeker.modpath .. '/' .. scripts[I] .. '.lua')
|
end
|
||||||
end
|
|
||||||
|
sneeker.log("debug", "Debugging is on")
|
||||||
|
|
||||||
local radius = tonumber(core.settings:get('tnt_radius') or 3)
|
|
||||||
|
if core.settings:get_bool("log_mods") then
|
||||||
|
core.log("action", "Loading mod \"" .. sneeker.modname .. "\" ...")
|
||||||
local def = {
|
end
|
||||||
hp_max = 20,
|
|
||||||
physical = true,
|
sneeker.mob_name = "sneeker:sneeker"
|
||||||
collisionbox = {-0.25, -0.7, -0.25, 0.25, 0.8, 0.25},
|
local old_spawnegg_name = "sneeker:spawnegg"
|
||||||
visual = 'mesh',
|
|
||||||
mesh = 'character.b3d',
|
local scripts = {
|
||||||
textures = {'sneeker.png'},
|
"functions",
|
||||||
makes_footstep_sound = false,
|
"tnt_function",
|
||||||
jump_height = 5,
|
--"spawn",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, script in ipairs(scripts) do
|
||||||
|
dofile(sneeker.modpath .. "/" .. script .. ".lua")
|
||||||
if core.global_exists('mobs') then
|
end
|
||||||
def.type = 'monster'
|
|
||||||
def.walk_velocity = 1.5
|
--[[
|
||||||
def.knock_back = 2
|
local function jump(self, pos, direction)
|
||||||
def.attack_type = 'explode'
|
local velocity = self.object:get_velocity()
|
||||||
def.explosion_radius = radius
|
if core.registered_nodes[core.get_node(pos).name].climbable then
|
||||||
--[[
|
self.object:set_velocity({x=velocity.x, y=4, z=velocity.z})
|
||||||
def.on_blast = function(object, damage)
|
return
|
||||||
explode(object)
|
end
|
||||||
end
|
|
||||||
]]
|
local spos = {x=pos.x+direction.x, y=pos.y, z=pos.z+direction.z}
|
||||||
def.animation = {
|
local node = core.get_node_or_nil(spos)
|
||||||
stand_start = 0,
|
spos.y = spos.y+1
|
||||||
stand_end = 79,
|
local node2 = core.get_node_or_nil(spos)
|
||||||
stand_speed = 30,
|
local def, def2 = {}
|
||||||
walk_start = 168,
|
if node and node.name then
|
||||||
walk_end = 187,
|
def = core.registered_items[node.name]
|
||||||
walk_speek = 30,
|
end
|
||||||
}
|
if node2 and node2.name then
|
||||||
def.sounds = {
|
def2 = core.registered_items[node2.name]
|
||||||
explode = 'sneeker_explode',
|
end
|
||||||
distance = 128,
|
if def and def.walkable
|
||||||
}
|
and def2 and not def2.walkable
|
||||||
|
and def.drawtype ~= "fencelike" then
|
||||||
mobs:register_mob(sneeker.mob_name, def)
|
self.object:set_velocity({
|
||||||
-- TODO: Add alias
|
x = velocity.x*2.2,
|
||||||
else
|
y = self.jump_height,
|
||||||
def.walk_speed = 1.5
|
z = velocity.z*2.2
|
||||||
def.knockback_level = 2
|
})
|
||||||
def.animation = {
|
end
|
||||||
stand_START = 0,
|
end
|
||||||
stand_END = 79,
|
|
||||||
walk_START = 168,
|
local function random_turn(self)
|
||||||
walk_END = 187,
|
if self.turn_timer > math.random(2, 5) then
|
||||||
}
|
local select_turn = math.random(1, 3)
|
||||||
def.animation_speed = 30
|
if select_turn == 1 then
|
||||||
|
self.turn = "left"
|
||||||
|
elseif select_turn == 2 then
|
||||||
local function jump(self,pos,direction)
|
self.turn = "right"
|
||||||
local velocity = self.object:getvelocity()
|
elseif select_turn == 3 then
|
||||||
if core.registered_nodes[core.get_node(pos).name].climbable then
|
self.turn = "straight"
|
||||||
self.object:setvelocity({x=velocity.x,y=4,z=velocity.z})
|
end
|
||||||
return
|
self.turn_timer = 0
|
||||||
end
|
self.turn_speed = 0.05*math.random()
|
||||||
|
end
|
||||||
local spos = {x=pos.x+direction.x,y=pos.y,z=pos.z+direction.z}
|
end
|
||||||
local node = core.get_node_or_nil(spos)
|
|
||||||
spos.y = spos.y+1
|
local def = {
|
||||||
local node2 = core.get_node_or_nil(spos)
|
hp_max = 20,
|
||||||
local def,def2 = {}
|
physical = true,
|
||||||
if node and node.name then
|
collisionbox = {-0.25, -0.7, -0.25, 0.25, 0.8, 0.25},
|
||||||
def = core.registered_items[node.name]
|
visual = "mesh",
|
||||||
end
|
mesh = "character.b3d",
|
||||||
if node2 and node2.name then
|
textures = {"sneeker.png"},
|
||||||
def2 = core.registered_items[node2.name]
|
makes_footstep_sound = false,
|
||||||
end
|
|
||||||
if def and def.walkable
|
-- Original
|
||||||
and def2 and not def2.walkable
|
animation = {
|
||||||
and def.drawtype ~= 'fencelike' then
|
stand_START = 0,
|
||||||
self.object:setvelocity({
|
stand_END = 79,
|
||||||
x=velocity.x*2.2,
|
walk_START = 168,
|
||||||
y=self.jump_height,
|
walk_END = 187
|
||||||
z=velocity.z*2.2
|
},
|
||||||
})
|
walk_speed = 1.5,
|
||||||
end
|
jump_height = 5,
|
||||||
end
|
animation_speed = 30,
|
||||||
|
knockback_level = 2
|
||||||
|
}
|
||||||
local function random_turn(self)
|
]]
|
||||||
if self.turn_timer > math.random(2,5) then
|
|
||||||
local select_turn = math.random(1,3)
|
local sneeker_on_activate = function(self, staticdata)
|
||||||
if select_turn == 1 then
|
--[[
|
||||||
self.turn = 'left'
|
self.yaw = 0
|
||||||
elseif select_turn == 2 then
|
self.anim = 1
|
||||||
self.turn = 'right'
|
]]
|
||||||
elseif select_turn == 3 then
|
self.timer = 0
|
||||||
self.turn = 'straight'
|
self.visualx = 1
|
||||||
end
|
--[[
|
||||||
self.turn_timer = 0
|
self.jump_timer = 0
|
||||||
self.turn_speed = 0.05*math.random()
|
self.turn_timer = 0
|
||||||
end
|
self.turn_speed = 0
|
||||||
end
|
]]
|
||||||
|
self.powered = false
|
||||||
|
--[[
|
||||||
def.on_activate = function(self,staticdata)
|
self.knockback = false
|
||||||
self.yaw = 0
|
self.state = math.random(1, 2)
|
||||||
self.anim = 1
|
self.old_y = self.object:get_pos().y
|
||||||
self.timer = 0
|
]]
|
||||||
self.visualx = 1
|
|
||||||
self.jump_timer = 0
|
local data = core.deserialize(staticdata)
|
||||||
self.turn_timer = 0
|
if data and type(data) == "table" then
|
||||||
self.turn_speed = 0
|
if data.powered == true then
|
||||||
self.powered = false
|
self.powered = true
|
||||||
self.knockback = false
|
self.object:set_properties({textures = {"sneeker_powered.png"}})
|
||||||
self.state = math.random(1,2)
|
end
|
||||||
self.old_y = self.object:getpos().y
|
else
|
||||||
|
if math.random(0, 20) == 20 then
|
||||||
local data = core.deserialize(staticdata)
|
self.powered = true
|
||||||
if data and type(data) == 'table' then
|
self.object:set_properties({textures = {"sneeker_powered.png"}})
|
||||||
if data.powered == true then
|
end
|
||||||
self.powered = true
|
end
|
||||||
self.object:set_properties({textures = {'sneeker_powered.png'}})
|
end
|
||||||
end
|
|
||||||
else
|
local function isnan(n)
|
||||||
if math.random(0,20) == 20 then
|
return tostring(n) == tostring((-1)^.5)
|
||||||
self.powered = true
|
end
|
||||||
self.object:set_properties({textures = {'sneeker_powered.png'}})
|
|
||||||
end
|
local sneeker_on_step = function(self, dtime)
|
||||||
end
|
if self.stunned then return false end
|
||||||
end
|
|
||||||
|
local pos = self.object:get_pos()
|
||||||
|
local inside = core.get_objects_inside_radius(pos, 10)
|
||||||
def.on_step = function(self, dtime)
|
local velocity = self.object:get_velocity()
|
||||||
if self.knockback then
|
|
||||||
return
|
self.timer = self.timer+0.01
|
||||||
end
|
|
||||||
|
if self.mode == "follow" and self.visualx < 2 then
|
||||||
local ANIM_STAND = 1
|
if not self.hiss then
|
||||||
local ANIM_WALK = 2
|
core.sound_play("sneeker_hiss", {pos=pos, gain=1.5, max_hear_distance=2*64})
|
||||||
|
end
|
||||||
local pos = self.object:getpos()
|
self.visualx = self.visualx+0.05
|
||||||
local yaw = self.object:getyaw()
|
self.object:set_properties({
|
||||||
local inside = core.get_objects_inside_radius(pos,10)
|
visual_size = {x=self.visualx, y=1}
|
||||||
local walk_speed = self.walk_speed
|
})
|
||||||
local animation = self.animation
|
self.hiss = true
|
||||||
local anim_speed = self.animation_speed
|
elseif self.visualx > 1 then
|
||||||
local velocity = self.object:getvelocity()
|
self.visualx = self.visualx-0.05
|
||||||
|
self.object:set_properties({
|
||||||
self.timer = self.timer+0.01
|
visual_size = {x=self.visualx, y=1}
|
||||||
self.turn_timer = self.turn_timer+0.01
|
})
|
||||||
self.jump_timer = self.jump_timer+0.01
|
self.hiss = false
|
||||||
|
end
|
||||||
if not self.chase
|
|
||||||
and self.timer > math.random(2,5) then
|
for _, object in ipairs(inside) do
|
||||||
if math.random() > 0.8 then
|
if object:is_player() then
|
||||||
self.state = 'stand'
|
self.mode = "follow"
|
||||||
else
|
end
|
||||||
self.state = 'walk'
|
end
|
||||||
end
|
|
||||||
self.timer = 0
|
if self.mode == "follow" then
|
||||||
end
|
local inside_2 = core.get_objects_inside_radius(pos, 2)
|
||||||
|
|
||||||
if self.turn == 'right' then
|
-- boom
|
||||||
self.yaw = self.yaw+self.turn_speed
|
if #inside_2 ~= 0 then
|
||||||
self.object:setyaw(self.yaw)
|
for _, object in ipairs(inside_2) do
|
||||||
elseif self.turn == 'left' then
|
if object:is_player() and object:get_hp() ~= 0 then
|
||||||
self.yaw = self.yaw-self.turn_speed
|
if self.visualx >= 2 then
|
||||||
self.object:setyaw(self.yaw)
|
self.object:remove()
|
||||||
end
|
sneeker.boom(pos, self.powered)
|
||||||
|
core.sound_play("sneeker_explode", {pos=pos, gain=1.5, max_hear_distance=2*64})
|
||||||
if self.chase and self.visualx < 2 then
|
return true
|
||||||
if self.hiss == false then
|
end
|
||||||
core.sound_play('sneeker_hiss',{pos=pos,gain=1.5,max_hear_distance=2*64})
|
end
|
||||||
end
|
end
|
||||||
self.visualx = self.visualx+0.05
|
end
|
||||||
self.object:set_properties({
|
|
||||||
visual_size = {x=self.visualx,y=1}
|
if #inside > 0 then
|
||||||
})
|
for _, object in ipairs(inside) do
|
||||||
self.hiss = true
|
if object:is_player() and object:get_hp() ~= 0 then
|
||||||
elseif self.visualx > 1 then
|
if #inside_2 > 0 then
|
||||||
self.visualx = self.visualx-0.05
|
for _, object in ipairs(inside_2) do
|
||||||
self.object:set_properties({
|
-- Stop move
|
||||||
visual_size = {x=self.visualx,y=1}
|
if object:is_player() then
|
||||||
})
|
--[[
|
||||||
self.hiss = false
|
if self.anim ~= ANIM_STAND then
|
||||||
end
|
self.object:set_animation({x=animation.stand_START, y=animation.stand_END}, anim_speed, 0)
|
||||||
|
self.anim = ANIM_STAND
|
||||||
self.chase = false
|
end
|
||||||
|
]]
|
||||||
for _,object in ipairs(inside) do
|
--self.object:set_velocity({x=0, y=velocity.y, z=0})
|
||||||
if object:is_player() then
|
return false
|
||||||
self.state = 'chase'
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.state == 'stand' then
|
-- follow player
|
||||||
if self.anim ~= ANIM_STAND then
|
local ppos = object:get_pos()
|
||||||
self.object:set_animation({x=animation.stand_START,y=animation.stand_END},anim_speed,0)
|
self.vec = {x=ppos.x-pos.x, y=ppos.y-pos.y, z=ppos.z-pos.z}
|
||||||
self.anim = ANIM_STAND
|
self.yaw = math.atan(self.vec.z/self.vec.x)+math.pi^2
|
||||||
end
|
if ppos.x > pos.x then
|
||||||
|
self.yaw = self.yaw+math.pi
|
||||||
random_turn(self)
|
end
|
||||||
|
self.yaw = self.yaw-2
|
||||||
if velocity.x ~= 0
|
self.object:set_yaw(self.yaw)
|
||||||
or velocity.z ~= 0 then
|
self.direction = {x=math.sin(self.yaw)*-1, y=0, z=math.cos(self.yaw)}
|
||||||
self.object:setvelocity({x=0,y=velocity.y,z=0})
|
|
||||||
end
|
local direction = self.direction
|
||||||
end
|
local dir_x = direction.x*2.5
|
||||||
|
local dir_y = velocity.y
|
||||||
if self.state == 'walk' then
|
local dir_z = direction.z*2.5
|
||||||
if self.anim ~= ANIM_WALK then
|
|
||||||
self.object:set_animation({x=animation.walk_START,y=animation.walk_END},anim_speed,0)
|
if not isnan(dir_x) and not isnan(dir_y) and not isnan(dir_z) then
|
||||||
self.anim = ANIM_WALK
|
self.object:set_velocity({x=direction.x*2.5, y=velocity.y, z=direction.z*2.5})
|
||||||
end
|
else
|
||||||
|
sneeker.log("warning", "Found NaN")
|
||||||
self.direction = {x=math.sin(yaw)*-1,y=-10,z=math.cos(yaw)}
|
for k, v in ipairs({x=dir_x, y=dir_y, z=dir_z}) do
|
||||||
if self.direction then
|
if isnan(v) then
|
||||||
self.object:setvelocity({x=self.direction.x*walk_speed,y=velocity.y,z=self.direction.z*walk_speed})
|
sneeker.log("warning", "\"" .. k .. "\" is not a number: " .. tostring(v))
|
||||||
end
|
end
|
||||||
|
end
|
||||||
random_turn(self)
|
end
|
||||||
|
end
|
||||||
local velocity = self.object:getvelocity()
|
end
|
||||||
|
end
|
||||||
if self.turn_timer > 1 then
|
end
|
||||||
local direction = self.direction
|
|
||||||
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 self.knockback then
|
||||||
or core.registered_nodes[core.get_node(npos).name].walkable then
|
return
|
||||||
local select_turn = math.random(1,2)
|
end
|
||||||
if select_turn == 1 then
|
|
||||||
self.turn = 'left'
|
local ANIM_STAND = 1
|
||||||
elseif select_turn == 2 then
|
local ANIM_WALK = 2
|
||||||
self.turn = 'right'
|
|
||||||
end
|
local pos = self.object:get_pos()
|
||||||
self.turn_timer = 0
|
local yaw = self.object:get_yaw()
|
||||||
self.turn_speed = 0.05*math.random()
|
local inside = core.get_objects_inside_radius(pos, 10)
|
||||||
end
|
local walk_speed = self.walk_speed
|
||||||
end
|
local animation = self.animation
|
||||||
|
local anim_speed = self.animation_speed
|
||||||
-- Jump
|
local velocity = self.object:get_velocity()
|
||||||
if self.jump_timer > 0.2 then
|
|
||||||
jump(self,pos,self.direction)
|
self.timer = self.timer+0.01
|
||||||
end
|
self.turn_timer = self.turn_timer+0.01
|
||||||
end
|
self.jump_timer = self.jump_timer+0.01
|
||||||
|
|
||||||
if self.state == 'chase' then
|
if not self.chase
|
||||||
if self.anim ~= ANIM_WALK then
|
and self.timer > math.random(2, 5) then
|
||||||
self.object:set_animation({x=animation.walk_START,y=animation.walk_END},anim_speed,0)
|
if math.random() > 0.8 then
|
||||||
self.anim = ANIM_WALK
|
self.state = "stand"
|
||||||
end
|
else
|
||||||
|
self.state = "walk"
|
||||||
self.turn = 'straight'
|
end
|
||||||
|
self.timer = 0
|
||||||
local inside_2 = core.get_objects_inside_radius(pos,2)
|
end
|
||||||
|
|
||||||
-- Boom
|
if self.turn == "right" then
|
||||||
if #inside_2 ~= 0 then
|
self.yaw = self.yaw+self.turn_speed
|
||||||
for _,object in ipairs(inside_2) do
|
self.object:set_yaw(self.yaw)
|
||||||
if object:is_player() and object:get_hp() ~= 0 then
|
elseif self.turn == "left" then
|
||||||
self.chase = true
|
self.yaw = self.yaw-self.turn_speed
|
||||||
if self.visualx >= 2 then
|
self.object:set_yaw(self.yaw)
|
||||||
self.object:remove()
|
end
|
||||||
sneeker.boom(pos,self.powered)
|
|
||||||
core.sound_play('sneeker_explode',{pos=pos,gain=1.5,max_hear_distance=2*64})
|
if self.chase and self.visualx < 2 then
|
||||||
end
|
if self.hiss == false then
|
||||||
end
|
core.sound_play("sneeker_hiss", {pos=pos, gain=1.5, max_hear_distance=2*64})
|
||||||
end
|
end
|
||||||
end
|
self.visualx = self.visualx+0.05
|
||||||
|
self.object:set_properties({
|
||||||
if #inside ~= 0 then
|
visual_size = {x=self.visualx, y=1}
|
||||||
for _,object in ipairs(inside) do
|
})
|
||||||
if object:is_player() and object:get_hp() ~= 0 then
|
self.hiss = true
|
||||||
if #inside_2 ~= 0 then
|
elseif self.visualx > 1 then
|
||||||
for _,object in ipairs(inside_2) do
|
self.visualx = self.visualx-0.05
|
||||||
-- Stop move
|
self.object:set_properties({
|
||||||
if object:is_player() then
|
visual_size = {x=self.visualx, y=1}
|
||||||
if self.anim ~= ANIM_STAND then
|
})
|
||||||
self.object:set_animation({x=animation.stand_START,y=animation.stand_END},anim_speed,0)
|
self.hiss = false
|
||||||
self.anim = ANIM_STAND
|
end
|
||||||
end
|
|
||||||
self.object:setvelocity({x=0,y=velocity.y,z=0})
|
self.chase = false
|
||||||
return
|
|
||||||
end
|
for _, object in ipairs(inside) do
|
||||||
end
|
if object:is_player() then
|
||||||
end
|
self.state = "chase"
|
||||||
|
end
|
||||||
local ppos = object:getpos()
|
end
|
||||||
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 self.state == "stand" then
|
||||||
if ppos.x > pos.x then
|
if self.anim ~= ANIM_STAND then
|
||||||
self.yaw = self.yaw+math.pi
|
self.object:set_animation({x=animation.stand_START, y=animation.stand_END}, anim_speed, 0)
|
||||||
end
|
self.anim = ANIM_STAND
|
||||||
self.yaw = self.yaw-2
|
end
|
||||||
self.object:setyaw(self.yaw)
|
|
||||||
self.direction = {x=math.sin(self.yaw)*-1,y=0,z=math.cos(self.yaw)}
|
random_turn(self)
|
||||||
|
|
||||||
local direction = self.direction
|
if velocity.x ~= 0
|
||||||
self.object:setvelocity({x=direction.x*2.5,y=velocity.y,z=direction.z*2.5})
|
or velocity.z ~= 0 then
|
||||||
|
self.object:set_velocity({x=0, y=velocity.y, z=0})
|
||||||
-- Jump
|
end
|
||||||
if self.jump_timer > 0.2 then
|
end
|
||||||
jump(self,pos,direction)
|
|
||||||
end
|
if self.state == "walk" then
|
||||||
end
|
if self.anim ~= ANIM_WALK then
|
||||||
end
|
self.object:set_animation({x=animation.walk_START, y=animation.walk_END}, anim_speed, 0)
|
||||||
else
|
self.anim = ANIM_WALK
|
||||||
self.state = 'stand'
|
end
|
||||||
end
|
|
||||||
end
|
self.direction = {x=math.sin(yaw)*-1, y=-10, z=math.cos(yaw)}
|
||||||
|
if self.direction then
|
||||||
-- Swim
|
self.object:set_velocity({x=self.direction.x*walk_speed, y=velocity.y, z=self.direction.z*walk_speed})
|
||||||
local node = core.get_node(pos)
|
end
|
||||||
if core.get_item_group(node.name,'water') ~= 0 then
|
|
||||||
self.object:setacceleration({x=0,y=1,z=0})
|
random_turn(self)
|
||||||
local velocity = self.object:getvelocity()
|
|
||||||
if self.object:getvelocity().y > 5 then
|
local velocity = self.object:get_velocity()
|
||||||
self.object:setvelocity({x=0,y=velocity.y-velocity.y/2,z=0})
|
|
||||||
else
|
if self.turn_timer > 1 then
|
||||||
self.object:setvelocity({x=0,y=velocity.y+1,z=0})
|
local direction = self.direction
|
||||||
end
|
local npos = {x=pos.x+direction.x, y=pos.y+0.2, z=pos.z+direction.z}
|
||||||
else
|
if velocity.x == 0 or velocity.z == 0
|
||||||
self.object:setacceleration({x=0,y=-10,z=0})
|
or core.registered_nodes[core.get_node(npos).name].walkable then
|
||||||
end
|
local select_turn = math.random(1, 2)
|
||||||
end
|
if select_turn == 1 then
|
||||||
|
self.turn = "left"
|
||||||
|
elseif select_turn == 2 then
|
||||||
def.on_punch = function(self,puncher,time_from_last_punch,tool_capabilities,dir)
|
self.turn = "right"
|
||||||
if self.knockback == false then
|
end
|
||||||
local knockback_level = self.knockback_level
|
self.turn_timer = 0
|
||||||
self.object:setvelocity({x=dir.x*knockback_level,y=3,z=dir.z*knockback_level})
|
self.turn_speed = 0.05*math.random()
|
||||||
self.knockback = true
|
end
|
||||||
core.after(0.6,function()
|
end
|
||||||
self.knockback = false
|
|
||||||
end)
|
-- Jump
|
||||||
end
|
if self.jump_timer > 0.2 then
|
||||||
if self.object:get_hp() < 1 then
|
jump(self, pos, self.direction)
|
||||||
local pos = self.object:getpos()
|
end
|
||||||
local x = 1/math.random(1,5)*dir.x
|
end
|
||||||
local z = 1/math.random(1,5)*dir.z
|
|
||||||
local p = {x=pos.x+x,y=pos.y,z=pos.z+z}
|
if self.state == "chase" then
|
||||||
local node = core.get_node_or_nil(p)
|
if self.anim ~= ANIM_WALK then
|
||||||
if node == nil or not node.name or node.name ~= 'air' then
|
self.object:set_animation({x=animation.walk_START, y=animation.walk_END}, anim_speed, 0)
|
||||||
p = pos
|
self.anim = ANIM_WALK
|
||||||
end
|
end
|
||||||
local obj = core.add_item(p, {name='tnt:gunpowder',count=math.random(0,2)})
|
|
||||||
end
|
self.turn = "straight"
|
||||||
end
|
|
||||||
|
local inside_2 = core.get_objects_inside_radius(pos, 2)
|
||||||
|
|
||||||
def.get_staticdata = function(self)
|
-- Boom
|
||||||
return core.serialize({
|
if #inside_2 ~= 0 then
|
||||||
powered = self.powered
|
for _, object in ipairs(inside_2) do
|
||||||
})
|
if object:is_player() and object:get_hp() ~= 0 then
|
||||||
end
|
self.chase = true
|
||||||
|
if self.visualx >= 2 then
|
||||||
|
self.object:remove()
|
||||||
core.register_entity(sneeker.mob_name, def)
|
sneeker.boom(pos, self.powered)
|
||||||
end
|
core.sound_play("sneeker_explode", {pos=pos, gain=1.5, max_hear_distance=2*64})
|
||||||
|
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
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
self.object:set_velocity({x=direction.x*2.5, y=velocity.y, z=direction.z*2.5})
|
||||||
|
|
||||||
|
-- Jump
|
||||||
|
if self.jump_timer > 0.2 then
|
||||||
|
jump(self, pos, direction)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.state = "stand"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Swim
|
||||||
|
local node = core.get_node(pos)
|
||||||
|
if core.get_item_group(node.name, "water") ~= 0 then
|
||||||
|
self.object:set_acceleration({x=0, y=1, z=0})
|
||||||
|
local velocity = self.object:get_velocity()
|
||||||
|
if self.object:get_velocity().y > 5 then
|
||||||
|
self.object:set_velocity({x=0, y=velocity.y-velocity.y/2, z=0})
|
||||||
|
else
|
||||||
|
self.object:set_velocity({x=0, y=velocity.y+1, z=0})
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.object:set_acceleration({x=0, y=-10, z=0})
|
||||||
|
end
|
||||||
|
]]
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
def.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||||
|
if self.knockback == false then
|
||||||
|
local knockback_level = self.knockback_level
|
||||||
|
self.object:set_velocity({x=dir.x*knockback_level, y=3, z=dir.z*knockback_level})
|
||||||
|
self.knockback = true
|
||||||
|
core.after(0.6, function()
|
||||||
|
self.knockback = false
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
if self.object:get_hp() < 1 then
|
||||||
|
local pos = self.object:get_pos()
|
||||||
|
local x = 1/math.random(1, 5)*dir.x
|
||||||
|
local z = 1/math.random(1, 5)*dir.z
|
||||||
|
local p = {x=pos.x+x, y=pos.y, z=pos.z+z}
|
||||||
|
local node = core.get_node_or_nil(p)
|
||||||
|
if node == nil or not node.name or node.name ~= "air" then
|
||||||
|
p = pos
|
||||||
|
end
|
||||||
|
local obj = core.add_item(p, {name="tnt:gunpowder", count=math.random(0, 2)})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
]]
|
||||||
|
|
||||||
|
local sneeker_get_staticdata = function(self)
|
||||||
|
return core.serialize({
|
||||||
|
powered = self.powered
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
--core.register_entity(sneeker.mob_name, def)
|
||||||
|
|
||||||
|
|
||||||
|
local spawn_nodes = {
|
||||||
|
"default:dirt",
|
||||||
|
"default:dirt_with_grass",
|
||||||
|
"default:dry_dirt_with_dry_grass",
|
||||||
|
"default:desert_sand",
|
||||||
|
"default:sand",
|
||||||
|
"default:stone",
|
||||||
|
"default:desert_stone",
|
||||||
|
}
|
||||||
|
|
||||||
|
if core.global_exists("nether") then
|
||||||
|
table.insert(spawn_nodes, "nether:rack")
|
||||||
|
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
|
||||||
|
5
mod.conf
5
mod.conf
@@ -1 +1,6 @@
|
|||||||
name = sneeker
|
name = sneeker
|
||||||
|
title = Sneeker
|
||||||
|
description = An explosive nuisance.
|
||||||
|
author = Rui
|
||||||
|
depends = cmer, default, tnt
|
||||||
|
optional_depends = asm_spawneggs, nether
|
||||||
|
51
settings.lua
51
settings.lua
@@ -1,4 +1,53 @@
|
|||||||
-- Settings for sneeker mod
|
-- Settings for sneeker mod
|
||||||
|
|
||||||
|
|
||||||
sneeker.debug = core.settings:get_bool('enable_debug_mods') or false
|
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
|
||||||
|
@@ -1,11 +1,23 @@
|
|||||||
# Sets maximum number of spawns that can exist in world.
|
# Sets maximum number of spawns that can exist in world.
|
||||||
sneeker.spawn_cap (Maximum spawns) int 10
|
sneeker.spawn_cap (Sneeker maximum spawns) int 10
|
||||||
|
|
||||||
# Sets possibility for spawn.
|
# Sets possibility for spawn.
|
||||||
sneeker.spawn_chance (Spawn chance) int 1000
|
sneeker.spawn_chance (Sneeker spawn chance) int 10000
|
||||||
|
|
||||||
# Sets frequency of spawn chance. Default 240 is equivalent to 4 minutes (60 * 4).
|
# Sets frequency of spawn chance. Default 240 is equivalent to 4 minutes (60 * 4).
|
||||||
sneeker.spawn_interval (Spawn interval) int 240
|
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.
|
# Sets the maximum light that a node can have for spawn to occur.
|
||||||
sneeker.spawn_maxlight (Max light for spawn) int 5
|
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
|
||||||
|
183
spawn.lua
183
spawn.lua
@@ -1,123 +1,84 @@
|
|||||||
-- Original code by Rui: WTFPL
|
|
||||||
|
|
||||||
|
local time_hr = sneeker.time_min * 60
|
||||||
local time_min = 60
|
|
||||||
local time_hr = time_min * 60
|
|
||||||
local time_day = time_hr * 24
|
local time_day = time_hr * 24
|
||||||
|
|
||||||
local spawn_cap = tonumber(core.settings:get('sneeker.spawn_cap')) or 10 -- Maximum number of spawns active at one time
|
|
||||||
local spawn_chance = tonumber(core.settings:get('sneeker.spawn_chance')) or 1000 -- 1/1000 chance of spawn
|
|
||||||
local spawn_interval = tonumber(core.settings:get('sneeker.spawn_interval')) or time_min * 4 -- Default interval is 4 minutes
|
|
||||||
local spawn_maxlight = tonumber(core.settings:get('sneeker.spawn_maxlight')) or 5 -- Maximum light of node for spawn
|
|
||||||
|
|
||||||
-- Display spawn chance as percentage in log
|
-- Display spawn chance as percentage in log
|
||||||
local spawn_chance_percent = math.floor(1 / spawn_chance * 100)
|
local spawn_chance_percent = math.floor(1 / sneeker.spawn_chance * 100)
|
||||||
if spawn_chance_percent < 1 then
|
if spawn_chance_percent < 1 then
|
||||||
spawn_chance_percent = 'Less than 1%'
|
spawn_chance_percent = "Less than 1%"
|
||||||
else
|
else
|
||||||
spawn_chance_percent = tostring(spawn_chance_percent) .. '%'
|
spawn_chance_percent = tostring(spawn_chance_percent) .. "%"
|
||||||
end
|
end
|
||||||
|
|
||||||
sneeker.log('Spawn cap: ' .. tostring(spawn_cap))
|
sneeker.log("Spawn cap: " .. tostring(sneeker.spawn_cap))
|
||||||
sneeker.log('Spawn chance: ' .. spawn_chance_percent)
|
sneeker.log("Spawn chance: " .. spawn_chance_percent)
|
||||||
sneeker.log('Spawn interval: ' .. tostring(spawn_interval) .. ' (' .. tostring(spawn_interval/60) .. ' minute(s))')
|
sneeker.log("Spawn interval: " .. tostring(sneeker.spawn_interval) .. " (" .. tostring(sneeker.spawn_interval/60) .. " minute(s))")
|
||||||
sneeker.log('Maximum light value for spawn: ' .. tostring(spawn_maxlight))
|
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
|
||||||
|
|
||||||
if core.global_exists('mobs') then
|
core.register_abm({
|
||||||
mobs:spawn({
|
nodenames = spawn_nodes,
|
||||||
name = sneeker.mob_name,
|
neighbors = {"air"},
|
||||||
nodes = {'default:dirt_with_grass', 'default:stone'},
|
interval = spawn_interval,
|
||||||
neighbors = {'air'},
|
chance = spawn_chance,
|
||||||
min_light = -1,
|
action = function(pos, node, _, active_object_count_wider)
|
||||||
max_light = spawn_maxlight,
|
if active_object_count_wider > 5 then
|
||||||
interval = spawn_interval,
|
return
|
||||||
chance = spawn_chance,
|
|
||||||
})
|
|
||||||
|
|
||||||
mobs:register_egg(sneeker.mob_name, 'Sneeker Spawn Egg', 'sneeker_spawnegg.png', 0, false)
|
|
||||||
else
|
|
||||||
core.register_abm({
|
|
||||||
nodenames = {'default:dirt_with_grass', 'default:stone'},
|
|
||||||
neighbors = {'air'},
|
|
||||||
interval = spawn_interval,
|
|
||||||
chance = spawn_chance,
|
|
||||||
action = function(pos, node, _, active_object_count_wider)
|
|
||||||
if active_object_count_wider > 5 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Check light value of node
|
|
||||||
pos.y = pos.y+1
|
|
||||||
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))
|
|
||||||
|
|
||||||
if not node_light or node_light > spawn_maxlight or node_light < -1 then
|
|
||||||
sneeker.log_debug('Node not dark enough for spawn')
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Spawn range
|
|
||||||
if pos.y > 31000 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Node must be touching air
|
|
||||||
if core.get_node(pos).name ~= 'air' then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
pos.y = pos.y+1
|
|
||||||
if core.get_node(pos).name ~= 'air' then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 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
|
||||||
})
|
|
||||||
|
-- Check light value of node
|
||||||
|
pos.y = pos.y+1
|
||||||
if core.get_modpath('spawneggs') and core.get_modpath('tnt') then
|
local node_light = core.get_node_light(pos)
|
||||||
core.register_craftitem(sneeker.spawnegg_name, {
|
|
||||||
description = 'Sneeker Spawn Egg',
|
-- Debugging spawning
|
||||||
inventory_image = 'sneeker_spawnegg.png',
|
sneeker.log("debug", "Node light level at " .. sneeker.get_pos_string(pos) .. ": " .. tostring(node_light))
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
|
||||||
if pointed_thing.type == 'node' then
|
-- Node light level
|
||||||
local pos = pointed_thing.above
|
if not node_light or node_light > spawn_maxlight then
|
||||||
pos.y = pos.y+1
|
sneeker.log("debug", "Node not dark enough for spawn")
|
||||||
core.add_entity(pos, sneeker.mob_name)
|
return
|
||||||
if not core.settings:get_bool('creative_mode') then
|
elseif node_light < spawn_minlight then
|
||||||
itemstack:take_item()
|
sneeker.log("debug", "Node too dark for spawn")
|
||||||
end
|
return
|
||||||
return itemstack
|
end
|
||||||
end
|
|
||||||
end
|
-- Spawn range
|
||||||
})
|
if spawn_minheight ~= nil and pos.y < spawn_minheight then
|
||||||
|
sneeker.log("debug", "Position is too low for spawn")
|
||||||
core.register_craft({
|
return
|
||||||
output = sneeker.spawnegg_name,
|
elseif pos.y > spawn_maxheight then
|
||||||
type = 'shapeless',
|
sneeker.log("debug", "Position is too high for spawn")
|
||||||
recipe = {
|
return
|
||||||
'spawneggs:egg', 'tnt:tnt',
|
end
|
||||||
},
|
|
||||||
})
|
-- Node must be touching air
|
||||||
|
if core.get_node(pos).name ~= "air" then
|
||||||
core.register_alias('spawneggs:sneeker', sneeker.spawnegg_name)
|
return
|
||||||
|
end
|
||||||
|
pos.y = pos.y+1
|
||||||
|
if core.get_node(pos).name ~= "air" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 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
|
||||||
end
|
})
|
||||||
|
@@ -1,13 +1,11 @@
|
|||||||
-- Original code by Rui: WTFPL
|
|
||||||
|
|
||||||
|
|
||||||
-- From TNT
|
-- From TNT
|
||||||
local cid_data = {}
|
local cid_data = {}
|
||||||
local radius = tonumber(core.settings: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,
|
||||||
}
|
}
|
||||||
core.after(0, function()
|
core.after(0, function()
|
||||||
for name, def in pairs(core.registered_nodes) do
|
for name, def in pairs(core.registered_nodes) do
|
||||||
@@ -40,8 +38,8 @@ local function eject_drops(drops, pos, radius)
|
|||||||
local obj = core.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:setacceleration({x=0, y=-10, z=0})
|
obj:set_acceleration({x=0, y=-10, z=0})
|
||||||
obj:setvelocity({x=math.random(-3, 3), y=10,
|
obj:set_velocity({x=math.random(-3, 3), y=10,
|
||||||
z=math.random(-3, 3)})
|
z=math.random(-3, 3)})
|
||||||
end
|
end
|
||||||
count = count - max
|
count = count - max
|
||||||
@@ -65,7 +63,7 @@ local function add_drop(drops, item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function destroy(drops, pos, cid)
|
local function destroy(drops, pos, cid)
|
||||||
if core.is_protected(pos, '') then
|
if core.is_protected(pos, "") then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local def = cid_data[cid]
|
local def = cid_data[cid]
|
||||||
@@ -75,7 +73,7 @@ local function destroy(drops, pos, cid)
|
|||||||
end
|
end
|
||||||
core.remove_node(pos)
|
core.remove_node(pos)
|
||||||
if def then
|
if def then
|
||||||
local node_drops = core.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
|
||||||
@@ -103,12 +101,12 @@ local function entity_physics(pos, radius)
|
|||||||
radius = radius * 2
|
radius = radius * 2
|
||||||
local objs = core.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:getpos()
|
local obj_pos = obj:get_pos()
|
||||||
local obj_vel = obj:getvelocity()
|
local obj_vel = obj:get_velocity()
|
||||||
local dist = math.max(1, vector.distance(pos, obj_pos))
|
local dist = math.max(1, vector.distance(pos, obj_pos))
|
||||||
|
|
||||||
if obj_vel ~= nil then
|
if obj_vel ~= nil then
|
||||||
obj:setvelocity(calc_velocity(pos, obj_pos,
|
obj:set_velocity(calc_velocity(pos, obj_pos,
|
||||||
obj_vel, radius * 10))
|
obj_vel, radius * 10))
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -131,7 +129,7 @@ local function add_effects(pos, radius)
|
|||||||
maxexptime = 3,
|
maxexptime = 3,
|
||||||
minsize = 8,
|
minsize = 8,
|
||||||
maxsize = 16,
|
maxsize = 16,
|
||||||
texture = 'sneeker_smoke.png',
|
texture = "sneeker_smoke.png",
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -149,12 +147,16 @@ local function explode(pos, radius)
|
|||||||
local drops = {}
|
local drops = {}
|
||||||
local p = {}
|
local p = {}
|
||||||
|
|
||||||
local c_air = core.get_content_id('air')
|
local c_air = core.get_content_id("air")
|
||||||
local c_tnt = core.get_content_id('tnt:tnt')
|
local c_tnt = nil
|
||||||
local c_tnt_burning = core.get_content_id('tnt:tnt_burning')
|
if core.settings:get_bool("enable_tnt", false) then
|
||||||
local c_gunpowder = core.get_content_id('tnt:gunpowder')
|
c_tnt = core.get_content_id("tnt:tnt")
|
||||||
local c_gunpowder_burning = core.get_content_id('tnt:gunpowder_burning')
|
end
|
||||||
local c_boom = core.get_content_id('tnt:boom')
|
|
||||||
|
local c_tnt_burning = core.get_content_id("tnt:tnt_burning")
|
||||||
|
local c_gunpowder = core.get_content_id("tnt:gunpowder")
|
||||||
|
local c_gunpowder_burning = core.get_content_id("tnt:gunpowder_burning")
|
||||||
|
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
|
||||||
@@ -183,13 +185,13 @@ local function explode(pos, radius)
|
|||||||
return drops
|
return drops
|
||||||
end
|
end
|
||||||
|
|
||||||
function sneeker.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
|
||||||
core.sound_play('sneeker_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})
|
||||||
core.set_node(pos, {name='tnt:boom'})
|
core.set_node(pos, {name="tnt:boom"})
|
||||||
core.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)
|
||||||
|
Reference in New Issue
Block a user