Skip to content

Commit

Permalink
Merge pull request #136 from Redmoonwow/fix/R2S-script-fix
Browse files Browse the repository at this point in the history
[fix] R2S scripting improvements
  • Loading branch information
Limiana authored Aug 22, 2024
2 parents 39cb944 + 492298e commit e448e27
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 40 deletions.
4 changes: 2 additions & 2 deletions Splatoon/SplatoonScripting/ScriptingProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -455,15 +455,15 @@ internal static void OnObjectEffect(uint Target, ushort Param1, ushort Param2)
}
}

internal static void OnStartingCast(uint target, uint castId)
internal static void OnStartingCast(uint source, uint castId)
{
for (var i = 0; i < Scripts.Count; i++)
{
if (Scripts[i].IsEnabled)
{
try
{
Scripts[i].OnStartingCast(target, castId);
Scripts[i].OnStartingCast(source, castId);
}
catch (Exception e) { Scripts[i].LogError(e, nameof(SplatoonScript.OnObjectEffect)); }
}
Expand Down
4 changes: 2 additions & 2 deletions Splatoon/SplatoonScripting/SplatoonScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ public virtual void OnVFXSpawn(uint target, string vfxPath) { }
/// <summary>
/// Will be called when a hostile object starts casting. These are the same messages which layout trigger system receives. This method will only be called if a script is enabled.
/// </summary>
/// <param name="target">Object ID that is targeted by VFX.</param>
/// <param name="source">Object ID that is source by VFX.</param>
/// <param name="castId">ID of cast action.</param>
public virtual void OnStartingCast(uint target, uint castId) { }
public virtual void OnStartingCast(uint source, uint castId) { }

/// <summary>
/// Will be called whenever plugin processes a message. These are the same messages which layout trigger system receives. This method will only be called if a script is enabled.
Expand Down
78 changes: 42 additions & 36 deletions SplatoonScripts/Duties/Dawntrail/R2S Venom Love Pair Split.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using ECommons.Hooks;
using ECommons.Hooks.ActionEffectTypes;
using ECommons.Logging;
using Splatoon;
using Splatoon.SplatoonScripting;
using System;
using System.Collections.Generic;
Expand All @@ -22,7 +23,7 @@ private enum PairSplit
}
public override HashSet<uint>? ValidTerritories { get; } = [1228];

public override Metadata? Metadata => new(1, "Redmoon");
public override Metadata? Metadata => new(2, "Redmoon");

const uint PoisonResistanceDownDebuffID = 3935;
bool IsShow = false;
Expand All @@ -35,71 +36,76 @@ public override void OnSetup()
Controller.RegisterElementFromCode("split", "{\"Name\":\"split\",\"type\":1,\"Enabled\":false,\"radius\":6.0,\"color\":4278190335,\"Filled\":false,\"fillIntensity\":0.14,\"originFillColor\":587202815,\"endFillColor\":587202815,\"overlayTextColor\":4278190335,\"overlayVOffset\":1.0,\"overlayText\":\"<< Spread >>\",\"refActorComparisonType\":1,\"includeRotation\":true,\"FaceMe\":true,\"refActorTetherTimeMin\":0.0,\"refActorTetherTimeMax\":0.0}");
}

public override void OnUpdate()
public override void OnStartingCast(uint source, uint castId)
{
if (Player.Object.StatusList.Any(x => x.StatusId == PoisonResistanceDownDebuffID) && IsShow && !IsAdd)
var sourceObj = source.GetObject();
if (sourceObj == null)
return;

if (sourceObj.DataId == 0 || sourceObj.DataId != 16941)
return;

if ((castId == 37252) || (castId == 39688) )
{
IsAdd = true;
HideElement();
LatchNextPairSplit = PairSplit.Split;
}

if (IsAdd && !(Player.Object.StatusList.Any(x => x.StatusId == PoisonResistanceDownDebuffID)))
if ((castId == 37253) || (castId == 39689))
{
IsAdd = false;
LatchNextPairSplit = PairSplit.Pair;
}
}

public override void OnVFXSpawn(uint target, string vfxPath)
{
if (IsShow && vfxPath.Contains("vfx/common/eff/m0906_stlp_ht4_03k2.avfx"))
if ((castId == 37254) || (castId == 37255) || (castId == 39692) || (castId == 39693))
{
HideElement();
ShowElement();
}

}

public override void OnMessage(string Message)
public override void OnActionEffectEvent(ActionEffectSet set)
{
if (Message.Contains("12685>37252") || (Message.Contains("12685>39688")))
{
LatchNextPairSplit = PairSplit.Split;
}
else if (Message.Contains("12685>37253") || (Message.Contains("12685>39689")))
{
LatchNextPairSplit = PairSplit.Pair;
}
else if (Message.Contains("12685>37254") ||
(Message.Contains("12685>37255")) ||
(Message.Contains("12685>39696")) ||
(Message.Contains("12685>39697")))
if (set.Action == null || (set.Source == null)) return;
if (set.Source.DataId == 0) return;

if ((set.Action.RowId == 37256) && (set.Source.DataId == 16945))
{
ShowElement();
HideElement();
}
else

if ((set.Action.RowId == 39691) && (set.Source.DataId == 16943))
{
// NOP
HideElement();
}
}

private void ShowElement()
{
if (LatchNextPairSplit == PairSplit.Pair)
Element? element = Controller.GetElementByName("Pair");
if ((LatchNextPairSplit == PairSplit.Pair) && element != null && !element.Enabled)
{
Controller.GetElementByName("Pair")!.Enabled = true;
}
else if (LatchNextPairSplit == PairSplit.Split)

element = Controller.GetElementByName("split");
if ((LatchNextPairSplit == PairSplit.Split) && element != null && !element.Enabled)
{
Controller.GetElementByName("split")!.Enabled = true;
}
else
{
}
IsShow = true;
}

private void HideElement()
{
Controller.GetRegisteredElements().Each(x => x.Value.Enabled = false);
IsShow = false;
Element? element = Controller.GetElementByName("Pair");
if (element != null && element.Enabled)
{
Controller.GetElementByName("Pair")!.Enabled = false;
}

element = Controller.GetElementByName("split");
if (element != null && element.Enabled)
{
Controller.GetElementByName("split")!.Enabled = false;
}
}

public override void OnReset()
Expand Down

0 comments on commit e448e27

Please sign in to comment.