# Creature management

Derive from Actor

Before using creature API, please create creature management object. The methods as follows:

local Creature = class.Creature.new()

The specific function name and description are as follows:

Serial number Function name Description
1 getAttr(...) Obtain attribute setting of creature
2 setAttr(...) Obtain attribute of creature
3 isAdult(...) Determine whether the creature is an adult
4 setOxygenNeed(...) Set if oxygen is necessary
5 getTamedOwnerID(...) Obtain the ID of tamer
6 setPanic(...) Set whether it is in panic
7 setAIActive(...) Set if AI takes effect
8 getActorID(...) Obtain actor ID of creature
9 getActorName(...) Obtain the name of creature
10 addModAttrib(...) Increase the attribute of model set
11 getModAttrib(...) Obtain the attribute of model set
12 setTeam(...) Set the creature team
13 getTeam(...) Set the creature team
14 getMaxFood(...) Get max satiety
15 getFood(...) Get satiety
16 setFood(...) Set satiety
17 getHpRecover(...) HP recovery
18 getMaxOxygen(...) Max oxygen volume
19 getWalkSpeed(...) Walking speed
20 getSwimSpeed(...) Swimming speed(in water)
21 getJumpPower(...) Jump force
22 getMass(...) Weight
23 getDodge(...) Dodge
24 getPunchAttack(...) Melee attack
25 getRangeAttack(...) Ranged attack
26 getPunchDefense(...) Melee defense
27 getRangeDefense(...) Ranged defense
28 setMaxHp(...) Set HP
29 setHP(...) Set HP
30 setHpRecover(...) Set HP recovery
31 setOxygen(...) Set oxygen
32 setWalkSpeed(...) Set walking speed
33 setSwimSpeed(...) Set swimming speed(in water)
34 setJumpPower(...) Set the jump force
35 setDodge(...) Set dodging
36 setPunchAttack(...) Set melee attack
37 setRangeAttack(...) Set ranged attack
38 setPunchDefense(...) Set melee defense
39 setRangeDefense(...) Set ranged defense

# getAttr

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Obtain attribute setting of creature
  • The specific use cases are as follows:
local result = Creature:getAttr(objid, attrtype)

# setAttr

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Obtain attribute of creature
  • The specific use cases are as follows:
local result = Creature:setAttr(objid, attrtype, val)

# isAdult

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Determine whether the creature is an adult
  • The specific use cases are as follows:
local result = Creature:isAdult(objId)
if result == ErrorCode.OK then print("That creature is an adult") end

# setOxygenNeed

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set if oxygen is necessary
  • The specific use cases are as follows:
local result = Creature:setOxygenNeed(objId, true)
if result == ErrorCode.OK then print("This creature lives on oxygen!") end

# getTamedOwnerID

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Obtain the ID of tamer
  • The specific use cases are as follows:
local result, ownerId = Creature:getTamedOwnerID(objId)
if result == ErrorCode.OK and ownerId ~= 0 then
	local result, nickName = Player:getNickname(ownerId)
	if result == ErrorCode.OK then print('Player<'+nickName+'>pet...')
end

# setPanic

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set whether it is in panic
  • The specific use cases are as follows:
local result = Creature:setPanic(objId, true)
if result == ErrorCode.OK then print("This creature is in panic") end

# setAIActive

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set if AI takes effect
  • The specific use cases are as follows:
local result = Creature:setAIActive(objId, true)
if result == ErrorCode.OK then print("The AI of that creature takes effect") end

# getActorID

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Obtain actor ID of creature
  • The specific use cases are as follows:
local wolfId, dogId = 3407, 3408 --Resource ID of Wolf/Dog
local result, actorId = Creature:getActorID(objId)
if result == ErrorCode.OK then
	if actorId == dogId then print("The creature is A Dog!") end
	if actorId == wolfId then print("The creature is A Wolf!") end
end

# getActorName

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Obtain the name of creature
  • The specific use cases are as follows:
local result = Creature:getActorName(objid)

# addModAttrib

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Increase the attribute of model set
  • The specific use cases are as follows:
