Add files via upload
parent
2cd40aa4ee
commit
d5419794f1
24
init.lua
24
init.lua
|
@ -762,6 +762,7 @@ function mobkit.actfunc(self, staticdata, dtime_s)
|
||||||
self.pos_history = {}
|
self.pos_history = {}
|
||||||
self.path_dir = 1
|
self.path_dir = 1
|
||||||
self.time_total = 0
|
self.time_total = 0
|
||||||
|
self.water_drag = self.water_drag or 1
|
||||||
|
|
||||||
local sdata = minetest.deserialize(staticdata)
|
local sdata = minetest.deserialize(staticdata)
|
||||||
if sdata then
|
if sdata then
|
||||||
|
@ -789,7 +790,8 @@ function mobkit.actfunc(self, staticdata, dtime_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
--hp
|
--hp
|
||||||
self.hp = self.hp or (self.max_hp or 10)
|
self.max_hp = self.max_hp or 10
|
||||||
|
self.hp = self.hp or self.max_hp
|
||||||
--armor
|
--armor
|
||||||
if type(self.armor_groups) ~= 'table' then
|
if type(self.armor_groups) ~= 'table' then
|
||||||
self.armor_groups={}
|
self.armor_groups={}
|
||||||
|
@ -817,7 +819,7 @@ function mobkit.stepfunc(self,dtime) -- not intended to be modified
|
||||||
end
|
end
|
||||||
|
|
||||||
-- dumb friction
|
-- dumb friction
|
||||||
if self.isonground then
|
if self.isonground and not self.isinliquid then
|
||||||
self.object:set_velocity({x= vel.x> 0.2 and vel.x*mobkit.friction or 0,
|
self.object:set_velocity({x= vel.x> 0.2 and vel.x*mobkit.friction or 0,
|
||||||
y=vel.y,
|
y=vel.y,
|
||||||
z=vel.z > 0.2 and vel.z*mobkit.friction or 0})
|
z=vel.z > 0.2 and vel.z*mobkit.friction or 0})
|
||||||
|
@ -866,7 +868,7 @@ function mobkit.stepfunc(self,dtime) -- not intended to be modified
|
||||||
local submergence = min(surface-spos.y,self.height)
|
local submergence = min(surface-spos.y,self.height)
|
||||||
local balance = self.buoyancy*self.height
|
local balance = self.buoyancy*self.height
|
||||||
local buoyacc = mobkit.gravity*((balance - submergence)^2/balance^2*sign(balance - submergence))
|
local buoyacc = mobkit.gravity*((balance - submergence)^2/balance^2*sign(balance - submergence))
|
||||||
self.object:set_acceleration({x=-vel.x,y=buoyacc-vel.y*abs(vel.y)*0.7,z=-vel.z})
|
self.object:set_acceleration({x=-vel.x*self.water_drag,y=buoyacc-vel.y*abs(vel.y)*0.7,z=-vel.z*self.water_drag})
|
||||||
else
|
else
|
||||||
self.isinliquid = false
|
self.isinliquid = false
|
||||||
self.object:set_acceleration({x=0,y=mobkit.gravity,z=0})
|
self.object:set_acceleration({x=0,y=mobkit.gravity,z=0})
|
||||||
|
@ -911,7 +913,7 @@ function mobkit.stepfunc(self,dtime) -- not intended to be modified
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
self:sensefunc()
|
if self.view_range then self:sensefunc() end
|
||||||
self:brainfunc()
|
self:brainfunc()
|
||||||
execute_queues(self)
|
execute_queues(self)
|
||||||
end
|
end
|
||||||
|
@ -1049,6 +1051,7 @@ end
|
||||||
|
|
||||||
function mobkit.lq_jumpattack(self,height,target)
|
function mobkit.lq_jumpattack(self,height,target)
|
||||||
local phase=1
|
local phase=1
|
||||||
|
local tgtbox = target:get_properties().collisionbox
|
||||||
local func=function(self)
|
local func=function(self)
|
||||||
if not mobkit.is_alive(target) then return true end
|
if not mobkit.is_alive(target) then return true end
|
||||||
if self.isonground then
|
if self.isonground then
|
||||||
|
@ -1069,15 +1072,14 @@ function mobkit.lq_jumpattack(self,height,target)
|
||||||
self.object:set_velocity(dir)
|
self.object:set_velocity(dir)
|
||||||
phase=3
|
phase=3
|
||||||
elseif phase==3 then -- in air
|
elseif phase==3 then -- in air
|
||||||
local twidth = target:get_properties().collisionbox[1]
|
local tgtpos = target:get_pos()
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
-- calculate attack spot
|
-- calculate attack spot
|
||||||
local dir = minetest.yaw_to_dir(self.object:get_yaw())
|
local yaw = self.object:get_yaw()
|
||||||
dir2 = vector.add(dir,self.attack.range+twidth)
|
local dir = minetest.yaw_to_dir(yaw)
|
||||||
local apos = vector.add(pos,dir2)
|
local apos = mobkit.pos_translate2d(pos,yaw,self.attack.range)
|
||||||
-- local tpos = mobkit.get_stand_pos(target) --test
|
|
||||||
-- tpos.y = tpos.y+height
|
if mobkit.is_pos_in_box(apos,tgtpos,tgtbox) then --bite
|
||||||
if mobkit.isnear2d(apos,target:get_pos(),0.25) then --bite
|
|
||||||
target:punch(self.object,1,self.attack)
|
target:punch(self.object,1,self.attack)
|
||||||
-- bounce off
|
-- bounce off
|
||||||
local vy = self.object:get_velocity().y
|
local vy = self.object:get_velocity().y
|
||||||
|
|
Loading…
Reference in New Issue