Skip to content

Commit

Permalink
1.0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
paissaheavyindustries committed Nov 17, 2023
1 parent 6b96500 commit e4d4dbf
Show file tree
Hide file tree
Showing 16 changed files with 199 additions and 39 deletions.
6 changes: 3 additions & 3 deletions Lemegeton/Action/ChatMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public enum ChatSeverityEnum
public string Text { get; set; } = "";

public override void Execute(Context ctx)
{
{
switch (ChatSeverity)
{
case ChatSeverityEnum.Normal:
ctx.State.cg.Print(Text);
ctx.State.cg.Print(ctx.ParseText(this, Text));
break;
case ChatSeverityEnum.Error:
ctx.State.cg.PrintError(Text);
ctx.State.cg.PrintError(ctx.ParseText(this, Text));
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Lemegeton/Action/IngameCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class IngameCommand : Core.Action

public override void Execute(Context ctx)
{
ctx.State.PostCommand(Command);
ctx.State.PostCommand(ctx.ParseText(this, Command));
}

}
Expand Down
4 changes: 3 additions & 1 deletion Lemegeton/Action/Notification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ public override void Execute(Context ctx)
{
ctx.State.plug.AddNotification(new Core.Notification()
{
Notif = this,
Severity = this.NotificationSeverity,
Text = this.Text,
SoundEffect = this.SoundEffect,
TTL = this.TTL,
TTS = this.TTS
TTS = this.TTS,
ctx = ctx,
});
}

Expand Down
10 changes: 5 additions & 5 deletions Lemegeton/Content/UltUcob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public class GrandOctetAm : Automarker
{

[AttributeOrderNumber(1000)]
public AutomarkerSigns Signs1 { get; set; }
public AutomarkerSigns Signs { get; set; }

[DebugOption]
[AttributeOrderNumber(2500)]
Expand All @@ -283,9 +283,9 @@ public GrandOctetAm(State state) : base(state)
{
Enabled = false;
Timing = new AutomarkerTiming() { TimingType = AutomarkerTiming.TimingTypeEnum.Inherit, Parent = state.cfg.DefaultAutomarkerTiming };
Signs1 = new AutomarkerSigns();
Signs1.SetRole("TwistingDive", AutomarkerSigns.SignEnum.Triangle, false);
Test = new System.Action(() => Signs1.TestFunctionality(state, null, Timing, SelfMarkOnly, AsSoftmarker));
Signs = new AutomarkerSigns();
Signs.SetRole("TwistingDive", AutomarkerSigns.SignEnum.Triangle, false);
Test = new System.Action(() => Signs.TestFunctionality(state, null, Timing, SelfMarkOnly, AsSoftmarker));
}

public override void Reset()
Expand Down Expand Up @@ -333,7 +333,7 @@ from ix in pty.Members where _markedPty.Contains(ix) == false select ix
}

AutomarkerPayload ap = new AutomarkerPayload(_state, SelfMarkOnly, AsSoftmarker);
ap.Assign(Signs1.Roles["TwistingDive"], _unmarkedGo[0].GameObject);
ap.Assign(Signs.Roles["TwistingDive"], _unmarkedGo[0].GameObject);
_state.ExecuteAutomarkers(ap, Timing);
}

Expand Down
92 changes: 91 additions & 1 deletion Lemegeton/Core/Context.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,101 @@
namespace Lemegeton.Core
using Lemegeton.Action;
using System;
using System.Text.RegularExpressions;
using static Lemegeton.Core.Timeline.Entry;

namespace Lemegeton.Core
{

public class Context
{

// ${...}
internal static Regex rex = new Regex(@"\$\{(?<id>[^${}]*)\}");

public State State { get; set; } = null;

public DateTime Created { get; set; } = DateTime.Now;
public string SourceName { get; set; } = "(source name)";
public string DestName { get; set; } = "(destination name)";
public string EffectName { get; set; } = "(effect name)";

internal Context Duplicate()
{
return (Context)MemberwiseClone();
}

internal string ParseExpressions(Action a, string text)
{
int i = 0;
while (true)
{
Match m = rex.Match(text);
if (m.Success == false)
{
break;
}
string val = "";
switch (m.Groups["id"].Value.ToLower())
{
case "_triggeredtime":
val = Created.ToString();
break;
case "_currenttime":
val = DateTime.Now.ToString();
break;
case "_since":
val = Math.Floor((DateTime.Now - Created).TotalSeconds).ToString();
break;
case "_sincems":
val = Math.Floor((DateTime.Now - Created).TotalMilliseconds).ToString();
break;
case "_ttl":
if (a is Lemegeton.Action.Notification)
{
Lemegeton.Action.Notification n = (Lemegeton.Action.Notification)a;
val = (Math.Ceiling(n.TTL) - Math.Floor((DateTime.Now - Created).TotalSeconds)).ToString();
}
else
{
val = "0";
}
break;
case "_ttlms":
if (a is Lemegeton.Action.Notification)
{
Lemegeton.Action.Notification n = (Lemegeton.Action.Notification)a;
val = (Math.Ceiling(n.TTL * 1000.0f) - Math.Floor((DateTime.Now - Created).TotalMilliseconds)).ToString();
}
else
{
val = "0";
}
break;
case "_effect":
val = EffectName;
break;
case "_src":
val = SourceName;
break;
case "_dest":
val = DestName;
break;
}
text = text.Substring(0, m.Index) + val + text.Substring(m.Index + m.Length);
i++;
if (i > 100)
{
break;
}
}
return text;
}

internal string ParseText(Action a, string text)
{
return ParseExpressions(a, text);
}

}

}
2 changes: 2 additions & 0 deletions Lemegeton/Core/Notification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ public enum NotificationSeverityEnum
Normal,
}

