Skip to content

Commit

Permalink
Effect fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Maupishon committed Sep 11, 2024
1 parent f67ac11 commit 5e7231f
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions Scripts/Nelderim/Items/Artifacts/ZleceniaBossy/ObronaZywiolow.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using Server;
using Server.Mobiles;
using Server.Network;
using Server.ACC.CSS.Systems;
using Server.Spells;


namespace Server.Items
{
Expand All @@ -14,6 +11,7 @@ public class ObronaZywiolow : ChaosShield

private DateTime m_ShieldEquipTime; // Track the time when the shield is equipped
private Timer m_RemoveEffectTimer; // Timer to remove the effect
private Timer m_DamageCooldownTimer; // Timer to prevent multiple damage applications

public static void Initialize()
{
Expand All @@ -27,7 +25,8 @@ public ObronaZywiolow()
Name = "Obrona Zywiolow - Zimno";
Attributes.DefendChance = 25;
Attributes.EnhancePotions = 15;
Label1 = "okruchy magicznego lodu pokrywaja tarcze";
// Fixed: Changed Label1 to Name
Name = "okruchy magicznego lodu pokrywaja tarcze";
}

public ObronaZywiolow(Serial serial) : base(serial)
Expand All @@ -49,11 +48,12 @@ public override void OnRemoved(object parent)
base.OnRemoved(parent);

StopRemoveEffectTimer();
StopDamageCooldownTimer();

Mobile mobile = parent as Mobile;
if (mobile != null)
{
RemoveDamagingEffect(mobile);
RemoveEffectCallback(); // Call directly on unequip
}
}

Expand Down Expand Up @@ -84,7 +84,7 @@ private void RemoveEffectCallback()
RemoveDamagingEffect(mobile);
}
}
// TODO: Nawet po zdjęciu tarczy efekt pozostaje, a powinien znikać - fix it

private void RemoveDamagingEffect(Mobile mobile)
{
int coldDamage = 10;
Expand All @@ -93,6 +93,26 @@ private void RemoveDamagingEffect(Mobile mobile)
mobile.SendMessage("The cold shield effect wears off.");
}

// Added these functions
public void StartDamageCooldownTimer()
{
if (m_DamageCooldownTimer != null)
StopDamageCooldownTimer();

TimeSpan duration = TimeSpan.FromSeconds(5); // Adjust the cooldown as needed

m_DamageCooldownTimer = Timer.DelayCall(duration, StopDamageCooldownTimer);
}

public void StopDamageCooldownTimer()
{
if (m_DamageCooldownTimer != null)
{
m_DamageCooldownTimer.Stop();
m_DamageCooldownTimer = null;
}
}

public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
Expand All @@ -110,14 +130,18 @@ public override void Deserialize(GenericReader reader)

public static void InternalCallback(Mobile attacker, Mobile defender, int damage, WeaponAbility a)
{
if (damage > 20 && attacker != null && defender != null)
// Cast attacker to ObronaZywiolow type to access custom methods/timers
if (damage > 20 && attacker != null && defender != null && defender.Weapon is BaseMeleeWeapon)
{
if (attacker.Weapon is BaseMeleeWeapon)
ObronaZywiolow obrona = defender.FindItemOnLayer(Layer.TwoHanded) as ObronaZywiolow;

if (obrona != null && obrona.m_DamageCooldownTimer == null)
{
int coldDamage = 10;
attacker.Damage(coldDamage);
defender.FixedParticles(0x3709, 10, 30, 5052, 0x480, 0, EffectLayer.LeftFoot);
attacker.SendMessage("Lodowa tarcza zmraza krew w Twych zylach");
obrona.StartDamageCooldownTimer();
}
}
}
Expand Down

0 comments on commit 5e7231f

Please sign in to comment.