SUSSY LITTLE BAKA UWU
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user