damage correction

master
Alexsandro Percy 2021-07-12 21:10:14 -03:00
parent 75c8981dc3
commit a716e1fea7
3 changed files with 8 additions and 9 deletions

View File

@ -34,7 +34,7 @@ function trike.physics(self)
self.object:set_velocity(vnew)
end
--local gravity_accell = {x=0,y=mobkit.gravity,z=0}
--self.object:set_acceleration(gravity_accell)
self.object:set_acceleration(self._last_accell)
local accel = self._last_accell
accel.y = accel.y + mobkit.gravity
self.object:set_acceleration(accel)
end

View File

@ -149,6 +149,7 @@ minetest.register_entity("trike:trike", {
hp_max = 50,
buoyancy = 2,
physics = trike.physics,
springiness = 0.3,
_passenger = nil,
_color = "#0063b0",
_rudder_angle = 0,
@ -160,6 +161,7 @@ minetest.register_entity("trike:trike", {
_longit_speed = 0,
_lastrot = {x=0,y=0,z=0},
_last_accell = {x=0,y=0,z=0},
lastvelocity = nil,
get_staticdata = function(self) -- unloaded/unloads ... is now saved
return minetest.serialize({

View File

@ -260,8 +260,8 @@ end
function trike.testImpact(self, velocity)
local collision = false
if self._last_vel == nil then return end
local impact = abs(trike.get_hipotenuse_value(velocity, self._last_vel))
if self.lastvelocity == nil then return end
local impact = abs(trike.get_hipotenuse_value(velocity, self.lastvelocity))
if impact > 2 then
--minetest.chat_send_all('impact: '.. impact .. ' - hp: ' .. self.hp_max)
local p = self.object:get_pos()
@ -454,7 +454,7 @@ function trike.flightstep(self)
self.power_gauge:set_attach(self.object,'',TRIKE_GAUGE_POWER_POSITION,{x=0,y=0,z=power_indicator_angle})
--lift calculation
accel.y = accel.y + mobkit.gravity --accel_y
--accel.y = accel.y + mobkit.gravity --accel_y
local new_accel = accel
if longit_speed > 2 then
new_accel = trike.getLiftAccel(self, velocity, new_accel, longit_speed, roll, curr_pos)
@ -467,10 +467,7 @@ function trike.flightstep(self)
if stop ~= true then
--self.object:set_velocity(velocity)
self._last_accell = new_accel
--self.object:set_acceleration(new_accel)
--self.object:set_pos(self.object:get_pos())
elseif stop == false then
self.object:set_velocity({x=0,y=0,z=0})
end