forked from VoxeLibre/VoxeLibre
Compare commits
2 Commits
master
...
flyer_alti
Author | SHA1 | Date |
---|---|---|
cora | cbd3e3264f | |
cora | d1a37f38b4 |
|
@ -2244,7 +2244,14 @@ local follow_flop = function(self)
|
||||||
|
|
||||||
return
|
return
|
||||||
elseif self.state == "flop" then
|
elseif self.state == "flop" then
|
||||||
|
if not is_glider(self) then
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
|
set_animation(self, "stand")
|
||||||
|
else
|
||||||
|
self.state = "walk"
|
||||||
|
set_animation(self, "walk")
|
||||||
|
return
|
||||||
|
end
|
||||||
self.object:set_acceleration({x = 0, y = 0, z = 0})
|
self.object:set_acceleration({x = 0, y = 0, z = 0})
|
||||||
set_velocity(self, 0)
|
set_velocity(self, 0)
|
||||||
end
|
end
|
||||||
|
@ -2487,11 +2494,17 @@ local do_states = function(self, dtime)
|
||||||
end
|
end
|
||||||
if self.facing_fence == true
|
if self.facing_fence == true
|
||||||
or cliff_or_danger
|
or cliff_or_danger
|
||||||
or random(1, 100) <= 30 then
|
or random(1, 100) <= 30
|
||||||
|
or ( (self.fly and not self.keep_flying)
|
||||||
set_velocity(self, 0)
|
or not self.fly ) then
|
||||||
|
if not is_glider(self) then
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
set_animation(self, "stand")
|
set_animation(self, "stand")
|
||||||
|
set_velocity(self, 0)
|
||||||
|
else
|
||||||
|
self.state = "walk"
|
||||||
|
set_animation(self, "walk")
|
||||||
|
end
|
||||||
local yaw = self.object:get_yaw() or 0
|
local yaw = self.object:get_yaw() or 0
|
||||||
yaw = set_yaw(self, yaw + 0.78, 8)
|
yaw = set_yaw(self, yaw + 0.78, 8)
|
||||||
else
|
else
|
||||||
|
@ -2517,9 +2530,14 @@ local do_states = function(self, dtime)
|
||||||
if self.runaway_timer > 5
|
if self.runaway_timer > 5
|
||||||
or is_at_cliff_or_danger(self) then
|
or is_at_cliff_or_danger(self) then
|
||||||
self.runaway_timer = 0
|
self.runaway_timer = 0
|
||||||
set_velocity(self, 0)
|
if not is_glider(self) then
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
set_animation(self, "stand")
|
set_animation(self, "stand")
|
||||||
|
set_velocity(self, 0)
|
||||||
|
else
|
||||||
|
self.state = "walk"
|
||||||
|
set_animation(self, "walk")
|
||||||
|
end
|
||||||
local yaw = self.object:get_yaw() or 0
|
local yaw = self.object:get_yaw() or 0
|
||||||
yaw = set_yaw(self, yaw + 0.78, 8)
|
yaw = set_yaw(self, yaw + 0.78, 8)
|
||||||
else
|
else
|
||||||
|
@ -2540,9 +2558,14 @@ local do_states = function(self, dtime)
|
||||||
or self.attack:get_hp() <= 0
|
or self.attack:get_hp() <= 0
|
||||||
or (self.attack:is_player() and mcl_mobs.invis[ self.attack:get_player_name() ]) then
|
or (self.attack:is_player() and mcl_mobs.invis[ self.attack:get_player_name() ]) then
|
||||||
|
|
||||||
|
if not is_glider(self) then
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
set_velocity(self, 0)
|
|
||||||
set_animation(self, "stand")
|
set_animation(self, "stand")
|
||||||
|
set_velocity(self, 0)
|
||||||
|
else
|
||||||
|
self.state = "walk"
|
||||||
|
set_animation(self, "walk")
|
||||||
|
end
|
||||||
self.attack = nil
|
self.attack = nil
|
||||||
self.v_start = false
|
self.v_start = false
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
|
@ -3389,7 +3412,11 @@ local mob_staticdata = function(self)
|
||||||
self.remove_ok = true
|
self.remove_ok = true
|
||||||
self.attack = nil
|
self.attack = nil
|
||||||
self.following = nil
|
self.following = nil
|
||||||
|
if not is_glider(self) then
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
|
else
|
||||||
|
self.state = "walk"
|
||||||
|
end
|
||||||
|
|
||||||
local tmp = {}
|
local tmp = {}
|
||||||
|
|
||||||
|
@ -3559,6 +3586,9 @@ local mob_activate = function(self, staticdata, def, dtime)
|
||||||
|
|
||||||
-- run on_spawn function if found
|
-- run on_spawn function if found
|
||||||
if self.on_spawn and not self.on_spawn_run then
|
if self.on_spawn and not self.on_spawn_run then
|
||||||
|
if self.fly then
|
||||||
|
self.desired_altitude = self.desired_altitude + math.random(-5,10)
|
||||||
|
end
|
||||||
if self.on_spawn(self) then
|
if self.on_spawn(self) then
|
||||||
self.on_spawn_run = true -- if true, set flag to run once only
|
self.on_spawn_run = true -- if true, set flag to run once only
|
||||||
end
|
end
|
||||||
|
@ -3570,10 +3600,73 @@ local mob_activate = function(self, staticdata, def, dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function get_speed_over_ground(self)
|
||||||
|
local p = self.object:get_velocity()
|
||||||
|
return vector.length(vector.new(p.x,0,p.z))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function check_ground(self) --return true if too close to the ground
|
||||||
|
local p = self.object:get_pos()
|
||||||
|
local n = minetest.find_nodes_in_area_under_air(vector.offset(p,0,-self.desired_altitude-1,0),vector.offset(p,0,0,0),{"group:solid","group:liquid"})
|
||||||
|
if #n > 0 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_random_velocity(self)
|
||||||
|
local v = self.object:get_velocity()
|
||||||
|
return vector.new(math.random(self.walk_velocity),v.y,math.random(self.walk_velocity))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function descend(self)
|
||||||
|
local v = self.object:get_velocity()
|
||||||
|
local gs = get_speed_over_ground(self)
|
||||||
|
local r = math.max(math.abs(self.fall_speed) - gs,1)
|
||||||
|
--minetest.log("descend "..tostring(r) .. " vel "..tostring(v.y).. " rate "..tostring(r))
|
||||||
|
if v.y > self.fall_speed then
|
||||||
|
--self.object:set_velocity(vector.new(v.x,-r,v.z))
|
||||||
|
self.object:add_velocity(vector.new(0,-r/10,0))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function climb(self)
|
||||||
|
local v = self.object:get_velocity()
|
||||||
|
local gs = get_speed_over_ground(self)
|
||||||
|
local r = self.run_velocity + gs
|
||||||
|
--minetest.log("climb "..tostring(r) .. " vel "..tostring(v.y).. " rate "..tostring(r))
|
||||||
|
if v.y < self.walk_velocity then
|
||||||
|
self.object:add_velocity(vector.new(0,r/10,0))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--self.floater
|
||||||
|
--self.desired altitude (above ground)
|
||||||
|
local function check_flight(self,dtime)
|
||||||
|
if self.floater or not self.fly then return end --floaters don't need altitdude adjustment
|
||||||
|
--self.state = "walk"
|
||||||
|
local gs = get_speed_over_ground(self)
|
||||||
|
if gs < 1 then
|
||||||
|
local y = self.object:get_yaw()
|
||||||
|
self.object:set_yaw((y + math.random(-30,30)) % 360)
|
||||||
|
set_velocity(self,math.random(1,self.walk_velocity))
|
||||||
|
end
|
||||||
|
if not self.flap_timer and check_ground(self) then
|
||||||
|
climb(self)
|
||||||
|
self.flap_timer = 0
|
||||||
|
elseif self.flap_timer then
|
||||||
|
if self.flap_timer > self.flap_time then
|
||||||
|
self.flap_timer = nil
|
||||||
|
else
|
||||||
|
self.flap_timer = self.flap_timer + dtime
|
||||||
|
end
|
||||||
|
else
|
||||||
|
descend(self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- main mob function
|
-- main mob function
|
||||||
local mob_step = function(self, dtime)
|
local mob_step = function(self, dtime)
|
||||||
check_item_pickup(self)
|
check_item_pickup(self)
|
||||||
|
check_flight(self,dtime)
|
||||||
if not self.fire_resistant then
|
if not self.fire_resistant then
|
||||||
mcl_burning.tick(self.object, dtime, self)
|
mcl_burning.tick(self.object, dtime, self)
|
||||||
end
|
end
|
||||||
|
@ -3720,8 +3813,13 @@ local mob_step = function(self, dtime)
|
||||||
if is_at_water_danger(self) and self.state ~= "attack" then
|
if is_at_water_danger(self) and self.state ~= "attack" then
|
||||||
if random(1, 10) <= 6 then
|
if random(1, 10) <= 6 then
|
||||||
set_velocity(self, 0)
|
set_velocity(self, 0)
|
||||||
|
if not is_glider(self) then
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
set_animation(self, "stand")
|
set_animation(self, "stand")
|
||||||
|
else
|
||||||
|
self.state = "walk"
|
||||||
|
set_animation(self, "walk")
|
||||||
|
end
|
||||||
yaw = yaw + random(-0.5, 0.5)
|
yaw = yaw + random(-0.5, 0.5)
|
||||||
yaw = set_yaw(self, yaw, 8)
|
yaw = set_yaw(self, yaw, 8)
|
||||||
end
|
end
|
||||||
|
@ -3770,9 +3868,14 @@ local mob_step = function(self, dtime)
|
||||||
follow_flop(self)
|
follow_flop(self)
|
||||||
|
|
||||||
if is_at_cliff_or_danger(self) then
|
if is_at_cliff_or_danger(self) then
|
||||||
|
if not is_glider(self) then
|
||||||
set_velocity(self, 0)
|
set_velocity(self, 0)
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
set_animation(self, "stand")
|
set_animation(self, "stand")
|
||||||
|
else
|
||||||
|
self.state = "walk"
|
||||||
|
set_animation(self, "walk")
|
||||||
|
end
|
||||||
local yaw = self.object:get_yaw() or 0
|
local yaw = self.object:get_yaw() or 0
|
||||||
yaw = set_yaw(self, yaw + 0.78, 8)
|
yaw = set_yaw(self, yaw + 0.78, 8)
|
||||||
end
|
end
|
||||||
|
@ -3915,6 +4018,9 @@ minetest.register_entity(name, {
|
||||||
view_range = def.view_range or 16,
|
view_range = def.view_range or 16,
|
||||||
walk_velocity = def.walk_velocity or 1,
|
walk_velocity = def.walk_velocity or 1,
|
||||||
run_velocity = def.run_velocity or 2,
|
run_velocity = def.run_velocity or 2,
|
||||||
|
desired_altitude = def.desired_altitude or 12, --over ground
|
||||||
|
flap_time = def.flap_time or 2, --time between wing glap / climb events
|
||||||
|
keep_flying = def.keep_flying or false,
|
||||||
damage = scale_difficulty(def.damage, 0, 0),
|
damage = scale_difficulty(def.damage, 0, 0),
|
||||||
light_damage = def.light_damage or 0,
|
light_damage = def.light_damage or 0,
|
||||||
sunlight_damage = def.sunlight_damage or 0,
|
sunlight_damage = def.sunlight_damage or 0,
|
||||||
|
|
|
@ -142,3 +142,5 @@ dofile(path .. "/slime+magma_cube.lua") -- Wuzzy
|
||||||
dofile(path .. "/spider.lua") -- Spider by AspireMint (fishyWET (CC-BY-SA 3.0 license for texture)
|
dofile(path .. "/spider.lua") -- Spider by AspireMint (fishyWET (CC-BY-SA 3.0 license for texture)
|
||||||
dofile(path .. "/vex.lua") -- KrupnoPavel
|
dofile(path .. "/vex.lua") -- KrupnoPavel
|
||||||
dofile(path .. "/wither.lua") -- Mesh and animation by toby109tt / https://github.com/22i
|
dofile(path .. "/wither.lua") -- Mesh and animation by toby109tt / https://github.com/22i
|
||||||
|
|
||||||
|
dofile(path .. "/phantom.lua") -- Mesh and animation by toby109tt / https://github.com/22i
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,62 @@
|
||||||
|
--Phantom for mcl2
|
||||||
|
--cora
|
||||||
|
--License for code WTFPL, cc0
|
||||||
|
|
||||||
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
|
mcl_mobs:register_mob("mobs_mc:phantom", {
|
||||||
|
description = S("Phantom"),
|
||||||
|
type = "monster",
|
||||||
|
spawn_class = "passive",
|
||||||
|
pathfinding = 1,
|
||||||
|
hp_min = 6,
|
||||||
|
hp_max = 6,
|
||||||
|
xp_min = 1,
|
||||||
|
xp_max = 3,
|
||||||
|
collisionbox = {-0.25, -0.01, -0.25, 0.25, 0.89, 0.25},
|
||||||
|
visual = "mesh",
|
||||||
|
mesh = "mobs_mc_phantom.b3d",
|
||||||
|
textures = {{"mobs_mc_phantom.png","mobs_mc_phantom_e.png","mobs_mc_phantom_e_s.png"}},
|
||||||
|
visual_size = {x=3, y=3},
|
||||||
|
walk_velocity = 3,
|
||||||
|
run_velocity = 5,
|
||||||
|
desired_altitude = 19,
|
||||||
|
keep_flying = true,
|
||||||
|
sounds = {
|
||||||
|
random = "mobs_mc_phantom_random",
|
||||||
|
damage = {name="mobs_mc_phantom_hurt", gain=0.3},
|
||||||
|
death = {name="mobs_mc_phantom_death", gain=0.6},
|
||||||
|
eat = "mobs_mc_animal_eat_generic",
|
||||||
|
distance = 16,
|
||||||
|
},
|
||||||
|
drops = {
|
||||||
|
{name = "mcl_mobitems:leather", --TODO: phantom membrane
|
||||||
|
chance = 1,
|
||||||
|
min = 1,
|
||||||
|
max = 2,
|
||||||
|
looting = "common",},
|
||||||
|
},
|
||||||
|
animation = {
|
||||||
|
stand_speed = 50,
|
||||||
|
walk_speed = 50,
|
||||||
|
fly_speed = 50,
|
||||||
|
stand_start = 0,
|
||||||
|
stand_end = 0,
|
||||||
|
fly_start = 0,
|
||||||
|
fly_end = 30,
|
||||||
|
walk_start = 0,
|
||||||
|
walk_end = 30,
|
||||||
|
},
|
||||||
|
fall_damage = 0,
|
||||||
|
fall_speed = -2.25,
|
||||||
|
attack_type = "dogfight",
|
||||||
|
floats = 1,
|
||||||
|
physical = true,
|
||||||
|
fly = true,
|
||||||
|
makes_footstep_sound = false,
|
||||||
|
fear_height = 0,
|
||||||
|
view_range = 16,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- spawn eggs
|
||||||
|
mcl_mobs:register_egg("mobs_mc:phantom", S("Phantom"), "mobs_mc_spawn_icon_phantom.png", 0)
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 644 B |
Loading…
Reference in New Issue