Skip to content

Commit 18a33b2

Browse files
authored
Merge pull request #77 from hocha113/8075
8075
2 parents cfc8add + 9848254 commit 18a33b2

File tree

14 files changed

+23
-18
lines changed

14 files changed

+23
-18
lines changed

Content/ADV/Common/BaseDamageTracker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public override void OnHitByProjectile(NPC npc, Projectile projectile, NPC.HitIn
165165
}
166166
}
167167

168-
public sealed override void OnKill(NPC npc) {
168+
public sealed override void OnNPCDeath(NPC npc) {
169169
if (IsTargetByID(npc)) {//这个判定是不必要的,不过还是写上吧
170170
Check(npc);//作为 DeathTrackingNPC 的子类,OnKill会被客户端调用,所以这里的运行不会出现问题
171171
}

Content/ADV/Common/DeathTrackingNPC.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ namespace CalamityOverhaul.Content.ADV.Common
66
internal class DeathTrackingNPC : GlobalNPC
77
{
88
public override bool InstancePerEntity => true;
9-
9+
private bool _deathHandled = false;
1010
public override void HitEffect(NPC npc, NPC.HitInfo hit) {
11-
if (npc.life > 0) {
11+
if (_deathHandled) {
1212
return;
1313
}
14-
OnKill(npc);
14+
if (npc.life <= 0 || !npc.active) {//有些情况下是手动设置的死亡,这时life可能不为0,但active会被设为false
15+
_deathHandled = true;
16+
OnNPCDeath(npc);
17+
}
1518
}
16-
1719
/// <summary>
1820
/// 当NPC被击杀时调用,在客户端或者服务端上均会运行
1921
/// </summary>
2022
/// <param name="npc"></param>
21-
public new virtual void OnKill(NPC npc) { }
23+
public virtual void OnNPCDeath(NPC npc) { }
2224
}
2325
}

Content/ADV/Common/GiftScenarioBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void IWorldInfo.OnWorldLoad() {
1818

1919
public override bool AppliesToEntity(NPC entity, bool lateInstantiation) => GiftScenarioBase.SpawnedDic.Keys.Any(g => g.TargetBossID == entity.type);
2020

21-
public override void OnKill(NPC npc) {
21+
public override void OnNPCDeath(NPC npc) {
2222
if (!CWRRef.GetBossRushActive()//Boss Rush时不触发礼物场景
2323
&& GiftScenarioBase.BossIDToInds.TryGetValue(npc.type, out var giftScenarioBase)
2424
&& giftScenarioBase.CanSpawned()) {

Content/ADV/Scenarios/Abysses/OldDukes/ModifyOldDuke.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public override bool CanOverride() {
7171
if (!CWRRef.Has) {//如果没有灾厄Mod,就不覆盖AI,避免潜在的兼容性问题
7272
return false;
7373
}
74+
if (!VaultUtils.isSinglePlayer) {
75+
return false;//本AI包含多个需要本地玩家驱动的状态转换和场景触发,在多人模式下可能会出现同步问题,暂时只在单人模式启用
76+
}
7477
if (CWRRef.GetBossRushActive()) {
7578
return false;
7679
}

Content/ADV/Scenarios/SupCal/FirstMetSupCal.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ void IWorldInfo.OnWorldLoad() {
261261
RandomTimer = 0;
262262
}
263263
public override bool AppliesToEntity(NPC entity, bool lateInstantiation) => entity.type == CWRID.NPC_CalamitasClone;//应用于目标NPC
264-
public override void OnKill(NPC npc) {
264+
public override void OnNPCDeath(NPC npc) {
265265
if (npc.type == CWRID.NPC_CalamitasClone && !CWRWorld.BossRush) {
266266
Spawned = true;
267267
RandomTimer = 60 * Main.rand.Next(3, 5);//给一个3到5秒的缓冲时间,打完立刻触发不太合适

Content/ADV/Scenarios/SupCal/ModifySupCalNPCs/ModifySupCalNPC.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace CalamityOverhaul.Content.ADV.Scenarios.SupCal.ModifySupCalNPCs
1313
internal class TraceSupCalDeath : DeathTrackingNPC
1414
{
1515
internal static bool SupCalDefeated { get; set; }
16-
public override void OnKill(NPC npc) {
16+
public override void OnNPCDeath(NPC npc) {
1717
if (npc.type == CWRID.NPC_SupremeCalamitas) {
1818
SupCalDefeated = true;
1919
}

Content/ADV/Scenarios/SupCal/Quest/PallbearerQuest/SupCalMoonLordReward.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void IWorldInfo.OnWorldLoad() {
148148
RandomTimer = 0;
149149
}
150150
public override bool AppliesToEntity(NPC entity, bool lateInstantiation) => entity.type == NPCID.MoonLordCore;
151-
public override void OnKill(NPC npc) {
151+
public override void OnNPCDeath(NPC npc) {
152152
if (npc.type == NPCID.MoonLordCore && !CWRWorld.BossRush) {
153153
Spawned = true;
154154
RandomTimer = 60 * Main.rand.Next(3, 5);//给一个3到5秒的缓冲时间,打完立刻触发不太合适

Content/ADV/Scenarios/SupCal/SupCalDefeat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void IWorldInfo.OnWorldLoad() {
9393
RandomTimer = 0;
9494
}
9595
public override bool AppliesToEntity(NPC entity, bool lateInstantiation) => entity.type == CWRID.NPC_SupremeCalamitas;
96-
public override void OnKill(NPC npc) {
96+
public override void OnNPCDeath(NPC npc) {
9797
if (npc.type == CWRID.NPC_SupremeCalamitas && Main.LocalPlayer.GetItem().type == HalibutOverride.ID && !CWRWorld.BossRush) {
9898
Spawned = true;
9999
RandomTimer = 60 * Main.rand.Next(3, 5);//给一个3到5秒的缓冲时间,打完立刻触发不太合适

Content/ADV/Scenarios/SupCal/SupCalPlayerDefeat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public override bool PreAI(NPC npc) {
166166
return true;
167167
}
168168

169-
public override void OnKill(NPC npc) {
169+
public override void OnNPCDeath(NPC npc) {
170170
if (npc.type == CWRID.NPC_SupremeCalamitas) {
171171
//Boss被击杀时重置状态
172172
hasRecordedDeath = false;

Content/ADV/Scenarios/SupCal/SupCalVictory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void IWorldInfo.OnWorldLoad() {
137137

138138
public override bool AppliesToEntity(NPC entity, bool lateInstantiation) => entity.type == CWRID.NPC_SupremeCalamitas;
139139

140-
public override void OnKill(NPC npc) {
140+
public override void OnNPCDeath(NPC npc) {
141141
if (FirstMetSupCal.ThisIsToFight && npc.type == CWRID.NPC_SupremeCalamitas) {
142142
Player player = Main.LocalPlayer;
143143
if (player.TryGetOverride<HalibutPlayer>(out var halibutPlayer)) {

0 commit comments

Comments
 (0)