• 注册后才能下载/购买插件!快来注册吧,注册即可免费下载 精翻插件 !【点我注册
  • RustSB.COM向广大野生Rust插件作者发出入驻邀请!详情请见[原创作者条约]

Hook​

CanCreateAbyssIslandAtPosition​

在系统尝试在某个位置创建深渊空岛时调用,用于检查该位置是否允许创建空岛。
代码:
object CanCreateAbyssIslandAtPosition(Vector3 position)
  • 返回 null - 允许在此位置创建空岛
  • 返回任何非 null 值 - 阻止在此位置创建空岛(系统会继续尝试其他位置)

参数名类型说明
positionVector3拟创建空岛的位置坐标

C#:
// 阻止在特定区域创建空岛
object CanCreateAbyssIslandAtPosition(Vector3 position)
{
    // 检查是否在禁区内(例如服务器小镇附近)
    Vector3 mainCityCenter = new Vector3(0, 0, 0);
    float forbiddenRadius = 500f;
    
    if (Vector3.Distance(position, mainCityCenter) < forbiddenRadius)
    {
        Puts($"阻止在服务器小镇附近 ({position}) 创建深渊空岛");
        return true; // 返回非 null 值阻止
    }
    
    // 检查是否与其他重要建筑冲突
    foreach (var monument in TerrainMeta.Path.Monuments)
    {
        if (Vector3.Distance(position, monument.transform.position) < 200f)
        {
            Puts($"阻止在遗迹附近 ({position}) 创建深渊空岛");
            return true;
        }
    }
    
    return null; // 允许创建
}

CanPlayerStartAbyss​

在玩家开始挑战深渊之前调用,用于检查是否允许玩家开始挑战。
C#:
object CanPlayerStartAbyss(BasePlayer player, string abyssType, string abyssName, string abyssID)
  • 返回 null - 允许玩家开始挑战
  • 返回任何非 null 值 - 阻止玩家开始挑战
参数名类型说明
playerBasePlayer尝试开始挑战的玩家对象
abyssTypestring深渊类型:"normal"(普通)、"limit"(限时)、"infinity"(无尽)
abyssNamestring深渊显示名称
abyssIDstring深渊唯一ID(无尽深渊为层数字符串)
C#:
// 阻止特定玩家开始挑战
object CanPlayerStartAbyss(BasePlayer player, string abyssType, string abyssName, string abyssID)
{
    // 检查玩家是否在黑名单中
    if (IsPlayerBlacklisted(player.UserIDString))
    {
        player.ChatMessage("你被禁止进入深渊挑战!");
        return true; // 返回非 null 值阻止
    }
    
    // 限制每天只能挑战普通深渊 3 次
    if (abyssType == "normal" && GetDailyAttempts(player) >= 3)
    {
        player.ChatMessage("今日普通深渊挑战次数已用完!");
        return true;
    }
    
    return null; // 允许挑战
}

OnPlayerStartAbyss​

在玩家成功开始深渊挑战后调用。
C#:
void OnPlayerStartAbyss(BasePlayer player, string abyssType, string abyssName, string abyssID)
返回值:无
参数名类型说明
playerBasePlayer开始挑战的玩家对象
abyssTypestring深渊类型:"normal"、"limit"、"infinity"
abyssNamestring深渊显示名称
abyssIDstring深渊唯一ID
C#:
void OnPlayerStartAbyss(BasePlayer player, string abyssType, string abyssName, string abyssID)
{
    Puts($"[深渊系统] {player.displayName} 开始挑战 {abyssName} ({abyssType})");
}

OnPlayerCompleteAbyss​

在玩家成功完成深渊挑战后调用。
C#:
void OnPlayerCompleteAbyss(BasePlayer player, string abyssType, string abyssName, string abyssID, float completionTime)
返回值:无
参数名类型说明
playerBasePlayer完成挑战的玩家对象
abyssTypestring深渊类型:"normal"、"limit"、"infinity"
abyssNamestring深渊显示名称
abyssIDstring深渊唯一ID
completionTimefloat完成用时(秒)
代码:
void OnPlayerCompleteAbyss(BasePlayer player, string abyssType, string abyssName, string abyssID, float completionTime)
{
    Puts($"[深渊系统] {player.displayName} 完成了 {abyssName},用时 {completionTime:F2} 秒");
}

