Compare commits
54 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
e35dd34462 | ||
|
c364ad6e85 | ||
|
38c6e79718 | ||
|
7dcc78393a | ||
|
a56b9c2ce9 | ||
|
59253fb4c1 | ||
|
0ff4681d5e | ||
|
8d144e47db | ||
|
9e1b11a52c | ||
|
e948a58c3d | ||
|
046e7d5e8c | ||
|
468d2a7a2a | ||
|
73b221c13f | ||
|
555110bb82 | ||
|
258d366b26 | ||
|
b69cc98d39 | ||
|
2b0871207f | ||
|
6605ac1545 | ||
|
822d73920d | ||
|
b7f0f34a41 | ||
|
84f51c893b | ||
|
85e849767f | ||
|
8485715aba | ||
|
ea60b5fe9b | ||
|
2ddc96de06 | ||
|
a2ce6cfea8 | ||
|
b165e45d92 | ||
|
677622d307 | ||
|
0ad9f2bd2a | ||
|
05019c9d7d | ||
|
1dc5b92314 | ||
|
d336800b35 | ||
|
398971d08c | ||
|
d777d4f000 | ||
|
9d7c566fdb | ||
|
b5c7aeb15d | ||
|
f50c7f37ca | ||
|
604eb77dc7 | ||
|
3f835fa65d | ||
|
fa0b50491f | ||
|
46a23df877 | ||
|
85ca164e14 | ||
|
930d52cb3d | ||
|
2712d7119c | ||
|
f6eca4002a | ||
|
b8a2e98ea0 | ||
|
102c9d9266 | ||
|
56033e8988 | ||
|
e8a37511ea | ||
|
83c26a3a41 | ||
|
14f9c3c6b3 | ||
|
299b12b5a4 | ||
|
07d7745455 | ||
|
3cc1158417 |
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
## Eclipse project files & directories
|
||||||
|
.project
|
||||||
|
.settings
|
121
LICENSE.txt
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
Creative Commons Legal Code
|
||||||
|
|
||||||
|
CC0 1.0 Universal
|
||||||
|
|
||||||
|
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||||
|
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
||||||
|
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||||
|
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||||
|
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
||||||
|
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
||||||
|
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
||||||
|
HEREUNDER.
|
||||||
|
|
||||||
|
Statement of Purpose
|
||||||
|
|
||||||
|
The laws of most jurisdictions throughout the world automatically confer
|
||||||
|
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||||
|
and subsequent owner(s) (each and all, an "owner") of an original work of
|
||||||
|
authorship and/or a database (each, a "Work").
|
||||||
|
|
||||||
|
Certain owners wish to permanently relinquish those rights to a Work for
|
||||||
|
the purpose of contributing to a commons of creative, cultural and
|
||||||
|
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.
|
15
README.md
@ -1,8 +1,17 @@
|
|||||||
# creeper
|
# Sneeker mobile mod for Minetest
|
||||||
|
|
||||||
Adds some explosive nuisance.
|
Adds some explosive nuisance.
|
||||||
|
|
||||||
## Forum Topic
|
## Forum Topic
|
||||||
- https://forum.minetest.net/viewtopic.php?t=11891
|
|
||||||
|
- Original thread: https://forum.minetest.net/viewtopic.php?t=11891
|
||||||
|
|
||||||
## License
|
## License
|
||||||
- **Code:** WTFPL
|
|
||||||
|
- **Code:**
|
||||||
|
- Original by Rui: [WTFPL][lic.wtfpl]
|
||||||
|
- AntumDeluge: [CC0][lic.cc0]
|
||||||
|
|
||||||
|
|
||||||
|
[lic.cc0]: LICENSE.txt
|
||||||
|
[lic.wtfpl]: LICENSE-wtfpl.txt
|
||||||
|
@ -1 +1,4 @@
|
|||||||
default
|
default
|
||||||
|
mobs?
|
||||||
|
spawneggs?
|
||||||
|
tnt?
|
||||||
|
30
functions.lua
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
-- 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
|
||||||
|
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
|
611
init.lua
@ -1,343 +1,384 @@
|
|||||||
creeper = {}
|
-- Original code by Rui: WTFPL
|
||||||
|
|
||||||
--[[
|
|
||||||
-- DISABLED!!!
|
|
||||||
do return end
|
|
||||||
--]]
|
|
||||||
|
|
||||||
dofile(minetest.get_modpath("creeper").."/tnt_function.lua")
|
sneeker = {}
|
||||||
dofile(minetest.get_modpath("creeper").."/spawn.lua")
|
sneeker.modname = core.get_current_modname()
|
||||||
|
sneeker.modpath = core.get_modpath(sneeker.modname)
|
||||||
|
|
||||||
local function jump(self,pos,direction)
|
if core.settings:get_bool('log_mods') then
|
||||||
local velocity = self.object:getvelocity()
|
core.log('action', 'Loading mod "' .. sneeker.modname .. '" ...')
|
||||||
if minetest.registered_nodes[minetest.get_node(pos).name].climbable then
|
|
||||||
self.object:setvelocity({x=velocity.x,y=4,z=velocity.z})
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local spos = {x=pos.x+direction.x,y=pos.y,z=pos.z+direction.z}
|
|
||||||
local node = minetest.get_node_or_nil(spos)
|
|
||||||
spos.y = spos.y+1
|
|
||||||
local node2 = minetest.get_node_or_nil(spos)
|
|
||||||
local def,def2 = {}
|
|
||||||
if node and node.name then
|
|
||||||
def = minetest.registered_items[node.name]
|
|
||||||
end
|
|
||||||
if node2 and node2.name then
|
|
||||||
def2 = minetest.registered_items[node2.name]
|
|
||||||
end
|
|
||||||
if def and def.walkable
|
|
||||||
and def2 and not def2.walkable
|
|
||||||
and def.drawtype ~= "fencelike" then
|
|
||||||
self.object:setvelocity({
|
|
||||||
x=velocity.x*2.2,
|
|
||||||
y=self.jump_height,
|
|
||||||
z=velocity.z*2.2
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function random_turn(self)
|
dofile(sneeker.modpath .. '/settings.lua')
|
||||||
if self.turn_timer > math.random(2,5) then
|
dofile(sneeker.modpath .. '/functions.lua')
|
||||||
local select_turn = math.random(1,3)
|
|
||||||
if select_turn == 1 then
|
sneeker.log_debug('Debugging is on')
|
||||||
self.turn = "left"
|
|
||||||
elseif select_turn == 2 then
|
sneeker.mob_name = sneeker.modname .. ':' .. sneeker.modname
|
||||||
self.turn = "right"
|
sneeker.spawnegg_name = sneeker.modname .. ':spawnegg'
|
||||||
elseif select_turn == 3 then
|
|
||||||
self.turn = "straight"
|
local scripts = {
|
||||||
end
|
'tnt_function',
|
||||||
self.turn_timer = 0
|
'spawn',
|
||||||
self.turn_speed = 0.05*math.random()
|
}
|
||||||
end
|
|
||||||
|
for I in pairs(scripts) do
|
||||||
|
dofile(sneeker.modpath .. '/' .. scripts[I] .. '.lua')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local radius = tonumber(core.settings:get('tnt_radius') or 3)
|
||||||
|
|
||||||
|
|
||||||
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,
|
||||||
|
jump_height = 5,
|
||||||
|
}
|
||||||
|
|
||||||
-- Original
|
|
||||||
animation = {
|
|
||||||
|
if core.global_exists('mobs') then
|
||||||
|
def.type = 'monster'
|
||||||
|
def.walk_velocity = 1.5
|
||||||
|
def.knock_back = 2
|
||||||
|
def.attack_type = 'explode'
|
||||||
|
def.explosion_radius = radius
|
||||||
|
--[[
|
||||||
|
def.on_blast = function(object, damage)
|
||||||
|
explode(object)
|
||||||
|
end
|
||||||
|
]]
|
||||||
|
def.animation = {
|
||||||
|
stand_start = 0,
|
||||||
|
stand_end = 79,
|
||||||
|
stand_speed = 30,
|
||||||
|
walk_start = 168,
|
||||||
|
walk_end = 187,
|
||||||
|
walk_speek = 30,
|
||||||
|
}
|
||||||
|
def.sounds = {
|
||||||
|
explode = 'sneeker_explode',
|
||||||
|
distance = 128,
|
||||||
|
}
|
||||||
|
|
||||||
|
mobs:register_mob(sneeker.mob_name, def)
|
||||||
|
-- TODO: Add alias
|
||||||
|
else
|
||||||
|
def.walk_speed = 1.5
|
||||||
|
def.knockback_level = 2
|
||||||
|
def.animation = {
|
||||||
stand_START = 0,
|
stand_START = 0,
|
||||||
stand_END = 79,
|
stand_END = 79,
|
||||||
walk_START = 168,
|
walk_START = 168,
|
||||||
walk_END = 187
|
walk_END = 187,
|
||||||
},
|
}
|
||||||
walk_speed = 1.5,
|
def.animation_speed = 30
|
||||||
jump_height = 5,
|
|
||||||
animation_speed = 30,
|
|
||||||
knockback_level = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
def.on_activate = function(self,staticdata)
|
|
||||||
self.yaw = 0
|
|
||||||
self.anim = 1
|
|
||||||
self.timer = 0
|
|
||||||
self.visualx = 1
|
|
||||||
self.jump_timer = 0
|
|
||||||
self.turn_timer = 0
|
|
||||||
self.turn_speed = 0
|
|
||||||
self.powered = false
|
|
||||||
self.knockback = false
|
|
||||||
self.state = math.random(1,2)
|
|
||||||
self.old_y = self.object:getpos().y
|
|
||||||
|
|
||||||
local data = minetest.deserialize(staticdata)
|
local function jump(self,pos,direction)
|
||||||
if data and type(data) == "table" then
|
local velocity = self.object:getvelocity()
|
||||||
if data.powered == true then
|
if core.registered_nodes[core.get_node(pos).name].climbable then
|
||||||
self.powered = true
|
self.object:setvelocity({x=velocity.x,y=4,z=velocity.z})
|
||||||
self.object:set_properties({textures = {"creeper_powered.png"}})
|
return
|
||||||
end
|
end
|
||||||
else
|
|
||||||
if math.random(0,20) == 20 then
|
local spos = {x=pos.x+direction.x,y=pos.y,z=pos.z+direction.z}
|
||||||
self.powered = true
|
local node = core.get_node_or_nil(spos)
|
||||||
self.object:set_properties({textures = {"creeper_powered.png"}})
|
spos.y = spos.y+1
|
||||||
|
local node2 = core.get_node_or_nil(spos)
|
||||||
|
local def,def2 = {}
|
||||||
|
if node and node.name then
|
||||||
|
def = core.registered_items[node.name]
|
||||||
|
end
|
||||||
|
if node2 and node2.name then
|
||||||
|
def2 = core.registered_items[node2.name]
|
||||||
|
end
|
||||||
|
if def and def.walkable
|
||||||
|
and def2 and not def2.walkable
|
||||||
|
and def.drawtype ~= 'fencelike' then
|
||||||
|
self.object:setvelocity({
|
||||||
|
x=velocity.x*2.2,
|
||||||
|
y=self.jump_height,
|
||||||
|
z=velocity.z*2.2
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def.on_step = function(self, dtime)
|
|
||||||
if self.knockback then
|
local function random_turn(self)
|
||||||
return
|
if self.turn_timer > math.random(2,5) then
|
||||||
|
local select_turn = math.random(1,3)
|
||||||
|
if select_turn == 1 then
|
||||||
|
self.turn = 'left'
|
||||||
|
elseif select_turn == 2 then
|
||||||
|
self.turn = 'right'
|
||||||
|
elseif select_turn == 3 then
|
||||||
|
self.turn = 'straight'
|
||||||
|
end
|
||||||
|
self.turn_timer = 0
|
||||||
|
self.turn_speed = 0.05*math.random()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ANIM_STAND = 1
|
|
||||||
local ANIM_WALK = 2
|
|
||||||
|
|
||||||
local pos = self.object:getpos()
|
def.on_activate = function(self,staticdata)
|
||||||
local yaw = self.object:getyaw()
|
self.yaw = 0
|
||||||
local inside = minetest.get_objects_inside_radius(pos,10)
|
self.anim = 1
|
||||||
local walk_speed = self.walk_speed
|
|
||||||
local animation = self.animation
|
|
||||||
local anim_speed = self.animation_speed
|
|
||||||
local velocity = self.object:getvelocity()
|
|
||||||
|
|
||||||
self.timer = self.timer+0.01
|
|
||||||
self.turn_timer = self.turn_timer+0.01
|
|
||||||
self.jump_timer = self.jump_timer+0.01
|
|
||||||
|
|
||||||
if not self.chase
|
|
||||||
and self.timer > math.random(2,5) then
|
|
||||||
if math.random() > 0.8 then
|
|
||||||
self.state = "stand"
|
|
||||||
else
|
|
||||||
self.state = "walk"
|
|
||||||
end
|
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
end
|
self.visualx = 1
|
||||||
|
self.jump_timer = 0
|
||||||
|
self.turn_timer = 0
|
||||||
|
self.turn_speed = 0
|
||||||
|
self.powered = false
|
||||||
|
self.knockback = false
|
||||||
|
self.state = math.random(1,2)
|
||||||
|
self.old_y = self.object:getpos().y
|
||||||
|
|
||||||
if self.turn == "right" then
|
local data = core.deserialize(staticdata)
|
||||||
self.yaw = self.yaw+self.turn_speed
|
if data and type(data) == 'table' then
|
||||||
self.object:setyaw(self.yaw)
|
if data.powered == true then
|
||||||
elseif self.turn == "left" then
|
self.powered = true
|
||||||
self.yaw = self.yaw-self.turn_speed
|
self.object:set_properties({textures = {'sneeker_powered.png'}})
|
||||||
self.object:setyaw(self.yaw)
|
end
|
||||||
end
|
else
|
||||||
|
if math.random(0,20) == 20 then
|
||||||
if self.chase and self.visualx < 2 then
|
self.powered = true
|
||||||
if self.hiss == false then
|
self.object:set_properties({textures = {'sneeker_powered.png'}})
|
||||||
minetest.sound_play("creeper_hiss",{pos=pos,gain=1.5,max_hear_distance=2*64})
|
end
|
||||||
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
|
|
||||||
|
|
||||||
self.chase = false
|
|
||||||
|
|
||||||
for _,object in ipairs(inside) do
|
|
||||||
if object:is_player() then
|
|
||||||
self.state = "chase"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.state == "stand" then
|
|
||||||
if self.anim ~= ANIM_STAND then
|
def.on_step = function(self, dtime)
|
||||||
self.object:set_animation({x=animation.stand_START,y=animation.stand_END},anim_speed,0)
|
if self.knockback then
|
||||||
self.anim = ANIM_STAND
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
random_turn(self)
|
local ANIM_STAND = 1
|
||||||
|
local ANIM_WALK = 2
|
||||||
if velocity.x ~= 0
|
|
||||||
or velocity.z ~= 0 then
|
|
||||||
self.object:setvelocity({x=0,y=velocity.y,z=0})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.state == "walk" then
|
|
||||||
if self.anim ~= ANIM_WALK then
|
|
||||||
self.object:set_animation({x=animation.walk_START,y=animation.walk_END},anim_speed,0)
|
|
||||||
self.anim = ANIM_WALK
|
|
||||||
end
|
|
||||||
|
|
||||||
self.direction = {x=math.sin(yaw)*-1,y=-10,z=math.cos(yaw)}
|
|
||||||
if self.direction then
|
|
||||||
self.object:setvelocity({x=self.direction.x*walk_speed,y=velocity.y,z=self.direction.z*walk_speed})
|
|
||||||
end
|
|
||||||
|
|
||||||
random_turn(self)
|
|
||||||
|
|
||||||
|
local pos = self.object:getpos()
|
||||||
|
local yaw = self.object:getyaw()
|
||||||
|
local inside = core.get_objects_inside_radius(pos,10)
|
||||||
|
local walk_speed = self.walk_speed
|
||||||
|
local animation = self.animation
|
||||||
|
local anim_speed = self.animation_speed
|
||||||
local velocity = self.object:getvelocity()
|
local velocity = self.object:getvelocity()
|
||||||
|
|
||||||
if self.turn_timer > 1 then
|
self.timer = self.timer+0.01
|
||||||
local direction = self.direction
|
self.turn_timer = self.turn_timer+0.01
|
||||||
local npos = {x=pos.x+direction.x,y=pos.y+0.2,z=pos.z+direction.z}
|
self.jump_timer = self.jump_timer+0.01
|
||||||
if velocity.x == 0 or velocity.z == 0
|
|
||||||
or minetest.registered_nodes[minetest.get_node(npos).name].walkable then
|
if not self.chase
|
||||||
local select_turn = math.random(1,2)
|
and self.timer > math.random(2,5) then
|
||||||
if select_turn == 1 then
|
if math.random() > 0.8 then
|
||||||
self.turn = "left"
|
self.state = 'stand'
|
||||||
elseif select_turn == 2 then
|
else
|
||||||
self.turn = "right"
|
self.state = 'walk'
|
||||||
end
|
end
|
||||||
self.turn_timer = 0
|
self.timer = 0
|
||||||
self.turn_speed = 0.05*math.random()
|
end
|
||||||
|
|
||||||
|
if self.turn == 'right' then
|
||||||
|
self.yaw = self.yaw+self.turn_speed
|
||||||
|
self.object:setyaw(self.yaw)
|
||||||
|
elseif self.turn == 'left' then
|
||||||
|
self.yaw = self.yaw-self.turn_speed
|
||||||
|
self.object:setyaw(self.yaw)
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.chase and self.visualx < 2 then
|
||||||
|
if self.hiss == false 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
|
||||||
|
|
||||||
|
self.chase = false
|
||||||
|
|
||||||
|
for _,object in ipairs(inside) do
|
||||||
|
if object:is_player() then
|
||||||
|
self.state = 'chase'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Jump
|
if self.state == 'stand' then
|
||||||
if self.jump_timer > 0.2 then
|
if self.anim ~= ANIM_STAND then
|
||||||
jump(self,pos,self.direction)
|
self.object:set_animation({x=animation.stand_START,y=animation.stand_END},anim_speed,0)
|
||||||
end
|
self.anim = ANIM_STAND
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.state == "chase" then
|
random_turn(self)
|
||||||
if self.anim ~= ANIM_WALK then
|
|
||||||
self.object:set_animation({x=animation.walk_START,y=animation.walk_END},anim_speed,0)
|
if velocity.x ~= 0
|
||||||
self.anim = ANIM_WALK
|
or velocity.z ~= 0 then
|
||||||
|
self.object:setvelocity({x=0,y=velocity.y,z=0})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.turn = "straight"
|
if self.state == 'walk' then
|
||||||
|
if self.anim ~= ANIM_WALK then
|
||||||
|
self.object:set_animation({x=animation.walk_START,y=animation.walk_END},anim_speed,0)
|
||||||
|
self.anim = ANIM_WALK
|
||||||
|
end
|
||||||
|
|
||||||
local inside_2 = minetest.get_objects_inside_radius(pos,2)
|
self.direction = {x=math.sin(yaw)*-1,y=-10,z=math.cos(yaw)}
|
||||||
|
if self.direction then
|
||||||
|
self.object:setvelocity({x=self.direction.x*walk_speed,y=velocity.y,z=self.direction.z*walk_speed})
|
||||||
|
end
|
||||||
|
|
||||||
-- Boom
|
random_turn(self)
|
||||||
if #inside_2 ~= 0 then
|
|
||||||
for _,object in ipairs(inside_2) do
|
local velocity = self.object:getvelocity()
|
||||||
if object:is_player() and object:get_hp() ~= 0 then
|
|
||||||
self.chase = true
|
if self.turn_timer > 1 then
|
||||||
if self.visualx >= 2 then
|
local direction = self.direction
|
||||||
self.object:remove()
|
local npos = {x=pos.x+direction.x,y=pos.y+0.2,z=pos.z+direction.z}
|
||||||
creeper.boom(pos,self.powered)
|
if velocity.x == 0 or velocity.z == 0
|
||||||
minetest.sound_play("creeper_explode",{pos=pos,gain=1.5,max_hear_distance=2*64})
|
or core.registered_nodes[core.get_node(npos).name].walkable then
|
||||||
|
local select_turn = math.random(1,2)
|
||||||
|
if select_turn == 1 then
|
||||||
|
self.turn = 'left'
|
||||||
|
elseif select_turn == 2 then
|
||||||
|
self.turn = 'right'
|
||||||
end
|
end
|
||||||
|
self.turn_timer = 0
|
||||||
|
self.turn_speed = 0.05*math.random()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Jump
|
||||||
|
if self.jump_timer > 0.2 then
|
||||||
|
jump(self,pos,self.direction)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if #inside ~= 0 then
|
if self.state == 'chase' then
|
||||||
for _,object in ipairs(inside) do
|
if self.anim ~= ANIM_WALK then
|
||||||
if object:is_player() and object:get_hp() ~= 0 then
|
self.object:set_animation({x=animation.walk_START,y=animation.walk_END},anim_speed,0)
|
||||||
if #inside_2 ~= 0 then
|
self.anim = ANIM_WALK
|
||||||
for _,object in ipairs(inside_2) do
|
end
|
||||||
-- Stop move
|
|
||||||
if object:is_player() then
|
self.turn = 'straight'
|
||||||
if self.anim ~= ANIM_STAND then
|
|
||||||
self.object:set_animation({x=animation.stand_START,y=animation.stand_END},anim_speed,0)
|
local inside_2 = core.get_objects_inside_radius(pos,2)
|
||||||
self.anim = ANIM_STAND
|
|
||||||
end
|
-- Boom
|
||||||
self.object:setvelocity({x=0,y=velocity.y,z=0})
|
if #inside_2 ~= 0 then
|
||||||
return
|
for _,object in ipairs(inside_2) do
|
||||||
end
|
if object:is_player() and object:get_hp() ~= 0 then
|
||||||
|
self.chase = true
|
||||||
|
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})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ppos = object:getpos()
|
|
||||||
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:setyaw(self.yaw)
|
|
||||||
self.direction = {x=math.sin(self.yaw)*-1,y=0,z=math.cos(self.yaw)}
|
|
||||||
|
|
||||||
local direction = self.direction
|
|
||||||
self.object:setvelocity({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
|
||||||
end
|
end
|
||||||
else
|
|
||||||
self.state = "stand"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Swim
|
if #inside ~= 0 then
|
||||||
local node = minetest.get_node(pos)
|
for _,object in ipairs(inside) do
|
||||||
if minetest.get_item_group(node.name,"water") ~= 0 then
|
if object:is_player() and object:get_hp() ~= 0 then
|
||||||
self.object:setacceleration({x=0,y=1,z=0})
|
if #inside_2 ~= 0 then
|
||||||
local velocity = self.object:getvelocity()
|
for _,object in ipairs(inside_2) do
|
||||||
if self.object:getvelocity().y > 5 then
|
-- Stop move
|
||||||
self.object:setvelocity({x=0,y=velocity.y-velocity.y/2,z=0})
|
if object:is_player() then
|
||||||
else
|
if self.anim ~= ANIM_STAND then
|
||||||
self.object:setvelocity({x=0,y=velocity.y+1,z=0})
|
self.object:set_animation({x=animation.stand_START,y=animation.stand_END},anim_speed,0)
|
||||||
end
|
self.anim = ANIM_STAND
|
||||||
else
|
end
|
||||||
self.object:setacceleration({x=0,y=-10,z=0})
|
self.object:setvelocity({x=0,y=velocity.y,z=0})
|
||||||
end
|
return
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def.on_punch = function(self,puncher,time_from_last_punch,tool_capabilities,dir)
|
local ppos = object:getpos()
|
||||||
if self.knockback == false then
|
self.vec = {x=ppos.x-pos.x,y=ppos.y-pos.y,z=ppos.z-pos.z}
|
||||||
local knockback_level = self.knockback_level
|
self.yaw = math.atan(self.vec.z/self.vec.x)+math.pi^2
|
||||||
self.object:setvelocity({x=dir.x*knockback_level,y=3,z=dir.z*knockback_level})
|
if ppos.x > pos.x then
|
||||||
self.knockback = true
|
self.yaw = self.yaw+math.pi
|
||||||
minetest.after(0.6,function()
|
end
|
||||||
self.knockback = false
|
self.yaw = self.yaw-2
|
||||||
end)
|
self.object:setyaw(self.yaw)
|
||||||
end
|
self.direction = {x=math.sin(self.yaw)*-1,y=0,z=math.cos(self.yaw)}
|
||||||
if self.object:get_hp() < 1 then
|
|
||||||
local pos = self.object:getpos()
|
|
||||||
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 = minetest.get_node_or_nil(p)
|
|
||||||
if node == nil or not node.name or node.name ~= "air" then
|
|
||||||
p = pos
|
|
||||||
end
|
|
||||||
local obj = minetest.add_item(p, {name="tnt:gunpowder",count=math.random(0,2)})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def.get_staticdata = function(self)
|
local direction = self.direction
|
||||||
return minetest.serialize({
|
self.object:setvelocity({x=direction.x*2.5,y=velocity.y,z=direction.z*2.5})
|
||||||
powered = self.powered
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_entity("creeper:creeper",def)
|
-- Jump
|
||||||
|
if self.jump_timer > 0.2 then
|
||||||
minetest.register_craftitem("creeper:spawnegg",{
|
jump(self,pos,direction)
|
||||||
description = "Creeper Spawn Egg",
|
end
|
||||||
inventory_image = "creeper_spawnegg.png",
|
end
|
||||||
stack_max = 64,
|
end
|
||||||
on_place = function(itemstack,placer,pointed_thing)
|
else
|
||||||
if pointed_thing.type == "node" then
|
self.state = 'stand'
|
||||||
local pos = pointed_thing.above
|
|
||||||
pos.y = pos.y+1
|
|
||||||
minetest.add_entity(pos,"creeper:creeper")
|
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
|
||||||
itemstack:take_item()
|
|
||||||
end
|
end
|
||||||
return itemstack
|
end
|
||||||
|
|
||||||
|
-- Swim
|
||||||
|
local node = core.get_node(pos)
|
||||||
|
if core.get_item_group(node.name,'water') ~= 0 then
|
||||||
|
self.object:setacceleration({x=0,y=1,z=0})
|
||||||
|
local velocity = self.object:getvelocity()
|
||||||
|
if self.object:getvelocity().y > 5 then
|
||||||
|
self.object:setvelocity({x=0,y=velocity.y-velocity.y/2,z=0})
|
||||||
|
else
|
||||||
|
self.object:setvelocity({x=0,y=velocity.y+1,z=0})
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.object:setacceleration({x=0,y=-10,z=0})
|
||||||
end
|
end
|
||||||
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:setvelocity({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:getpos()
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
def.get_staticdata = function(self)
|
||||||
|
return core.serialize({
|
||||||
|
powered = self.powered
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
core.register_entity(sneeker.mob_name, def)
|
||||||
|
end
|
||||||
|
1
mod.conf
Normal file
@ -0,0 +1 @@
|
|||||||
|
name = sneeker
|
4
settings.lua
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
-- Settings for sneeker mod
|
||||||
|
|
||||||
|
|
||||||
|
sneeker.debug = core.settings:get_bool('enable_debug_mods') or false
|
11
settingtypes.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Sets maximum number of spawns that can exist in world.
|
||||||
|
sneeker.spawn_cap (Maximum spawns) int 10
|
||||||
|
|
||||||
|
# Sets possibility for spawn.
|
||||||
|
sneeker.spawn_chance (Spawn chance) int 1000
|
||||||
|
|
||||||
|
# Sets frequency of spawn chance. Default 240 is equivalent to 4 minutes (60 * 4).
|
||||||
|
sneeker.spawn_interval (Spawn interval) int 240
|
||||||
|
|
||||||
|
# Sets the maximum light that a node can have for spawn to occur.
|
||||||
|
sneeker.spawn_maxlight (Max light for spawn) int 5
|
151
spawn.lua
@ -1,32 +1,123 @@
|
|||||||
minetest.register_abm({
|
-- Original code by Rui: WTFPL
|
||||||
nodenames = {"default:dirt_with_grass","default:stone"},
|
|
||||||
neighbors = {"air"},
|
|
||||||
interval = 30,
|
local time_min = 60
|
||||||
chance = 9000,
|
local time_hr = time_min * 60
|
||||||
action = function(pos, node, _, active_object_count_wider)
|
local time_day = time_hr * 24
|
||||||
if active_object_count_wider > 5 then
|
|
||||||
return
|
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
|
||||||
|
local spawn_chance_percent = math.floor(1 / 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(spawn_cap))
|
||||||
|
sneeker.log('Spawn chance: ' .. spawn_chance_percent)
|
||||||
|
sneeker.log('Spawn interval: ' .. tostring(spawn_interval) .. ' (' .. tostring(spawn_interval/60) .. ' minute(s))')
|
||||||
|
sneeker.log('Maximum light value for spawn: ' .. tostring(spawn_maxlight))
|
||||||
|
|
||||||
|
|
||||||
|
if core.global_exists('mobs') then
|
||||||
|
mobs:spawn({
|
||||||
|
name = sneeker.mob_name,
|
||||||
|
nodes = {'default:dirt_with_grass', 'default:stone'},
|
||||||
|
neighbors = {'air'},
|
||||||
|
min_light = -1,
|
||||||
|
max_light = spawn_maxlight,
|
||||||
|
interval = spawn_interval,
|
||||||
|
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
|
||||||
pos.y = pos.y+1
|
})
|
||||||
if not minetest.get_node_light(pos) then
|
|
||||||
return
|
|
||||||
end
|
if core.get_modpath('spawneggs') and core.get_modpath('tnt') then
|
||||||
if minetest.get_node_light(pos) > 5 then
|
core.register_craftitem(sneeker.spawnegg_name, {
|
||||||
return
|
description = 'Sneeker Spawn Egg',
|
||||||
end
|
inventory_image = 'sneeker_spawnegg.png',
|
||||||
if minetest.get_node_light(pos) < -1 then
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
return
|
if pointed_thing.type == 'node' then
|
||||||
end
|
local pos = pointed_thing.above
|
||||||
if pos.y > 31000 then
|
pos.y = pos.y+1
|
||||||
return
|
core.add_entity(pos, sneeker.mob_name)
|
||||||
end
|
if not core.settings:get_bool('creative_mode') then
|
||||||
if minetest.get_node(pos).name ~= "air" then
|
itemstack:take_item()
|
||||||
return
|
end
|
||||||
end
|
return itemstack
|
||||||
pos.y = pos.y+1
|
end
|
||||||
if minetest.get_node(pos).name ~= "air" then
|
end
|
||||||
return
|
})
|
||||||
end
|
|
||||||
minetest.add_entity(pos,"creeper:creeper")
|
core.register_craft({
|
||||||
|
output = sneeker.spawnegg_name,
|
||||||
|
type = 'shapeless',
|
||||||
|
recipe = {
|
||||||
|
'spawneggs:egg', 'tnt:tnt',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
core.register_alias('spawneggs:sneeker', sneeker.spawnegg_name)
|
||||||
end
|
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,17 @@
|
|||||||
|
-- Original code by Rui: WTFPL
|
||||||
|
|
||||||
|
|
||||||
-- 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 +37,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:setacceleration({x=0, y=-10, z=0})
|
obj:setacceleration({x=0, y=-10, z=0})
|
||||||
@ -62,7 +65,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 +73,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 +101,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:getpos()
|
local obj_pos = obj:getpos()
|
||||||
local obj_vel = obj:getvelocity()
|
local obj_vel = obj:getvelocity()
|
||||||
@ -115,7 +118,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 +131,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,12 +149,12 @@ 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 = minetest.get_content_id("tnt:tnt")
|
local c_tnt = core.get_content_id('tnt:tnt')
|
||||||
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
|
||||||
@ -180,14 +183,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)
|
||||||
|