Skip to content

Commit

Permalink
Fix OF teleporters disappearing
Browse files Browse the repository at this point in the history
* Since 8f745e3. Caused OF teleporters using "ArmorFactorBuff" as a string directly for their hardcoded spell instead of calling `eSpellType.Whatever.ToString()`, and thus it went unnoticed during the refactor.
* Optimized `PortSpell` to not create a new spell everytime it's called (now a static field initialized only once).
  • Loading branch information
bm01 committed Aug 18, 2024
1 parent 6195179 commit 848f85e
Showing 1 changed file with 25 additions and 30 deletions.
55 changes: 25 additions & 30 deletions GameServer/scripts/teleporters/OFTeleporters.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using DOL.AI.Brain;
using DOL.Database;
using DOL.GS.Effects;
Expand All @@ -14,7 +13,7 @@ public class OFAssistant : GameNPC
{
public override bool AddToWorld()
{
if (!(base.AddToWorld()))
if (!base.AddToWorld())
return false;

Level = 100;
Expand Down Expand Up @@ -105,38 +104,17 @@ private IList<OFAssistant> Assistants
set { m_ofAssistants = value; }
}

private DbSpell m_buffSpell;
private Spell m_portSpell;

private static Spell PORT_SPELL;
private ECSGameTimer castTimer;
private ECSGameTimer followupTimer;

private Spell PortSpell
{
get
{
m_buffSpell = new DbSpell();
m_buffSpell.ClientEffect = 4468;
m_buffSpell.CastTime = 5;
m_buffSpell.Icon = 4468;
m_buffSpell.Duration = ReportInterval;
m_buffSpell.Target = "Self";
m_buffSpell.Type = "ArmorFactorBuff";
m_buffSpell.Name = "TELEPORTER_EFFECT";
m_buffSpell.RecastDelay = ReportInterval;
m_portSpell = new Spell(m_buffSpell, 0);
return m_portSpell;
}
set { m_portSpell = value; }
}

public void StartTeleporting()
{
if (castTimer is null)
castTimer = new ECSGameTimer(this);

bool cast = CastSpell(PortSpell, SkillBase.GetSpellLine(GlobalSpellsLines.Mob_Spells), false);
if (GetSkillDisabledDuration(PortSpell) > 0)
bool cast = CastSpell(PORT_SPELL, SkillBase.GetSpellLine(GlobalSpellsLines.Mob_Spells), false);
if (GetSkillDisabledDuration(PORT_SPELL) > 0)
cast = false;

if (Assistants == null)
Expand Down Expand Up @@ -190,11 +168,11 @@ public void StartTeleporting()
eChatLoc.CL_ChatWindow);
}

castTimer.Interval = PortSpell.CastTime;
castTimer.Interval = PORT_SPELL.CastTime;
castTimer.Callback += new ECSGameTimer.ECSTimerCallback(CastTimerCallback);
castTimer.Start(PortSpell.CastTime);
castTimer.Start(PORT_SPELL.CastTime);
followupTimer = new ECSGameTimer(this, CastTimerCallback);
followupTimer.Interval = m_portSpell.CastTime + 10000; //10s after
followupTimer.Interval = PORT_SPELL.CastTime + 10000; //10s after
followupTimer.Callback = CastTimerCallback;
followupTimer.Start(followupTimer.Interval);
foreach (OFAssistant assi in Assistants)
Expand Down Expand Up @@ -712,9 +690,26 @@ private int CastTimerCallback(ECSGameTimer selfRegenerationTimer)

public override bool AddToWorld()
{
if (!(base.AddToWorld()))
if (!base.AddToWorld())
return false;

if (PORT_SPELL == null)
{
DbSpell buffSpell = new()
{
ClientEffect = 4468,
CastTime = 5,
Icon = 4468,
Duration = ReportInterval,
Target = eSpellTarget.SELF.ToString(),
Type = eSpellType.SpecArmorFactorBuff.ToString(),
Name = "TELEPORTER_EFFECT",
RecastDelay = ReportInterval
};

PORT_SPELL = new Spell(buffSpell, 0);
}

if (Realm == eRealm.None)
Realm = eRealm.Albion;

Expand Down

0 comments on commit 848f85e

Please sign in to comment.