Skip to content

GN_Item 物品接口

GetEquipDurability

用途: 读取人物或英雄装备的当前耐久。

pascal
function This_Player.GetEquipDurability(
  Slot: Integer; IsHero: Boolean): Integer;
参数说明
Slot装备位置 0..15
IsHeroFalse 人物,True 当前已加载的英雄

返回内部耐久值,1000 对应显示耐久 1。空槽、位置无效、英雄未加载或耐久耗尽时返回 0

pascal
if This_Player.GetEquipDurability(1, False) > 0 then
  DebugOut('武器仍有耐久');

GN_Item_Give

用途: 创建物品,写入已注册的命名属性后放入背包。

pascal
function GN_Item_Give(Player: TPlayer; const ItemName: string;
  ForceBind: Boolean; const AttrsJson: string): Integer;
参数说明
Player当前有效的玩家对象
ItemName物品模板名称
ForceBindTrue 额外永久绑定;False 保留模板规则
AttrsJson命名属性 JSON;无属性可传 {}

JSON 示例:{"yanshen":{"element.1":100}}

返回值说明
1成功
-1玩家或参数无效
-2物品不存在
-3背包已满或入包失败
-4JSON、属性或编码无效
-5属性容量超限
pascal
GN_Item_Give(This_Player, '木剑', False, '{}');

GN_Item_GiveWithRare

用途: 同时写入命名属性和六槽极品值后发放物品。

pascal
function GN_Item_GiveWithRare(Player: TPlayer; const ItemName: string;
  ForceBind: Boolean; const AttrsJson: string;
  Rare1, Rare2, Rare3, Rare4, Rare5, Rare6: Int64): Integer;

返回值与 GN_Item_Give 相同。Int32 模式下每个极品值为 0..255;Int64 模式下为非负 Int64,越界返回 -1

GN_ItemRare_Get / GN_ItemRare_Set

用途: 按位置读取或设置物品的六槽极品值。

pascal
function GN_ItemRare_Get(Player: TPlayer;
  LocationType, ItemId, RareSlot: Integer;
  DefaultValue: Int64): Int64;
function GN_ItemRare_Set(Player: TPlayer;
  LocationType, ItemId, RareSlot: Integer;
  Value: Int64): Boolean;
LocationTypeItemId 的含义
0人物装备位置 0..15
1当前背包列表下标,从 0 开始
2物品 MakeIndex,先查装备再查背包

RareSlot1..6Value=0 清除该槽。读取失败返回 DefaultValue,设置失败返回 False。背包下标会变化,不应跨操作长期保存。

GN_ItemAttr 对象接口

用途: 通过物品对象读写已注册的命名数值属性。

pascal
function GN_ItemAttr_Get(Item: TBaseItem;
  const Namespace, Key: string; DefaultValue: Int64): Int64;
function GN_ItemAttr_Set(Item: TBaseItem;
  const Namespace, Key: string; Value: Int64): Integer;
function GN_ItemAttr_Remove(Item: TBaseItem;
  const Namespace, Key: string): Boolean;
function GN_ItemAttr_Exists(Item: TBaseItem;
  const Namespace, Key: string): Boolean;

SetValue=0 表示删除。

Set 返回值说明
1新增
2更新或删除
0没有变化
-1物品无效
-2属性未注册
-3超过 32 项
-4超过 128 字节编码容量
-5属性数据损坏或格式不支持

当前公开登记的命名属性为 yanshen / element.1element.17。保存属性只负责存储,不会自动产生战斗效果。

GN_ItemAttr 装备接口

用途: 按人物装备位置读写命名数值属性。

pascal
function GN_ItemAttr_GetEquipped(Player: TPlayer; Slot: Integer;
  IsHero: Boolean; const Namespace, Key: string;
  DefaultValue: Int64): Int64;
function GN_ItemAttr_SetEquipped(Player: TPlayer; Slot: Integer;
  IsHero: Boolean; const Namespace, Key: string;
  Value: Int64): Integer;
function GN_ItemAttr_RemoveEquipped(Player: TPlayer; Slot: Integer;
  IsHero: Boolean; const Namespace, Key: string): Boolean;
function GN_ItemAttr_ExistsEquipped(Player: TPlayer; Slot: Integer;
  IsHero: Boolean; const Namespace, Key: string): Boolean;

返回规则与对象接口相同。当前只支持 IsHero=False;传入 True 会报告该能力不可用。

pascal
GN_ItemAttr_ExistsEquipped(
  This_Player, 1, False, 'yanshen', 'element.1');

GOW-Next 引擎开发手册 · 原版 API 兼容列表持续核验中