Some cleanup of contains keys and try get values (#246)
This commit is contained in:
parent
9cbb0cfd23
commit
a236617ad9
69 changed files with 3508 additions and 350 deletions
|
|
@ -21,7 +21,9 @@ namespace Server.Items
|
|||
public override void OnHit(Mobile attacker, Mobile defender, int damage)
|
||||
{
|
||||
if (!Validate(attacker) || !CheckMana(attacker, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClearCurrentAbility(attacker);
|
||||
|
||||
|
|
@ -73,7 +75,9 @@ namespace Server.Items
|
|||
var damage = Utility.RandomMinMax(level, level * 2);
|
||||
|
||||
if (!m.Player)
|
||||
{
|
||||
damage *= 2;
|
||||
}
|
||||
|
||||
m.PlaySound(0x133);
|
||||
m.Damage(damage, from);
|
||||
|
|
@ -89,14 +93,17 @@ namespace Server.Items
|
|||
|
||||
public static void EndBleed(Mobile m, bool message)
|
||||
{
|
||||
if (!m_Table.TryGetValue(m, out var t))
|
||||
if (!m_Table.Remove(m, out var t))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
t.Stop();
|
||||
m_Table.Remove(m);
|
||||
|
||||
if (message)
|
||||
{
|
||||
m.SendLocalizedMessage(1060167); // The bleeding wounds have healed, you are no longer bleeding!
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTimer : Timer
|
||||
|
|
@ -117,7 +124,9 @@ namespace Server.Items
|
|||
DoBleed(m_Mobile, m_From, 5 - m_Count);
|
||||
|
||||
if (++m_Count == 5)
|
||||
{
|
||||
EndBleed(m_Mobile, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ namespace Server.Items
|
|||
public override void OnHit(Mobile attacker, Mobile defender, int damage)
|
||||
{
|
||||
if (!Validate(attacker) || !CheckMana(attacker, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClearCurrentAbility(attacker);
|
||||
|
||||
|
|
@ -49,7 +51,9 @@ namespace Server.Items
|
|||
public static bool GetBonus(Mobile targ, ref int bonus)
|
||||
{
|
||||
if (!m_Table.TryGetValue(targ, out var info))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bonus = info.m_Bonus;
|
||||
return true;
|
||||
|
|
@ -63,11 +67,10 @@ namespace Server.Items
|
|||
|
||||
public static void EndBlock(Mobile m)
|
||||
{
|
||||
if (!m_Table.TryGetValue(m, out var info))
|
||||
return;
|
||||
|
||||
info.m_Timer?.Stop();
|
||||
m_Table.Remove(m);
|
||||
if (m_Table.Remove(m, out var info))
|
||||
{
|
||||
info.m_Timer?.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
private class BlockInfo
|
||||
|
|
|
|||
|
|
@ -19,7 +19,10 @@ namespace Server.Items
|
|||
|
||||
public override void OnHit(Mobile attacker, Mobile defender, int damage)
|
||||
{
|
||||
if (!Validate(attacker) || !CheckMana(attacker, true)) return;
|
||||
if (!Validate(attacker) || !CheckMana(attacker, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClearCurrentAbility(attacker);
|
||||
|
||||
|
|
@ -31,7 +34,9 @@ namespace Server.Items
|
|||
|
||||
// Do not reset timer if one is already in place.
|
||||
if (!IsWounded(defender))
|
||||
{
|
||||
BeginWound(defender, defender.Player ? PlayerDuration : NPCDuration);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsWounded(Mobile m) => m_Table.ContainsKey(m);
|
||||
|
|
@ -39,7 +44,9 @@ namespace Server.Items
|
|||
public static void BeginWound(Mobile m, TimeSpan duration)
|
||||
{
|
||||
if (m_Table.TryGetValue(m, out var timer))
|
||||
{
|
||||
timer?.Stop();
|
||||
}
|
||||
|
||||
m_Table[m] = timer = new InternalTimer(m, duration);
|
||||
timer.Start();
|
||||
|
|
@ -49,10 +56,9 @@ namespace Server.Items
|
|||
|
||||
public static void EndWound(Mobile m)
|
||||
{
|
||||
if (m_Table.TryGetValue(m, out var timer))
|
||||
if (m_Table.Remove(m, out var timer))
|
||||
{
|
||||
timer.Stop();
|
||||
m_Table.Remove(m);
|
||||
}
|
||||
|
||||
m.YellowHealthbar = false;
|
||||
|
|
|
|||
|
|
@ -22,17 +22,17 @@ namespace Server.Items
|
|||
{
|
||||
if (!base.CheckSkills( from ))
|
||||
return false;
|
||||
|
||||
|
||||
if (!(from.Weapon is Fists))
|
||||
return true;
|
||||
|
||||
|
||||
Skill skill = from.Skills.Anatomy;
|
||||
|
||||
|
||||
if (skill?.Base >= 80.0)
|
||||
return true;
|
||||
|
||||
|
||||
from.SendLocalizedMessage( 1061811 ); // You lack the required anatomy skill to perform that attack!
|
||||
|
||||
|
||||
return false;
|
||||
}*/
|
||||
|
||||
|
|
@ -91,10 +91,9 @@ namespace Server.Items
|
|||
|
||||
public static void EndImmunity(Mobile m)
|
||||
{
|
||||
if (m_Table.TryGetValue(m, out var timer))
|
||||
if (m_Table.Remove(m, out var timer))
|
||||
{
|
||||
timer?.Stop();
|
||||
m_Table.Remove(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -71,11 +71,15 @@ namespace Server.Items
|
|||
canSwing = !attacker.Paralyzed && !attacker.Frozen;
|
||||
|
||||
if (canSwing)
|
||||
{
|
||||
canSwing = !(attacker.Spell is Spell sp) || !sp.IsCasting || !sp.BlocksMovement;
|
||||
}
|
||||
}
|
||||
|
||||
if ((attacker as PlayerMobile)?.DuelContext?.CheckItemEquip(attacker, this) == false)
|
||||
{
|
||||
canSwing = false;
|
||||
}
|
||||
|
||||
if (canSwing && attacker.HarmfulCheck(defender))
|
||||
{
|
||||
|
|
@ -85,9 +89,13 @@ namespace Server.Items
|
|||
if (OnFired(attacker, defender))
|
||||
{
|
||||
if (CheckHit(attacker, defender))
|
||||
{
|
||||
OnHit(attacker, defender);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMiss(attacker, defender);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -105,7 +113,9 @@ namespace Server.Items
|
|||
{
|
||||
if (attacker.Player && !defender.Player && (defender.Body.IsAnimal || defender.Body.IsMonster) &&
|
||||
Utility.RandomDouble() <= 0.4)
|
||||
{
|
||||
defender.AddToBackpack(Ammo);
|
||||
}
|
||||
|
||||
if (Core.ML && m_Velocity > 0)
|
||||
{
|
||||
|
|
@ -116,10 +126,14 @@ namespace Server.Items
|
|||
AOS.Damage(defender, attacker, bonus * 3, 100, 0, 0, 0, 0);
|
||||
|
||||
if (attacker.Player)
|
||||
{
|
||||
attacker.SendLocalizedMessage(1072794); // Your arrow hits its mark with velocity!
|
||||
}
|
||||
|
||||
if (defender.Player)
|
||||
{
|
||||
defender.SendLocalizedMessage(1072795); // You have been hit by an arrow with velocity!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -136,17 +150,17 @@ namespace Server.Items
|
|||
{
|
||||
var ammo = AmmoType;
|
||||
|
||||
if (pm.RecoverableAmmo.ContainsKey(ammo))
|
||||
pm.RecoverableAmmo[ammo]++;
|
||||
else
|
||||
pm.RecoverableAmmo.Add(ammo, 1);
|
||||
pm.RecoverableAmmo.TryGetValue(ammo, out var result);
|
||||
pm.RecoverableAmmo[ammo] = result + 1;
|
||||
|
||||
if (!pm.Warmode)
|
||||
{
|
||||
m_RecoveryTimer ??= Timer.DelayCall(TimeSpan.FromSeconds(10), pm.RecoverAmmo);
|
||||
|
||||
if (!m_RecoveryTimer.Running)
|
||||
{
|
||||
m_RecoveryTimer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -177,9 +191,13 @@ namespace Server.Items
|
|||
{
|
||||
// consume ammo
|
||||
if (quiver?.ConsumeTotal(AmmoType) == true)
|
||||
{
|
||||
quiver.InvalidateWeight();
|
||||
}
|
||||
else if (pack?.ConsumeTotal(AmmoType) != true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (quiver.FindItemByType(AmmoType) == null && pack?.FindItemByType(AmmoType) == null)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue