removed mobkit dependency

master
Alexsandro Percy 2022-05-29 14:11:39 -03:00
parent 9f7825ab09
commit a675511946
4 changed files with 22 additions and 22 deletions

View File

@ -34,17 +34,17 @@ function pa28.physics(self)
--buoyancy --buoyancy
local surface = nil local surface = nil
local surfnodename = nil local surfnodename = nil
local spos = mobkit.get_stand_pos(self) local spos = airutils.get_stand_pos(self)
spos.y = spos.y+0.01 spos.y = spos.y+0.01
-- get surface height -- get surface height
local snodepos = mobkit.get_node_pos(spos) local snodepos = airutils.get_node_pos(spos)
local surfnode = mobkit.nodeatpos(spos) local surfnode = airutils.nodeatpos(spos)
while surfnode and (surfnode.drawtype == 'liquid' or surfnode.drawtype == 'flowingliquid') do while surfnode and (surfnode.drawtype == 'liquid' or surfnode.drawtype == 'flowingliquid') do
surfnodename = surfnode.name surfnodename = surfnode.name
surface = snodepos.y +0.5 surface = snodepos.y +0.5
if surface > spos.y+self.height then break end if surface > spos.y+self.height then break end
snodepos.y = snodepos.y+1 snodepos.y = snodepos.y+1
surfnode = mobkit.nodeatpos(snodepos) surfnode = airutils.nodeatpos(snodepos)
end end
local new_velocity = nil local new_velocity = nil
@ -59,18 +59,18 @@ function pa28.physics(self)
local height = self.height local height = self.height
local submergence = min(surface-spos.y,height)/height local submergence = min(surface-spos.y,height)/height
-- local balance = self.buoyancy*self.height -- local balance = self.buoyancy*self.height
local buoyacc = mobkit.gravity*(self.buoyancy-submergence) local buoyacc = airutils.gravity*(self.buoyancy-submergence)
--[[mobkit.set_acceleration(self.object, --[[airutils.set_acceleration(self.object,
{x=-vel.x*self.water_drag,y=buoyacc-vel.y*abs(vel.y)*0.4,z=-vel.z*self.water_drag})]]-- {x=-vel.x*self.water_drag,y=buoyacc-vel.y*abs(vel.y)*0.4,z=-vel.z*self.water_drag})]]--
accell = {x=-vel.x*self.water_drag,y=buoyacc-(vel.y*abs(vel.y)*0.4),z=-vel.z*self.water_drag} accell = {x=-vel.x*self.water_drag,y=buoyacc-(vel.y*abs(vel.y)*0.4),z=-vel.z*self.water_drag}
--local v_accell = {x=0,y=buoyacc-(vel.y*abs(vel.y)*0.4),z=0} --local v_accell = {x=0,y=buoyacc-(vel.y*abs(vel.y)*0.4),z=0}
--mobkit.set_acceleration(self.object,v_accell) --airutils.set_acceleration(self.object,v_accell)
new_velocity = vector.add(vel, vector.multiply(accell, self.dtime)) new_velocity = vector.add(vel, vector.multiply(accell, self.dtime))
else else
mobkit.set_acceleration(self.object,{x=0,y=0,z=0}) airutils.set_acceleration(self.object,{x=0,y=0,z=0})
self.isinliquid = false self.isinliquid = false
new_velocity = vector.add(vel, {x=0,y=mobkit.gravity * self.dtime,z=0}) new_velocity = vector.add(vel, {x=0,y=airutils.gravity * self.dtime,z=0})
--self.object:set_velocity(new_velocity) --self.object:set_velocity(new_velocity)
end end
@ -104,7 +104,7 @@ function pa28.physics(self)
end end
if pa28.mode == 2 then if pa28.mode == 2 then
self.object:set_acceleration({x=0,y=mobkit.gravity,z=0}) self.object:set_acceleration({x=0,y=airutils.gravity,z=0})
end end
end end

View File

@ -211,7 +211,7 @@ minetest.register_entity("pa28:pa28", {
end, end,
on_activate = function(self, staticdata, dtime_s) on_activate = function(self, staticdata, dtime_s)
mobkit.actfunc(self, staticdata, dtime_s) airutils.actfunc(self, staticdata, dtime_s)
if staticdata ~= "" and staticdata ~= nil then if staticdata ~= "" and staticdata ~= nil then
local data = minetest.deserialize(staticdata) or {} local data = minetest.deserialize(staticdata) or {}
self._energy = data.stored_energy self._energy = data.stored_energy
@ -288,11 +288,11 @@ minetest.register_entity("pa28:pa28", {
end end
end, end,
--on_step = mobkit.stepfunc, --on_step = airutils.stepfunc,
on_step = function(self,dtime,colinfo) on_step = function(self,dtime,colinfo)
self.dtime = math.min(dtime,0.2) self.dtime = math.min(dtime,0.2)
self.colinfo = colinfo self.colinfo = colinfo
self.height = mobkit.get_box_height(self) self.height = airutils.get_box_height(self)
-- physics comes first -- physics comes first
local vel = self.object:get_velocity() local vel = self.object:get_velocity()
@ -375,8 +375,8 @@ minetest.register_entity("pa28:pa28", {
if airutils.set_paint(self, puncher, itmstck, "pa28_painting.png") == false then if airutils.set_paint(self, puncher, itmstck, "pa28_painting.png") == false then
if not self.driver and toolcaps and toolcaps.damage_groups if not self.driver and toolcaps and toolcaps.damage_groups
and toolcaps.damage_groups.fleshy and item_name ~= airutils.fuel then and toolcaps.damage_groups.fleshy and item_name ~= airutils.fuel then
--mobkit.hurt(self,toolcaps.damage_groups.fleshy - 1) --airutils.hurt(self,toolcaps.damage_groups.fleshy - 1)
--mobkit.make_sound(self,'hit') --airutils.make_sound(self,'hit')
self.hp_max = self.hp_max - 10 self.hp_max = self.hp_max - 10
minetest.sound_play("pa28_collision", { minetest.sound_play("pa28_collision", {
object = self.object, object = self.object,

View File

@ -1,5 +1,5 @@
name = pa28 name = pa28
depends = mobkit,default,biofuel,airutils depends = default,biofuel,airutils
optional_depends = compassgps optional_depends = compassgps
author = APercy author = APercy
description = Adds a craftable PA28 description = Adds a craftable PA28

View File

@ -253,7 +253,7 @@ function pa28.testDamage(self, velocity, position)
if self._last_vel == nil then return end if self._last_vel == nil then return end
--lets calculate the vertical speed, to avoid the bug on colliding on floor with hard lag --lets calculate the vertical speed, to avoid the bug on colliding on floor with hard lag
if abs(velocity.y - self._last_vel.y) > 2 then if abs(velocity.y - self._last_vel.y) > 2 then
local noded = mobkit.nodeatpos(mobkit.pos_shift(p,{y=low_node_pos})) local noded = airutils.nodeatpos(airutils.pos_shift(p,{y=low_node_pos}))
if (noded and noded.drawtype ~= 'airlike') then if (noded and noded.drawtype ~= 'airlike') then
collision = true collision = true
else else
@ -271,7 +271,7 @@ function pa28.testDamage(self, velocity, position)
end end
if impact > 1.2 and self._longit_speed > 3 then if impact > 1.2 and self._longit_speed > 3 then
local noded = mobkit.nodeatpos(mobkit.pos_shift(p,{y=low_node_pos})) local noded = airutils.nodeatpos(airutils.pos_shift(p,{y=low_node_pos}))
if (noded and noded.drawtype ~= 'airlike') then if (noded and noded.drawtype ~= 'airlike') then
minetest.sound_play("pa28_touch", { minetest.sound_play("pa28_touch", {
--to_player = self.driver_name, --to_player = self.driver_name,
@ -535,7 +535,7 @@ function pa28.flightstep(self)
if newroll > 360 then newroll = newroll - 360 end if newroll > 360 then newroll = newroll - 360 end
if newroll < -360 then newroll = newroll + 360 end if newroll < -360 then newroll = newroll + 360 end
local hull_direction = mobkit.rot_to_dir(rotation) --minetest.yaw_to_dir(yaw) local hull_direction = airutils.rot_to_dir(rotation) --minetest.yaw_to_dir(yaw)
local nhdir = {x=hull_direction.z,y=0,z=-hull_direction.x} -- lateral unit vector local nhdir = {x=hull_direction.z,y=0,z=-hull_direction.x} -- lateral unit vector
local longit_speed = vector.dot(velocity,hull_direction) local longit_speed = vector.dot(velocity,hull_direction)
@ -549,7 +549,7 @@ function pa28.flightstep(self)
local accel = vector.add(longit_drag,later_drag) local accel = vector.add(longit_drag,later_drag)
local stop = false local stop = false
local node_bellow = mobkit.nodeatpos(mobkit.pos_shift(curr_pos,{y=-2.0})) local node_bellow = airutils.nodeatpos(airutils.pos_shift(curr_pos,{y=-2.0}))
local is_flying = true local is_flying = true
if self.colinfo then if self.colinfo then
is_flying = not self.colinfo.touching_ground is_flying = not self.colinfo.touching_ground
@ -586,7 +586,7 @@ function pa28.flightstep(self)
if longit_speed == 0 and is_flying == false and is_attached == false and self._engine_running == false then if longit_speed == 0 and is_flying == false and is_attached == false and self._engine_running == false then
if pa28.mode == 1 then if pa28.mode == 1 then
self.object:move_to(curr_pos) self.object:move_to(curr_pos)
self.object:set_acceleration({x=0,y=mobkit.gravity,z=0}) self.object:set_acceleration({x=0,y=airutils.gravity,z=0})
end end
return return
end end
@ -738,7 +738,7 @@ function pa28.flightstep(self)
--for mode==1, see at custom_physics --for mode==1, see at custom_physics
if pa28.mode == 2 then if pa28.mode == 2 then
self.object:move_to(curr_pos) self.object:move_to(curr_pos)
mobkit.set_acceleration(self.object, new_accel) airutils.set_acceleration(self.object, new_accel)
end end
else else
if stop == true then if stop == true then