Skip to content

Commit

Permalink
Chain lightning
Browse files Browse the repository at this point in the history
  • Loading branch information
Limiana committed Aug 2, 2024
1 parent bf8fb79 commit 5839aaf
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 0 deletions.
111 changes: 111 additions & 0 deletions SplatoonScripts/Duties/Dawntrail/R4S Chain Lightning.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
using Dalamud.Game.ClientState.Objects.Types;
using ECommons;
using ECommons.DalamudServices;
using ECommons.Hooks;
using ECommons.Hooks.ActionEffectTypes;
using ECommons.Logging;
using ECommons.Throttlers;
using Splatoon;
using Splatoon.SplatoonScripting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace SplatoonScriptsOfficial.Duties.Dawntrail;
public class R4S_Chain_Lightning : SplatoonScript
{
public override HashSet<uint>? ValidTerritories { get; } = [1232];
public override Metadata? Metadata => new(1, "NightmareXIV");
uint TowerID = 13061;
List<List<uint>> Towers = [];
Layout VoidZone = null!;
long ResetAt = long.MaxValue;

IEnumerable<IBattleChara> GetTowers() => Svc.Objects.OfType<IBattleNpc>().Where(x => x.NameId == TowerID);

public override void OnSetup()
{
for(int i = 0; i < 6; i++)
{
Controller.RegisterElementFromCode($"Tower{i}", "{\"Name\":\"Tower\",\"type\":1,\"radius\":7.0,\"color\":3355508223,\"fillIntensity\":0.3,\"originFillColor\":1677721855,\"endFillColor\":1677721855,\"refActorComparisonType\":2,\"refActorTetherTimeMin\":0.0,\"refActorTetherTimeMax\":0.0,\"refActorTetherConnectedWithPlayer\":[]}");
}
Controller.TryRegisterLayoutFromCode("~Lv2~{\"Name\":\"void zone lol\",\"Group\":\"\",\"ZoneLockH\":[1232],\"ElementsL\":[{\"Name\":\"\",\"type\":2,\"refX\":110.0,\"refY\":150.0,\"offX\":110.0,\"offY\":180.0,\"radius\":0.0,\"color\":4278190335,\"fillIntensity\":0.345,\"originFillColor\":1157628159,\"endFillColor\":1157628159,\"thicc\":10.0,\"refActorTetherTimeMin\":0.0,\"refActorTetherTimeMax\":0.0,\"refActorTetherConnectedWithPlayer\":[]},{\"Name\":\"\",\"type\":2,\"refX\":90.0,\"refY\":150.0,\"offX\":90.0,\"offY\":180.0,\"radius\":0.0,\"color\":4278190335,\"fillIntensity\":0.345,\"originFillColor\":1157628159,\"endFillColor\":1157628159,\"thicc\":10.0,\"refActorTetherTimeMin\":0.0,\"refActorTetherTimeMax\":0.0,\"refActorTetherConnectedWithPlayer\":[]}]}", out VoidZone!);
}

public override void OnUpdate()
{
if(Environment.TickCount64 > ResetAt) Reset();
this.Controller.GetRegisteredElements().Each(x => x.Value.Enabled = false);
if(Towers.Count > 0)
{
VoidZone.Enabled = true;
uint[] towersConcat = [.. Towers.SafeSelect(0), .. Towers.SafeSelect(1) ?? []];
for(int i = 0; i < towersConcat.Length; i++)
{
if(towersConcat[i].GetObject() == null) Reset();
if(Controller.TryGetElementByName($"Tower{i}", out var e))
{
e.Enabled = true;
e.refActorObjectID = towersConcat[i];
}
}
}
else
{
VoidZone.Enabled = false;
}
}

public override void OnDirectorUpdate(DirectorUpdateCategory category)
{
if(category.EqualsAny(DirectorUpdateCategory.Commence, DirectorUpdateCategory.Recommence, DirectorUpdateCategory.Wipe))
{
Reset();
ResetAt = long.MaxValue;
}
}

public override void OnVFXSpawn(uint target, string vfxPath)
{
if(vfxPath == "vfx/channeling/eff/chn_chainlightning_0t1.avfx")
{
if(EzThrottler.Throttle("ChainLightning.Recast", 500))
{
Reset();
Towers.Add([]);
}
Towers.Last().Add(target);
ResetAt = Environment.TickCount64 + 30 * 1000;
}
if(vfxPath == "vfx/channeling/eff/chn_chainlightning_1t1.avfx")
{
if(EzThrottler.Throttle("ChainLightning.Recast", 500))
{
Towers.Add([]);
}
Towers.Last().Add(target);
ResetAt = Environment.TickCount64 + 30 * 1000;
}
}

public override void OnActionEffectEvent(ActionEffectSet set)
{
//PluginLog.Information($"Cast: {set.Action.RowId}");
if(set.Action?.RowId.EqualsAny(38426u, 38427u) == true)
{
PluginLog.Information($"Cast detected");
if(Towers.Count > 0 && EzThrottler.Throttle("ChainLightning.Remove", 500))
{
Towers.RemoveAt(0);
}
}
}

void Reset()
{
Towers.Clear();
}
}
38 changes: 38 additions & 0 deletions SplatoonScripts/Duties/Dawntrail/R4S Midnight Sabbath.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Dalamud.Game.ClientState.Objects.Types;
using ECommons;
using ECommons.DalamudServices;
using ECommons.ExcelServices;
using ECommons.GameFunctions;
using ECommons.Hooks.ActionEffectTypes;
using ECommons.Logging;
using Splatoon.SplatoonScripting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SplatoonScriptsOfficial.Duties.Dawntrail;
public unsafe class R4S_Midnight_Sabbath : SplatoonScript
{
public override HashSet<uint>? ValidTerritories { get; } = [1232];
public override Metadata? Metadata => new(1, "NightmareXIV");

uint TowerID = 13562;

public override void OnUpdate()
{
foreach(var x in Svc.Objects.OfType<IBattleNpc>().Where(x => x.NameId == 13562))
{
//PluginLog.Information($"{x.Struct()->OrnamentData.OrnamentId}");
}
}

public override void OnActionEffectEvent(ActionEffectSet set)
{
if(set.Source is IBattleNpc b && b.NameId == TowerID)
{
PluginLog.Information($"Cast: {ExcelActionHelper.GetActionName(set.Action, true)}");
}
}
}

0 comments on commit 5839aaf

Please sign in to comment.