OnPlayerFailAbyss​

在玩家深渊挑战失败时调用。
C#:
void OnPlayerFailAbyss(BasePlayer player, string abyssType, string abyssName, string abyssID, string reason)
返回值:无
参数名类型说明
playerBasePlayer挑战失败的玩家对象
abyssTypestring深渊类型:"normal"、"limit"、"infinity"
abyssNamestring深渊显示名称
abyssIDstring深渊唯一ID
reasonstring失败原因(如:"玩家死亡"、"时间耗尽"等)
C#:
void OnPlayerFailAbyss(BasePlayer player, string abyssType, string abyssName, string abyssID, string reason)
{
    Puts($"[深渊系统] {player.displayName} 在 {abyssName} 失败了,原因:{reason}");
}

CanPlayerBuyAbyssShopItem​

在玩家购买深渊精华商店商品前调用,用于检查是否允许购买。
C#:
object CanPlayerBuyAbyssShopItem(BasePlayer player, string itemName, string itemID, int price)
返回值
  • 返回 null - 允许玩家购买
  • 返回任何非 null 值 - 阻止玩家购买
参数
参数名类型说明
playerBasePlayer尝试购买的玩家对象
itemNamestring商品显示名称
itemIDstring商品唯一ID
priceint商品价格(深渊精华)
代码:
// 限制特定商品的购买条件
object CanPlayerBuyAbyssShopItem(BasePlayer player, string itemName, string itemID, int price)
{
    if (GetPlayerLevel(player) < 10)
    {
        player.ChatMessage("需要达到 10 级才能购买此商品!");
        return true;
    }
    return null; // 允许购买
}

OnPlayerBuyAbyssShopItem​

在玩家成功购买深渊精华商店商品后调用。
C#:
void OnPlayerBuyAbyssShopItem(BasePlayer player, string itemName, string itemID, int price)
返回值:无
参数名类型说明
playerBasePlayer购买商品的玩家对象
itemNamestring商品显示名称
itemIDstring商品唯一ID
priceint商品价格(深渊精华)
代码:
void OnPlayerBuyAbyssShopItem(BasePlayer player, string itemName, string itemID, int price)
{
    Puts($"[深渊商店] {player.displayName} 购买了 {itemName},花费 {price} 深渊精华");
}

API​

IsPlayerInAbyss​

描述:检查玩家是否正在挑战深渊。
参数
参数名类型说明
playerBasePlayer玩家对象

参数名类型说明
playerIdulong玩家ID
返回值:bool - 如果玩家正在挑战深渊返回 true,否则返回 false
示例
C#:
// 检查玩家是否在深渊中
bool isInAbyss = (bool)DWAbyss?.Call("IsPlayerInAbyss", player);
if (isInAbyss)
{
    player.ChatMessage("你正在挑战深渊,无法执行此操作!");
    return;
}

// 通过玩家ID检查
bool isInAbyss2 = (bool)DWAbyss?.Call("IsPlayerInAbyss", player.userID);

HasPlayerCompletedAbyssLevel​

描述:检查玩家是否已完成指定深渊。
参数
参数名类型说明
playerBasePlayer玩家对象
abyssTypestring深渊类型:"normal"(普通)、"limit"(限时)、"infinity"(无尽)
也支持中文:"普通"、"限时"、"无尽"
abyssIDstring深渊ID(普通/限时深渊传入配置的ID,无尽深渊传入层级数字字符串,如 "10" 表示第10层)
返回值:bool - 如果已完成返回 true,否则返回 false
示例
C#:
// 检查玩家是否完成了普通深渊第一层
bool hasCompleted = (bool)DWAbyss?.Call("HasPlayerCompletedAbyssLevel", player, "normal", "normal_001");

if (hasCompleted)
{
    player.ChatMessage("你已经完成过这个深渊了!");
}

// 检查玩家是否完成了无尽深渊第50层
bool hasCompleted50 = (bool)DWAbyss?.Call("HasPlayerCompletedAbyssLevel", player, "infinity", "50");

GetPlayerAbyssProgress​

