Skip to content

Commit 46480ed

Browse files
authored
Merge pull request #1 from gmriggs/master
merge latest changes from gmriggs/EmoteScript -> ACEmulator/EmoteScript main repo
2 parents 1c88fb2 + 15d4840 commit 46480ed

File tree

7 files changed

+27
-4
lines changed

7 files changed

+27
-4
lines changed

EmoteScript.Tests/Scripts/AllEmotes.es

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ InqOwnsItems: 1234, StackSize: 5
7777
InqPackSpace
7878
InqPackSpace: 2
7979
InqQuest: TestQuest
80+
InqQuestBitsOn: TestQuest, 0x80
81+
InqQuestBitsOff: TestQuest, 0x80
8082
InqQuestSolves: TestQuest, 1-5
8183
InqRawAttributeStat: Strength, 50-100
8284
InqRawAttributeStat: Strength, 50
@@ -129,6 +131,8 @@ SetInt64Stat: TotalExperience = 500,000
129131
SetIntStat: NumDeaths, 5
130132
SetMyQuestCompletions: TestQuest, 5
131133
SetQuestCompletions: TestQuest, 5
134+
SetQuestBitsOn: TestQuest, 0x80
135+
SetQuestBitsOff: TestQuest, 0x80
132136
SetSanctuaryPosition: 0x12340001 [1 2 3] 1 0 0 0
133137
Sound: Sound.Wound1
134138
Sound: Wound1

EmoteScriptLib/Converter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ public static List<string> BuildScript(Emote emote, int depth)
260260

261261
var indent = string.Concat(Enumerable.Repeat(" ", depth));
262262

263+
// TODO: detect when fields are used outside of fluent syntax, and fallback on kvp syntax
263264
scriptLines.Add($"{indent}- {emote.ToString(true)}");
264265

265266
if (emote.Branches != null)

EmoteScriptLib/Entity/Emote.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,11 @@ public string GetFluentString()
846846
case EmoteType.SetMyQuestCompletions:
847847
case EmoteType.SetQuestCompletions:
848848
return $"{Message}, {Amount}";
849+
case EmoteType.SetQuestBitsOn:
850+
case EmoteType.SetQuestBitsOff:
851+
case EmoteType.InqQuestBitsOn:
852+
case EmoteType.InqQuestBitsOff:
853+
return $"{Message}, 0x{Amount:X}";
849854

850855
case EmoteType.Turn:
851856
var rotation = new Quaternion(AnglesX ?? 0, AnglesY ?? 0, AnglesZ ?? 0, AnglesW ?? 1);

EmoteScriptLib/JSON/Emote.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public Emote(EmoteScriptLib.Emote emote)
4040
{
4141
type = (uint)emote.Type;
4242
delay = emote.Delay ?? 0.0f;
43-
extent = emote.Extent ?? 1.0f;
43+
extent = emote.Extent ?? (emote.Type == Entity.Enum.EmoteType.Say ? 0.0f : 1.0f);
4444
amount = (uint?)emote.Amount;
4545
motion = (uint?)emote.Motion;
4646
msg = emote.Message;

EmoteScriptLib/Parser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ public static float DegreesToRads(float degrees)
856856
{
857857
// heading
858858
var rads = DegreesToRads(degrees);
859-
return Quaternion.CreateFromAxisAngle(Vector3.UnitY, rads);
859+
return Quaternion.CreateFromAxisAngle(Vector3.UnitZ, rads);
860860
}
861861

862862
var match = Regex.Match(rotStr, @"([\d.-]+) ([\d.-]+) ([\d.-]+) ([\d.-]+)");

EmoteScriptLib/SQL/SQLReader.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,20 @@ public void PopulateFields(object record, List<string> currentColumns, List<stri
135135
}
136136
var value = GetValueType(prop, fields[i]);
137137

138-
if (DefaultValues.TryGetValue(propName, out var defaultValue) && value.ToString().Equals(defaultValue))
138+
// special handling for default extent based on emote type
139+
if (propName.Equals("Extent"))
140+
{
141+
var defaultExtent = "1";
142+
143+
var typeIdx = currentColumns.IndexOf("type");
144+
145+
if (typeIdx != -1 && fields[typeIdx] == "8") // EmoteType.Say
146+
defaultExtent = "0";
147+
148+
if (value.ToString().Equals(defaultExtent))
149+
continue;
150+
}
151+
else if (DefaultValues.TryGetValue(propName, out var defaultValue) && value.ToString().Equals(defaultValue))
139152
continue;
140153

141154
prop.SetValue(record, value, null);

EmoteScriptLib/SQL/SQLWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static List<string> GetSQL(List<Emote> emotes)
5858

5959
var typeStr = $"{(int)emote.Type} /* {emote.Type} */";
6060
var delay = emote.Delay?.ToString() ?? "0";
61-
var extent = emote.Extent?.ToString() ?? "1";
61+
var extent = emote.Extent?.ToString() ?? (emote.Type == EmoteType.Say ? "0" : "1");
6262
var motionStr = emote.Motion != null ? $"0x{(uint)emote.Motion:X8} /* {emote.Motion} */" : "NULL";
6363
var message = GetSQLString(emote.Message);
6464
var testString = GetSQLString(emote.TestString);

0 commit comments

Comments
 (0)