Compare commits

..

12 Commits
master ... cmer

Author SHA1 Message Date
Jordan Irwin
e1496df0a6 Remove tnt:boom node after explosion 2021-07-20 11:09:19 -07:00
Jordan Irwin
2289f6a261 Add to TODO list 2021-07-20 11:05:43 -07:00
Jordan Irwin
fa8363fef6 Add setting to customize spawning nodes 2021-07-20 11:05:24 -07:00
Jordan Irwin
00dcdda702 Delete unused spawn.lua 2021-07-20 11:02:04 -07:00
Jordan Irwin
793f75e5ca Add to TODO list 2021-07-19 23:07:49 -07:00
Jordan Irwin
4b2bf116d7 Update README 2021-07-19 23:07:36 -07:00
Jordan Irwin
7df19604b0 Add to TODO list 2021-07-19 23:05:13 -07:00
Jordan Irwin
e75731dcff Fix chasing player when close 2021-07-19 23:04:55 -07:00
Jordan Irwin
f9c850c55d Add to TODO list 2021-07-19 21:30:49 -07:00
Jordan Irwin
6033dbf52a Fix tnt drop 2021-07-19 21:29:56 -07:00
Jordan Irwin
b2494a40f7 Fix entity vertical positioning 2021-07-19 20:46:56 -07:00
Jordan Irwin
76edba7a48 Begin converting to cmer API 2021-07-19 19:19:54 -07:00
9 changed files with 28 additions and 114 deletions

@ -19,7 +19,7 @@ Settings documented in [reference][].
### Requirements: ### Requirements:
- Depends: cmer, default, tnt - Depends: cmer, default, tnt
- Optional depends: nether, sounds, simple_protection - Optional depends: nether, sounds
### Links: ### Links:

@ -2,14 +2,11 @@
TODO: TODO:
- add version using mobs_redo API - add version using mobs_redo API
- add version using cmer API - add version using cmer API
- add griefing option
- add wear to armor when exploding - add wear to armor when exploding
- add no-griefing setting
- disable attacking if damage disabled - disable attacking if damage disabled
- make powered versions run faster when chasing - make powered versions run faster when chasing
- fix knockback when chasing - fix knockback when chasing
- fix hit sound when chasing - fix hit sound when chasing
- make sneeker stop when within 2 of player - make sneeker stop when within 2 of player
- use asm_spawneggs for egg - use asm_spawneggs for egg
- add localization support
- add Spanish translation
- fix removing single node if protected

@ -1,17 +1,10 @@
next
----
- uses "sounds" mod
v1.1 v1.1
---- ----
- added sound when hit - added sound when hit
- fixed entity vertical positioning - fixed entity vertical positioning
- fixed tnt:boom node left after explosion
- added setting to customize spawn nodes - added setting to customize spawn nodes
- added simple_protection support - fixed tnt:boom node left after explosion
v1.0 v1.0
---- ----

@ -104,10 +104,6 @@
<td class="name" nowrap><a href="#sneeker.spawn_mapblock_limit">sneeker.spawn_mapblock_limit</a></td> <td class="name" nowrap><a href="#sneeker.spawn_mapblock_limit">sneeker.spawn_mapblock_limit</a></td>
<td class="summary">Limits the number of entities that can spawn per mapblock (16x16x16).</td> <td class="summary">Limits the number of entities that can spawn per mapblock (16x16x16).</td>
</tr> </tr>
<tr>
<td class="name" nowrap><a href="#sneeker.spawn_nodes">sneeker.spawn_nodes</a></td>
<td class="summary">Comma-separated list of nodes on which sneeker can spawn.</td>
</tr>
</table> </table>
<br/> <br/>
@ -477,33 +473,6 @@
</dd>
<dt>
<a name = "sneeker.spawn_nodes"></a>
<strong>sneeker.spawn_nodes</strong>
</dt>
<dd>
Comma-separated list of nodes on which sneeker can spawn.
</ul>
</ul>
</ul>
</ul>
<h3>Type:</h3>
<ul>
<i>string</i>
</ul>
<h3>Default:</h3>
<ul>
<i>default:dirt_with_dry_grass,default:dry_dirt,default:dry_dirt_with_dry_grass,default:desert_sand,nether:rack</i>
</ul>
</ul>
</dd> </dd>
</dl> </dl>
@ -512,7 +481,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-07-20 11:23:32 </i> <i style="float:right;">Last updated 2021-07-19 17:34:41 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