public Lemegeton.Action.Notification Notif { get; set; } = null;
public string Text { get; set; } = "(undefined)";
public State.SoundEffectEnum SoundEffect { get; set; } = State.SoundEffectEnum.None;
public NotificationSeverityEnum Severity { get; set; } = NotificationSeverityEnum.Normal;
public DateTime SpawnTime { get; set; } = DateTime.Now;
public float TTL { get; set; } = 5.0f;
public bool FirstDisplay { get; set; } = true;
public bool TTS { get; set; } = false;
public Context ctx { get; set; } = null;

}

Expand Down
4 changes: 2 additions & 2 deletions Lemegeton/Core/State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ internal void InvokeCastBegin(uint src, uint dest, ushort actionId, float castTi
Timeline tl = _timeline;
if (tl != null)
{
tl.FeedEventCastBegin(this, GetActorById(dest), actionId, castTime);
tl.FeedEventCastBegin(this, GetActorById(src), GetActorById(dest), actionId, castTime);
}
OnCastBegin?.Invoke(src, dest, actionId, castTime, rotation);
}
Expand All @@ -290,7 +290,7 @@ internal void InvokeAction(uint src, uint dest, ushort actionId)
Timeline tl = _timeline;
if (tl != null)
{
tl.FeedEventCastEnd(this, GetActorById(dest), actionId);
tl.FeedEventCastEnd(this, GetActorById(src), GetActorById(dest), actionId);
}
OnAction?.Invoke(src, dest, actionId);
}
Expand Down
52 changes: 32 additions & 20 deletions Lemegeton/Core/Timeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ public IEnumerable<Entry> PeekEntries(int maxAmount, float timeBackward, float t
return (from ix in CurrentEncounter.Entries where EventIsInVisibleWindow(ix, timeBackward, timeForward) == true select ix).Take(maxAmount);
}

