1
0
Fork 0

Integrate mob punching into collision detection

This commit is contained in:
jordan4ibanez 2021-04-20 22:41:13 -04:00
parent 6b52b94516
commit 751c4c2d99
2 changed files with 22 additions and 1 deletions

View File

@ -90,7 +90,14 @@ mobs.punch_attack_walk = function(self,dtime)
if self.punch_timer > 0 then
self.punch_timer = self.punch_timer - dtime
end
print(self.punch_timer)
end
mobs.punch_attack = function(self)
self.attacking:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = self.damage}
}, nil)
self.punch_timer = self.punch_timer_cooloff
end

View File

@ -29,6 +29,13 @@ mobs.collision = function(self)
local collision_count = 0
local check_for_attack = false
if self.hostile and self.attacking then
check_for_attack = true
end
for _,object in ipairs(minetest_get_objects_inside_radius(pos, radius*1.25)) do
if object and object ~= self.object and (object:is_player() or object:get_luaentity()._cmi_is_mob == true) then--and
--don't collide with rider, rider don't collide with thing
@ -85,6 +92,13 @@ mobs.collision = function(self)
if object:is_player() then
vel2 = vector_multiply(vel2, 2.5)
--integrate mob punching into collision detection
if check_for_attack and self.punch_timer <= 0 then
if object == self.attacking then
mobs.punch_attack(self)
end
end
end
self.object:add_velocity(vel1)