Appearance
角色模块管理接口 Actor
具体函数名及描述如下:
GetItemId
lua
local itemId = Actor:GetItemId(objId)
GetDropItemNum
lua
local num = Actor:GetDropItemNum(objId)
SetTeam
- 参数及类型:
- objid:
number
角色objid - teamid:
number
队伍ID AbsoluteCampTypeAbsoluteCampType - bResetAttr:
bool
是否重置属性(填玩家有效,默认false)
- objid:
- 返回值及类型:
- ret:
bool
设置成功(true)
- ret:
- 该方法的主要作用: 设置角色队伍
- 具体使用案例如下:
lua
-- 设置玩家为3队
local result = Actor:SetTeam(Player:GetHostUin(), AbsoluteCampType.Team3)
GetTeam
lua
local team = Actor:GetTeam(Player:GetHostUin())
AddHp
- 参数及类型:
- 返回值及类型:
- ret:
bool
成功(true)
- ret:
- 该方法的主要作用: 增加角色当前生命量
- 具体使用案例如下:
lua
local ret = Actor:AddHp(objid, hp)
GetMaxHP
lua
local value = Actor:GetMaxHP(objid)
SetNickName
lua
local result = Actor:SetNickName(Player:GetHostUin(), "昵称123")
GetNickName
lua
-- 获取玩家昵称
local nickname = Actor:GetNickName(Player:GetHostUin())
GetCurMapId
lua
local mapId = Actor:GetCurMapId(objId)
IsPlayer
lua
local isPlayer = Actor:IsPlayer(objId)
PlaySoundEffectById
- 参数及类型:
- 返回值及类型:
- ret:
bool
播放成功(true)
- ret:
- 该方法的主要作用: 在指定角色身上播放音效
- 具体使用案例如下:
lua
-- 对象上播放3d音效10379, 音量100, 音调1, 不循环
local result = Actor:PlaySoundEffectById(Player:GetHostUin(), 10379, 100, 1, false)
StopSoundEffectById
- 参数及类型:
- 返回值及类型:
- ret:
bool
停止成功(true)
- ret:
- 该方法的主要作用: 停止指定对象身上的音效
- 具体使用案例如下:
lua
-- 停止播放3d音效10379
local result = Actor:StopSoundEffectById(Player:GetHostUin(), 10379)
PauseSoundEffectById
- 参数及类型:
- 返回值及类型:
- ret:
bool
停止成功(true)
- ret:
- 该方法的主要作用: 暂停/恢复指定对象身上的音效
- 具体使用案例如下:
lua
--暂停播放3d音效10379
local result = Actor:PauseSoundEffectById(Player:GetHostUin(), 10379, true)
RotateFaceToActor
- 参数及类型:
- 返回值及类型:
- ret:
bool
旋转成功(true)
- ret:
- 该方法的主要作用: 使生物朝向目标生物
- 具体使用案例如下:
lua
local ret = Actor:RotateFaceToActor(objid, targetid)
GetActorFacade
lua
local facade = Actor:GetActorFacade(Player:GetHostUin())
PlayBodyParticleById
- 参数及类型:
- 返回值及类型:
- ret:
bool
成功(true)
- ret:
- 该方法的主要作用: 在指定对象身上播放粒子特效
- 具体使用案例如下:
lua
-- 对象上播放特效,特效id为1005,播放时间10秒,特效偏移y 2个方块位置,特效y旋转45,特效缩放为2倍
local result = Actor:PlayBodyParticleById(Player:GetHostUin(), 1005, 10, {x = 0, y = 2, z = 0}, {x = 0, y = 45, z = 0}, {x = 2, y = 2, z = 2})
StopBodyEffectById
- 参数及类型:
- 返回值及类型:
- ret:
bool
成功(true)
- ret:
- 该方法的主要作用: 停止指定对象身上的粒子特效
- 具体使用案例如下:
lua
local result = Actor:StopBodyEffectById(Player:GetHostUin(), 1005)
SetBodyParticleTransform
- 参数及类型:
- 返回值及类型:
- ret:
bool
成功(true)
- ret:
- 该方法的主要作用: 设置指定对象身上的特效大小
- 具体使用案例如下:
lua
-- 修改对象上播放的特效,特效id为1005,播放时间10秒,特效偏移y 2个方块位置,特效y旋转45,特效缩放为2倍
local result = Actor:SetBodyParticleTransform(Player:GetHostUin(), 1005, {x = 0, y = 2, z = 0}, {x = 0, y = 45, z = 0}, {x = 2, y = 2, z = 2})
GetRidingActorObjId
lua
local ridingObjId = Actor:GetRidingActorObjId(Player:GetHostUin())
GetFaceDirection
lua
local face = Actor:GetFaceDirection(objId)
TryMoveToActor
- 参数及类型:
- 返回值及类型:
- ret:
bool
成功(true)
- ret:
- 该方法的主要作用: 使对象向目标行动者移动(如果执行对象是刚创建出来的需要加个等待时间)
- 具体使用案例如下:
lua
local objs = World:SpawnCreature(x + 5, y + 1, z, 3400)
local objId = objs[1]
self:ThreadWait(0.2)
-- 创建嘟嘟鸟往房主走
local result = Actor:TryMoveToActor(objId, Player:GetHostUin(), 5)
SetFaceDirection
lua
local result = Actor:SetFaceDirection(objId, 0, 90, 0)
KillSelf
lua
local result = Actor:KillSelf(objId)
SetAttr
- 参数及类型:
- 返回值及类型:
- ret:
bool
设置成功(true)
- ret:
- 该方法的主要作用: 设置角色属性
- 具体使用案例如下:
lua
-- 设置攻击力300
local result = Actor:SetAttr(objId, RoleAttr.Atk, 300)
GetAttr
lua
-- 获取最大血量
local maxHp = Actor:GetAttr(objId, RoleAttr.MaxHp)
SetActorPermissions
- 参数及类型:
- 返回值及类型:
- ret:
bool
成功(true)
- ret:
- 该方法的主要作用: 设置对象权限
- 具体使用案例如下:
lua
local result = Actor:SetActorPermissions(objId, Ability.EnableBeattacked, true)
GetActorPermissions
- 参数及类型:
- 返回值及类型:
- ret:
bool
开关
- ret:
- 该方法的主要作用: 获取对象权限
- 具体使用案例如下:
lua
local state = Actor:GetActorPermissions(objId, Ability.Attack)
SetFaceYaw
lua
local result = Actor:SetFaceYaw(objId, 90)
GetFaceYaw
lua
local yaw = Actor:GetFaceYaw(objId)
SetFacePitch
- 参数及类型:
- 返回值及类型:
- ret:
bool
设置成功(true)
- ret:
- 该方法的主要作用: 设置actor视角仰望角度
- 具体使用案例如下:
lua
local pitch = Actor:GetFacePitch(Player:GetHostUin())
GetFacePitch
lua
local pitch = Actor:GetFacePitch(objid)
SetPosition
- 参数及类型:
- 返回值及类型:
- ret:
bool
设置成功(true)
- ret:
- 该方法的主要作用: 设置角色位置
- 具体使用案例如下:
lua
local result = Actor:SetPosition(objId, x, y, z)
GetPosition
lua
local x, y, z = Actor:GetPosition(objId)
ChangeCustomModel
lua
-- 改变玩家外观为萤火虫
local result = Actor:ChangeCustomModel(Player:GetHostUin(), "mob_3419")
RecoverinitialModel
lua
local result = Actor:RecoverinitialModel(Player:GetHostUin())
ActorHurt
- 参数及类型:
- 返回值及类型:
- ret:
bool
成功(true)
- ret:
- 该方法的主要作用: 使对象A对对象B造成伤害
- 具体使用案例如下:
lua
-- 玩家对生物造成近战伤害10点
local result = Actor:ActorHurt(Player:GetHostUin(), objId, 10, HurtType.Melee)
SetImmuneType
- 参数及类型:
- 返回值及类型:
- code:
bool
成功(true)
- code:
- 该方法的主要作用: 设置免疫伤害类型
- 具体使用案例如下:
lua
-- 设置免疫爆炸伤害
local result = Actor:SetImmuneType(objId, HurtType.Bomb, true)
-- 设置免疫所有伤害
Actor:SetImmuneType(objId, HurtType.All, true)
ChangActorMoveType
- 参数及类型:
- 返回值及类型: return:bool。如果角色没有设置的移动模式对应的能力,返回失败。
- 该方法的主要作用: 改变玩家移动方式
- 具体使用案例如下:
lua
local result = Actor:ChangActorMoveType(Player:GetHostUin(), MoveType.Flying)
GetActorMovementMode
lua
local moveType = Actor:GetActorMovementMode(Player:GetHostUin())
GetBoundSzie
lua
local size = Actor:GetBoundSzie(objId)
RandomFacadeID
- 参数及类型: 无
- 返回值及类型:
- ret:
string
随机外观ID
- ret:
- 该方法的主要作用: 随机一个外观获取其 id字符串
- 具体使用案例如下:
lua
local facadeID = Actor:RandomFacadeID()
GetObjType
- 参数及类型:
- objid:
number
生物objid
- objid:
- 返回值及类型:
- ret:itype获取结果 ObjType
- 该方法的主要作用: 判断对象是否是玩家/生物
- 具体使用案例如下:
lua
local objType = Actor:GetObjType(objId)
TryMoveToPos
- 参数及类型:
- 返回值及类型:
- ret:
bool
移动成功(true)
- ret:
- 该方法的主要作用: 尝试移动到某个位置走寻路 方块坐标
- 具体使用案例如下:
lua
local result = Actor:TryMoveToPos(objId, x + 10, y + 1, z, false, false)
AppendSpeed
- 参数及类型:
- 返回值及类型:
- code:
bool
成功(true)
- code:
- 该方法的主要作用: 给对象附加一个速度
- 具体使用案例如下:
lua
-- 给对象增加个x轴20,y轴10,z轴0的移动速度
local result = Actor:AppendSpeed(objId, 20, 10, 0)
FindNearestBlock
- 参数及类型:
- 返回值及类型:
- x,y,z:
number
方块坐标
- x,y,z:
- 该方法的主要作用: 寻找对象附近某个类型方块的最近位置
- 具体使用案例如下:
lua
--查找玩家50格子内最近的草块(草块ID为100)
local block = Actor:FindNearestBlock(Player:GetHostUin(), 100, 50)
GetEyeHeight
lua
local height = Actor:GetEyeHeight(objId)
ClearActorWithId
- 参数及类型: actorid:number:生物类型,bkill:bool:是否杀死生物(默认false,可以区分是否产生掉落物)
- 返回值及类型:
- ret:
bool
成功(true)
- ret:
- 该方法的主要作用: 清除生物ID为actorid的生物
- 具体使用案例如下:
lua
local result = Actor:ClearActorWithId(3400, false)
IsExist
lua
local isExist = Actor:IsExist(objId)
PlayAnim
- 参数及类型:
- 返回值及类型:
- ret:
bool
成功(true)
- ret:
- 该方法的主要作用: 对象播放动作
- 具体使用案例如下:
lua
local result = Actor:PlayAnim(objId, 100100, 1, AnimMode.Default)
PlayHandAnim
- 参数及类型:
- 返回值及类型:
- ret:
bool
成功(true)
- ret:
- 该方法的主要作用: 对象手持播放动作
- 具体使用案例如下:
lua
local result = Actor:PlayHandAnim(objId, 100100, 1, AnimMode.Once)
MountActor
- 参数及类型:
- 返回值及类型:
- ret:
bool
成功(true)
- ret:
- 该方法的主要作用: 角色骑乘
- 具体使用案例如下:
lua
local result = Actor:MountActor(Player:GetHostUin(), objId, true, true)
DisMountActor
lua
local result = Actor:DisMountActor(Player:GetHostUin())
PickupActor
- 参数及类型:
- 返回值及类型:
- ret:
bool
抓取成功(true)
- ret:
- 该方法的主要作用: 对象抓举对象
- 具体使用案例如下:
lua
local result = Actor:PickupActor(Player:GetHostUin(), objId)
TryPickupActorForward
- 参数及类型:
- 返回值及类型:
- ret:
bool
抓取成功(true)
- ret:
- 该方法的主要作用: 尝试抓取前方指定距离的对象
- 具体使用案例如下:
lua
local result = Actor:TryPickupActorForward(Player:GetHostUin(), 30)
DropActor
- 参数及类型:
- 返回值及类型:
- ret:
bool
投掷成功(true)
- ret:
- 该方法的主要作用: 尝试投掷角色
- 具体使用案例如下:
lua
local result = Actor:DropActor(Player:GetHostUin(), {x = 1, y = 2, z = 0}, true, 500, true)
EscapePickup
lua
self:ThreadWait(0.1)
local result = Actor:EscapePickup(objId)