Skip to content

Commit

Permalink
Event script API and ElseThread is .seq
Browse files Browse the repository at this point in the history
  • Loading branch information
Tirlititi committed Sep 14, 2023
1 parent cfc7cce commit 935e207
Show file tree
Hide file tree
Showing 32 changed files with 913 additions and 548 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ public class CalcStack
{
public Boolean push(Int32 arg0)
{
if (this.topOfStackID >= (Int32)this.stack.Length - 1)
{
if (this.topOfStackID >= this.stack.Length - 1)
return false;
}
this.stack[this.topOfStackID] = arg0;
this.topOfStackID++;
return true;
Expand All @@ -20,7 +18,7 @@ public Boolean pop(out Int32 output)
{
if (this.topOfStackID == 0)
{
Log.Error($"[{nameof(CalcStack)}.{nameof(pop)}]if (this.topOfStackID == 0)");
Log.Error($"[{nameof(CalcStack)}.{nameof(pop)}] this.topOfStackID == 0");
output = default;
return false;
}
Expand All @@ -31,30 +29,24 @@ public Boolean pop(out Int32 output)

public Boolean advanceTopOfStack()
{
if (this.topOfStackID >= (Int32)this.stack.Length - 1)
{
if (this.topOfStackID >= this.stack.Length - 1)
return false;
}
this.topOfStackID++;
return true;
}

public Boolean retreatTopOfStack()
{
if (this.topOfStackID == 0)
{
return false;
}
this.topOfStackID--;
return true;
}

public void emptyCalcStack()
{
for (Int32 i = 0; i < (Int32)this.stack.Length; i++)
{
for (Int32 i = 0; i < this.stack.Length; i++)
this.stack[i] = 0;
}
this.topOfStackID = 0;
}

Expand All @@ -68,10 +60,8 @@ public Int32 getValueAtOffset(Int32 offset)
return this.stack[this.topOfStackID + offset];
}

private const Int32 stackSize = 16;

private Int32[] stack = new Int32[16];

private const Int32 STACK_SIZE = 16;
private Int32[] stack = new Int32[STACK_SIZE];
private Int32 topOfStackID;
}
}

1 comment on commit 935e207

@Tirlititi
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this commit:

  • Add ElseThread code in .seq files (related to Battle SFX Sequence).
  • Add multiple operations for event scripts that can be modified with Hades Workshop. An update of Hades Workshop reflects these new possibilities here.
  • In the party selection menu, an empty line can be present to make room for removing characters from the party, to really address the initial request of Request: Remove the 4 man party restriction #235.
  • Add an API (C#, NCalc and event scripts) to get the treasure hunter points, as computed by the scripts in Daguerreo and Treno.
  • Some ground work for using battle SFX effects in fields and SPS effects from anywhere. I'm not sure if I'll carry on though as it seems to be tedious to implement (although that would be cool to have the possibility to have cutscenes in which Thunder or Stop is casted).

About ElseThread:
It can be used much like the usual if then else for threads, with .seq code like this:

StartThread: Condition= GetRandom(0, 3) == 0 ; Sync
	// Do something with 33% chances
ElseThread: Condition= GetRandom(0, 2) == 0 ; Sync
	// Do something else with 33% chances
ElseThread: Sync
	// Do something else with 33% chances
EndThread

Not only it allows alternatives like the above but it's also more robust than what is used so far for non-random alternatives - a block with a condition and another separated block with the opposite condition - because the condition requirement could change if the threads are run synchronously.

About SPS effects:
SPS are the little 3D effects in fields, like particle emitters, glowing orbs, teleportation effects... They are field-specific, so normally you can't use eg. Vivi's fire effect melting the ice of the Ice Cavern in other fields. Now, It is possible to change the SPS field origin with the following script code:

RunSPSCode( 0, 129, FIELD_ID, 0, 0 )

After using that in any field, the SPS originating from FIELD_ID can be used. However, currently, only the SPS originating from 1 field at a time can be used. So "importing" the SPS from another field will destroy the SPS of the current field. At least that restriction I would like to remove.

About extended script operations:
People who learnt how to modify event scripts in Hades Workshop can now use a couple more operations. I made a short video showcase with several of the added features.
Link to video
Link to script code

The additional API is defined for Hades Workshop in a file ScriptAPI.txt. The new functions appear in the function list in the tool.
In most situations, you shouldn't really edit ScriptAPI.txt yourself because the API inside has to match the API coded in Memoria. So unless you're adding your own API in your own fork of Memoria, editing Hades Workshop's additional API will lead to bugs.

Please sign in to comment.