Disable child tool for some mobs
This commit is contained in:
parent
c53412d875
commit
fcdc04374c
@ -211,7 +211,8 @@ by manipulating the drowning fields (see the mob field reference).
|
|||||||
### Breeding
|
### Breeding
|
||||||
|
|
||||||
Breeding will make mobs mate and create offspring. To enable, call
|
Breeding will make mobs mate and create offspring. To enable, call
|
||||||
`rp_mobs.handle_breeding` in `on_step`.
|
`rp_mobs.handle_breeding` in `on_step`. You also need to add the tag
|
||||||
|
`"child_exists"` to the mob definition.
|
||||||
|
|
||||||
In particular, to breed, two adult mobs of the same type need to be “horny” and close
|
In particular, to breed, two adult mobs of the same type need to be “horny” and close
|
||||||
to each other. Then, a random mob of the pair gets pregnant and will soon
|
to each other. Then, a random mob of the pair gets pregnant and will soon
|
||||||
@ -328,6 +329,8 @@ The field `_cmi_is_mob=true` will be set automatically for all mobs and can be u
|
|||||||
the player alone. Peaceful mobs may still turn hostile when provoked.
|
the player alone. Peaceful mobs may still turn hostile when provoked.
|
||||||
Mobs that start hostile towards the player do not count as peaceful.
|
Mobs that start hostile towards the player do not count as peaceful.
|
||||||
If the setting `spawn_peaceful_only` is enabled, only mobs with this tag can spawn.
|
If the setting `spawn_peaceful_only` is enabled, only mobs with this tag can spawn.
|
||||||
|
* `"child_exists"`: Mob has a functional child version. This tag is only
|
||||||
|
for informing other mobs; it does not have an effect in the `rp_mobs` code
|
||||||
* Example: `tags = { animal = 1, peaceful = 1, exploder = 1 }`
|
* Example: `tags = { animal = 1, peaceful = 1, exploder = 1 }`
|
||||||
* A peaceful animal, plus a custom `"exploder"` tag.
|
* A peaceful animal, plus a custom `"exploder"` tag.
|
||||||
|
|
||||||
@ -697,6 +700,8 @@ Turns the mob into an adult.
|
|||||||
#### `rp_mobs.turn_into_child(mob)`
|
#### `rp_mobs.turn_into_child(mob)`
|
||||||
|
|
||||||
Turns the mob into a child.
|
Turns the mob into a child.
|
||||||
|
IMPORTANT: You *must* check whether the mob has the `"child_exists"` tag before calling this.
|
||||||
|
Don't call this function if the mob does not have this tag.
|
||||||
|
|
||||||
#### `rp_mobs.advance_child_growth(mob, dtime)`
|
#### `rp_mobs.advance_child_growth(mob, dtime)`
|
||||||
|
|
||||||
|
@ -182,10 +182,10 @@ end
|
|||||||
|
|
||||||
rp_mobs.mobdef_has_tag = function(mobname, tag_name)
|
rp_mobs.mobdef_has_tag = function(mobname, tag_name)
|
||||||
local mobdef = rp_mobs.registered_mobs[mobname]
|
local mobdef = rp_mobs.registered_mobs[mobname]
|
||||||
if not mobdef then
|
if not mobdef or not mobdef.entity_definition or not mobdef.entity_definition._tags then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return mobdef._tags[tag_name] == 1
|
return mobdef.entity_definition._tags[tag_name] == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local flip_over_collisionbox = function(box, is_child, y_offset)
|
local flip_over_collisionbox = function(box, is_child, y_offset)
|
||||||
|
@ -37,7 +37,7 @@ local task_queue_roam_settings = {
|
|||||||
--
|
--
|
||||||
rp_mobs.register_mob("rp_mobs_mobs:boar", {
|
rp_mobs.register_mob("rp_mobs_mobs:boar", {
|
||||||
description = S("Boar"),
|
description = S("Boar"),
|
||||||
tags = { animal = 1, peaceful = 1 },
|
tags = { animal = 1, child_exists = 1, peaceful = 1 },
|
||||||
drops = {
|
drops = {
|
||||||
{name="rp_mobs_mobs:pork_raw", chance=1, min=1, max=4},
|
{name="rp_mobs_mobs:pork_raw", chance=1, min=1, max=4},
|
||||||
},
|
},
|
||||||
|
@ -152,7 +152,7 @@ end
|
|||||||
|
|
||||||
rp_mobs.register_mob("rp_mobs_mobs:sheep", {
|
rp_mobs.register_mob("rp_mobs_mobs:sheep", {
|
||||||
description = S("Sheep"),
|
description = S("Sheep"),
|
||||||
tags = { animal = 1, peaceful = 1 },
|
tags = { animal = 1, child_exists = 1, peaceful = 1 },
|
||||||
drops = {
|
drops = {
|
||||||
{name="rp_mobs_mobs:meat_raw", chance=1, min=2, max=4},
|
{name="rp_mobs_mobs:meat_raw", chance=1, min=2, max=4},
|
||||||
},
|
},
|
||||||
|
@ -33,7 +33,7 @@ local task_queue_roam_settings = {
|
|||||||
|
|
||||||
rp_mobs.register_mob("rp_mobs_mobs:skunk", {
|
rp_mobs.register_mob("rp_mobs_mobs:skunk", {
|
||||||
description = S("Skunk"),
|
description = S("Skunk"),
|
||||||
tags = { animal = 1, peaceful = 1 },
|
tags = { animal = 1, child_exists = 1, peaceful = 1 },
|
||||||
drops = {
|
drops = {
|
||||||
{name="rp_mobs_mobs:meat_raw", chance=1, min=1, max=2},
|
{name="rp_mobs_mobs:meat_raw", chance=1, min=1, max=2},
|
||||||
},
|
},
|
||||||
|
@ -164,7 +164,7 @@ minetest.register_craftitem(
|
|||||||
end
|
end
|
||||||
local obj = pointed_thing.ref
|
local obj = pointed_thing.ref
|
||||||
local ent = obj:get_luaentity()
|
local ent = obj:get_luaentity()
|
||||||
if ent and ent._cmi_is_mob and not ent._child then
|
if ent and ent._cmi_is_mob and not ent._child and rp_mobs.mobdef_has_tag(ent.name, "child_exists") then
|
||||||
local pos = obj:get_pos()
|
local pos = obj:get_pos()
|
||||||
rp_mobs.turn_into_child(obj)
|
rp_mobs.turn_into_child(obj)
|
||||||
if not minetest.is_creative_enabled(placer:get_player_name()) then
|
if not minetest.is_creative_enabled(placer:get_player_name()) then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user