Skip to content

Commit

Permalink
zzre: Fix crash for unimplemented NPC script instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Helco committed Jan 21, 2024
1 parent cc65d2c commit d2a392d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion zzre/game/Zanzarah.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using Veldrid;
using zzio.vfs;
Expand Down Expand Up @@ -43,7 +44,7 @@ public Zanzarah(ITagContainer diContainer, IZanzarahContainer zanzarahContainer)
tagContainer.AddTag(UI = new UI(this));
this.zanzarahContainer = zanzarahContainer;

var savegame = new zzio.Savegame() { sceneId = 0210 };
var savegame = new zzio.Savegame() { sceneId = 3600 };
/*using (var fileStream = new System.IO.FileStream(@"C:\dev\zanzarah\Save\_0004.dat", System.IO.FileMode.Open, System.IO.FileAccess.Read))
using (var reader = new System.IO.BinaryReader(fileStream))
savegame = zzio.Savegame.ReadNew(reader);
Expand Down
11 changes: 11 additions & 0 deletions zzre/game/systems/npc/NPCScript.Execute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ partial class NPCScript
private const string CmdRevive = "b";
private const string CmdLookAtTrigger = "c";
private const string CmdPlaySound = "e";
private const string CmdStartActorEffect = "g";
private const string CmdEndActorEffect = "h";

protected override OpReturn Execute(in DefaultEcs.Entity entity, ref components.ScriptExecution script, RawInstruction instruction)
{
Expand Down Expand Up @@ -198,6 +200,15 @@ protected override OpReturn Execute(in DefaultEcs.Entity entity, ref components.
PlaySound(entity, id);
return OpReturn.Continue;

case CmdStartActorEffect:
var effectI = int.Parse(args[0]);
StartActorEffect(entity, effectI);
return OpReturn.Continue;

case CmdEndActorEffect:
EndActorEffect(entity);
return OpReturn.Continue;

default: return OpReturn.UnknownInstruction;
}
}
Expand Down
10 changes: 10 additions & 0 deletions zzre/game/systems/npc/NPCScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,14 @@ private void PlaySound(DefaultEcs.Entity entity, int soundId)
{
Console.WriteLine("Warning: unimplemented NPC instruction \"playSound\"");
}

private void StartActorEffect(DefaultEcs.Entity entity, int effectId)
{
Console.WriteLine("Warning unimplemented NPC instruction \"startActorEffect\"");
}

private void EndActorEffect(DefaultEcs.Entity entity)
{
Console.WriteLine("Warning unimplemented NPC instruction \"endActorEffect\"");
}
}

0 comments on commit d2a392d

Please sign in to comment.