forked from VoxeLibre/VoxeLibre
Finish creeper movement ai and move jump_check into environment
This commit is contained in:
parent
cd6f07537f
commit
0b763f54b5
|
@ -53,40 +53,6 @@ local cliff_check = function(self,dtime)
|
|||
return free_fall
|
||||
end
|
||||
|
||||
--check if a mob needs to jump
|
||||
local jump_check = function(self,dtime)
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
pos.y = pos.y + 0.1
|
||||
local dir = minetest_yaw_to_dir(self.yaw)
|
||||
|
||||
local collisionbox = self.object:get_properties().collisionbox
|
||||
local radius = collisionbox[4] + 0.5
|
||||
|
||||
vector_multiply(dir, radius)
|
||||
|
||||
--only jump if there's a node and a non-solid node above it
|
||||
local test_dir = vector.add(pos,dir)
|
||||
|
||||
local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0
|
||||
|
||||
test_dir.y = test_dir.y + 1
|
||||
|
||||
local green_flag_2 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") == 0
|
||||
|
||||
if green_flag_1 and green_flag_2 then
|
||||
--can jump over node
|
||||
return(1)
|
||||
elseif green_flag_1 and not green_flag_2 then
|
||||
--wall in front of mob
|
||||
return(2)
|
||||
end
|
||||
|
||||
--nothing to jump over
|
||||
return(0)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- state switching logic (stand, walk, run, attacks)
|
||||
local land_state_list_wandering = {"stand", "walk"}
|
||||
|
@ -157,7 +123,7 @@ local land_state_execution = function(self,dtime)
|
|||
mobs.movement_rotation_lock(self)
|
||||
|
||||
--check for nodes to jump over
|
||||
local node_in_front_of = jump_check(self)
|
||||
local node_in_front_of = mobs.jump_check(self)
|
||||
|
||||
if node_in_front_of == 1 then
|
||||
|
||||
|
|
|
@ -34,7 +34,14 @@ mobs.explode_attack_walk = function(self,dtime)
|
|||
|
||||
self.explosion_animation = self.explosion_animation + (dtime/2)
|
||||
|
||||
print(self.explosion_animation)
|
||||
end
|
||||
|
||||
--make explosive mobs jump
|
||||
--check for nodes to jump over
|
||||
--explosive mobs will just ride against walls for now
|
||||
local node_in_front_of = mobs.jump_check(self)
|
||||
if node_in_front_of == 1 then
|
||||
mobs.jump(self)
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
local minetest_line_of_sight = minetest.line_of_sight
|
||||
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
||||
local minetest_yaw_to_dir = minetest.yaw_to_dir
|
||||
local minetest_get_node = minetest.get_node
|
||||
local minetest_get_item_group = minetest.get_item_group
|
||||
|
||||
local vector_new = vector.new
|
||||
local vector_multiply = vector.multiply
|
||||
|
||||
-- default function when mobs are blown up with TNT
|
||||
local do_tnt = function(obj, damage)
|
||||
|
@ -71,3 +76,37 @@ mobs.detect_closest_player_within_radius = function(self, line_of_sight, radius,
|
|||
|
||||
return(winner_player)
|
||||
end
|
||||
|
||||
|
||||
--check if a mob needs to jump
|
||||
mobs.jump_check = function(self,dtime)
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
pos.y = pos.y + 0.1
|
||||
local dir = minetest_yaw_to_dir(self.yaw)
|
||||
|
||||
local collisionbox = self.object:get_properties().collisionbox
|
||||
local radius = collisionbox[4] + 0.5
|
||||
|
||||
vector_multiply(dir, radius)
|
||||
|
||||
--only jump if there's a node and a non-solid node above it
|
||||
local test_dir = vector.add(pos,dir)
|
||||
|
||||
local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0
|
||||
|
||||
test_dir.y = test_dir.y + 1
|
||||
|
||||
local green_flag_2 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") == 0
|
||||
|
||||
if green_flag_1 and green_flag_2 then
|
||||
--can jump over node
|
||||
return(1)
|
||||
elseif green_flag_1 and not green_flag_2 then
|
||||
--wall in front of mob
|
||||
return(2)
|
||||
end
|
||||
|
||||
--nothing to jump over
|
||||
return(0)
|
||||
end
|
|
@ -151,6 +151,7 @@ mobs:register_mob("mobs_mc:creeper_charged", {
|
|||
"mobs_mc_creeper_charge.png"},
|
||||
},
|
||||
visual_size = {x=3, y=3},
|
||||
rotate = 270,
|
||||
sounds = {
|
||||
attack = "tnt_ignite",
|
||||
death = "mobs_mc_creeper_death",
|
||||
|
|
Loading…
Reference in New Issue