Skip to content

Commit

Permalink
- Added: New method to GameLiving, InCombatInLast(milliseconds).
Browse files Browse the repository at this point in the history
  • Loading branch information
geshidol committed Jul 4, 2011
1 parent cd9aa25 commit 5bb3047
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions GameServer/gameobjects/GameLiving.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,24 @@ public virtual bool InCombat
}
}

/// <summary>
/// Check this flag to see if this living has been involved in combat in the given milliseconds
/// </summary>
public virtual bool InCombatInLast(int milliseconds)
{
if ((InCombatPvEInLast(milliseconds) || InCombatPvPInLast(milliseconds)) == false)
{
if (Attackers.Count > 0)
{
Attackers.Clear();
}

return false;
}

return true;
}

/// <summary>
/// checks if the living is involved in pvp combat
/// </summary>
Expand All @@ -1200,6 +1218,21 @@ public virtual bool InCombatPvP
}
}

/// <summary>
/// checks if the living is involved in pvp combat in the given milliseconds
/// </summary>
public virtual bool InCombatPvPInLast(int milliseconds)
{
Region region = CurrentRegion;
if (region == null)
return false;

if (LastCombatTickPvP == 0)
return false;

return LastCombatTickPvP + milliseconds >= region.Time;
}

/// <summary>
/// checks if the living is involved in pve combat
/// </summary>
Expand All @@ -1221,6 +1254,24 @@ public virtual bool InCombatPvE
}
}

/// <summary>
/// checks if the living is involved in pve combat in the given milliseconds
/// </summary>
public virtual bool InCombatPvEInLast(int milliseconds)
{
Region region = CurrentRegion;
if (region == null)
return false;

if (LastCombatTickPvE == 0)
return false;

//if (LastCombatTickPvE + 10000 - region.Time > 0 && this is GameNPC && (this as GameNPC).Brain is IControlledBrain)
// log.Debug(Name + " in combat " + (LastCombatTickPvE + 10000 - region.Time));

return LastCombatTickPvE + milliseconds >= region.Time;
}

/// <summary>
/// Returns the amount of experience this living is worth
/// </summary>
Expand Down

0 comments on commit 5bb3047

Please sign in to comment.