mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-23 00:19:32 +01:00
Start setting up hostile punch attack type
This commit is contained in:
parent
d371d6fdc9
commit
6b52b94516
4 changed files with 44 additions and 0 deletions
|
@ -323,6 +323,7 @@ function mobs:register_mob(name, def)
|
|||
neutral = def.neutral,
|
||||
attacking = nil,
|
||||
visual_size_origin = def.visual_size or {x = 1, y = 1, z = 1},
|
||||
punch_timer_cooloff = def.punch_timer_cooloff or 0.5,
|
||||
--end j4i stuff
|
||||
|
||||
-- MCL2 extensions
|
||||
|
|
|
@ -159,8 +159,15 @@ local land_state_execution = function(self,dtime)
|
|||
|
||||
elseif self.state == "attack" then
|
||||
|
||||
--execute mob attack type
|
||||
if self.attack_type == "explode" then
|
||||
|
||||
mobs.explode_attack_walk(self, dtime)
|
||||
|
||||
elseif self.attack_type == "punch" then
|
||||
|
||||
mobs.punch_attack_walk(self,dtime)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -573,6 +580,14 @@ mobs.mob_step = function(self, dtime)
|
|||
|
||||
--go get the closest player ROAR >:O
|
||||
if attacking then
|
||||
|
||||
--set initial punch timer
|
||||
if self.attacking == nil then
|
||||
if self.attack_type == "punch" then
|
||||
self.punch_timer = -1
|
||||
end
|
||||
end
|
||||
|
||||
self.attacking = attacking
|
||||
--no player in area
|
||||
else
|
||||
|
|
|
@ -68,4 +68,29 @@ mobs.reverse_explosion_animation = function(self,dtime)
|
|||
end
|
||||
|
||||
mobs.handle_explosion_animation(self)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
mobs.punch_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)
|
||||
|
||||
mobs.set_velocity(self, self.run_velocity)
|
||||
|
||||
mobs.set_mob_animation(self, "run")
|
||||
|
||||
if self.punch_timer > 0 then
|
||||
self.punch_timer = self.punch_timer - dtime
|
||||
end
|
||||
|
||||
print(self.punch_timer)
|
||||
|
||||
end
|
|
@ -48,6 +48,8 @@ table.insert(drops_zombie, {
|
|||
local zombie = {
|
||||
type = "monster",
|
||||
spawn_class = "hostile",
|
||||
hostile = true,
|
||||
rotate = 270,
|
||||
hp_min = 20,
|
||||
hp_max = 20,
|
||||
xp_min = 5,
|
||||
|
@ -89,6 +91,7 @@ local zombie = {
|
|||
sunlight_damage = 2,
|
||||
view_range = 16,
|
||||
attack_type = "punch",
|
||||
punch_timer_cooloff = 0.5,
|
||||
harmed_by_heal = true,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue