removed mobkit dependency
parent
4048fd552e
commit
ae8ec99401
|
@ -34,17 +34,17 @@ function hidroplane.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 hidroplane.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
|
||||||
|
|
||||||
|
|
|
@ -236,7 +236,7 @@ minetest.register_entity("hidroplane:hidro", {
|
||||||
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
|
||||||
|
@ -322,11 +322,11 @@ minetest.register_entity("hidroplane:hidro", {
|
||||||
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()
|
||||||
|
@ -408,8 +408,8 @@ minetest.register_entity("hidroplane:hidro", {
|
||||||
if airutils.set_paint(self, puncher, itmstck, "hidroplane_painting.png") == false then
|
if airutils.set_paint(self, puncher, itmstck, "hidroplane_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("hidroplane_collision", {
|
minetest.sound_play("hidroplane_collision", {
|
||||||
object = self.object,
|
object = self.object,
|
||||||
|
|
|
@ -208,7 +208,7 @@ function hidroplane.testImpact(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=-2.8}))
|
local noded = airutils.nodeatpos(airutils.pos_shift(p,{y=-2.8}))
|
||||||
if (noded and noded.drawtype ~= 'airlike') then
|
if (noded and noded.drawtype ~= 'airlike') then
|
||||||
collision = true
|
collision = true
|
||||||
else
|
else
|
||||||
|
@ -227,7 +227,7 @@ function hidroplane.testImpact(self, velocity, position)
|
||||||
end
|
end
|
||||||
|
|
||||||
if impact > 1.0 and self._longit_speed > 2 then
|
if impact > 1.0 and self._longit_speed > 2 then
|
||||||
local noded = mobkit.nodeatpos(mobkit.pos_shift(p,{y=-2.8}))
|
local noded = airutils.nodeatpos(airutils.pos_shift(p,{y=-2.8}))
|
||||||
if (noded and noded.drawtype ~= 'airlike') then
|
if (noded and noded.drawtype ~= 'airlike') then
|
||||||
if noded.drawtype ~= 'liquid' then
|
if noded.drawtype ~= 'liquid' then
|
||||||
minetest.sound_play("hidroplane_touch", {
|
minetest.sound_play("hidroplane_touch", {
|
||||||
|
@ -246,7 +246,7 @@ function hidroplane.testImpact(self, velocity, position)
|
||||||
if self._last_water_touch <= 3 then self._last_water_touch = self._last_water_touch + self.dtime end
|
if self._last_water_touch <= 3 then self._last_water_touch = self._last_water_touch + self.dtime end
|
||||||
if impact > 0.2 and self._longit_speed > 1 and self._last_water_touch >=3 then
|
if impact > 0.2 and self._longit_speed > 1 and self._last_water_touch >=3 then
|
||||||
self._last_water_touch = 0
|
self._last_water_touch = 0
|
||||||
local noded = mobkit.nodeatpos(mobkit.pos_shift(p,{y=-2.8}))
|
local noded = airutils.nodeatpos(airutils.pos_shift(p,{y=-2.8}))
|
||||||
if (noded and noded.drawtype ~= 'airlike') then
|
if (noded and noded.drawtype ~= 'airlike') then
|
||||||
if noded.drawtype == 'liquid' then
|
if noded.drawtype == 'liquid' then
|
||||||
minetest.sound_play("hidroplane_touch_water", {
|
minetest.sound_play("hidroplane_touch_water", {
|
||||||
|
@ -447,7 +447,7 @@ function hidroplane.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)
|
||||||
|
@ -461,7 +461,7 @@ function hidroplane.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=-3}))
|
local node_bellow = airutils.nodeatpos(airutils.pos_shift(curr_pos,{y=-3}))
|
||||||
local is_flying = true
|
local is_flying = true
|
||||||
if node_bellow and node_bellow.drawtype ~= 'airlike' then is_flying = false end
|
if node_bellow and node_bellow.drawtype ~= 'airlike' then is_flying = false end
|
||||||
--if is_flying then minetest.chat_send_all('is flying') end
|
--if is_flying then minetest.chat_send_all('is flying') end
|
||||||
|
@ -587,7 +587,7 @@ function hidroplane.flightstep(self)
|
||||||
if accel == nil then accel = {x=0,y=0,z=0} end
|
if accel == nil then accel = {x=0,y=0,z=0} end
|
||||||
|
|
||||||
--lift calculation
|
--lift calculation
|
||||||
--accel.y = accel_y --accel.y + mobkit.gravity --accel_y
|
--accel.y = accel_y --accel.y + airutils.gravity --accel_y
|
||||||
|
|
||||||
--lets apply some bob in water
|
--lets apply some bob in water
|
||||||
if self.isinliquid then
|
if self.isinliquid then
|
||||||
|
|
2
mod.conf
2
mod.conf
|
@ -1,5 +1,5 @@
|
||||||
name = hidroplane
|
name = hidroplane
|
||||||
depends = mobkit,default,biofuel,airutils
|
depends = default,biofuel,airutils
|
||||||
author = APercy
|
author = APercy
|
||||||
description = Adds a craftable hydroplane
|
description = Adds a craftable hydroplane
|
||||||
title = Super Duck Hydroplane
|
title = Super Duck Hydroplane
|
||||||
|
|
Loading…
Reference in New Issue