描述:获取玩家的深渊挑战进度详细信息。
参数
参数名类型说明
playerBasePlayer玩家对象
abyssTypestring深渊类型:"normal"、"limit"、"infinity"
abyssIDstring深渊ID
返回值:Dictionary<string, object> - 包含进度信息的字典,如果未找到则返回 null
返回字典内容
普通/限时深渊
JSON:
{
    "hasCompleted": bool,              // 是否已完成
    "completionCount": int,            // 完成次数
    "bestTime": float,                 // 最佳完成时间(秒)
    "lastCompletionTime": string,      // 最后完成时间(格式:yyyy-MM-dd HH:mm:ss)
    "isCurrentlyInAbyss": bool,        // 当前是否在挑战中
    "currentWave": int,                // 当前波次(如果在挑战中)
    "totalWaves": int,                 // 总波次(如果在挑战中)
    "islandId": string,                // 空岛ID(如果在挑战中)
    "startTime": string,               // 开始时间(如果在挑战中)
    "isCompleted": bool                // 是否已完成当前挑战(如果在挑战中)
}
无尽深渊
JSON:
{
    "hasCompleted": bool,              // 是否已完成指定层级
    "currentLevel": int,               // 当前层级
    "highestLevel": int,               // 历史最高层级
    "totalCompletions": int,           // 总完成层数
    "isCurrentlyInAbyss": bool,        // 当前是否在挑战中
    ... // 其他挑战中的字段(同上)
}
示例
C#:
var progress = DWAbyss?.Call("GetPlayerAbyssProgress", player, "normal", "normal_001") as Dictionary<string, object>;

if (progress != null)
{
    bool hasCompleted = (bool)progress["hasCompleted"];
    int completionCount = (int)progress["completionCount"];
    float bestTime = (float)progress["bestTime"];
    
    player.ChatMessage($"完成状态:{(hasCompleted ? "已完成" : "未完成")}");
    player.ChatMessage($"完成次数:{completionCount}");
    player.ChatMessage($"最佳时间:{bestTime:F2} 秒");
    
    if ((bool)progress["isCurrentlyInAbyss"])
    {
        int currentWave = (int)progress["currentWave"];
        int totalWaves = (int)progress["totalWaves"];
        player.ChatMessage($"当前正在挑战中:第 {currentWave}/{totalWaves} 波");
    }
}

GetPlayerCurrentAbyssIsland​

描述:获取玩家当前正在挑战的深渊空岛信息。
参数
参数名类型说明
playerBasePlayer玩家对象
返回值:Dictionary<string, object> - 如果玩家正在挑战返回空岛信息字典,否则返回 null
返回字典内容
JSON:
{
    "islandId": string,                // 空岛唯一ID
    "playerId": ulong,                 // 玩家ID
    "playerName": string,              // 玩家名称
    "abyssType": string,               // 深渊类型
    "abyssName": string,               // 深渊名称
    "position": Vector3,               // 空岛位置
    "currentWave": int,                // 当前波次
    "totalWaves": int,                 // 总波次
    "isActive": bool,                  // 是否激活
    "isCompleted": bool,               // 是否已完成
    "creationTime": string,            // 创建时间
    "startTime": string,               // 开始时间
    "npcCount": int,                   // 当前NPC数量
    "islandEntityCount": int           // 空岛实体数量
}
示例
C#:
var island = DWAbyss?.Call("GetPlayerCurrentAbyssIsland", player) as Dictionary<string, object>;

if (island != null)
{
    string abyssName = (string)island["abyssName"];
    int currentWave = (int)island["currentWave"];
    int totalWaves = (int)island["totalWaves"];
    int npcCount = (int)island["npcCount"];
    Vector3 position = (Vector3)island["position"];
    
    player.ChatMessage($"你正在挑战:{abyssName}");
    player.ChatMessage($"当前进度:第 {currentWave}/{totalWaves} 波");
    player.ChatMessage($"剩余敌人:{npcCount}");
    player.ChatMessage($"空岛位置:{position}");
}
else
{
    player.ChatMessage("你当前没有在挑战深渊。");
}

IsAbyssNPC​

描述:检查指定NPC是否是深渊NPC。
参数