public void ExecuteEntry(State st, Entry e, Reaction.ReactionTriggerEnum rt, bool allowJump, bool allowSync, float syncOffset)
public void ExecuteEntry(Context ctx, Entry e, Reaction.ReactionTriggerEnum rt, bool allowJump, bool allowSync, float syncOffset)
{
bool jumped = false;
if (e.Handlers != null)
Expand All @@ -695,21 +695,21 @@ public void ExecuteEntry(State st, Entry e, Reaction.ReactionTriggerEnum rt, boo
Encounter ec = (from ix in Encounters where ix.Id == enc select ix).FirstOrDefault();
if (ec != null)
{
st.Log(LogLevelEnum.Debug, null, "Timeline jumping to encounter {0}", ec.Id);
ctx.State.Log(LogLevelEnum.Debug, null, "Timeline jumping to encounter {0}", ec.Id);
CurrentEncounter = ec;
jumped = true;
}
else
{
st.Log(LogLevelEnum.Debug, null, "Timeline tried to jump to encounter {0} but it has not been defined", enc);
ctx.State.Log(LogLevelEnum.Debug, null, "Timeline tried to jump to encounter {0} but it has not been defined", enc);
}
}
break;
case Handler.HandlerTypeEnum.JumpToTime:
if (allowJump == true)
{
float time = h.ValueAsFloat();
st.Log(LogLevelEnum.Debug, null, "Timeline jumping to time {0}", time);
ctx.State.Log(LogLevelEnum.Debug, null, "Timeline jumping to time {0}", time);
CurrentTime = time;
LastJumpPoint = time;
AutoSync = 0.0f;
Expand All @@ -727,7 +727,7 @@ public void ExecuteEntry(State st, Entry e, Reaction.ReactionTriggerEnum rt, boo
{
if (ent.Id == eg)
{
st.Log(LogLevelEnum.Debug, null, "Timeline jumping to encounter {0}, entry {1} (at {2})", enc.Id, ent.Id, ent.StartTime);
ctx.State.Log(LogLevelEnum.Debug, null, "Timeline jumping to encounter {0}, entry {1} (at {2})", enc.Id, ent.Id, ent.StartTime);
CurrentEncounter = enc;
jumped = true;
found = true;
Expand All @@ -739,7 +739,7 @@ public void ExecuteEntry(State st, Entry e, Reaction.ReactionTriggerEnum rt, boo
}
if (found == false)
{
st.Log(LogLevelEnum.Debug, null, "Timeline tried to jump to entry {0} but it has not been defined", eg);
ctx.State.Log(LogLevelEnum.Debug, null, "Timeline tried to jump to entry {0} but it has not been defined", eg);
}
}
break;
Expand All @@ -758,7 +758,7 @@ public void ExecuteEntry(State st, Entry e, Reaction.ReactionTriggerEnum rt, boo
}
if (jumped == false && allowSync == true)
{
st.Log(LogLevelEnum.Debug, null, "Timeline autosync to {0} ({1} from current time {2}, entry at {3}, sync offset {4})", e.StartTime + syncOffset, (e.StartTime + syncOffset) - CurrentTime, CurrentTime, e.StartTime, syncOffset);
ctx.State.Log(LogLevelEnum.Debug, null, "Timeline autosync to {0} ({1} from current time {2}, entry at {3}, sync offset {4})", e.StartTime + syncOffset, (e.StartTime + syncOffset) - CurrentTime, CurrentTime, e.StartTime, syncOffset);
AutoSync = (e.StartTime + syncOffset) - CurrentTime;
}
if (e.ReactionsActive() == false)
Expand All @@ -776,8 +776,8 @@ public void ExecuteEntry(State st, Entry e, Reaction.ReactionTriggerEnum rt, boo
if (r.Trigger != rt)
{
continue;
}
st.QueueReactionExecution(new Context { State = st }, r, 0.0f);
}
ctx.State.QueueReactionExecution(ctx, r, 0.0f);
}
}
}
Expand Down Expand Up @@ -903,7 +903,9 @@ public void FeedNewCombatant(State st, GameObject go)
{
continue;
}
ExecuteEntry(st, e, Reaction.ReactionTriggerEnum.Spawn, true, true, 0.0f);
Context ctx = new Context { State = st };
ctx.SourceName = go.Name.ToString();
ExecuteEntry(ctx, e, Reaction.ReactionTriggerEnum.Spawn, true, true, 0.0f);
}
}
}
Expand All @@ -917,7 +919,8 @@ public void FeedEventTargettable(State st)
{
continue;
}
ExecuteEntry(st, e, Reaction.ReactionTriggerEnum.Targettable, true, true, 0.0f);
Context ctx = new Context { State = st };
ExecuteEntry(ctx, e, Reaction.ReactionTriggerEnum.Targettable, true, true, 0.0f);
}
}

Expand All @@ -930,16 +933,17 @@ public void FeedEventUntargettable(State st)
{
continue;
}
ExecuteEntry(st, e, Reaction.ReactionTriggerEnum.Untargettable, true, true, 0.0f);
Context ctx = new Context { State = st };
ExecuteEntry(ctx, e, Reaction.ReactionTriggerEnum.Untargettable, true, true, 0.0f);
}
}

