Skip to content

Commit

Permalink
Quick ai fix to fix npcs with AI_DefaultNew & make all ai able to pro…
Browse files Browse the repository at this point in the history
…gress through the script (#94)

* quick ai fix to get its initial state unstuck

* switched npcs with AI_DefaultNew to use AI_Default since DefaultNew is missing
  • Loading branch information
mettaursp authored May 10, 2024
1 parent 51d9ce5 commit 758ad19
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Maple2.Server.Game/Model/Field/Actor/ActorState/AiState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public bool SetAi(string name) {
return false;
}

if (name == "AI_DefaultNew.xml") {
name = "AI_Default.xml";
}

AiMetadata? metadata;

if (!actor.Field.AiMetadata.TryGet(name, out metadata)) {
Expand All @@ -54,7 +58,8 @@ public void Update(long tickCount) {
if (nextUpdate > tickCount) {
return;
}
if (AiMetadata is null || lastEvaluated != AiMetadata) {

if (AiMetadata is null) {
if (actor.Value.Metadata.AiPath != "") {
actor.AppendDebugMessage("Missing AI\n");
actor.AppendDebugMessage(actor.Value.Metadata.AiPath);
Expand All @@ -65,6 +70,10 @@ public void Update(long tickCount) {
return;
}

if (lastEvaluated != AiMetadata) {
aiStack.Clear();
}

lastEvaluated = AiMetadata;

if (aiStack.Count == 0) {
Expand Down

0 comments on commit 758ad19

Please sign in to comment.