|
|
|
@@ -86,7 +86,7 @@ minetest.register_entity(
|
|
|
|
|
self._tmr = self._tmr + elapsed
|
|
|
|
|
self.object:set_yaw(math.rad(math.fmod((math.floor(math.fmod(math.deg(self.object:get_yaw()), 360) / 90) * 90), 360)))
|
|
|
|
|
--get yaw and convert it into param2
|
|
|
|
|
local p = self.object:getyaw()
|
|
|
|
|
local p = self.object:get_yaw()
|
|
|
|
|
--convert yaw from rad to degrees
|
|
|
|
|
local yaw = math.deg(p)
|
|
|
|
|
yaw = math.floor(yaw / 90)
|
|
|
|
@@ -97,13 +97,13 @@ minetest.register_entity(
|
|
|
|
|
p = yaw
|
|
|
|
|
--add -y force
|
|
|
|
|
local force = {x = 0, y = -10, z = 0}
|
|
|
|
|
self.object:setvelocity(force)
|
|
|
|
|
self.object:set_velocity(force)
|
|
|
|
|
if self._tmr < 0.2 then
|
|
|
|
|
return
|
|
|
|
|
else
|
|
|
|
|
self._tmr = 0
|
|
|
|
|
end
|
|
|
|
|
local pos = self.object:getpos()
|
|
|
|
|
local pos = self.object:get_pos()
|
|
|
|
|
local pos1 = {x = pos.x, y = pos.y + 0.5, z = pos.z}
|
|
|
|
|
local d
|
|
|
|
|
--swap 1 and 3 in p
|
|
|
|
@@ -135,14 +135,14 @@ minetest.register_entity(
|
|
|
|
|
end
|
|
|
|
|
if d then
|
|
|
|
|
local bullet_ent = minetest.add_entity(pos1, "portalgun:bullet1")
|
|
|
|
|
bullet_ent:setvelocity(d)
|
|
|
|
|
bullet_ent:set_velocity(d)
|
|
|
|
|
--rotate bullet to by 90 degrees in x axis
|
|
|
|
|
local yaw = math.rad(math.fmod((math.floor(math.fmod(math.deg(self.object:get_yaw()), 360) / 90) * 90), 360))
|
|
|
|
|
bullet_ent:set_yaw(yaw)
|
|
|
|
|
minetest.sound_play("portalgun_bullet1", {pos = pos, gain = 1, max_hear_distance = 15})
|
|
|
|
|
else
|
|
|
|
|
local obj = minetest.add_entity(pos1, "portalgun:turretgun")
|
|
|
|
|
obj:setyaw(self.object:getyaw())
|
|
|
|
|
obj:set_yaw(self.object:get_yaw())
|
|
|
|
|
self.object:remove()
|
|
|
|
|
end
|
|
|
|
|
return true
|
|
|
|
@@ -226,7 +226,7 @@ minetest.register_entity(
|
|
|
|
|
on_step = function(self, elapsed, moveresult)
|
|
|
|
|
self.object:set_yaw(math.rad(math.fmod((math.floor(math.fmod(math.deg(self.object:get_yaw()), 360) / 90) * 90), 360)))
|
|
|
|
|
--get yaw and convert it into param2
|
|
|
|
|
local p = self.object:getyaw()
|
|
|
|
|
local p = self.object:get_yaw()
|
|
|
|
|
--convert yaw from rad to degrees
|
|
|
|
|
local yaw = math.deg(p)
|
|
|
|
|
yaw = math.floor(yaw / 90)
|
|
|
|
@@ -238,7 +238,7 @@ minetest.register_entity(
|
|
|
|
|
local pos = self.object:get_pos()
|
|
|
|
|
local pos1 = {x = pos.x, y = pos.y + 0.5, z = pos.z}
|
|
|
|
|
local force = {x = 0, y = -10, z = 0}
|
|
|
|
|
self.object:setvelocity(force)
|
|
|
|
|
self.object:set_velocity(force)
|
|
|
|
|
self._tmr = self._tmr + elapsed
|
|
|
|
|
if self._tmr < 0.2 then
|
|
|
|
|
return
|
|
|
|
@@ -278,7 +278,7 @@ minetest.register_entity(
|
|
|
|
|
if d then
|
|
|
|
|
local obj = minetest.add_entity(pos1, "portalgun:turretgun2")
|
|
|
|
|
--set yaw to same as this object
|
|
|
|
|
obj:setyaw(self.object:getyaw())
|
|
|
|
|
obj:setyaw(self.object:get_yaw())
|
|
|
|
|
self.object:remove()
|
|
|
|
|
end
|
|
|
|
|
return true
|
|
|
|
|