local modAttrType = MODATTRIB_TYPE.MODATTR_MOVE_SPEED
local result = Creature:addModAttrib(objid, modAttrType, 5)
if result == ErrorCode.OK then print('Increase the moving speed of monster') end

# getModAttrib

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Obtain the attribute of model set
  • The specific use cases are as follows:
local modAttrType = MODATTRIB_TYPE.MODATTR_MOVE_SPEED
local result, modAttrVal = Creature:getModAttrib(objid, modAttrType)
if result == ErrorCode.OK then print('The moving speed of monster is', modAttrVal) end

# setTeam

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set the creature team
  • The specific use cases are as follows:
local result = Creature:setTeam(objids, teamid)

# getTeam

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set the creature team
  • The specific use cases are as follows:
local result = Creature:getTeam(objid)

# getMaxFood

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get max satiety
  • The specific use cases are as follows:
local result = Creature:getMaxFood(objid)

# getFood

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get satiety
  • The specific use cases are as follows:
local result = Creature:getFood(objid)

# setFood

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set satiety
  • The specific use cases are as follows:
local result = Creature:setFood(objid, val)

# getHpRecover

  • Parameters and types:
  • Return value and types:
  • The main role of this method: HP recovery
  • The specific use cases are as follows:
local result = Creature:getHpRecover(objid)

# getMaxOxygen

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Max oxygen volume
  • The specific use cases are as follows:
local result = Creature:getMaxOxygen(objid)

# getWalkSpeed

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Walking speed
  • The specific use cases are as follows:
local result = Creature:getWalkSpeed(objid)

# getSwimSpeed

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Swimming speed(in water)
  • The specific use cases are as follows:
local result = Creature:getSwimSpeed(objid)

# getJumpPower

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Jump force
  • The specific use cases are as follows:
local result = Creature:getJumpPower(objid)

# getMass

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Weight
  • The specific use cases are as follows:
local result = Creature:getMass(objid)

# getDodge

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Dodge
  • The specific use cases are as follows:
local result = Creature:getDodge(objid)

# getPunchAttack

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Melee attack
  • The specific use cases are as follows:
local result = Creature:getPunchAttack(objid)

# getRangeAttack

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Ranged attack
  • The specific use cases are as follows:
local result = Creature:getRangeAttack(objid)

# getPunchDefense

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Melee defense
  • The specific use cases are as follows:
local result = Creature:getPunchDefense(objid)

# getRangeDefense

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Ranged defense
  • The specific use cases are as follows:
local result = Creature:getRangeDefense(objid)

# setMaxHp

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set HP
  • The specific use cases are as follows:
local result = Creature:setMaxHp(objid, val)

# setHP

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set HP
  • The specific use cases are as follows:
local result = Creature:setHP(objid, val)

# setHpRecover

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set HP recovery
  • The specific use cases are as follows:
local result = Creature:setHpRecover(objid)

# setOxygen

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set oxygen
  • The specific use cases are as follows:
local result = Creature:setOxygen(objid, val)

# setWalkSpeed

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set walking speed
  • The specific use cases are as follows:
local result = Creature:setWalkSpeed(objid, val)

# setSwimSpeed

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set swimming speed(in water)
  • The specific use cases are as follows:
local result = Creature:setSwimSpeed(objid, val)

# setJumpPower

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set the jump force
  • The specific use cases are as follows:
local result = Creature:setJumpPower(objid, val)

# setDodge

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set dodging
  • The specific use cases are as follows:
local result = Creature:setDodge(objid, val)

# setPunchAttack

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set melee attack
  • The specific use cases are as follows:
local result = Creature:setPunchAttack(objid, val)

# setRangeAttack

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set ranged attack
  • The specific use cases are as follows:
local result = Creature:setRangeAttack(objid, val)

# setPunchDefense

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set melee defense
  • The specific use cases are as follows:
local result = Creature:setPunchDefense(objid, val)

# setRangeDefense

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Set ranged defense
  • The specific use cases are as follows:
local result = Creature:setRangeDefense(objid, val)
Last Update: 11/22/2019, 2:31:59 PM