Skip to content

Commit

Permalink
Adding methods to QuestManager (#1052)
Browse files Browse the repository at this point in the history
* Fixing stance shuffling / refactoring moveto chains a bit

* Fixing vendor rotate

* Removing debug message

* Fixing stance change for player activating switches

* Adding methods to QuestManager

* Adding TimeSpanExtensions

* Adjusting walk/run threshold

* Adding quest restrictions for portals, and portal spawning triggered by monster deaths

* Updating function names

* Adding HasQuestCompletes

* Adding support for character titles to emotes

* Added emote hooks for portal use and creature death

* Adding KillTaunt and NewEnemy, updating questName@comment format

* Updating broadcast emotes

* Updating InqQuestSolves

* Adding fixes for Aerfalle

* Fixed rolling balls of death
  • Loading branch information
gmriggs authored and LtRipley36706 committed Oct 13, 2018
1 parent aad8974 commit 678681f
Show file tree
Hide file tree
Showing 30 changed files with 778 additions and 280 deletions.
48 changes: 48 additions & 0 deletions Source/ACE.Common/Extensions/TimeSpanExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.Text;

namespace ACE.Common.Extensions
{
public static class TimeSpanExtensions
{
public static string GetFriendlyString(this TimeSpan timeSpan)
{
// use datetime here?
// this probably won't work with numDays...
//var numYears = timeSpan.GetYears();
//var numMonths = timeSpan.GetMonths();

var numDays = timeSpan.ToString("%d");
var numHours = timeSpan.ToString("%h");
var numMinutes = timeSpan.ToString("%m");
var numSeconds = timeSpan.ToString("%s");

var sb = new StringBuilder();

// did retail display months/years?

//if (numYears > 0) sb.Append(numYears + "y ");
//if (numMonths > 0) sb.Append(numMonths + "mo ");

if (numDays != "0") sb.Append(numDays + "d ");
if (numHours != "0") sb.Append(numHours + "h ");
if (numMinutes != "0") sb.Append(numMinutes + "m ");
if (numSeconds != "0") sb.Append(numSeconds + "s ");

return sb.ToString().Trim();
}

public static uint SecondsPerMonth = 60 * 60 * 24 * 30; // 30-day estimate
public static uint SecondsPerYear = 60 * 60 * 24 * 365; // non-leap year

public static uint GetMonths(this TimeSpan timeSpan)
{
return (uint)timeSpan.TotalSeconds / SecondsPerMonth;
}

public static uint GetYears(this TimeSpan timeSpan)
{
return (uint)timeSpan.TotalSeconds / SecondsPerYear;
}
}
}
20 changes: 18 additions & 2 deletions Source/ACE.Database/WorldDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ public TreasureDeath GetCachedDeathTreasure(uint dataId)
/// <summary>
/// This takes under 1 second to complete.
/// </summary>
public void CacheAllDeathTresures()
public void CacheAllDeathTreasures()
{
using (var context = new WorldDbContext())
{
Expand Down Expand Up @@ -680,7 +680,7 @@ public List<TreasureWielded> GetCachedWieldedTreasure(uint dataId)
/// <summary>
/// This takes under 1 second to complete.
/// </summary>
public void CacheAllWieldedTresuresInParallel()
public void CacheAllWieldedTreasuresInParallel()
{
using (var context = new WorldDbContext())
{
Expand All @@ -693,5 +693,21 @@ public void CacheAllWieldedTresuresInParallel()
cachedWieldedTreasure[result.Key] = result.ToList();
}
}

private readonly ConcurrentDictionary<string, Quest> cachedQuest = new ConcurrentDictionary<string, Quest>();

public Quest GetCachedQuest(string questName)
{
if (cachedQuest.TryGetValue(questName, out var quest))
return quest;

using (var context = new WorldDbContext())
{
quest = context.Quest.FirstOrDefault(q => q.Name.Equals(questName));
cachedQuest[questName] = quest;

return quest;
}
}
}
}
3 changes: 3 additions & 0 deletions Source/ACE.Entity/Enum/WeenieError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ namespace ACE.Entity.Enum
/// The enum is used in handling 0x028A and 0x028B messages and also some other messages like UseDone.<para/>
/// We split the enum up into 2 enums because each function uses only a specific set of the enum values.<para/>
/// There are cases where the value was used by multiple messages e.g. 0x0036 ActionCancelled.
///
/// Client error messages:
/// http://ac.yotesfan.com/client/errors.php
/// </summary>
public enum WeenieError
{
Expand Down
2 changes: 1 addition & 1 deletion Source/ACE.Server/Command/Handlers/AdminCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ public static void HandleSmite(Session session, params string[] parameters)
if (wo is Player) // I don't recall if @smite all would kill players in range, assuming it didn't
continue;

if (wo is Creature creature)
if (wo is Creature creature && creature.IsAttackable())
creature.Smite(session.Player);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/ACE.Server/Command/Handlers/SentinelCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public static void HandlePortalBypass(Session session, params string[] parameter
{
// @portal_bypass - Toggles the ability to bypass portal restrictions.

var param = session.Player.IgnorePortalRestrictions ?? false;
var param = session.Player.IgnorePortalRestrictions;

switch (param)
{
Expand Down
5 changes: 5 additions & 0 deletions Source/ACE.Server/Entity/DamageHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ private void OnHealInternal(uint healAmount, uint currentHealth, uint maxHealth)
TotalDamage[damager] *= scalar;
}

/// <summary>
/// Returns the list of players or creatures who inflicted damage
/// </summary>
public List<WorldObject> Damagers { get => Log.Select(l => l.DamageSource).Distinct().ToList(); }

/// <summary>
/// Returns the WorldObject that last damaged this WorldObject
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions Source/ACE.Server/Entity/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public DateTime GetSpawnTime()
if (_generator.CurrentlyPoweringUp)
{
// initial spawn delay
if (_generator.GeneratorInitialDelay == 6000) // spawn repair golem immediately?
_generator.GeneratorInitialDelay = 0;

return DateTime.UtcNow.AddSeconds(_generator.GeneratorInitialDelay);
}
else
Expand Down Expand Up @@ -153,6 +156,10 @@ public void ProcessQueue()

Spawned.Add(obj.Guid.Full, registry);
}
else
{
//_generator.CurrentCreate--;
}
}
else
{
Expand Down
Loading

0 comments on commit 678681f

Please sign in to comment.