object CanCreateAbyssIslandAtPosition(Vector3 position)
| 参数名 | 类型 | 说明 |
|---|---|---|
| position | Vector3 | 拟创建空岛的位置坐标 |
// 阻止在特定区域创建空岛
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; // 允许创建
}
object CanPlayerStartAbyss(BasePlayer player, string abyssType, string abyssName, string abyssID)
| 参数名 | 类型 | 说明 |
|---|---|---|
| player | BasePlayer | 尝试开始挑战的玩家对象 |
| abyssType | string | 深渊类型:"normal"(普通)、"limit"(限时)、"infinity"(无尽) |
| abyssName | string | 深渊显示名称 |
| abyssID | string | 深渊唯一ID(无尽深渊为层数字符串) |
// 阻止特定玩家开始挑战
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; // 允许挑战
}
void OnPlayerStartAbyss(BasePlayer player, string abyssType, string abyssName, string abyssID)
| 参数名 | 类型 | 说明 |
|---|---|---|
| player | BasePlayer | 开始挑战的玩家对象 |
| abyssType | string | 深渊类型:"normal"、"limit"、"infinity" |
| abyssName | string | 深渊显示名称 |
| abyssID | string | 深渊唯一ID |
void OnPlayerStartAbyss(BasePlayer player, string abyssType, string abyssName, string abyssID)
{
Puts($"[深渊系统] {player.displayName} 开始挑战 {abyssName} ({abyssType})");
}
void OnPlayerCompleteAbyss(BasePlayer player, string abyssType, string abyssName, string abyssID, float completionTime)
| 参数名 | 类型 | 说明 |
|---|---|---|
| player | BasePlayer | 完成挑战的玩家对象 |
| abyssType | string | 深渊类型:"normal"、"limit"、"infinity" |
| abyssName | string | 深渊显示名称 |
| abyssID | string | 深渊唯一ID |
| completionTime | float | 完成用时(秒) |
void OnPlayerCompleteAbyss(BasePlayer player, string abyssType, string abyssName, string abyssID, float completionTime)
{
Puts($"[深渊系统] {player.displayName} 完成了 {abyssName},用时 {completionTime:F2} 秒");
}
void OnPlayerFailAbyss(BasePlayer player, string abyssType, string abyssName, string abyssID, string reason)
| 参数名 | 类型 | 说明 |
|---|---|---|
| player | BasePlayer | 挑战失败的玩家对象 |
| abyssType | string | 深渊类型:"normal"、"limit"、"infinity" |
| abyssName | string | 深渊显示名称 |
| abyssID | string | 深渊唯一ID |
| reason | string | 失败原因(如:"玩家死亡"、"时间耗尽"等) |
void OnPlayerFailAbyss(BasePlayer player, string abyssType, string abyssName, string abyssID, string reason)
{
Puts($"[深渊系统] {player.displayName} 在 {abyssName} 失败了,原因:{reason}");
}
object CanPlayerBuyAbyssShopItem(BasePlayer player, string itemName, string itemID, int price)
| 参数名 | 类型 | 说明 |
|---|---|---|
| player | BasePlayer | 尝试购买的玩家对象 |
| itemName | string | 商品显示名称 |
| itemID | string | 商品唯一ID |
| price | int | 商品价格(深渊精华) |
// 限制特定商品的购买条件
object CanPlayerBuyAbyssShopItem(BasePlayer player, string itemName, string itemID, int price)
{
if (GetPlayerLevel(player) < 10)
{
player.ChatMessage("需要达到 10 级才能购买此商品!");
return true;
}
return null; // 允许购买
}
void OnPlayerBuyAbyssShopItem(BasePlayer player, string itemName, string itemID, int price)
| 参数名 | 类型 | 说明 |
|---|---|---|
| player | BasePlayer | 购买商品的玩家对象 |
| itemName | string | 商品显示名称 |
| itemID | string | 商品唯一ID |
| price | int | 商品价格(深渊精华) |
void OnPlayerBuyAbyssShopItem(BasePlayer player, string itemName, string itemID, int price)
{
Puts($"[深渊商店] {player.displayName} 购买了 {itemName},花费 {price} 深渊精华");
}
| 参数名 | 类型 | 说明 |
|---|---|---|
| player | BasePlayer | 玩家对象 |
| 参数名 | 类型 | 说明 |
|---|---|---|
| playerId | ulong | 玩家ID |
// 检查玩家是否在深渊中
bool isInAbyss = (bool)DWAbyss?.Call("IsPlayerInAbyss", player);
if (isInAbyss)
{
player.ChatMessage("你正在挑战深渊,无法执行此操作!");
return;
}
// 通过玩家ID检查
bool isInAbyss2 = (bool)DWAbyss?.Call("IsPlayerInAbyss", player.userID);
| 参数名 | 类型 | 说明 |
|---|---|---|
| player | BasePlayer | 玩家对象 |
| abyssType | string | 深渊类型:"normal"(普通)、"limit"(限时)、"infinity"(无尽) 也支持中文:"普通"、"限时"、"无尽" |
| abyssID | string | 深渊ID(普通/限时深渊传入配置的ID,无尽深渊传入层级数字字符串,如 "10" 表示第10层) |
// 检查玩家是否完成了普通深渊第一层
bool hasCompleted = (bool)DWAbyss?.Call("HasPlayerCompletedAbyssLevel", player, "normal", "normal_001");
if (hasCompleted)
{
player.ChatMessage("你已经完成过这个深渊了!");
}
// 检查玩家是否完成了无尽深渊第50层
bool hasCompleted50 = (bool)DWAbyss?.Call("HasPlayerCompletedAbyssLevel", player, "infinity", "50");
| 参数名 | 类型 | 说明 |
|---|---|---|
| player | BasePlayer | 玩家对象 |
| abyssType | string | 深渊类型:"normal"、"limit"、"infinity" |
| abyssID | string | 深渊ID |
{
"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 // 是否已完成当前挑战(如果在挑战中)
}
{
"hasCompleted": bool, // 是否已完成指定层级
"currentLevel": int, // 当前层级
"highestLevel": int, // 历史最高层级
"totalCompletions": int, // 总完成层数
"isCurrentlyInAbyss": bool, // 当前是否在挑战中
... // 其他挑战中的字段(同上)
}
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} 波");
}
}
| 参数名 | 类型 | 说明 |
|---|---|---|
| player | BasePlayer | 玩家对象 |
{
"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 // 空岛实体数量
}
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("你当前没有在挑战深渊。");
}
| 参数名 | 类型 | 说明 |
|---|---|---|
| npc | BaseEntity | NPC实体 |
{
"isAbyssNPC": bool, // 是否是深渊NPC(总是 true)
"islandId": string, // 所属空岛ID
"playerId": ulong, // 空岛所有者玩家ID
"playerName": string, // 空岛所有者玩家名称
"abyssType": string, // 深渊类型
"currentWave": int, // 当前波次
"isActive": bool // 空岛是否激活
}
// 在 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;
}
}
| 参数名 | 类型 | 说明 |
|---|---|---|
| entity | BaseEntity | 实体对象 |
{
"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 // 空岛是否激活
}
// 在 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;
}
| 参数名 | 类型 | 说明 |
|---|---|---|
| player | BasePlayer | 玩家对象 |
int essence = (int)DWAbyss?.Call("API_GetPlayerAbyssEssence", player);
player.ChatMessage($"你当前拥有 {essence} 深渊精华");
| 参数名 | 类型 | 说明 |
|---|---|---|
| player | BasePlayer | 玩家对象 |
| amount | int | 数量 |
| reason | string | 原因(用于日志,可选,默认 "API调用") |
// 给予玩家 100 深渊精华
DWAbyss?.Call("API_AddPlayerAbyssEssence", player, 100, "每日登录奖励");
player.ChatMessage("你获得了 100 深渊精华!");
| 参数名 | 类型 | 说明 |
|---|---|---|
| player | BasePlayer | 玩家对象 |
| amount | int | 数量 |
// 尝试扣除玩家 500 深渊精华
bool success = (bool)DWAbyss?.Call("API_TakePlayerAbyssEssence", player, 500);
if (success)
{
player.ChatMessage("成功扣除 500 深渊精华!");
}
else
{
player.ChatMessage("深渊精华不足!");
}