-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Metatable:Creature
The Creature metatable contains all of the methods that handle/require creatures.
This metatable is also inherited by the Player, Monster and Npc metatables, therefore they can use these Creature methods.
Creating an instance of the Creature metatable (2 options):
local creature = Creature(uid)
local creature = Creature(name)
addCondition(condition, force = false)
addHealth(healthChange)
addMana(manaChange, animationOnLoss = false)
canSee(position)
canSeeCreature(creature)
changeSpeed(delta)
getBaseSpeed()
getCondition(conditionType, conditionId = CONDITIONID_COMBAT, subId = 0)
getDamageMap()
getDescription(distance)
getDirection()
getEvents()
getFollowCreature()
getHealth()
getId()
getLight()
getMana()
getMaster()
getMaxHealth()
getMaxMana()
getName()
getOutfit()
getParent()
getPathTo(pos, minTargetDist = 0, maxTargetDist = 1, fullPathSearch = true, clearSight = true, maxSearchDist = 0)
getPosition()
getSkull()
getSpeed()
getSummons()
getTarget()
getTile()
getZone()
isCreature()
isHealthHidden()
isInGhostMode()
isItem()
isMonster()
isMovementBlocked()
isNpc()
isPlayer()
isRemoved()
isTile()
registerEvent(name)
remove()
removeCondition(conditionType, conditionId = CONDITIONID_COMBAT, subId = 0, force = false)
say(text, type, ghost = false, target = nil, position)
setDirection(direction)
setDropLoot(doDrop)
setFollowCreature(followedCreature)
setHealth(health)
setHiddenHealth(hide)
setLight(color, level)
setMaster(master)
setMaxHealth(maxHealth)
setMovementBlocked(bool)
setOutfit(outfit)
setSkull(skull)
setTarget(target)
teleportTo(position, pushMovement = false)
unregisterEvent(name)
Description: N/A
Parameters:Returns: N/A
- condition - No description
- force - (optional, default: false)
Example:
local creature = Creature(...)
creature:addCondition(some_userdata, false)
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- healthChange - No description
Example:
local creature = Creature(...)
creature:addHealth(1)
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- manaChange - No description
- animationOnLoss - (optional, default: false)
Example:
local creature = Creature(...)
creature:addMana(1, false)
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- position - No description
Example:
local creature = Creature(...)
creature:canSee(Position())
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- creature - No description
Example:
local creature = Creature(...)
creature:canSeeCreature(some_userdata)
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- delta - No description
Example:
local creature = Creature(...)
creature:changeSpeed(unknown)
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getBaseSpeed()
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- conditionType - No description
- conditionId - (optional, default: CONDITIONID_COMBAT)
- subId - (optional, default: 0)
Example:
local creature = Creature(...)
creature:getCondition(CONDITION_POISON, CONDITIONID_COMBAT, 0)
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getDamageMap()
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- distance - No description
Example:
local creature = Creature(...)
creature:getDescription(1)
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getDirection()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getEvents()
[To the top] Added in version: 1.2
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getFollowCreature()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getHealth()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getId()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getLight()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getMana()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getMaster()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getMaxHealth()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getMaxMana()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getName()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getOutfit()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getParent()
[To the top] Added in version: 1.0
getPathTo(pos[, minTargetDist = 0[, maxTargetDist = 1[, fullPathSearch = true[, clearSight = true[, maxSearchDist = 0]]]]])
Description: N/A
Parameters:Returns: N/A
- pos - No description
- minTargetDist - (optional, default: 0)
- maxTargetDist - (optional, default: 1)
- fullPathSearch - (optional, default: true)
- clearSight - (optional, default: true)
- maxSearchDist - (optional, default: 0)
Example:
local creature = Creature(...)
creature:getPathTo(Position(), 0, 1, true, true, 0)
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getPosition()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getSkull()
[To the top] Added in version: 1.0 for players, since 1.1 for any creature
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getSpeed()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getSummons()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getTarget()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:getTile()
[To the top] Added in version: 1.0
Description: Returns the zone (ZoneType_t) of a tile
Parameters: None
Returns: (enum) ZoneType_t
Example:
local creature = Creature(...)
creature:getZone()
[To the top] Added in version: 1.3
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:isCreature()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:isHealthHidden()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:isInGhostMode()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:isItem()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:isMonster()
[To the top] Added in version: 1.0
Description: Check if this creature can move or if it is blocked.
Parameters: None
Returns: bool (true/false)
Example:
local creature = Creature(...)
if not creature:isMovementBlocked() then
creature::setMovementBlocked(true)
print("Blocking " .. creature:getName() .. " from being able to move.")
end
[To the top] Added in version: 1.3 #2553
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:isNpc()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:isPlayer()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:isRemoved()
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: false
Example:
local creature = Creature(...)
creature:isTile()
[To the top] Added in version: 1.1
Description: N/A
Parameters:Returns: N/A
- name - No description
Example:
local creature = Creature(...)
creature:registerEvent(some_name)
[To the top] Added in version: 1.0
Description: N/A
Parameters: None
Returns: N/A
Example:
local creature = Creature(...)
creature:remove()
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- conditionType - No description
- conditionId - (optional, default: CONDITIONID_COMBAT)
- subId - (optional, default: 0)
- force - (optional, default: false)
Example:
local creature = Creature(...)
creature:removeCondition(CONDITION_POISON, CONDITIONID_COMBAT, 0, false)
[To the top] Added in version: 1.0
Description: Test description
Parameters:Returns: N/A
- text - Text shown to others.
- type - Type of text that is shown.
- ghost - (optional, default: false)
- target - (optional, default: nullptr)
- position - (optional)
Example:
local creature = Creature(...)
creature:say(any_string, TALKTYPE_SAY, false, nil, nil)
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- direction - No description
Example:
local creature = Creature(...)
creature:setDirection(NORTH)
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- doDrop - No description
Example:
local creature = Creature(...)
creature:setDropLoot(unknown)
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- followedCreature - No description
Example:
local creature = Creature(...)
creature:setFollowCreature(some_userdata)
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- health - No description
Example:
local creature = Creature(...)
creature:setHealth(185)
[To the top] Added in version: 1.3
Description: N/A
Parameters:Returns: N/A
- hide - No description
Example:
local creature = Creature(...)
creature:setHiddenHealth(unknown)
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- color - No description
- level - No description
Example:
local creature = Creature(...)
creature:setLight(0xD7, LIGHT_LEVEL_DAY)
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- master - No description
Example:
local creature = Creature(...)
creature:setMaster(some_userdata)
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- maxHealth - No description
Example:
local creature = Creature(...)
creature:setMaxHealth(185)
[To the top] Added in version: 1.0
Description: Block or unblock a creature from being able to move
Parameters:Returns: N/A
- bool - true/false - Block or unblock player
Example:
local creature = Creature(...)
if creature:isMovementBlocked() then
creature::setMovementBlocked(false)
print("Allowing " .. creature:getName() .. " to move again.")
end
[To the top] Added in version: 1.3 #2553
Description: N/A
Parameters:Returns: N/A
- outfit - No description
Example:
local creature = Creature(...)
creature:setOutfit(unknown)
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- skull - No description
Example:
local creature = Creature(...)
creature:setSkull(SKULL_RED)
[To the top] Added in version: 1.0 for players, since 1.1 for any creature
Description: N/A
Parameters:Returns: N/A
- target - No description
Example:
local creature = Creature(...)
creature:setTarget(some_userdata)
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- position - No description
- pushMovement - (optional, default: false)
Example:
local creature = Creature(...)
creature:teleportTo(Position(), false)
[To the top] Added in version: 1.0
Description: N/A
Parameters:Returns: N/A
- name - No description
Example:
local creature = Creature(...)
creature:unregisterEvent(some_name)
[To the top] Added in version: 1.0