对象搜索与验证¶
gObjFind(name)¶
通过角色名查找已连接的玩家。返回 GameObject 或 nil。
local target = gObjFind("SomePlayer")
if target then
LogAdd(LOG_BLUE, "Found " .. target.Name .. " at map " .. target.Map)
end
gObjCalcDistance(lpObj, lpTarget) / gObjCalcDistance(x, y, tx, ty)¶
计算两个对象或两个坐标对之间的距离。
- 返回值:
number(指针无效时返回 -1)
local dist = gObjCalcDistance(player, target)
if dist <= 3 then
LogAdd(LOG_GREEN, "Target is within melee range.")
end
-- 坐标版本
local dist2 = gObjCalcDistance(100, 100, 105, 105)
FindMonsterClassInVP(lpObj, class, distance)¶
检查对象视野中指定距离内是否存在指定类别的怪物。
- 返回值:
boolean
FindMonsterCharacterInVP(lpObj, bIndex)¶
检查对象视野中是否存在指定的对象索引。
- 返回值:
boolean
if FindMonsterCharacterInVP(monster, player.Index) then
LogAdd(LOG_RED, "Player is visible to the monster.")
end
gObjIsConnected(aIndex) / gObjIsConnected(aIndex, dbNumber)¶
指定索引的对象已连接时返回 true。双参数版本还会检查数据库编号。
gObjIsConnectedGP(aIndex)¶
对象处于 GamePlay 状态时返回 true。
gObjIsConnectedGS(aIndex)¶
对象处于 GameServer 连接状态时返回 true。
gObjIsNameValid(aIndex, name)¶
验证指定 aIndex 的对象是否拥有给定的角色名。
- 返回值:
boolean
gObjIsAccountValid(aIndex, account, accountIndex, [login])¶
验证指定对象的账号名和账号索引。
- 返回值:
boolean
gObjSearchDuplicateItem(lpObj) / gObjSearchDuplicateItem(lpObj, serial)¶
搜索玩家背包中的重复物品。单参数版本检查所有物品;双参数版本检查指定序列号。
- 返回值:
boolean
Help