跳转至

视野函数

视野系统控制每个玩家可见的对象(玩家、怪物、物品)。这些函数管理视野的创建、销毁和同步。

高级用法

视野函数属于底层函数,主要用于自定义传送逻辑、副本地图或强制刷新外观。使用不当可能导致隐身玩家或客户端不同步。


gObjSetViewport(aIndex, state)

设置指定对象的视野状态,更新附近玩家看到它的方式。

  • 参数:
    • aIndex (integer): 对象索引。
    • state (integer): 视野状态(VIEWPORT_CREATEVIEWPORT_DESTROYVIEWPORT_SEND)。
  • 返回值: void
-- 强制视野状态变更
gObjSetViewport(aIndex, 1)

gObjViewportClose(lpObj)

关闭玩家的视野。从所有附近玩家和物品中清除其可见性。

  • 参数:
    • lpObj (GameObject): 玩家对象。
  • 返回值: void
-- 传送前关闭视野
gObjViewportClose(player)
gObjTeleport(aIndex, 0, 130, 130)

gObjClearViewport(lpObj)

完全清除给定对象的所有视野数据 — 从其视野列表中移除所有已追踪的玩家、怪物和物品。

  • 参数:
    • lpObj (GameObject): 玩家对象。
  • 返回值: void
gObjClearViewport(player)

gObjClearViewportOfMine(lpObj)

从所有其他玩家的视野中移除此对象。其他玩家将停止看到此对象,直到视野重建。

  • 参数:
    • lpObj (GameObject): 玩家对象。
  • 返回值: void
-- 使玩家暂时对其他人不可见
gObjClearViewportOfMine(player)

gObjViewportListProtocolDestroy(lpObj)

向客户端发送视野销毁数据包,从玩家屏幕上移除附近的对象。

  • 参数:
    • lpObj (GameObject): 玩家对象。
  • 返回值: void
gObjViewportListProtocolDestroy(player)

gObjViewportListProtocolCreate(lpObj)

向客户端发送视野创建数据包,刷新所有附近对象的外观。适用于更改玩家装备、职业或视觉状态后使用。

  • 参数:
    • lpObj (GameObject): 玩家对象。
  • 返回值: void
-- 为附近所有人刷新玩家外观
gObjViewportListProtocolCreate(player)

gObjViewportListProtocol(aIndex)

向玩家发送完整的视野协议数据 — 销毁旧视野,然后发送所有玩家、怪物、召唤兽、物品、公会和阵营数据。

  • 参数:
    • aIndex (integer): 对象索引。
  • 返回值: void
-- 完全重建玩家视野
gObjViewportListProtocol(aIndex)

gObjViewportListDestroy(aIndex)

销毁地图视野范围内的所有视野条目。处理玩家、怪物和物品视野。

  • 参数:
    • aIndex (integer): 对象索引。
  • 返回值: void
gObjViewportListDestroy(aIndex)

gObjViewportListCreate(aIndex)

为地图视野范围内的所有对象创建视野条目。将附近的玩家、怪物和物品添加到视野中。

  • 参数:
    • aIndex (integer): 对象索引。
  • 返回值: void
gObjViewportListCreate(aIndex)

gObjViewportAttackAreaUsed(aIndex, bIndex)

检查两个对象之间的攻击区域是否在视野范围内。

  • 参数:
    • aIndex (integer): 攻击者对象索引。
    • bIndex (integer): 目标对象索引。
  • 返回值: boolean — 目标在攻击者视野范围内时返回 true
if gObjViewportAttackAreaUsed(aIndex, bIndex) then
    -- 目标在视野范围内,继续攻击
end