Skip to content

pet

Asks about the creatures a player has tamed and tames a wild one, as the Animal Taming skill does.

Source: src/Moongate.Server.Ultima/Modules/PetModule.cs

pet.attend(player) -> boolean

Whether the caller is the one that answers the player now: true for the first that asks, false for whoever asks again within half a second. Every pet within hearing hears the same words of its owner in the same moment: each asks, one answers for all. False for an NPC or a player not in the world.

ParameterTypeDefault
playerinteger

Returns boolean.

pet.control_chance(player, creature) -> number

The chance, 0 to 1, that the creature obeys the player: 1 for a creature that asks 29.1 of Animal Taming or less and for the staff; else from the player's Animal Taming and Animal Lore against what the creature asks, less 0.01 for each point of loyalty it lacks. 0 for a player or a creature that is not in the world.

ParameterTypeDefault
playerinteger
creatureinteger

Returns number.

pet.corpse(corpse) -> table?

What the corpse of a bonded pet says, as { owner, fits }: the serial of the owner it had, and whether the pet would fit in the followers of that owner now (it must be in the world). nil for an item that is not the corpse of a bonded pet, or a serial that is not an item.

ParameterTypeDefault
corpseinteger

Returns table?.

pet.feed(player, creature, item) -> PetFeedResultType

Gives the item, with all the units of its stack, as food to the creature of the player: when it eats that item its loyalty rises by ultima.pets.food_gain for each unit and the item is gone. Gives a PetFeedResultType: Fed, AlreadyHappy (eaten all the same), Bonded (eaten, and this food bonded the pet with its owner), WrongFood (the item is kept) or NotYours.

ParameterTypeDefault
playerinteger
creatureinteger
iteminteger

Returns PetFeedResultType.

pet.followers(player) -> integer

How many followers the player has: the slots of the creatures in the world that are its own, and of the one it rides. 0 for an NPC or a serial that is not in the world.

ParameterTypeDefault
playerinteger

Returns integer.

pet.hire(player, creature) -> PetResultType

Makes the creature the player's own as a hireling, when it is a free creature of the world and its slots fit in the player's followers, and shows the player its new followers. It needs no taming entry and is marked as hired, so its loyalty is not drained. Gives a PetResultType: Ok, NotAnNpc, AlreadyOwned, TooManyFollowers or NoPlayer. The pay is the script's: it takes the gold first.

ParameterTypeDefault
playerinteger
creatureinteger

Returns PetResultType.

pet.hire_period() -> integer

The seconds of one period a hireling is paid for: ultima.pets.hire_pay_minutes, 30 minutes by default.

Returns integer.

pet.info(creature) -> table?

What taming knows of the creature, as { min_skill, slots, owner }: the Animal Taming it takes in points (a try has a chance from 0.1 under it to 49.9 above), the followers it counts for, and the serial of its owner, 0 when it has none. nil for a creature that cannot be tamed, a player, or a serial that is not a mobile in the world.

ParameterTypeDefault
creatureinteger

Returns table?.

pet.lore(creature) -> table?

What Animal Lore reads of a creature, as { armor, damage_min, damage_max, foods, loyalty, bonded, min_skill, slots, owner }: its armor rating, the least and most damage of its template (0 when it has none), the kinds of food it eats (meat, fruit, grain, fish, eggs) as a list, its loyalty 0 to 100 (nil when it has no owner), whether it is bonded with its owner, the Animal Taming it asks and its slots (nil when it cannot be tamed) and the serial of its owner, 0 when it has none. nil for a player or a serial that is not a mobile in the world.

ParameterTypeDefault
creatureinteger

Returns table?.

pet.loyalty(creature) -> integer?

How loyal the creature is to its owner, 0 to 100; 100 for one that has not lost any. nil for a creature that has no owner, a player, or a serial that is not a mobile in the world.

ParameterTypeDefault
creatureinteger

Returns integer?.

pet.max_followers() -> integer

How many followers a player may have (ultima.pets.max_followers).

Returns integer.

pet.obey(player, creature) -> PetObeyResultType

Rolls the control chance of the creature for the player. Gives a PetObeyResultType: Obeyed, Disobeyed (the pet loses loyalty: the script shows it angry and does not carry the order out), Wild (it had none left and is no one's any more) or NotYours. Release is never rolled.

ParameterTypeDefault
playerinteger
creatureinteger

Returns PetObeyResultType.

pet.owner(creature) -> integer?

The serial of the owner of the creature (the player that tamed it, or the caster of a summon); nil for a creature with no owner (0 is not an owner) or a serial that is not a mobile in the world.

The serial of the player that owns a creature, nil when it has none:

local master = pet.owner(creature)
if master and master ~= user then
mobile.message(user, "That creature belongs to someone else.")
end
ParameterTypeDefault
creatureinteger

Returns integer?.

pet.refresh(player) -> boolean

Tells the game that the followers of the player may have changed, such as when a spell gave it a creature: they are counted again at the next ask and the player is shown its status with the new count. False for a serial that is not a player in the world.

Tell the game the followers of a player changed, so they are counted again and the status shows the new number:

npc.set_prop(creature, "owner", player)
pet.refresh(player)
ParameterTypeDefault
playerinteger

Returns boolean.

pet.release(player, creature) -> boolean

Lets the creature go: it is no one's any more and wild again, and the player has one follower less. True when the creature is a creature of the world that is the player's own; false otherwise.

ParameterTypeDefault
playerinteger
creatureinteger

Returns boolean.

pet.slots_of(template) -> integer

How many followers a creature of the mobile template counts for once a player owns it: its entry in data/taming.toml, else the control_slots of its template, else 1.

How many followers a creature of a template counts for, such as before a spell calls one:

if pet.followers(caster) + pet.slots_of("airele_summon") > pet.max_followers() then
return 1049645 -- too many followers
end
ParameterTypeDefault
templatestring

Returns integer.

pet.tame(player, creature) -> PetResultType

Makes the creature the player's own, when it is a wild creature of the world that can be tamed and its slots fit in the player's followers, and shows the player its new followers. Gives a PetResultType: Ok, NotAnNpc, NotTamable, AlreadyOwned, TooManyFollowers or NoPlayer. It does not roll the skill: the script does that first.

ParameterTypeDefault
playerinteger
creatureinteger

Returns PetResultType.

Made with ❤️ by Tom

Buy me a coffee