forked from MineClone5/MineClone5
Implement skeletons/strays
This commit is contained in:
parent
99e808296b
commit
c9f71d66f5
|
@ -324,6 +324,7 @@ function mobs:register_mob(name, def)
|
||||||
attacking = nil,
|
attacking = nil,
|
||||||
visual_size_origin = def.visual_size or {x = 1, y = 1, z = 1},
|
visual_size_origin = def.visual_size or {x = 1, y = 1, z = 1},
|
||||||
punch_timer_cooloff = def.punch_timer_cooloff or 0.5,
|
punch_timer_cooloff = def.punch_timer_cooloff or 0.5,
|
||||||
|
projectile_cooldown = projectile_cooldown or 2,
|
||||||
--end j4i stuff
|
--end j4i stuff
|
||||||
|
|
||||||
-- MCL2 extensions
|
-- MCL2 extensions
|
||||||
|
|
|
@ -168,6 +168,10 @@ local land_state_execution = function(self,dtime)
|
||||||
|
|
||||||
mobs.punch_attack_walk(self,dtime)
|
mobs.punch_attack_walk(self,dtime)
|
||||||
|
|
||||||
|
elseif self.attack_type == "projectile" then
|
||||||
|
|
||||||
|
mobs.projectile_attack_walk(self,dtime)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -602,7 +606,7 @@ mobs.mob_step = function(self, dtime)
|
||||||
|
|
||||||
--count down hostile cooldown timer when no players in range
|
--count down hostile cooldown timer when no players in range
|
||||||
if self.neutral and self.hostile and not attacking and self.hostile_cooldown_timer then
|
if self.neutral and self.hostile and not attacking and self.hostile_cooldown_timer then
|
||||||
|
|
||||||
self.hostile_cooldown_timer = self.hostile_cooldown_timer - dtime
|
self.hostile_cooldown_timer = self.hostile_cooldown_timer - dtime
|
||||||
|
|
||||||
if self.hostile_cooldown_timer <= 0 then
|
if self.hostile_cooldown_timer <= 0 then
|
||||||
|
|
|
@ -2,6 +2,7 @@ local vector_direction = vector.direction
|
||||||
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
||||||
local vector_distance = vector.distance
|
local vector_distance = vector.distance
|
||||||
local vector_multiply = vector.multiply
|
local vector_multiply = vector.multiply
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
_____ _ _
|
_____ _ _
|
||||||
| ___| | | | |
|
| ___| | | | |
|
||||||
|
@ -151,4 +152,58 @@ mobs.punch_attack = function(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.attacking:add_velocity(dir)
|
self.attacking:add_velocity(dir)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--[[
|
||||||
|
______ _ _ _ _
|
||||||
|
| ___ \ (_) | | (_) |
|
||||||
|
| |_/ / __ ___ _ ___ ___| |_ _| | ___
|
||||||
|
| __/ '__/ _ \| |/ _ \/ __| __| | |/ _ \
|
||||||
|
| | | | | (_) | | __/ (__| |_| | | __/
|
||||||
|
\_| |_| \___/| |\___|\___|\__|_|_|\___|
|
||||||
|
_/ |
|
||||||
|
|__/
|
||||||
|
]]--
|
||||||
|
|
||||||
|
|
||||||
|
mobs.projectile_attack_walk = function(self,dtime)
|
||||||
|
|
||||||
|
--this needs an exception
|
||||||
|
if self.attacking == nil or not self.attacking:is_player() then
|
||||||
|
self.attacking = nil
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
mobs.set_yaw_while_attacking(self)
|
||||||
|
|
||||||
|
local distance_from_attacking = vector_distance(self.object:get_pos(), self.attacking:get_pos())
|
||||||
|
|
||||||
|
|
||||||
|
if distance_from_attacking >= self.reach then
|
||||||
|
mobs.set_velocity(self, self.run_velocity)
|
||||||
|
mobs.set_mob_animation(self,"run")
|
||||||
|
else
|
||||||
|
mobs.set_velocity(self,0)
|
||||||
|
mobs.set_mob_animation(self,"stand")
|
||||||
|
end
|
||||||
|
|
||||||
|
--do this to not load data into other mobs
|
||||||
|
if not self.projectile_timer then
|
||||||
|
self.projectile_timer = self.projectile_cooldown
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.projectile_timer > 0 then
|
||||||
|
self.projectile_timer = self.projectile_timer - dtime
|
||||||
|
|
||||||
|
--shoot
|
||||||
|
if self.projectile_timer <= 0 then
|
||||||
|
--reset timer
|
||||||
|
self.projectile_timer = self.projectile_cooldown
|
||||||
|
mobs.shoot_projectile(self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -1,4 +1,5 @@
|
||||||
local math_floor = math.floor
|
local math_floor = math.floor
|
||||||
|
local vector_direction = vector.direction
|
||||||
|
|
||||||
mobs.feed_tame = function(self)
|
mobs.feed_tame = function(self)
|
||||||
return nil
|
return nil
|
||||||
|
@ -337,3 +338,21 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
end
|
end
|
||||||
]]--
|
]]--
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--do internal per mob projectile calculations
|
||||||
|
mobs.shoot_projectile = function(self)
|
||||||
|
|
||||||
|
local pos1 = self.object:get_pos()
|
||||||
|
--add mob eye height
|
||||||
|
pos1.y = pos1.y + self.eye_height
|
||||||
|
|
||||||
|
local pos2 = self.attacking:get_pos()
|
||||||
|
--add player eye height
|
||||||
|
pos2.y = pos2.y + self.attacking:get_properties().eye_height
|
||||||
|
|
||||||
|
--get direction
|
||||||
|
local dir = vector_direction(pos1,pos2)
|
||||||
|
|
||||||
|
--call internal shoot_arrow function
|
||||||
|
self.shoot_arrow(self,pos1,dir)
|
||||||
|
end
|
|
@ -22,6 +22,8 @@ local skeleton = {
|
||||||
xp_min = 6,
|
xp_min = 6,
|
||||||
xp_max = 6,
|
xp_max = 6,
|
||||||
breath_max = -1,
|
breath_max = -1,
|
||||||
|
eye_height = 1.5,
|
||||||
|
projectile_cooldown = 1.5,
|
||||||
armor = {undead = 100, fleshy = 100},
|
armor = {undead = 100, fleshy = 100},
|
||||||
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.98, 0.3},
|
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.98, 0.3},
|
||||||
pathfinding = 1,
|
pathfinding = 1,
|
||||||
|
@ -43,7 +45,7 @@ local skeleton = {
|
||||||
walk_velocity = 1.2,
|
walk_velocity = 1.2,
|
||||||
run_velocity = 2.4,
|
run_velocity = 2.4,
|
||||||
damage = 2,
|
damage = 2,
|
||||||
reach = 2,
|
reach = 3,
|
||||||
drops = {
|
drops = {
|
||||||
{name = mobs_mc.items.arrow,
|
{name = mobs_mc.items.arrow,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
|
|
Loading…
Reference in New Issue