Compare commits

..

4 Commits

2 changed files with 27 additions and 18 deletions

View File

@ -1,6 +1,6 @@
# Pyramids (with Treasurer support) [`tsm_pyramids`] # Pyramids (with Treasurer support) [`tsm_pyramids`]
* Version: 1.0.2 * Version: 1.0.3
## Description ## Description
This is a mod for Minetest Game which adds randomly spawned pyramids in deserts and This is a mod for Minetest Game which adds randomly spawned pyramids in deserts and

View File

@ -151,7 +151,7 @@ MUMMY_DEF.on_punch = function(self, puncher, time_from_last_punch, tool_capabili
end end
self.attacker = puncher self.attacker = puncher
if damage > 0 then if damage and damage > 0 then
self.last_damage = { self.last_damage = {
type = "punch", type = "punch",
puncher = puncher, puncher = puncher,
@ -284,20 +284,23 @@ MUMMY_DEF.on_step = function(self, dtime)
if self.state == 1 then if self.state == 1 then
self.yawwer = true self.yawwer = true
self.attacker = "" self.attacker = ""
for _,object in ipairs(minetest.get_objects_inside_radius(self.object:get_pos(), 4)) do local pos_obj = self.object:get_pos()
if object:is_player() then if pos_obj then
self.yawwer = false for _,object in ipairs(minetest.get_objects_inside_radius(pos_obj, 4)) do
local NPC = self.object:get_pos() if object:is_player() then
local PLAYER = object:get_pos() self.yawwer = false
self.vec = {x=PLAYER.x-NPC.x, y=PLAYER.y-NPC.y, z=PLAYER.z-NPC.z} local NPC = self.object:get_pos()
self.yaw = math.atan(self.vec.z/self.vec.x)+math.pi^2 local PLAYER = object:get_pos()
if PLAYER.x > NPC.x then self.vec = {x=PLAYER.x-NPC.x, y=PLAYER.y-NPC.y, z=PLAYER.z-NPC.z}
self.yaw = self.yaw + math.pi self.yaw = math.atan(self.vec.z/self.vec.x)+math.pi^2
end if PLAYER.x > NPC.x then
self.yaw = self.yaw - 2 self.yaw = self.yaw + math.pi
self.object:set_yaw(self.yaw) end
self.attacker = object self.yaw = self.yaw - 2
end self.object:set_yaw(self.yaw)
self.attacker = object
end
end
end end
if self.attacker == "" and self.turn_timer > math.random(1,4) then if self.attacker == "" and self.turn_timer > math.random(1,4) then
@ -306,7 +309,8 @@ MUMMY_DEF.on_step = function(self, dtime)
self.turn_timer = 0 self.turn_timer = 0
self.direction = {x = math.sin(self.yaw)*-1, y = -20, z = math.cos(self.yaw)} self.direction = {x = math.sin(self.yaw)*-1, y = -20, z = math.cos(self.yaw)}
end end
self.object:set_velocity({x=0,y=self.object:get_velocity().y,z=0}) local old_vel = self.object:get_velocity()
self.object:set_velocity({x=0,y=old_vel and old_vel.y or 0,z=0})
if self.npc_anim ~= ANIM_STAND then if self.npc_anim ~= ANIM_STAND then
self.anim = get_animations() self.anim = get_animations()
self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, mummy_animation_speed, mummy_animation_blend) self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, mummy_animation_speed, mummy_animation_blend)
@ -321,7 +325,12 @@ MUMMY_DEF.on_step = function(self, dtime)
if self.state == 2 then if self.state == 2 then
if self.direction ~= nil then if self.direction ~= nil then
self.object:set_velocity({x=self.direction.x*mummy_chillaxin_speed,y=self.object:get_velocity().y,z=self.direction.z*mummy_chillaxin_speed}) local old_vel = self.object:get_velocity()
self.object:set_velocity({
x=self.direction.x*mummy_chillaxin_speed,
y=old_vel and old_vel.y or 0,
z=self.direction.z*mummy_chillaxin_speed,
})
end end
if self.turn_timer > math.random(1,4) and not self.attacker then if self.turn_timer > math.random(1,4) and not self.attacker then
self.yaw = 360 * math.random() self.yaw = 360 * math.random()