Metatable:Creature - RodrigoOt/forgottenserver GitHub Wiki

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)

###Available methods: [addCondition(condition[, force = false])](#addCondition{condition[, force = false]})
addHealth(healthChange)
[addMana(manaChange[, animationOnLoss = false])](#addMana{manaChange[, animationOnLoss = false]})
canSee(position)
canSeeCreature(creature)
changeSpeed(delta)
getBaseSpeed()
[getCondition(conditionType[, conditionId = CONDITIONID_COMBAT[, subId = 0]])](#getCondition{conditionType[, conditionId = CONDITIONID_COMBAT[, subId = 0]]})
getDamageMap()
getDescription(distance)
getDirection()
getFollowCreature()
getHealth()
getId()
getLight()
getMana()
getMaster()
getMaxHealth()
getMaxMana()
getName()
getOutfit()
getParent()
[getPathTo(pos[, minTargetDist = 0[, maxTargetDist = 1[, fullPathSearch = true[, clearSight = true[, maxSearchDist = 0]]]]])](#getPathTo{pos[, minTargetDist = 0[, maxTargetDist = 1[, fullPathSearch = true[, clearSight = true[, maxSearchDist = 0]]]]]})
getPosition()
getSkull()
getSpeed()
getSummons()
getTarget()
getTile()
isCreature()
isHealthHidden()
isInGhostMode()
isItem()
isMonster()
isNpc()
isPlayer()
isRemoved()
isTile()
registerEvent(name)
remove()
[removeCondition(conditionType[, conditionId = CONDITIONID_COMBAT[, subId = 0[, force = false]]])](#removeCondition{conditionType[, conditionId = CONDITIONID_COMBAT[, subId = 0[, force = false]]]})
[say(text, type[, ghost = false[, target = nil[, position]]])](#say{text, type[, ghost = false[, target = nil[, position]]]})
setDirection(direction)
setDropLoot(doDrop)
setFollowCreature(followedCreature)
setHiddenHealth(hide)
[setLight(color, level)](#setLight{color, level})
setMaster(master)
setMaxHealth(maxHealth)
setOutfit(outfit)
setSkull(skull) setTarget(target)
[teleportTo(position[, pushMovement = false])](#teleportTo{position[, pushMovement = false]})
unregisterEvent(name)


###### addCondition(condition[, force = false]) > **Description:** N/A > **Parameters:**
  • _condition_ - _No description_
  • _force_ - _(optional, default: false)_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:addCondition(some_userdata, false) ``` > **Added in version:** 1.0
###### addHealth(healthChange) > **Description:** N/A > **Parameters:**
  • _healthChange_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:addHealth(1) ``` > **Added in version:** 1.0
###### addMana(manaChange[, animationOnLoss = false]) > **Description:** N/A > **Parameters:**
  • _manaChange_ - _No description_
  • _animationOnLoss_ - _(optional, default: false)_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:addMana(1, false) ``` > **Added in version:** 1.0
###### canSee(position) > **Description:** N/A > **Parameters:**
  • _position_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:canSee(Position()) ``` > **Added in version:** 1.0
###### canSeeCreature(creature) > **Description:** N/A > **Parameters:**
  • _creature_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:canSeeCreature(some_userdata) ``` > **Added in version:** 1.0
###### changeSpeed(delta) > **Description:** N/A > **Parameters:**
  • _delta_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:changeSpeed(unknown) ``` > **Added in version:** 1.0
###### getBaseSpeed() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getBaseSpeed() ``` > **Added in version:** 1.0
###### getCondition(conditionType[, conditionId = CONDITIONID_COMBAT[, subId = 0]]) > **Description:** N/A > **Parameters:**
  • _conditionType_ - _No description_
  • _conditionId_ - _(optional, default: CONDITIONID_COMBAT)_
  • _subId_ - _(optional, default: 0)_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getCondition(CONDITION_POISON, CONDITIONID_COMBAT, 0) ``` > **Added in version:** 1.0
###### getDamageMap() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getDamageMap() ``` > **Added in version:** 1.0
###### getDescription(distance) > **Description:** N/A > **Parameters:**
  • _distance_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getDescription(1) ``` > **Added in version:** 1.0
###### getDirection() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getDirection() ``` > **Added in version:** 1.0
###### getFollowCreature() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getFollowCreature() ``` > **Added in version:** 1.0
###### getHealth() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getHealth() ``` > **Added in version:** 1.0
###### getId() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getId() ``` > **Added in version:** 1.0
###### getLight() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getLight() ``` > **Added in version:** 1.0
###### getMana() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getMana() ``` > **Added in version:** 1.0
###### getMaster() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getMaster() ``` > **Added in version:** 1.0
###### getMaxHealth() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getMaxHealth() ``` > **Added in version:** 1.0
###### getMaxMana() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getMaxMana() ``` > **Added in version:** 1.0
###### getName() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getName() ``` > **Added in version:** 1.0
###### getOutfit() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getOutfit() ``` > **Added in version:** 1.0
###### getParent() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getParent() ``` > **Added in version:** 1.0
###### getPathTo(pos[, minTargetDist = 0[, maxTargetDist = 1[, fullPathSearch = true[, clearSight = true[, maxSearchDist = 0]]]]]) > **Description:** N/A > **Parameters:**
  • _pos_ - _No description_
  • _minTargetDist_ - _(optional, default: 0)_
  • _maxTargetDist_ - _(optional, default: 1)_
  • _fullPathSearch_ - _(optional, default: true)_
  • _clearSight_ - _(optional, default: true)_
  • _maxSearchDist_ - _(optional, default: 0)_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getPathTo(Position(), 0, 1, true, true, 0) ``` > **Added in version:** 1.0
###### getPosition() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getPosition() ``` > **Added in version:** 1.0
###### getSkull() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getSkull() ``` > **Added in version:** 1.0 for players, since 1.1 for any creature
###### getSpeed() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getSpeed() ``` > **Added in version:** 1.0
###### getSummons() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getSummons() ``` > **Added in version:** 1.0
###### getTarget() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getTarget() ``` > **Added in version:** 1.0
###### getTile() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:getTile() ``` > **Added in version:** 1.0
###### isCreature() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:isCreature() ``` > **Added in version:** 1.0
###### isHealthHidden() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:isHealthHidden() ``` > **Added in version:** 1.0
###### isInGhostMode() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:isInGhostMode() ``` > **Added in version:** 1.0
###### isItem() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:isItem() ``` > **Added in version:** 1.0
###### isMonster() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:isMonster() ``` > **Added in version:** 1.0
###### isNpc() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:isNpc() ``` > **Added in version:** 1.0
###### isPlayer() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:isPlayer() ``` > **Added in version:** 1.0
###### isRemoved() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:isRemoved() ``` > **Added in version:** 1.0
###### isTile() > **Description:** N/A > **Parameters:** None > **Returns:** false > **Example:** ```Lua local creature = Creature(...) creature:isTile() ``` > **Added in version:** 1.1
###### registerEvent(name) > **Description:** N/A > **Parameters:**
  • _name_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:registerEvent(some_name) ``` > **Added in version:** 1.0
###### remove() > **Description:** N/A > **Parameters:** None > **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:remove() ``` > **Added in version:** 1.0
###### removeCondition(conditionType[, conditionId = CONDITIONID_COMBAT[, subId = 0[, force = false]]]) > **Description:** N/A > **Parameters:**
  • _conditionType_ - _No description_
  • _conditionId_ - _(optional, default: CONDITIONID_COMBAT)_
  • _subId_ - _(optional, default: 0)_
  • _force_ - _(optional, default: false)_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:removeCondition(CONDITION_POISON, CONDITIONID_COMBAT, 0, false) ``` > **Added in version:** 1.0
###### say(text, type[, ghost = false[, target = nil[, position]]]) > **Description:** Test description > **Parameters:**
  • _text_ - _Text shown to others._
  • _type_ - _Type of text that is shown._
  • _ghost_ - _(optional, default: false)_
  • _target_ - _(optional, default: nullptr)_
  • _position_ - _(optional)_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:say(any_string, TALKTYPE_SAY, false, nil, nil) ``` > **Added in version:** 1.0
###### setDirection(direction) > **Description:** N/A > **Parameters:**
  • _direction_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:setDirection(NORTH) ``` > **Added in version:** 1.0
###### setDropLoot(doDrop) > **Description:** N/A > **Parameters:**
  • _doDrop_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:setDropLoot(unknown) ``` > **Added in version:** 1.0
###### setFollowCreature(followedCreature) > **Description:** N/A > **Parameters:**
  • _followedCreature_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:setFollowCreature(some_userdata) ``` > **Added in version:** 1.0
###### setHiddenHealth(hide) > **Description:** N/A > **Parameters:**
  • _hide_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:setHiddenHealth(unknown) ``` > **Added in version:** 1.0
###### setLight(color, level) > **Description:** N/A > **Parameters:**
  • _color_ - _No description_
  • _level_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:setLight(0xD7, LIGHT_LEVEL_DAY) ``` > **Added in version:** 1.0
###### setMaster(master) > **Description:** N/A > **Parameters:**
  • _master_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:setMaster(some_userdata) ``` > **Added in version:** 1.0
###### setMaxHealth(maxHealth) > **Description:** N/A > **Parameters:**
  • _maxHealth_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:setMaxHealth(185) ``` > **Added in version:** 1.0
###### setOutfit(outfit) > **Description:** N/A > **Parameters:**
  • _outfit_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:setOutfit(unknown) ``` > **Added in version:** 1.0
###### setSkull(skull) > **Description:** N/A > **Parameters:**
  • _skull_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:setSkull(SKULL_RED) ``` > **Added in version:** 1.0 for players, since 1.1 for any creature
###### setTarget(target) > **Description:** N/A > **Parameters:**
  • _target_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:setTarget(some_userdata) ``` > **Added in version:** 1.0
###### teleportTo(position[, pushMovement = false]) > **Description:** N/A > **Parameters:**
  • _position_ - _No description_
  • _pushMovement_ - _(optional, default: false)_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:teleportTo(Position(), false) ``` > **Added in version:** 1.0
###### unregisterEvent(name) > **Description:** N/A > **Parameters:**
  • _name_ - _No description_
> **Returns:** N/A > **Example:** ```Lua local creature = Creature(...) creature:unregisterEvent(some_name) ``` > **Added in version:** 1.0
⚠️ **GitHub.com Fallback** ⚠️