fix evil bunny

This commit is contained in:
tenplus1 2023-05-28 12:19:49 +01:00
parent 24ae2e25a2
commit 87a7c09378
2 changed files with 36 additions and 25 deletions

View File

@ -5,10 +5,13 @@ local S = mobs.intllib_animal
-- Bunny by ExeterDad
mobs:register_mob("mobs_animal:bunny", {
stepheight = 0.6,
type = "animal",
passive = true,
passive = false,--true,
attack_type = "dogfight",
attack_players = true,
damage = 5,
reach = 1,
stepheight = 0.6,
hp_min = 1,
hp_max = 4,
armor = 200,
@ -61,26 +64,40 @@ stepheight = 0.6,
-- Monty Python tribute
local item = clicker:get_wielded_item()
local player_name = clicker:get_player_name()
if item:get_name() == "mobs:lava_orb" then
if self.owner == player_name
and item:get_name() == "mobs:lava_orb" then
-- take orb
if not mobs.is_creative(clicker:get_player_name()) then
item:take_item()
clicker:set_wielded_item(item)
end
self.base_texture = {"mobs_bunny_evil.png"}
self.object:set_properties({
textures = {"mobs_bunny_evil.png"}
-- set special bunny attributes
local staticdata = minetest.serialize({
type = "monster",
hp_max = 20,
health = 20,
damage = 5,
run_velocity = 3,
passive = false,
runaway = false,
runaway_from = {},
runaway_timer = 0,
tamed = false,
base_texture = {"mobs_bunny_evil.png"}
})
self.type = "monster"
self.health = 20
self.passive = false
self.runaway = false
-- add evil bunny
local obj = minetest.add_entity(
self.object:get_pos(), "mobs_animal:bunny", staticdata)
return
-- remove old bunny
if obj:get_luaentity() then
mobs:remove(self, true)
end
end
end,
@ -107,11 +124,10 @@ stepheight = 0.6,
self.object:set_properties({textures = self.base_texture})
end
return true -- run only once, false/nil runs every activation
end,
self.base_texture = self.texture
attack_type = "dogfight",
damage = 5
return true -- run only once, false/nil runs every activation
end
})

View File

@ -136,19 +136,14 @@ for _, col in ipairs(all_colours) do
-- simple truth table P1/P2 horns/no_horns
local breed_out = {
["P1_N"] = {["P2_N"] = 5 ,["P2_H"] = 50 },
["P1_H"] = {["P2_N"] = 50,["P2_H"] = 95 }
["P1_N"] = {["P2_N"] = 5 ,["P2_H"] = 50},
["P1_H"] = {["P2_N"] = 50,["P2_H"] = 95}
}
local p1 = "P1_N" -- no horns
local p2 = "P2_N" -- no horns
if parent1.attribute_horns then p1 = "P1_H" end
if parent2.attribute_horns then p2 = "P2_H" end
local p1 = parent1.attribute_horns and "P1_H" or "P1_N"
local p2 = parent2.attribute_horns and "P2_H" or "P2_N"
local horn_chance = breed_out[p1][p2]
local horns = random(100) <= horn_chance
local pos = parent1.object:get_pos()
-- can't see an easy way to pass horn attribute into