public void FeedEventCastBegin(State st, GameObject go, uint abilityId, float castTime)
public void FeedEventCastBegin(State st, GameObject src, GameObject dest, uint abilityId, float castTime)
{
uint nameId = 0;
if (go is Character)
if (dest is Character)
{
Character ch = (Character)go;
Character ch = (Character)dest;
nameId = ch.NameId;
}
IEnumerable<Encounter> encs = GetEncountersForEvents(Encounter.Trigger.EventTypeEnum.All, Encounter.Trigger.TriggerTypeEnum.OnCastBegin, nameId, 0, abilityId);
Expand Down Expand Up @@ -973,16 +977,20 @@ public void FeedEventCastBegin(State st, GameObject go, uint abilityId, float ca
{
continue;
}
ExecuteEntry(st, e, Reaction.ReactionTriggerEnum.OnCastBegin, false, true, 0.0f - castTime);
Context ctx = new Context { State = st };
ctx.SourceName = src.Name.ToString();
ctx.EffectName = st.plug.GetActionName(abilityId);
ctx.DestName = dest.Name.ToString();
ExecuteEntry(ctx, e, Reaction.ReactionTriggerEnum.OnCastBegin, false, true, 0.0f - castTime);
}
}

public void FeedEventCastEnd(State st, GameObject go, uint abilityId)
public void FeedEventCastEnd(State st, GameObject src, GameObject dest, uint abilityId)
{
uint nameId = 0;
if (go is Character)
if (dest is Character)
{
Character ch = (Character)go;
Character ch = (Character)dest;
nameId = ch.NameId;
}
IEnumerable<Encounter> encs = GetEncountersForEvents(Encounter.Trigger.EventTypeEnum.All, Encounter.Trigger.TriggerTypeEnum.OnCastEnd, nameId, 0, abilityId);
Expand Down Expand Up @@ -1016,7 +1024,11 @@ public void FeedEventCastEnd(State st, GameObject go, uint abilityId)
{
continue;
}
ExecuteEntry(st, e, Reaction.ReactionTriggerEnum.OnCastEnd, true, true, 0.0f);
Context ctx = new Context { State = st };
ctx.SourceName = src.Name.ToString();
ctx.EffectName = st.plug.GetActionName(abilityId);
ctx.DestName = dest.Name.ToString();
ExecuteEntry(ctx, e, Reaction.ReactionTriggerEnum.OnCastEnd, true, true, 0.0f);
}
}

Expand Down
9 changes: 9 additions & 0 deletions Lemegeton/Language/Chinese.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ internal class Chinese : Core.Language

public Chinese(State st) : base(st)
{
#region 1.0.2.2
//AddEntry("Content/Ultimate/UltUcob/GrandOctetAm", "(P3) Grand Octet Twintania Dive automarker");
AddEntry("Content/Ultimate/UltUcob/GrandOctetAm/Enabled", "启用");
AddEntry("Content/Ultimate/UltUcob/GrandOctetAm/SelfMarkOnly", "仅标记自己");
AddEntry("Content/Ultimate/UltUcob/GrandOctetAm/AsSoftmarker", "显示客户端软标记");
//AddEntry("Content/Ultimate/UltUcob/GrandOctetAm/Signs", "Marker configuration");
//AddEntry("Content/Ultimate/UltUcob/GrandOctetAm/Signs/TwistingDive", "Dive target");
AddEntry("Content/Ultimate/UltUcob/GrandOctetAm/Test", "测试标记");
#endregion
#region 1.0.2.1
//AddEntry("Job/BLU", "Blue Mage");
//AddEntry("Content/Ultimate/UltUcob/TenstrikeAm", "(P3) Tenstrike Trio automarker");
Expand Down
9 changes: 9 additions & 0 deletions Lemegeton/Language/Danish.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ internal class Danish : Core.Language

public Danish(State st) : base(st)
{
#region 1.0.2.2
//AddEntry("Content/Ultimate/UltUcob/GrandOctetAm", "(P3) Grand Octet Twintania Dive automarker");
AddEntry("Content/Ultimate/UltUcob/GrandOctetAm/Enabled", "Aktiveret");
AddEntry("Content/Ultimate/UltUcob/GrandOctetAm/SelfMarkOnly", "Kun selvmarkering");
AddEntry("Content/Ultimate/UltUcob/GrandOctetAm/AsSoftmarker", "Vis som klientbaserede bløde markører");
//AddEntry("Content/Ultimate/UltUcob/GrandOctetAm/Signs", "Marker configuration");
//AddEntry("Content/Ultimate/UltUcob/GrandOctetAm/Signs/TwistingDive", "Dive target");
AddEntry("Content/Ultimate/UltUcob/GrandOctetAm/Test", "Test tildeling");
#endregion
#region 1.0.2.1
AddEntry("Job/BLU", "Blue Mage");
//AddEntry("Content/Ultimate/UltUcob/TenstrikeAm", "(P3) Tenstrike Trio automarker");
Expand Down
Loading

0 comments on commit e4d4dbf

Please sign in to comment.