Update mobs

master
Lean Rada 2015-01-29 11:11:35 +08:00
parent cfb7ea288c
commit 18a9909f43
5 changed files with 37 additions and 19 deletions

View File

@ -60,7 +60,10 @@ function mobs.default_prototype:on_step(dtime)
end
if not defense:is_dark() then
self:damage(self.object:get_hp() * math.random() + 1)
local damage = self.object:get_hp() * math.random()
if damage >= 0.5 then
self:damage(math.ceil(damage))
end
end
if self.life_timer <= 0 then

View File

@ -216,7 +216,7 @@ minetest.register_entity("defense:gooball", {
space = vector.add(space, back)
bnode = minetest.get_node_or_nil(space)
until not bnode or bnode.name == "air"
place_goo(space, 6)
place_goo(space, 9)
self.object:remove()
end
end,
@ -235,6 +235,9 @@ minetest.register_node("defense:goo", {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.5+2/16, 0.5},
},
selection_box = {
type = "wallmounted",
},
paramtype = "light",
paramtype2 = "wallmounted",
liquid_viscosity = 4,

View File

@ -1,5 +1,5 @@
defense.mobs.register_mob("defense:paniki", {
hp_max = 3,
hp_max = 7,
collisionbox = {-0.3,-0.3,-0.3, 0.3,0.3,0.3},
mesh = "defense_paniki.b3d",
textures = {"defense_paniki.png"},
@ -17,7 +17,7 @@ defense.mobs.register_mob("defense:paniki", {
move_speed = 16,
attack_damage = 1,
attack_range = 1.1,
attack_interval = 0.8,
attack_interval = 1.2,
rank = 0,
leader = nil,

View File

@ -46,8 +46,6 @@ defense.mobs.register_mob("defense:sarangay", {
on_step = function(self, dtime)
defense.mobs.default_prototype.on_step(self, dtime)
if self.charging then
minetest.chat_send_all(self.charge_power)
if self.charge_power > 0.5 then
self:hunt()
end
@ -70,25 +68,20 @@ defense.mobs.register_mob("defense:sarangay", {
else
local nearest = self:find_nearest_player()
if nearest then
if math.abs(self.object:getpos().y - nearest.position.y) < 4 then
if nearest.distance > 4 and math.random() < 0.1 then
self:set_charging_state(true)
self.destination = nil
elseif nearest.distance < 4 then
self:hunt()
else
local dir = vector.direction(nearest.position, self.object:getpos())
self.destination = vector.add(nearest.position, vector.multiply(dir, 12))
end
else
if nearest.distance > 4 and math.random() < 0.1 then
self:set_charging_state(true)
self.destination = nil
elseif nearest.distance < 4 then
self:hunt()
else
local dir = vector.direction(nearest.position, self.object:getpos())
self.destination = vector.add(nearest.position, vector.multiply(dir, 12))
end
end
end
end,
set_charging_state = function(self, state)
minetest.chat_send_all(dump(state))
self.charging = state
if state then
self.charge_power = 0.1

View File

@ -1,5 +1,5 @@
defense.mobs.register_mob("defense:unggoy", {
hp_max = 3,
hp_max = 11,
collisionbox = {-0.4,-0.01,-0.4, 0.4,1.5,0.4},
mesh = "defense_unggoy.b3d",
textures = {"defense_unggoy.png"},
@ -51,4 +51,23 @@ defense.mobs.register_mob("defense:unggoy", {
end
end
end,
is_standing = function(self)
-- Able to stand on top of others
if defense.mobs.default_prototype.is_standing(self) then
return true
else
local pos = self.object:getpos()
pos.y = pos.y - 1
for _,o in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
if o ~= self.object then
local e = o:get_luaentity()
if e and e.name == self.name then
return true
end
end
end
return false
end
end,
})