Skip to content

Commit

Permalink
Mobs: Ability to specify armor_groups. (Copied from upstream). Rela…
Browse files Browse the repository at this point in the history
…tes to #25
  • Loading branch information
alek13 committed Dec 22, 2023
1 parent a64b706 commit e92cabd
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions mods/_various/mobs/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ local atan = function(x)
return atann(x)
end
end
local table_copy = table.copy


-- Load settings
Expand Down Expand Up @@ -2202,9 +2203,19 @@ local mob_activate = function(self, staticdata, def)
self.path.stuck = false
self.path.following = false -- currently following path?
self.path.stuck_timer = 0 -- if stuck for too long search for path
-- end init

self.object:set_armor_groups({immortal = 1, fleshy = self.armor})
-- Armor groups (immortal = 1 for custom damage handling)
local armor

if type(self.armor) == "table" then
armor = table_copy(self.armor)
else
armor = {fleshy = self.armor, immortal = 1}
end

self.object:set_armor_groups(armor)

-- mob defaults
self.old_y = self.object:get_pos().y
self.old_health = self.health
self.sounds.distance = self.sounds.distance or 10
Expand Down

0 comments on commit e92cabd

Please sign in to comment.