mobile
Acts on a mobile in the world, a player or an NPC: teleports it, reads where it is, plays a sound on it, tells a player something.
Source: src/Moongate.Server.Ultima/Modules/MobileModule.cs
Functions
Section titled “Functions”add_stat_bonus
Section titled “add_stat_bonus”mobile.add_stat_bonus(serial, stat, amount, seconds, replace?) -> booleanRaises the mobile's 'strength', 'dexterity' or 'intelligence' by amount for seconds, as a strength or an agility potion does: a player's maximum hits, stamina or mana rise with it (an NPC's stay), and when the time is up both go back and what is above the new maximum is lost. The bonus is never saved and ends when the player leaves. False when it has a bonus of that stat already, for an unknown stat or mobile, or an amount or a time that is not positive. With replace true, as a spell buff does, a weaker bonus of the stat is replaced by this one and only one as strong or stronger refuses it.
A shrine that makes a player stronger for two minutes, once at a time:
if not mobile.add_stat_bonus(user, "strength", 10, 120) then mobile.message_cliloc(user, 502173) -- You are already under a similar effect.endA spell buff passes true last: a weaker bonus of the stat is replaced, and only one as strong or stronger refuses it:
mobile.add_stat_bonus(target, "dexterity", 11, 120, true)| Parameter | Type | Default |
|---|---|---|
serial | integer | |
stat | string | |
amount | integer | |
seconds | integer | |
replace (optional) | boolean | nil |
Returns boolean.
add_stat_curse
Section titled “add_stat_curse”mobile.add_stat_curse(serial, stat, amount, seconds, refresh?) -> booleanLowers the mobile's 'strength', 'dexterity' or 'intelligence' by amount for seconds, as the curses of Magery do: a player's maximum hits, stamina or mana fall with it (an NPC's stay) and what is above the new maximum is lost; it ends when the time is up or the player leaves, and is never saved. A stronger curse of the same stat replaces the one it is under; false when that one is at least as strong, for an unknown stat or mobile, or an amount or a time that is not positive. With refresh true, as a song that keeps a curse up does, a curse as strong is replaced too and its time starts over, and only a stronger one refuses it. A bonus of the same stat is kept: the two add up.
A curse of the dexterity, as Clumsy casts it: 11 points for two minutes. A curse of the same stat that is as strong or stronger stays:
if mobile.add_stat_curse(target, "dexterity", 11, 120) then mobile.message(target, "Your hands feel clumsy.")end| Parameter | Type | Default |
|---|---|---|
serial | integer | |
stat | string | |
amount | integer | |
seconds | integer | |
refresh (optional) | boolean | nil |
Returns boolean.
aggressed
Section titled “aggressed”mobile.aggressed(serial) -> table?The serials of the players and NPCs the mobile acted against within `aggressor_seconds` (two minutes by default), as a list; empty for a quiet mobile, nil for a serial that is not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns table?.
aggressors
Section titled “aggressors”mobile.aggressors(serial) -> table?The serials of the players and NPCs that acted against the mobile within `aggressor_seconds` (two minutes by default), as a list; empty for a quiet mobile, nil for a serial that is not in the world.
Who attacked a mobile within aggressor_seconds (two minutes by default), and whom it attacked:
for _, attacker in ipairs(mobile.aggressors(who) or {}) do mobile.message(attacker, "You have been fighting " .. mobile.name(who) .. ".")end
if #(mobile.aggressed(who) or {}) > 0 then -- who has hit somebody latelyend| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns table?.
animate
Section titled “animate”mobile.animate(serial, action, frames?, repeat_count?) -> booleanPlays an action (0 to 65535) of the mobile's body, seen by its player and those who see it, with frames (1 to 255, default 5) and how many times (1 to 255, default 1). The bodies do not share the numbers: use the names of HumanAnimationType, MonsterAnimationType or AnimalAnimationType. False for a mobile not in the world or a number out of range.
Some of the names: HumanAnimationType has Bow, Salute, Fidget1, Spell1; MonsterAnimationType has
Attack1, GetHit, Pillage, Fidget1; AnimalAnimationType has Eat, Alert, LieDown. A number works
too:
mobile.animate(who, HumanAnimationType.Bow)| Parameter | Type | Default |
|---|---|---|
serial | integer | |
action | integer | |
frames (optional) | integer | 5 |
repeat_count (optional) | integer | 1 |
Returns boolean.
backpack
Section titled “backpack”mobile.backpack(serial) -> integer?The serial of the backpack the mobile wears, to look into with item.contents; nil for a mobile without one or not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns integer?.
body_type
Section titled “body_type”mobile.body_type(serial) -> BodyType?The kind of the mobile's body, as data/bodies.toml says, a BodyType: Human (every race of player and the human NPCs), Monster, Animal, Sea, Equipment, or Empty for a body the file does not list; it tells which animations the body has. Nil for a mobile not in the world.
The kind of the body tells which animations it has:
if mobile.body_type(who) == BodyType.Human then mobile.animate(who, HumanAnimationType.Eat) end| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns BodyType?.
criminal
Section titled “criminal”mobile.criminal(serial) -> boolean?Whether the mobile is a criminal now, its name in grey for those who see it; nil for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns boolean?.
mobile.cure(serial) -> booleanEnds the mobile's poison and its green bar; false when it was not poisoned or is unknown.
A healer’s blessing that ends a poison:
if mobile.cure(user) then mobile.message_cliloc(user, 500231) -- You feel cured of poison!end| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns boolean.
direction
Section titled “direction”mobile.direction(serial) -> DirectionType?The direction the mobile faces, a DirectionType; nil for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns DirectionType?.
disguise
Section titled “disguise”mobile.disguise(serial, options, seconds) -> booleanDisguises the mobile for the seconds given: the options table may hold name (a text of at most 30 characters), name_list (the id of a list of data/names.toml, such as 'male', to take a random name from), body (0 to 65535) and hue (0 to 65535); what it lacks stays. When the time is up, the mobile dies or logs in after a restart that took longer, its own looks come back. A rider that takes a body that is not a human one is dismounted. False, with nothing changed, for a mobile already disguised, dead or not in the world, an empty table, a bad value or a time that is not positive.
The options may name a body, a hue, a name or the id of a list of names; what is left out stays. The mobile gets its own back when the time is up, when it dies and at login after a restart:
mobile.disguise(caster, { name_list = "male", hue = 0x3F0 }, 120)mobile.disguise(caster, { body = 0xE1 }, 60) -- a wolf; a rider is dismounted| Parameter | Type | Default |
|---|---|---|
serial | integer | |
options | table | |
seconds | number |
Returns boolean.
end_disguise
Section titled “end_disguise”mobile.end_disguise(serial) -> booleanGives the mobile its own name, body and hue back at once; false when it was not disguised.
mobile.end_disguise(who)| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns boolean.
mobile.flags(serial) -> table?What the mobile is, as { hidden, frozen, war_mode }, each true or false; nil for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns table?.
get_prop
Section titled “get_prop”mobile.get_prop(serial, key) -> any?A value the mobile, a player or an NPC, keeps across restarts: a string, a number or a bool; nil when it has none.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
key | string |
Returns any?.
hands_empty
Section titled “hands_empty”mobile.hands_empty(serial) -> booleanWhether the mobile holds nothing in either hand, as stealing needs: nothing in the one-handed and nothing in the two-handed layer, a shield included. False for an unknown mobile.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns boolean.
has_free_hand
Section titled “has_free_hand”mobile.has_free_hand(serial) -> booleanWhether the mobile has a hand free, as drinking a potion needs: not when it holds a two-handed weapon, nor a one-handed weapon with a shield. False for an unknown mobile.
Refuses to drink with both hands full:
if not mobile.has_free_hand(user) then mobile.message_cliloc(user, 502172) -- You must have a free hand to drink a potion. return trueend| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns boolean.
has_night_sight
Section titled “has_night_sight”mobile.has_night_sight(serial) -> booleanWhether the mobile has night sight; false for an unknown mobile.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns boolean.
mobile.heal(patient, amount, healer?) -> integer?Gives the mobile amount hit points back, up to its maximum, and tells how many it got: what a bandage or a heal spell does. The healer, optional, is told to the on_heal of an NPC, whose script may change the amount (a number replaces it, false gives none) before it lands; regeneration is not a heal. Its player sees the new status, the players around the health bar. 0 for a dead mobile, an amount of 0 or less or a mobile at its maximum; nil for a mobile not in the world.
Healing a patient; the on_heal of an NPC patient may change the amount before it lands:
local gained = mobile.heal(patient, 12, healer)| Parameter | Type | Default |
|---|---|---|
patient | integer | |
amount | number | |
healer (optional) | integer | nil |
Returns integer?.
hunger
Section titled “hunger”mobile.hunger(serial) -> integer?How full the mobile is, from 0 (starving) to 20 (full); a player loses a point every ultima.regeneration.hunger_minutes, counted from when it entered the world, and at 0 gets no hit points back; the staff neither gets hungry nor starves. Nil for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns integer?.
is_dead
Section titled “is_dead”mobile.is_dead(serial) -> booleanTrue for a player that is dead, a ghost; false for anyone else, an NPC that dies leaves the world, or a serial that is not a mobile.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns boolean.
is_disguised
Section titled “is_disguised”mobile.is_disguised(serial) -> booleanWhether a mobile.disguise is on the mobile now.
if mobile.is_disguised(caster) then return 1061631 end| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns boolean.
is_female
Section titled “is_female”mobile.is_female(serial) -> booleanWhether the mobile, a player or an NPC, is female; false for a male one and for an unknown serial.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns boolean.
is_mounted
Section titled “is_mounted”mobile.is_mounted(serial) -> booleanTrue when the mobile rides a mount, such as a horse; false for a mobile on foot or a serial that is not a mobile in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns boolean.
is_murderer
Section titled “is_murderer”mobile.is_murderer(serial) -> booleanTrue for a player with five kills or more reported against it, a murderer with a red name; false for anyone else or a serial that is not a mobile.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns boolean.
is_paralyzed
Section titled “is_paralyzed”mobile.is_paralyzed(serial) -> booleanWhether the mobile is frozen by a paralysis that has not ended; a mobile frozen by mobile.set_frozen is not.
if mobile.is_paralyzed(who) then mobile.release_paralysis(who) end| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns boolean.
is_player
Section titled “is_player”mobile.is_player(serial) -> booleanWhether the serial is a player's character in the world; false for an NPC or an unknown serial.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns boolean.
mobile.kill(serial, killer?) -> booleanKills a mobile: it leaves its corpse with what it carried and wore and the players around see and hear it die. An NPC runs its on_death(npc, corpse, killer) and leaves the world; a player stays as a ghost. killer is the serial of who did it, kept on the corpse, or nil. False for a mobile not in the world, a player that is dead already, or a body without a ghost.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
killer (optional) | integer | nil |
Returns boolean.
mobile.light(serial) -> integer?The light level where the mobile stands, 0 (day) to 30 (dark): the hour, or its dungeon's; nil for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns integer?.
location
Section titled “location”mobile.location(serial) -> table?Where the mobile stands, as a table { x, y, z, map }; nil for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns table?.
max_weight
Section titled “max_weight”mobile.max_weight(serial) -> integer?The stones the mobile may carry before it is overloaded: 40 and 3.5 a point of strength; nil for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns integer?.
message
Section titled “message”mobile.message(serial, text) -> booleanA system message, in the lower left of the screen, read only by that player (cut at 128 characters); false for an empty text, an NPC or a player not in the world.
mobile.message(who, "That is too far away.")| Parameter | Type | Default |
|---|---|---|
serial | integer | |
text | string |
Returns boolean.
message_cliloc
Section titled “message_cliloc”mobile.message_cliloc(serial, cliloc, args?) -> booleanA system message of the client's own texts, by cliloc number, read only by that player in the language of its client; args fills its ~1_NAME~ places, split by tabs. False for a number not above 0, an NPC or a player not in the world.
mobile.message_cliloc(who, 500867)| Parameter | Type | Default |
|---|---|---|
serial | integer | |
cliloc | integer | |
args (optional) | string | nil |
Returns boolean.
murders
Section titled “murders”mobile.murders(serial) -> table?The murder counts of the mobile as { kills, short_term }: the kills a victim reported (five make a murderer, red) and the short-term murders (five make a resurrection cost skills and stats). nil for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns table?.
mobile.name(serial) -> string?The mobile's name; nil for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns string?.
notoriety
Section titled “notoriety”mobile.notoriety(serial) -> string?The notoriety others see the mobile with, as a name: innocent (blue), ally, attackable, criminal (grey), enemy, murderer (red) or invulnerable (yellow). A criminal reads criminal and a murderer murderer, whatever its template says. nil for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns string?.
paralyze
Section titled “paralyze”mobile.paralyze(serial, seconds) -> booleanParalyzes the mobile for the seconds given: it neither steps, turns nor casts until they pass, and the time is saved with it, so a player that logs out is freed at the right moment. False, with nothing changed, for a mobile already frozen or dead, a time that is not positive or a mobile that is not in the world; a paralysis does not stack or extend.
A paralysis lasts a few seconds, is kept with the mobile, and does not stack or extend; release_paralysis ends it at once:
if mobile.paralyze(target, 7 + magery * 0.2) then spell.disturb(target)end| Parameter | Type | Default |
|---|---|---|
serial | integer | |
seconds | number |
Returns boolean.
pathfind_to
Section titled “pathfind_to”mobile.pathfind_to(serial, x, y, z) -> booleanTells the player's client to walk its character to x, y, z of its map by itself, as after a double right click on the ground: the client finds the way and walks it step by step, and the player may walk elsewhere at any time. It is the client that decides: a spot too far or with no way to it is simply not walked to, and the server is not told. True when the client was told; false for an NPC, a player that is not in the world, or coordinates outside 0 to 65535 (x, y) and -128 to 127 (z).
A guide that sends who asks the way to the bank of Britain: the player’s client walks there by itself, and the player can stop by walking elsewhere:
function guide.on_speech(serial, speaker, text) if text:lower():find("bank", 1, true) then npc.say(serial, "Follow your feet.") mobile.pathfind_to(speaker, 1434, 1699, 0) endend| Parameter | Type | Default |
|---|---|---|
serial | integer | |
x | number | |
y | number | |
z | number |
Returns boolean.
play_music
Section titled “play_music”mobile.play_music(serial, music) -> booleanPlays a music (a MusicType) to the player, until its region gives it another; false for an NPC or a player not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
music | MusicType | string |
Returns boolean.
play_sound
Section titled “play_sound”mobile.play_sound(serial, sound) -> booleanPlays a sound id (0 to 65535) where the mobile stands, for the players within 15 cells; false for a mobile not in the world or a sound out of range.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
sound | integer |
Returns boolean.
poison
Section titled “poison”mobile.poison(serial, level) -> anyPoisons the mobile at level 0 (lesser), 1 (regular), 2 (greater), 3 (deadly) or 4 (lethal): it loses hits every few seconds until the poison wears off, is cured or kills, its health bar turns green and it gets no hits back. 'poisoned' when it is, 'higher' when a poison as strong or stronger is at work already; false for an unknown level, a dead or unknown mobile. The level is saved with the mobile.
A trap that poisons whoever opens the chest:
if mobile.poison(user, 1) == "poisoned" then mobile.message(user, "A cloud of green gas rises from the chest!")end| Parameter | Type | Default |
|---|---|---|
serial | integer | |
level | integer |
Returns any.
poison_level
Section titled “poison_level”mobile.poison_level(serial) -> anyThe level of the mobile's poison, 0 (lesser) to 4 (lethal); nil when it is not poisoned or is unknown.
Refuses a deadly poisoned player at the gate:
local level = mobile.poison_level(user)
if level and level >= 3 then mobile.message(user, "Come back when you are cured.")end| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns any.
region
Section titled “region”mobile.region(serial) -> string?The name of the region the mobile stands in; nil outside every region or for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns string?.
release_paralysis
Section titled “release_paralysis”mobile.release_paralysis(serial) -> booleanEnds the mobile's paralysis and frees it at once; false when it was not paralyzed.
mobile.release_paralysis(who)| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns boolean.
resurrect
Section titled “resurrect”mobile.resurrect(corpse, healer?) -> booleanRaises a dead player, a ghost, at once: its living body is back with 10 hit points, full stamina and no mana, and a death robe replaces its shroud; false for a player that is not dead. Given the corpse of an NPC instead, raises the NPC a corpse is of, on a later turn of the game loop: one of the same template is born where the corpse lies, with the name and the facing of who died and the equipment of its template, and the corpse is gone with what was left inside. False, and nothing is started, for what is not an item with the corpse graphic; a corpse that names no template is left as it is. The optional healer is told to the on_resurrect of the NPC that rises.
| Parameter | Type | Default |
|---|---|---|
corpse | integer | |
healer (optional) | integer | nil |
Returns boolean.
mobile.say(serial, text) -> booleanThe mobile says text overhead, seen by the players around it, as a countdown over a held explosion potion. False for an unknown mobile or blank text.
A countdown over the player who holds a lit fuse:
for count = 3, 1, -1 do mobile.say(user, tostring(count)) wait(1)end| Parameter | Type | Default |
|---|---|---|
serial | integer | |
text | string |
Returns boolean.
set_body
Section titled “set_body”mobile.set_body(serial, body) -> booleanGives the mobile another body graphic (0 to 65535), seen at once by its player and the players around; false for a body out of range or a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
body | integer |
Returns boolean.
set_criminal
Section titled “set_criminal”mobile.set_criminal(serial, criminal) -> booleanMakes the mobile a criminal for ultima.crime.criminal_seconds, starting the time again if it is one, or pardons it at once with false; false for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
criminal | boolean |
Returns boolean.
set_frozen
Section titled “set_frozen”mobile.set_frozen(serial, frozen) -> booleanFreezes or frees the mobile: frozen, it neither steps nor turns; saved with the mobile. A paralysis that was running is ended by it, so its time does not lift the freeze. False for a mobile not in the world.
A freeze set by a script is the script’s own: it ends a paralysis that was running, so the time of that paralysis does not lift it later:
mobile.set_frozen(statue, true) -- stays frozen until a script or a command frees it| Parameter | Type | Default |
|---|---|---|
serial | integer | |
frozen | boolean |
Returns boolean.
set_hidden
Section titled “set_hidden”mobile.set_hidden(serial, hidden) -> booleanHides or reveals the mobile: hidden, the players around no longer see it, hear it, open its paperdoll or read its tooltip, and NPCs do not sense it; the staff still sees it and world.mobiles_in_range still returns it. Saved with the mobile. False for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
hidden | boolean |
Returns boolean.
set_hue
Section titled “set_hue”mobile.set_hue(serial, hue) -> booleanGives the mobile another skin hue (0 to 65535, 0 the colours of its art), seen at once by its player and the players around; false for a hue out of range or a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
hue | integer |
Returns boolean.
set_hunger
Section titled “set_hunger”mobile.set_hunger(serial, hunger) -> booleanSets how full the mobile is, kept from 0 (starving) to 20 (full); false for a mobile not in the world.
Feeding a mobile; thirst works the same way:
mobile.set_hunger(who, mobile.hunger(who) + 3)mobile.set_thirst(who, mobile.thirst(who) + 3)| Parameter | Type | Default |
|---|---|---|
serial | integer | |
hunger | integer |
Returns boolean.
set_name
Section titled “set_name”mobile.set_name(serial, name) -> booleanGives the mobile another name of at most 30 characters, seen by its player and the players around; false for a blank or longer name or a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
name | string |
Returns boolean.
set_night_sight
Section titled “set_night_sight”mobile.set_night_sight(serial, level, seconds) -> booleanGives the player a personal light of level (0 to 30, more is brighter) for seconds, as a night sight potion does; it ends when the time is up or the player leaves. False when it has night sight already, for an unknown mobile, a level out of range or a time that is not positive.
A torch-bearer’s blessing that lets a player see in the dark for twenty minutes:
if not mobile.set_night_sight(user, 13, 1200) then mobile.message(user, "You already have night sight.")end| Parameter | Type | Default |
|---|---|---|
serial | integer | |
level | integer | |
seconds | integer |
Returns boolean.
set_prop
Section titled “set_prop”mobile.set_prop(serial, key, value?) -> booleanKeeps a string, a number or a bool on the mobile across restarts, a player's saved with its character; nil removes it. False for a table, a function, a blank key or a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
key | string | |
value (optional) | any | nil |
Returns boolean.
set_skill
Section titled “set_skill”mobile.set_skill(serial, skill, value, cap?) -> booleanSets a skill of the mobile in points (50.5), and its cap when given; the value stays between 0 and the cap. False for a cap outside 0 to 6553.5 or a mobile not in the world; a skill number that is no SkillType raises an error. The mobile's player sees it in the skill window.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
skill | SkillType | string | |
value | number | |
cap (optional) | number | nil |
Returns boolean.
set_stats
Section titled “set_stats”mobile.set_stats(serial, values) -> booleanChanges the mobile's numbers, given as a table with any of those mobile.stats gives but body; hits, mana and stamina stay between 0 and their maximum, also when only the maximum changes. Its player sees its bars or status change, the players around its health bar. False, with nothing changed, for an unknown name, a value that is not a whole number, a strength, dexterity, intelligence or maximum outside 0 to 65535, an empty table or a mobile not in the world.
mobile.set_stats(who, { hits = 10, strength = 80 })| Parameter | Type | Default |
|---|---|---|
serial | integer | |
values | table |
Returns boolean.
set_stealth_steps
Section titled “set_stealth_steps”mobile.set_stealth_steps(serial, steps) -> booleanSets how many steps the hidden mobile may take before a step shows it (0 to 1000); hiding or showing it again clears them, and running always shows it. False for a mobile not in the world or a number out of range.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
steps | integer |
Returns boolean.
set_thirst
Section titled “set_thirst”mobile.set_thirst(serial, thirst) -> booleanSets how quenched the mobile is, kept from 0 (parched) to 20 (quenched); false for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
thirst | integer |
Returns boolean.
set_war_mode
Section titled “set_war_mode”mobile.set_war_mode(serial, war_mode) -> booleanPuts the mobile in war mode or in peace, seen by its player and the players around; a mobile comes back in peace after a restart. False for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
war_mode | boolean |
Returns boolean.
mobile.skill(serial, skill) -> table?A skill of the mobile as { value, cap, lock }: value and cap in points (50.5), lock is up, down or locked; a skill never trained is 0. nil for a mobile not in the world.
mobile.skill(who, SkillType.Magery).value| Parameter | Type | Default |
|---|---|---|
serial | integer | |
skill | SkillType | string |
Returns table?.
skill_points
Section titled “skill_points”mobile.skill_points(serial, skill) -> number?The value of one skill of the mobile in points (50.5) as a plain number, without the table mobile.skill builds; 0 for a skill never trained, nil for a mobile not in the world.
One skill as a plain number of points, 0 when never trained:
if mobile.skill_points(who, SkillType.Magery) >= 50 then mobile.message(who, "You know your magic well.")end| Parameter | Type | Default |
|---|---|---|
serial | integer | |
skill | SkillType | string |
Returns number?.
skills
Section titled “skills”mobile.skills(serial) -> table?The skills of the mobile above 0, as a table of name (magery, evaluating_intelligence) and value in points; nil for a mobile not in the world.
Every skill above 0, as a table of name and value:
mobile.skills(who).magery| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns table?.
stat_bonus
Section titled “stat_bonus”mobile.stat_bonus(serial, stat) -> integerWhat the mobile's 'strength', 'dexterity' or 'intelligence' is moved by now: the bonus less the curse it is under; 0 for none, an unknown stat or mobile.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
stat | string |
Returns integer.
mobile.stats(serial) -> table?The mobile's numbers as a table: body, strength, dexterity, intelligence, hits, hits_max, mana, mana_max, stamina, stamina_max, fame, karma, base_strength, base_dexterity, base_hits_max, base_stamina_max; nil for a mobile not in the world. Strength, dexterity and the maximums count the timed bonuses (mobile.add_stat_bonus); the base_ ones are what mobile.set_stats sets. Read only; change them with mobile.set_stats.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns table?.
stealth_steps
Section titled “stealth_steps”mobile.stealth_steps(serial) -> integer?How many more steps the mobile may take hidden before a step shows it, as the Stealth skill gave them; 0 for none, nil for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns integer?.
teleport
Section titled “teleport”mobile.teleport(serial, x, y, z, map?, with_pets?) -> booleanTeleports the mobile to x, y, z on its map, or on the given map (a MapType or its name, such as Tokuno); the players around the old spot lose it and those around the new one see it. With the sixth argument true, the creatures that follow it (pets and hirelings within 3 tiles, on its map, not told to stay, not fighting) arrive at the same spot after it; with the text "bonded" only the bonded pets do, as Recall brings them. False for a mobile not in the world, a map that does not exist or is not loaded, a spot outside the map or a z outside -128 to 127.
A player’s client is told of the map change (0xBF 0x08) and where it stands (0x20):
mobile.teleport(who, x, y, z, "Tokuno")The last argument brings the pets and hirelings of the player that are within 3 tiles: true for all of them,
"bonded" for the bonded pets only, as Recall does:
mobile.teleport(who, x, y, z, "Tokuno", true)mobile.teleport(who, x, y, z, "Tokuno", "bonded")| Parameter | Type | Default |
|---|---|---|
serial | integer | |
x | integer | |
y | integer | |
z | integer | |
map (optional) | any | nil |
with_pets (optional) | any | nil |
Returns boolean.
template
Section titled “template”mobile.template(serial) -> string?The id of the mobile template an NPC was made from, such as f_baker; nil for a player or a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns string?.
thirst
Section titled “thirst”mobile.thirst(serial) -> integer?How quenched the mobile is, from 0 (parched) to 20 (quenched); a player loses a point every ultima.regeneration.hunger_minutes, counted as for hunger, and at 0 gets no stamina back; the staff is left alone. Nil for a mobile not in the world.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns integer?.
mobile.turn(serial, direction) -> booleanTurns the mobile on the spot, without a step, to one of the eight directions, named as mobile.direction gives them (north, south_east); the turn is seen by those around and by the mobile's own client. A frozen mobile does not turn. False for a mobile not in the world or a direction that is not one of the eight.
The turn is on the spot, without a step, and is seen by those around and by the mobile’s own client; a frozen mobile does not turn:
mobile.turn(who, "south_east")| Parameter | Type | Default |
|---|---|---|
serial | integer | |
direction | string |
Returns boolean.
weight
Section titled “weight”mobile.weight(serial) -> integer?The stones the mobile carries: what it wears and everything inside, without the bank box, each pile rounded up as its tooltip says; nil for a mobile not in the world.
if mobile.weight(who) > mobile.max_weight(who) then ... end| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns integer?.
Made with ❤️ by Tom