@ -1,13 +1,13 @@
--[[
local sounds_enabled = core.get_modpath("sounds") ~= nil
local hit_sound local hit_sound
if core.get_modpath("default") then if sounds_enabled then
hit_sound = "player_damage"
elseif core.get_modpath("sounds") then
hit_sound = "sounds_entity_hit" hit_sound = "sounds_entity_hit"
end end
--[[
local function jump(self, pos, direction) local function jump(self, pos, direction)
local velocity = self.object:get_velocity() local velocity = self.object:get_velocity()
if core.registered_nodes[core.get_node(pos).name].climbable then if core.registered_nodes[core.get_node(pos).name].climbable then
@ -52,12 +52,10 @@ local function random_turn(self)
end end
end end
local walk_speed = 1.5
local def = { local def = {
hp_max = 20, hp_max = 20,
physical = true, physical = true,
collisionbox = {-0.25, 0.3, -0.25, 0.25, 1.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 = {"sneeker.png"}, textures = {"sneeker.png"},
@ -70,7 +68,7 @@ local def = {
walk_START = 168, walk_START = 168,
walk_END = 187 walk_END = 187
}, },
walk_speed = walk_speed, walk_speed = 1.5,
jump_height = 5, jump_height = 5,
animation_speed = 30, animation_speed = 30,
knockback_level = 2 knockback_level = 2
@ -196,8 +194,8 @@ end
local function expand(self) local function expand(self)
if self.expanding and self.visualx < 2 then if self.expanding and self.visualx < 2 then
if self.hiss == false and sounds then if self.hiss == false then
sounds.fuse(1, {object=self.object, gain=1.5, max_hear_distance=2*64}) core.sound_play("sneeker_hiss", {object=self.object, gain=1.5, max_hear_distance=2*64})
end end
self.visualx = self.visualx+0.05 self.visualx = self.visualx+0.05
self.object:set_properties({ self.object:set_properties({
@ -216,39 +214,9 @@ end
local function explode(self, pos) local function explode(self, pos)
self.object:remove() self.object:remove()
sneeker.boom(pos, self.powered) sneeker.boom(pos, self.powered)
core.sound_play("sneeker_explode", {object=self.object, gain=sneeker.boom_gain, max_hear_distance=2*64})
end end
--[[
local function h_collides(pos, collision_info, touching_ground)
if not touching_ground or type(collision_info) ~= "table" or #collision_info == 0 then
return false
end
local pos_y = math.floor(pos.y)
local h_col
for _, col in ipairs(collision_info) do
local npos = col.node_pos
if npos and col.type == "node" then
-- exclude ground collisions
if math.floor(npos.y) > pos_y then
h_col = col
break
end
end
end
if not h_col then return false end
local h_vel = {
x = math.floor(h_col.new_velocity.x * 10) / 10,
z = math.floor(h_col.new_velocity.z * 10) / 10,
}
return h_vel.x < walk_speed and h_vel.z < walk_speed, h_col.node_pos
end
]]
local function chase(self, target) local function chase(self, target)
-- FIXME: why does setting mode = "chase" not work? -- FIXME: why does setting mode = "chase" not work?
if not self.chase_anim then if not self.chase_anim then
@ -289,7 +257,7 @@ local function end_chase(self)
self.expanding = false self.expanding = false
end end
def.on_step = function(self, dtime, moveresult) def.on_step = function(self, staticdata, dtime_s)
--[[ --[[
-- update lifetime timer -- update lifetime timer
-- FIXME: this is longer than realtime -- FIXME: this is longer than realtime
@ -337,13 +305,6 @@ def.on_step = function(self, dtime, moveresult)
end end
end end
if self.chase or self.state == "chase" or self.state == "walk" then
local collided, npos = h_collides(pos, moveresult.collisions, moveresult.touching_ground)
if collided then
jump(self, npos, self.direction)
end
end
local yaw = self.object:get_yaw() local yaw = self.object:get_yaw()
local inside = core.get_objects_inside_radius(pos, 10) local inside = core.get_objects_inside_radius(pos, 10)
local walk_speed = self.walk_speed local walk_speed = self.walk_speed
@ -439,6 +400,11 @@ def.on_step = function(self, dtime, moveresult)
self.turn_speed = 0.05*math.random() 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
]] ]]
@ -548,6 +514,11 @@ def.on_step = function(self, dtime, moveresult)
if can_set then if can_set then
self.object:set_velocity({x=direction.x*2.5, y=velocity.y, z=direction.z*2.5}) self.object:set_velocity({x=direction.x*2.5, y=velocity.y, z=direction.z*2.5})
end end
-- Jump
if self.jump_timer > 0.2 then
jump(self, pos, direction)
end
end end
end end
else else

@ -2,8 +2,7 @@ name = sneeker
title = Sneeker title = Sneeker
description = An explosive nuisance. description = An explosive nuisance.
license = MIT license = MIT
version = 1.1 version = 1.0
author = Rui, Jordan Irwin (AntumDeluge) author = Rui, Jordan Irwin (AntumDeluge)
min_minetest_version = 5.0
depends = cmer, default, tnt depends = cmer, default, tnt
optional_depends = nether, sounds, simple_protection optional_depends = nether, sounds

BIN
sounds/sneeker_explode.ogg Normal file

Binary file not shown.

BIN
sounds/sneeker_hiss.ogg Normal file

Binary file not shown.

@ -164,21 +164,8 @@ local function add_drop(drops, item)
end end
end end
local function is_protected(pos, name) return core.is_protected(pos, name) end
if core.global_exists("simple_protection") and simple_protection.can_access then
is_protected = function(pos, name)
local s_protect_name = name
-- simple_protection ignores names with empty strings
if s_protect_name == "" then
s_protect_name = " "
end
return core.is_protected(pos, name) or not simple_protection.can_access(pos, s_protect_name)
end
end
local function destroy(drops, pos, cid) local function destroy(drops, pos, cid)
if is_protected(pos, "") then if core.is_protected(pos, "") then
return return
end end
local def = cid_data[cid] local def = cid_data[cid]
@ -307,9 +294,7 @@ function sneeker.boom(pos, large)
if large then if large then
radius = large_radius radius = large_radius
end end
if sounds then core.sound_play("sneeker_explode", {pos=pos, gain=1.5, max_hear_distance=2*64})
sounds.explosion(1, {pos=pos, gain=sneeker.boom_gain, max_hear_distance=2*64})
end
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)