now sussy mini crewmates can be hit and they run away.

This commit is contained in:
Looki2000 2023-01-30 16:53:03 +01:00
parent 20c937f1e4
commit 8df420796a
2 changed files with 28 additions and 6 deletions

View File

@ -1,3 +1,4 @@
local entity = { local entity = {
physical = true, physical = true,
collisionbox = {-0.25, 0, -0.25, 0.25, 0.5, 0.25}, collisionbox = {-0.25, 0, -0.25, 0.25, 0.5, 0.25},
@ -38,6 +39,8 @@ local entity = {
smallest_distance_to_lost_player = 10, -- smallest distance to lost player smallest_distance_to_lost_player = 10, -- smallest distance to lost player
largest_distance_to_stand_still = 3, -- largest distance to stand still next to the player largest_distance_to_stand_still = 3, -- largest distance to stand still next to the player
smallest_distance_to_stop_run_away = 30, -- smallest distance to stop run away from player
-------------------------- --------------------------
block_lastly_in_front = false, block_lastly_in_front = false,
@ -55,6 +58,10 @@ local entity = {
self.rotation_direction = math.random(-1, 1) self.rotation_direction = math.random(-1, 1)
end, end,
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
self.mode = 3
end,
on_step = function(self, dtime) on_step = function(self, dtime)
-- play amogus sound randomly with different pitch depending on situation -- play amogus sound randomly with different pitch depending on situation
@ -106,7 +113,6 @@ local entity = {
-- I will write it later. -- I will write it later.
--end --end
-- if mode is 0 or 1 (stand still or walk) and distance is smaller or equal to largest_distance_to_find_player, set mode to 2 (chase) -- if mode is 0 or 1 (stand still or walk) and distance is smaller or equal to largest_distance_to_find_player, set mode to 2 (chase)
if (self.mode == 0 or self.mode == 1) and distance <= self.largest_distance_to_find_player then if (self.mode == 0 or self.mode == 1) and distance <= self.largest_distance_to_find_player then
@ -123,8 +129,25 @@ local entity = {
-- if mode is 4 (rest mode) and distance is greater than largest_distance_to_stand_still, set mode to 2 (chase) -- if mode is 4 (rest mode) and distance is greater than largest_distance_to_stand_still, set mode to 2 (chase)
elseif self.mode == 4 and distance > self.largest_distance_to_stand_still then elseif self.mode == 4 and distance > self.largest_distance_to_stand_still then
self.mode = 2 self.mode = 2
-- running away mode
elseif self.mode == 3 then
-- if distance is greater than smallest_distance_to_lost_player, set mode to 0 (stand still)
if distance > self.smallest_distance_to_stop_run_away then
self.mode = 1
else
-- jump if on ground
local pos = self.object:get_pos()
pos.y = pos.y - 0.2
local bnode = minetest.get_node(pos)
if bnode.name ~= "air" then
local vel = self.object:get_velocity()
vel.y = vel.y + self.jump_force
self.object:set_velocity(vel)
end
end
end end
-- if if not performing an action related to the player -- if if not performing an action related to the player
if (self.mode == 0 or self.mode == 1) then if (self.mode == 0 or self.mode == 1) then

View File

@ -1,5 +1,6 @@
dofile(minetest.get_modpath("player_api") .. "/api.lua") dofile(minetest.get_modpath("player_api") .. "/api.lua")
-- Default player appearance -- Default player appearance
player_api.register_model("amogus_entity.obj", { player_api.register_model("amogus_entity.obj", {
animation_speed = 30, animation_speed = 30,
@ -15,13 +16,11 @@ player_api.register_model("amogus_entity.obj", {
sit = {x = 81, y = 160, eye_height = 0.8, override_local = true, sit = {x = 81, y = 160, eye_height = 0.8, override_local = true,
collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.0, 0.3}} collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.0, 0.3}}
}, },
--collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
stepheight = 0.6, stepheight = 0.6,
eye_height = 1.47,collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}, eye_height = 1.47,
--visual = "mesh", collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
rotation = 0,
visual = "mesh", visual = "mesh",
visual_size = {x=10, y=10, z=10}, visual_size = {x=10, y=10, z=10},