参数名类型说明
npcBaseEntityNPC实体
返回值:Dictionary<string, object> - 如果是深渊NPC返回对应的空岛信息字典,否则返回 null

返回字典内容
JSON:
{
    "isAbyssNPC": bool,                // 是否是深渊NPC(总是 true)
    "islandId": string,                // 所属空岛ID
    "playerId": ulong,                 // 空岛所有者玩家ID
    "playerName": string,              // 空岛所有者玩家名称
    "abyssType": string,               // 深渊类型
    "currentWave": int,                // 当前波次
    "isActive": bool                   // 空岛是否激活
}
示例
C#:
// 在 OnEntityDeath 中使用
void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
{
    var npcInfo = DWAbyss?.Call("IsAbyssNPC", entity) as Dictionary<string, object>;
    
    if (npcInfo != null)
    {
        // 这是深渊NPC
        string playerName = (string)npcInfo["playerName"];
        string abyssType = (string)npcInfo["abyssType"];
        
        Puts($"深渊NPC被击杀!所属玩家:{playerName},深渊类型:{abyssType}");
        
        // 可以阻止其他插件对深渊NPC的处理
        return;
    }
}

IsAbyssIslandEntity​

描述:检查指定实体是否是深渊空岛的实体(包括岛屿结构、NPC、玩家建造的实体)。
参数
参数名类型说明
entityBaseEntity实体对象
返回值:Dictionary<string, object> - 如果是空岛实体返回对应的空岛信息字典,否则返回 null
返回字典内容
JSON:
{
    "isIslandEntity": bool,            // 是否是空岛实体(总是 true)
    "entityType": string,              // 实体类型:"island_structure"(岛屿结构)、"npc"(NPC)、"player_built"(玩家建造)
    "islandId": string,                // 所属空岛ID
    "playerId": ulong,                 // 空岛所有者玩家ID
    "playerName": string,              // 空岛所有者玩家名称
    "abyssType": string,               // 深渊类型
    "currentWave": int,                // 当前波次(仅 NPC 类型)
    "isActive": bool                   // 空岛是否激活
}
示例
C#:
// 在 OnEntityKill 中使用
object OnEntityKill(BaseEntity entity)
{
    var entityInfo = DWAbyss?.Call("IsAbyssIslandEntity", entity) as Dictionary<string, object>;
    
    if (entityInfo != null)
    {
        string entityType = (string)entityInfo["entityType"];
        
        if (entityType == "island_structure")
        {
            // 阻止删除空岛结构
            Puts("阻止删除深渊空岛结构!");
            return true;
        }
        else if (entityType == "npc")
        {
            // 这是深渊NPC
            Puts("这是深渊NPC实体");
        }
        else if (entityType == "player_built")
        {
            // 这是玩家在空岛建造的实体
            Puts("这是玩家在深渊空岛建造的实体");
        }
    }
    
    return null;
}

API_GetPlayerAbyssEssence​

描述:获取玩家的深渊精华数量。
参数
参数名类型说明
playerBasePlayer玩家对象
返回值:int - 深渊精华数量
示例
C#:
int essence = (int)DWAbyss?.Call("API_GetPlayerAbyssEssence", player);
player.ChatMessage($"你当前拥有 {essence} 深渊精华");

API_AddPlayerAbyssEssence​

描述:给予玩家深渊精华。
参数
参数名类型说明
playerBasePlayer玩家对象
amountint数量
reasonstring原因(用于日志,可选,默认 "API调用")
返回值:无
示例
C#:
// 给予玩家 100 深渊精华
DWAbyss?.Call("API_AddPlayerAbyssEssence", player, 100, "每日登录奖励");
player.ChatMessage("你获得了 100 深渊精华!");

API_TakePlayerAbyssEssence​

描述:扣除玩家深渊精华。
参数
参数名类型说明
playerBasePlayer玩家对象
amountint数量
返回值:bool - 是否成功扣除(精华不足时返回 false)
示例
C#:
// 尝试扣除玩家 500 深渊精华
bool success = (bool)DWAbyss?.Call("API_TakePlayerAbyssEssence", player, 500);

if (success)
{
    player.ChatMessage("成功扣除 500 深渊精华!");
}
else
{
    player.ChatMessage("深渊精华不足!");
}