Character Information Functions
get_level(character)
Get a character's level.
Arguments:
character(character): The character to check
Returns:
number: Character's level (0 if invalid)
Example:
local actor = get_actor()
if actor then
local level = get_level(actor)
if level < 10 then
say("You're still quite young, adventurer.")
elseif level < 30 then
say("You're growing in strength!")
else
say("You're a seasoned warrior!")
end
endget_name(character)
Get a character's name.
Arguments:
character(character): The character to check
Returns:
string: Character's name (empty string if invalid)
Example:
local actor = get_actor()
if actor then
local name = get_name(actor)
say("Welcome, " .. name .. "!")
endget_hp_percent(character)
Get a character's current HP as a percentage.
Arguments:
character(character): The character to check
Returns:
number: HP percentage (0-100)
Example:
local actor = get_actor()
if actor then
local hp = get_hp_percent(actor)
if hp < 25 then
say("You look badly wounded! Here, take this.")
heal(actor, 100)
end
endis_pc(character)
Check if a character is a player character (not NPC).
Arguments:
character(character): The character to check
Returns:
boolean:trueif player character,falseotherwise
Example:
local actor = get_actor()
if actor and is_pc(actor) then
say("Ah, a fellow adventurer!")
else
say("Another traveler passes by.")
endis_immortal(character)
Check if a character is an immortal.
Arguments:
character(character): The character to check
Returns:
boolean:trueif immortal,falseotherwise
Example:
local actor = get_actor()
if actor and is_immortal(actor) then
say("Greetings, mighty one!")
emo("The sage bows deeply.")
endcan_see(char1, char2)
Check if char1 can see char2.
Arguments:
char1(character): The observerchar2(character): The target
Returns:
boolean:trueif char1 can see char2,falseotherwise
Example:
local actor = get_actor()
local mob = get_mob_context()
if actor and mob and can_see(mob, actor) then
say("I can see you clearly.")
else
say("Who goes there? I sense a presence...")
endis_fighting(character)
Check if a character is currently fighting.
Arguments:
character(character): The character to check
Returns:
boolean:trueif fighting,falseotherwise
Example:
local actor = get_actor()
if actor and is_fighting(actor) then
say("I won't help you while you're in combat!")
else
say("How can I assist you?")
endis_sleeping(character)
Check if a character is sleeping.
Arguments:
character(character): The character to check
Returns:
boolean:trueif sleeping,falseotherwise
Example:
local actor = get_actor()
if actor and is_sleeping(actor) then
emo("The sage speaks softly so as not to wake anyone.")
endCharacter State and Alignment Functions
is_npc(character)
Check if a character is an NPC.
Arguments:
character(character): The character to check
Returns:
boolean:trueif NPC,falseif player or invalid
Example:
local actor = get_actor()
if actor then
if is_npc(actor) then
say("Another NPC approaches.")
else
say("A player character approaches.")
end
endis_good(character)
Check if a character is good aligned (alignment > 350).
Arguments:
character(character): The character to check
Returns:
boolean:trueif good aligned,falseotherwise
Example:
local actor = get_actor()
if actor then
if is_good(actor) then
say("I sense goodness in your heart.")
-- Give good-aligned reward
end
endis_neutral(character)
Check if a character is neutral aligned (alignment -350 to 350).
Arguments:
character(character): The character to check
Returns:
boolean:trueif neutral aligned,falseotherwise
Example:
local actor = get_actor()
if actor then
if is_neutral(actor) then
say("You walk the path of balance.")
end
endis_evil(character)
Check if a character is evil aligned (alignment < -350).
Arguments:
character(character): The character to check
Returns:
boolean:trueif evil aligned,falseotherwise
Example:
local actor = get_actor()
if actor then
if is_evil(actor) then
say("I sense darkness in your soul!")
attack(actor)
end
endis_charmed(character)
Check if a character is charmed.
Arguments:
character(character): The character to check
Returns:
boolean:trueif charmed,falseotherwise
Example:
local actor = get_actor()
if actor and is_charmed(actor) then
say("I can see you're under someone's influence.")
endis_affected(character, affect)
Check if a character has a specific affect/spell.
Arguments:
character(character): The character to checkaffect(number): The affect flag to check for
Common Affect Flags:
1: AFF_BLIND2: AFF_INVISIBLE4: AFF_DETECT_EVIL8: AFF_DETECT_INVIS16: AFF_DETECT_MAGIC32: AFF_DETECT_HIDDEN64: AFF_HOLD128: AFF_SANCTUARY256: AFF_FAERIE_FIRE512: AFF_INFRARED1024: AFF_CURSE2048: AFF_FLAMING4096: AFF_POISON8192: AFF_PROTECT16384: AFF_PARALYSIS32768: AFF_SNEAK65536: AFF_HIDE131072: AFF_SLEEP262144: AFF_CHARM
Returns:
boolean:trueif character has the affect,falseotherwise
Example:
local actor = get_actor()
if actor then
if is_affected(actor, 128) then -- AFF_SANCTUARY
say("I see you're protected by sanctuary.")
end
if is_affected(actor, 4096) then -- AFF_POISON
say("You're poisoned! Let me help.")
heal(actor, 50) -- This won't cure poison, just heal
end
endget_align(character)
Get a character's exact alignment value.
Arguments:
character(character): The character to check
Returns:
number: Alignment value (-1000 to 1000, 0 if invalid)
Example:
local actor = get_actor()
if actor then
local align = get_align(actor)
if align > 500 then
say("You radiate with goodness!")
elseif align < -500 then
say("Darkness surrounds you...")
else
say("You seem balanced in your nature.")
end
endget_position(character)
Get a character's current position.
Arguments:
character(character): The character to check
Returns:
number: Position value (see positions below)
Position Values:
0: POS_DEAD1: POS_MORTAL2: POS_INCAP3: POS_STUNNED4: POS_SLEEPING5: POS_RESTING6: POS_SITTING7: POS_FIGHTING8: POS_STANDING
Example:
local actor = get_actor()
if actor then
local pos = get_position(actor)
if pos == 4 then -- POS_SLEEPING
say("Wake up, sleepyhead!")
elseif pos == 5 then -- POS_RESTING
say("Rest well, weary traveler.")
end
endget_sex(character)
Get a character's gender.
Arguments:
character(character): The character to check
Returns:
number: Gender value (0=neutral, 1=male, 2=female)
Example:
local actor = get_actor()
if actor then
local sex = get_sex(actor)
if sex == 1 then
say("Welcome, good sir!")
elseif sex == 2 then
say("Welcome, my lady!")
else
say("Welcome, traveler!")
end
endget_race(character)
Get a character's race name.
Arguments:
character(character): The character to check
Returns:
string: Race name (e.g., "human", "elf", "dwarf")
Example:
local actor = get_actor()
if actor then
local race = get_race(actor)
if race == "elf" then
say("Greetings, child of the forest!")
elseif race == "dwarf" then
say("Welcome, stout friend!")
elseif race == "human" then
say("Ah, a fellow human!")
else
say("Welcome, " .. race .. "!")
end
endget_class(character)
Get a character's class name.
Arguments:
character(character): The character to check
Returns:
string: Class name (e.g., "warrior", "mage", "thief") or "none" for NPCs
Example:
local actor = get_actor()
if actor and not is_npc(actor) then
local class = get_class(actor)
if class == "mage" then
say("I sense great magical potential in you!")
elseif class == "warrior" then
say("A mighty warrior stands before me!")
elseif class == "thief" then
say("Keep your hands where I can see them!")
end
endget_gold(character)
Get a character's gold amount.
Arguments:
character(character): The character to check
Returns:
number: Amount of gold (0 if invalid)
Example:
local actor = get_actor()
if actor then
local gold = get_gold(actor)
if gold >= 1000 then
say("You're quite wealthy!")
elseif gold >= 100 then
say("You have a decent amount of coin.")
else
say("You don't have much gold, do you?")
end
endget_vnum(character)
Get a mob's virtual number (NPCs only).
Arguments:
character(character): The character to check
Returns:
number: Virtual number (0 if not NPC or invalid)
Example:
local mob = get_mob_context()
if mob then
local vnum = get_vnum(mob)
log_message("Mob " .. vnum .. " is executing script")
endget_fighting(character)
Get who a character is currently fighting.
Arguments:
character(character): The character to check
Returns:
character: The character they're fighting, ornilif not fighting
Example:
local actor = get_actor()
if actor then
local enemy = get_fighting(actor)
if enemy then
tell(actor, "You're fighting " .. get_name(enemy) .. "!")
end
end