-----------------------------------
-- Area: Bhaflau Thickets
--   NM: Harvestman
-- !pos 398.130 -10.675 179.169 52
-----------------------------------
---@type TMobEntity
local entity = {}

entity.spawnPoints =
{
    { x = 356.491, y = -10.675, z = 182.225 },
    { x = 357.948, y = -10.675, z = 177.231 },
    { x = 364.000, y = -10.676, z = 176.769 },
    { x = 369.237, y = -10.278, z = 179.810 },
    { x = 371.528, y = -9.840,  z = 181.042 },
    { x = 373.973, y = -9.553,  z = 178.583 },
    { x = 375.870, y = -9.036,  z = 181.486 },
    { x = 377.112, y = -9.000,  z = 179.200 },
    { x = 380.435, y = -9.096,  z = 178.209 },
    { x = 380.959, y = -9.194,  z = 181.637 },
    { x = 382.677, y = -9.516,  z = 181.875 },
    { x = 383.883, y = -9.765,  z = 178.624 },
    { x = 387.268, y = -10.127, z = 177.871 },
    { x = 387.054, y = -9.942,  z = 181.333 },
    { x = 389.147, y = -10.018, z = 182.877 },
    { x = 390.353, y = -10.074, z = 179.626 },
    { x = 392.070, y = -10.064, z = 181.579 },
    { x = 393.146, y = -10.201, z = 179.211 },
    { x = 395.518, y = -10.161, z = 182.840 },
    { x = 397.328, y = -10.675, z = 177.963 },
    { x = 399.160, y = -10.675, z = 181.891 },
    { x = 403.122, y = -10.422, z = 177.294 },
    { x = 407.181, y = -10.033, z = 181.391 },
    { x = 411.102, y = -9.778,  z = 177.972 },
    { x = 413.000, y = -9.805,  z = 180.875 },
    { x = 416.462, y = -9.500,  z = 178.266 },
    { x = 419.854, y = -9.323,  z = 178.984 },
    { x = 419.624, y = -9.265,  z = 180.703 },
    { x = 421.206, y = -9.200,  z = 181.413 },
    { x = 419.525, y = -9.280,  z = 183.398 },
    { x = 417.531, y = -10.023, z = 186.221 },
    { x = 421.866, y = -9.656,  z = 186.200 },
    { x = 423.552, y = -10.078, z = 189.230 },
    { x = 420.982, y = -10.103, z = 189.634 },
    { x = 418.558, y = -10.266, z = 192.114 },
    { x = 420.931, y = -10.380, z = 193.180 },
    { x = 422.828, y = -10.688, z = 196.083 },
    { x = 420.294, y = -10.675, z = 196.669 },
    { x = 418.123, y = -10.675, z = 198.101 },
    { x = 419.052, y = -10.675, z = 200.530 },
    { x = 421.628, y = -10.675, z = 200.887 },
    { x = 423.095, y = -10.716, z = 204.030 },
    { x = 419.669, y = -10.860, z = 204.568 },
    { x = 416.866, y = -12.203, z = 207.875 },
    { x = 420.937, y = -12.356, z = 209.366 },
    { x = 423.800, y = -13.466, z = 212.621 },
    { x = 416.983, y = -13.571, z = 212.461 },
    { x = 414.921, y = -14.970, z = 218.169 },
    { x = 422.112, y = -15.565, z = 221.375 },
    { x = 418.066, y = -9.500,  z = 182.069 },
}

entity.onMobInitialize = function(mob)
    mob:setMobMod(xi.mobMod.ADD_EFFECT, 1)
    xi.mob.updateNMSpawnPoint(mob)
    mob:setRespawnTime(math.random(75600, 86400)) -- 21-24 hours
end

entity.onAdditionalEffect = function(mob, target, damage)
    return xi.mob.onAddEffect(mob, target, damage, xi.mob.ae.POISON, { power = 100, duration = math.random(6, 9) })
end

entity.onMobDeath = function(mob, player, optParams)
    xi.hunts.checkHunt(mob, player, 451)
end

entity.onMobDespawn = function(mob)
    -- Set Harvesman's spawnpoint and respawn time (21-24 hours)
    xi.mob.updateNMSpawnPoint(mob)
    mob:setRespawnTime(math.random(75600, 86400))
end

return entity
