diff --git a/mods/amogus_entities/entities/amogus_entity.lua b/mods/amogus_entities/entities/amogus_entity.lua index 2174d18..94e34e5 100644 --- a/mods/amogus_entities/entities/amogus_entity.lua +++ b/mods/amogus_entities/entities/amogus_entity.lua @@ -9,26 +9,72 @@ local entity = { textures = {"amogus_entity.png"}, on_rightclick = function(self, clicker) - minetest.chat_send_player(clicker:get_player_name(), "AMOGUS") + minetest.chat_send_player(clicker:get_player_name(), "WHY ARE YOU SUCH SUSSY BAKA?") end, + + -- physics config -- <--- HERE IS PART FOR YOU "USER" (NERD) + gravity = 9.81, -- m/s^2 + + walk_acceletation_speed = 0.2, -- self explainatory + jump_force = 20, -- self explainatory + + friction = 0.5, -- friction (0.0 - no friction like perfectly smooth ice | 1.0 - full friction and can't even move) + rotation_friction = 0.5, -- the same but for rotation + bounciness = 0.5, -- bounciness (0.0 - no bounce at all | 1.0 - full bounce and bouces infinitely back to the same height) + -------------------- + + is_going_forward = true, - gravity = 9.81/60, - speed = 0.1, + block_lastly_in_front = false, + direction_velocity = 0, + + on_activate = function(self, staticdata) + local direction = math.random() * 2 * math.pi + + -- procesing config values -- + --friction = 1 - self.friction + --rotation_friction = 1 - self.rotation_friction + bounciness = 1 - self.bounciness + ----------------------------- + + -- kill itself (debugging) + --self.object:remove() + + end, + on_step = function(self, dtime) - -- Switch "is_going_forward" 1% chance randomly between true and false + + -- play amogus sound randomly + if math.random(500) == 1 then + minetest.sound_play("amogus_sound", { + pos = self.object:get_pos(), + gain = 1.0, + max_hear_distance = 5 + }) + end + + + + + -- random changing between walking and standing still if math.random(200) == 1 then self.is_going_forward = not self.is_going_forward end + -- perform calculations on direction + local dir = self.object:get_yaw() + local dir_cos = math.cos(dir) + local dir_sin = math.sin(dir) + -- Go forward if "is_going_forward" is true if self.is_going_forward then - local pos = self.object:get_pos() - local dir = self.object:get_yaw() - pos.x = pos.x + math.cos(dir) * self.speed - pos.z = pos.z + math.sin(dir) * self.speed - self.object:set_pos(pos) + --local pos = self.object:get_pos() + local vel = self.object:get_velocity() + vel.x = vel.x + dir_cos * self.walk_acceletation_speed + vel.z = vel.z + dir_sin * self.walk_acceletation_speed + self.object:set_velocity(vel) end -- some chance of turning left or right @@ -38,18 +84,48 @@ local entity = { self.object:set_yaw(self.object:get_yaw() - math.pi/2) end - -- Make it also jump when running into some block + + + + + -- print curent amogus entity y position + --minetest.chat_send_player("singleplayer", "Y: " .. pos.y) + + -- print delta time + minetest.chat_send_player("singleplayer", "dtime: " .. dtime) + + + -- Make it also jump when some block is in front of it local pos = self.object:get_pos() + + pos.x = pos.x + dir_cos + pos.z = pos.z + dir_sin + local bnode = minetest.get_node(pos) if bnode.name ~= "air" then - local vel = self.object:get_velocity() - vel.y = vel.y + 5 - self.object:set_velocity(vel) + if self.block_lastly_in_front == false then + self.block_lastly_in_front = true + local vel = self.object:get_velocity() + vel.y = vel.y + self.jump_force + self.object:set_velocity(vel) + end + else + self.block_lastly_in_front = false end - -- change velocity by gravity + + + + local vel = self.object:get_velocity() - vel.y = vel.y - self.gravity + + -- change velocity by gravity + vel.y = vel.y - self.gravity * dtime * 2 + + -- change velocity by friction + vel.x = vel.x * (1 - self.friction * dtime) + vel.z = vel.z * (1 - self.friction * dtime) + self.object:set_velocity(vel) end diff --git a/mods/amogus_entities/models/amogus_entity.obj b/mods/amogus_entities/models/amogus_entity.obj index 7d6fccf..97d4e91 100644 --- a/mods/amogus_entities/models/amogus_entity.obj +++ b/mods/amogus_entities/models/amogus_entity.obj @@ -1,106 +1,112 @@ -# Blender v3.4.0 OBJ File: 'amogus.blend' +# Blender 3.4.0 # www.blender.org o body -v 0.250000 1.312500 -0.250000 -v 0.250000 1.312500 -0.375000 -v 0.250000 1.000000 -0.250000 -v 0.250000 1.000000 -0.375000 -v -0.250000 1.312500 -0.375000 v -0.250000 1.312500 -0.250000 -v -0.250000 1.000000 -0.375000 +v -0.375000 1.312500 -0.250000 v -0.250000 1.000000 -0.250000 -v 0.312500 1.125000 0.437500 -v 0.312500 1.125000 0.250000 -v 0.312500 0.375000 0.437500 -v 0.312500 0.375000 0.250000 -v -0.312500 1.125000 0.250000 -v -0.312500 1.125000 0.437500 -v -0.312500 0.375000 0.250000 -v -0.312500 0.375000 0.437500 -v 0.375000 1.437500 0.250000 -v 0.375000 1.437500 -0.250000 -v 0.375000 0.312500 0.250000 -v 0.375000 0.312500 -0.250000 -v -0.375000 1.437500 -0.250000 -v -0.375000 1.437500 0.250000 -v -0.375000 0.312500 -0.250000 -v -0.375000 0.312500 0.250000 -vt 0.000000 0.687500 -vt 0.500000 0.687500 -vt 0.500000 1.000000 -vt 0.000000 1.000000 -vt 0.000000 0.687500 -vt 0.125000 0.687500 -vt 0.125000 1.000000 -vt 0.000000 1.000000 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.125000 1.000000 -vt 0.000000 1.000000 -vt -0.000000 0.687500 -vt 0.125000 0.687500 -vt 0.500000 1.000000 -vt 0.000000 0.875000 -vt 0.500000 0.875000 -vt 0.000000 0.875000 -vt 0.500000 0.875000 -vt 0.500000 1.000000 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vt 0.968971 0.969702 -vn 0.0000 0.0000 -1.0000 -vn 1.0000 0.0000 0.0000 +v -0.375000 1.000000 -0.250000 +v -0.375000 1.312500 0.250000 +v -0.250000 1.312500 0.250000 +v -0.375000 1.000000 0.250000 +v -0.250000 1.000000 0.250000 +v 0.437500 1.125000 -0.312500 +v 0.250000 1.125000 -0.312500 +v 0.437500 0.375000 -0.312500 +v 0.250000 0.375000 -0.312500 +v 0.250000 1.125000 0.312500 +v 0.437500 1.125000 0.312500 +v 0.250000 0.375000 0.312500 +v 0.437500 0.375000 0.312500 +v 0.250000 1.437500 -0.375000 +v -0.250000 1.437500 -0.375000 +v 0.250000 0.312500 -0.375000 +v -0.250000 0.312500 -0.375000 +v -0.250000 1.437500 0.375000 +v 0.250000 1.437500 0.375000 +v -0.250000 0.312500 0.375000 +v 0.250000 0.312500 0.375000 +vn -1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 -1.0000 +vn 1.0000 -0.0000 -0.0000 vn -0.0000 -0.0000 1.0000 -vn -1.0000 0.0000 0.0000 -vn 0.0000 1.0000 0.0000 -vn 0.0000 -1.0000 -0.0000 -s off -f 4/1/1 7/2/1 5/3/1 2/4/1 -f 3/5/2 4/6/2 2/7/2 1/8/2 -f 12/9/3 19/10/3 17/11/3 10/12/3 -f 7/13/4 8/14/4 6/15/4 5/16/4 -f 6/17/5 1/8/5 2/18/5 5/19/5 -f 7/20/6 4/21/6 3/22/6 8/14/6 -f 13/23/3 10/12/3 17/11/3 22/24/3 -f 11/25/2 12/9/2 10/12/2 9/26/2 -f 16/27/3 11/25/3 9/26/3 14/28/3 -f 15/29/4 16/27/4 14/28/4 13/23/4 -f 14/28/5 9/26/5 10/12/5 13/23/5 -f 15/29/6 12/9/6 11/25/6 16/27/6 -f 15/29/3 13/23/3 22/24/3 24/30/3 -f 19/10/2 20/31/2 18/32/2 17/11/2 -f 23/33/4 24/30/4 22/24/4 21/34/4 -f 22/24/5 17/11/5 18/32/5 21/34/5 -f 23/33/6 20/31/6 19/10/6 24/30/6 -f 15/29/3 24/30/3 19/10/3 12/9/3 -f 6/35/1 21/34/1 18/32/1 1/36/1 -f 8/37/1 23/33/1 21/34/1 6/35/1 -f 3/38/1 1/36/1 18/32/1 20/31/1 -f 8/37/1 3/38/1 20/31/1 23/33/1 +vn -0.0000 1.0000 -0.0000 +vn -0.0000 -1.0000 -0.0000 +vt 0.000000 1.000000 +vt 0.968971 0.969702 +vt 0.000000 1.000000 +vt 0.125000 1.000000 +vt 0.000000 0.875000 +vt 0.000000 0.687500 +vt 0.500000 1.000000 +vt 0.968971 0.969702 +vt 0.000000 0.687500 +vt 0.125000 0.687500 +vt 0.500000 0.875000 +vt 0.500000 1.000000 +vt 0.125000 0.687500 +vt 0.500000 0.875000 +vt -0.000000 0.687500 +vt 0.500000 1.000000 +vt 0.968971 0.969702 +vt 0.500000 0.687500 +vt 0.125000 1.000000 +vt 0.000000 0.875000 +vt 0.000000 1.000000 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +s 0 +f 4/9/1 7/18/1 5/12/1 2/3/1 +f 3/6/2 4/10/2 2/4/2 1/1/2 +f 12/26/3 19/33/3 17/31/3 10/24/3 +f 7/19/4 8/21/4 6/15/4 5/13/4 +f 6/16/5 1/1/5 2/5/5 5/14/5 +f 7/20/6 4/11/6 3/7/6 8/21/6 +f 13/27/3 10/24/3 17/31/3 22/36/3 +f 11/25/2 12/26/2 10/24/2 9/23/2 +f 16/30/3 11/25/3 9/23/3 14/28/3 +f 15/29/4 16/30/4 14/28/4 13/27/4 +f 14/28/5 9/23/5 10/24/5 13/27/5 +f 15/29/6 12/26/6 11/25/6 16/30/6 +f 15/29/3 13/27/3 22/36/3 24/38/3 +f 19/33/2 20/34/2 18/32/2 17/31/2 +f 23/37/4 24/38/4 22/36/4 21/35/4 +f 22/36/5 17/31/5 18/32/5 21/35/5 +f 23/37/6 20/34/6 19/33/6 24/38/6 +f 15/29/3 24/38/3 19/33/3 12/26/3 +f 6/17/1 21/35/1 18/32/1 1/2/1 +f 8/22/1 23/37/1 21/35/1 6/17/1 +f 3/8/1 1/2/1 18/32/1 20/34/1 +f 8/22/1 3/8/1 20/34/1 23/37/1 o left_leg -v -0.062500 0.437500 0.187500 -v -0.062500 0.437500 -0.187500 -v -0.062500 -0.000000 0.187500 -v -0.062500 0.000000 -0.187500 -v -0.312500 0.437500 -0.187500 -v -0.312500 0.437500 0.187500 -v -0.312500 0.000000 -0.187500 -v -0.312500 -0.000000 0.187500 +v 0.187500 0.437500 0.062500 +v -0.187500 0.437500 0.062500 +v 0.187500 -0.000000 0.062500 +v -0.187500 0.000000 0.062500 +v -0.187500 0.437500 0.312500 +v 0.187500 0.437500 0.312500 +v -0.187500 0.000000 0.312500 +v 0.187500 -0.000000 0.312500 +vn -1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 -1.0000 +vn 1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 1.0000 +vn -0.0000 1.0000 -0.0000 +vn -0.0000 -1.0000 -0.0000 vt 0.968971 0.969702 vt 0.968971 0.969702 vt 0.968971 0.969702 @@ -109,28 +115,28 @@ vt 0.968971 0.969702 vt 0.968971 0.969702 vt 0.968971 0.969702 vt 0.968971 0.969702 -vn 0.0000 0.0000 -1.0000 -vn 1.0000 0.0000 0.0000 -vn 0.0000 -0.0000 1.0000 -vn -1.0000 0.0000 0.0000 -vn 0.0000 1.0000 0.0000 -vn 0.0000 -1.0000 -0.0000 -s off -f 28/39/7 31/40/7 29/41/7 26/42/7 -f 27/43/8 28/39/8 26/42/8 25/44/8 -f 32/45/9 27/43/9 25/44/9 30/46/9 -f 31/40/10 32/45/10 30/46/10 29/41/10 -f 30/46/11 25/44/11 26/42/11 29/41/11 -f 31/40/12 28/39/12 27/43/12 32/45/12 +s 0 +f 28/42/7 31/45/7 29/43/7 26/40/7 +f 27/41/8 28/42/8 26/40/8 25/39/8 +f 32/46/9 27/41/9 25/39/9 30/44/9 +f 31/45/10 32/46/10 30/44/10 29/43/10 +f 30/44/11 25/39/11 26/40/11 29/43/11 +f 31/45/12 28/42/12 27/41/12 32/46/12 o right_leg -v 0.312500 0.437500 0.187500 -v 0.312500 0.437500 -0.187500 -v 0.312500 -0.000000 0.187500 -v 0.312500 0.000000 -0.187500 -v 0.062500 0.437500 -0.187500 -v 0.062500 0.437500 0.187500 -v 0.062500 0.000000 -0.187500 -v 0.062500 -0.000000 0.187500 +v 0.187500 0.437500 -0.312500 +v -0.187500 0.437500 -0.312500 +v 0.187500 -0.000000 -0.312500 +v -0.187500 0.000000 -0.312500 +v -0.187500 0.437500 -0.062500 +v 0.187500 0.437500 -0.062500 +v -0.187500 0.000000 -0.062500 +v 0.187500 -0.000000 -0.062500 +vn -1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 -1.0000 +vn 1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 1.0000 +vn -0.0000 1.0000 -0.0000 +vn -0.0000 -1.0000 -0.0000 vt 0.968971 0.969702 vt 0.968971 0.969702 vt 0.968971 0.969702 @@ -139,16 +145,10 @@ vt 0.968971 0.969702 vt 0.968971 0.969702 vt 0.968971 0.969702 vt 0.968971 0.969702 -vn 0.0000 0.0000 -1.0000 -vn 1.0000 0.0000 0.0000 -vn 0.0000 -0.0000 1.0000 -vn -1.0000 0.0000 0.0000 -vn 0.0000 1.0000 0.0000 -vn 0.0000 -1.0000 -0.0000 -s off -f 36/47/13 39/48/13 37/49/13 34/50/13 -f 35/51/14 36/47/14 34/50/14 33/52/14 -f 40/53/15 35/51/15 33/52/15 38/54/15 -f 39/48/16 40/53/16 38/54/16 37/49/16 -f 38/54/17 33/52/17 34/50/17 37/49/17 -f 39/48/18 36/47/18 35/51/18 40/53/18 +s 0 +f 36/50/13 39/53/13 37/51/13 34/48/13 +f 35/49/14 36/50/14 34/48/14 33/47/14 +f 40/54/15 35/49/15 33/47/15 38/52/15 +f 39/53/16 40/54/16 38/52/16 37/51/16 +f 38/52/17 33/47/17 34/48/17 37/51/17 +f 39/53/18 36/50/18 35/49/18 40/54/18 diff --git a/mods/amogus_items/init.lua b/mods/amogus_items/init.lua index 97a32d4..05b0d51 100644 --- a/mods/amogus_items/init.lua +++ b/mods/amogus_items/init.lua @@ -2,13 +2,13 @@ minetest.register_craftitem("amogus_items:amogus", { description = "Amogus", inventory_image = "amogus_item.png", - on_use = function(itemstack, user) - minetest.sound_play("amogus_sound", { - pos = user:get_pos(), - gain = 1.0, - max_hear_distance = 5 - }) - end, + --on_use = function(itemstack, user) + -- minetest.sound_play("amogus_sound", { + -- pos = user:get_pos(), + -- gain = 1.0, + -- max_hear_distance = 5 + -- }) + --end, --on_place = function(itemstack, placer, pointed_thing) -- local pos = pointed_thing.above @@ -24,6 +24,11 @@ minetest.register_craftitem("amogus_items:amogus", { if pointed_thing.type == "node" then local pos = pointed_thing.above minetest.add_entity(pos, "amogus_entities:amogus") + minetest.sound_play("amogus_sound", { + pos = pos, + gain = 1.0, + max_hear_distance = 5 + }) end return itemstack end