Skip to content

Commit

Permalink
Add support for Enlightenment (#3094)
Browse files Browse the repository at this point in the history
* Add support for Enlightenment

* Update Enlightenment.cs

* Update Enlightenment.cs

* comments

* Update Enlightenment.cs

* Update Enlightenment.cs

* Update Specialization rules

If skill is specialized via augmentation gem and is tinkering skill, it can be removed/refunded. If retrained, it will go back to specialized.

If skill is Salvaging, it will refund xp spent only, and remain specialized.

* Update Enlightenment.cs

* Update Enlightenment.cs

* Update Player_Skills.cs

* Update appveyor.yml
  • Loading branch information
LtRipley36706 authored Jul 29, 2020
1 parent 618c13c commit 929c307
Show file tree
Hide file tree
Showing 9 changed files with 309 additions and 135 deletions.
7 changes: 5 additions & 2 deletions Source/ACE.Entity/Enum/EmoteType.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ACE.Entity.Enum
namespace ACE.Entity.Enum
{
/// <summary>
/// exported from the decompiled client. actual usage of these is 100% speculative.
Expand Down Expand Up @@ -127,6 +127,9 @@ public enum EmoteType
SetFloatStat = 118,
AddContract = 119,
RemoveContract = 120,
InqContractsFull = 121
InqContractsFull = 121,

// Unknown Id Emotes & Custom Emotes
Enlightenment = 9001
}
}
7 changes: 7 additions & 0 deletions Source/ACE.Entity/Models/WeenieExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ public static Position GetPosition(this Weenie weenie, PositionType property)
// Utility
// =====================================

public static string GetName(this Weenie weenie)
{
var name = weenie.GetProperty(PropertyString.Name);

return name;
}

public static string GetPluralName(this Weenie weenie)
{
var pluralName = weenie.GetProperty(PropertyString.PluralName);
Expand Down
2 changes: 1 addition & 1 deletion Source/ACE.Server/Command/Handlers/DeveloperFixCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ private static void UnspecializeSkills(OfflinePlayer player)

var sac = skill.Value.SAC;

if (sac != SkillAdvancementClass.Specialized || !Player.IsSkillSpecializedViaAugmentation(skill.Key))
if (sac != SkillAdvancementClass.Specialized || Player.AugSpecSkills.Contains(skill.Key))
continue;

refundXP += skill.Value.PP;
Expand Down
265 changes: 206 additions & 59 deletions Source/ACE.Server/Entity/Enlightenment.cs

Large diffs are not rendered by default.

34 changes: 29 additions & 5 deletions Source/ACE.Server/WorldObjects/Managers/EmoteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,15 @@ public float ExecuteEmote(PropertiesEmote emoteSet, PropertiesEmoteAction emote,

break;

case EmoteType.Enlightenment:

if (player != null)
{
Enlightenment.HandleEnlightenment(WorldObject, player);
}

break;

case EmoteType.EraseMyQuest:
case EmoteType.EraseQuest:

Expand Down Expand Up @@ -530,11 +539,26 @@ public float ExecuteEmote(PropertiesEmote emoteSet, PropertiesEmoteAction emote,

case EmoteType.InqPackSpace:

//if (player != null)
//{
// var freeSpace = player.ContainerCapacity > player.ItemCapacity;
// InqCategory(freeSpace ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote);
//}
if (player != null)
{
var numRequired = emote.Amount ?? 1;

success = false;
if (numRequired > 10000) // Since emote was not in 16py and we have just the two fields to go on, I will assume you could "mask" the value to pick between free Item Capacity space or free Container Capacity space
{
var freeSpace = player.GetFreeContainerSlots();

success = freeSpace >= (numRequired - 10000);
}
else
{
var freeSpace = player.GetFreeInventorySlots(false); // assuming this was only for main pack. makes things easier at this point.

success = freeSpace >= numRequired;
}

ExecuteEmoteSet(success ? EmoteCategory.TestSuccess : EmoteCategory.TestFailure, emote.Message, targetObject, true);
}
break;

case EmoteType.InqMyQuest:
Expand Down
12 changes: 11 additions & 1 deletion Source/ACE.Server/WorldObjects/Player_Inventory.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;

using ACE.Database;
using ACE.DatLoader;
using ACE.DatLoader.FileTypes;
using ACE.Entity;
Expand Down Expand Up @@ -2836,6 +2836,12 @@ public void GiveFromEmote(WorldObject emoter, uint weenieClassId, int amount = 1
// player.Session.Network.EnqueueSend(new GameEventCommunicationTransientString(player.Session, "You do not have enough pack space to use that!"));
//else //if (playerOutOfContainerSlots)
// player.Session.Network.EnqueueSend(new GameEventCommunicationTransientString(player.Session, "You do not have enough container slots to use that!"));

// Font of Enlightenment and Rebirth tries to give you Attribute Reset Certificate.
var itemBeingGiven = DatabaseManager.World.GetCachedWeenie(weenieClassId);
var msg = new GameMessageSystemChat($"{emoter.Name} tries to give you {(itemStacks > 1 ? $"{itemStacks} " : "")}{(itemStacks > 1 ? itemBeingGiven.GetPluralName() : itemBeingGiven.GetName())}.", ChatMessageType.Broadcast);
Session.Network.EnqueueSend(msg);

return;
}

Expand Down Expand Up @@ -2880,7 +2886,11 @@ public void GiveFromEmote(WorldObject emoter, uint weenieClassId, int amount = 1
public bool TryCreateForGive(WorldObject giver, WorldObject itemBeingGiven)
{
if (!TryCreateInInventoryWithNetworking(itemBeingGiven))
{
var msg = new GameMessageSystemChat($"{giver.Name} tries to give you {(itemBeingGiven.StackSize > 1 ? $"{itemBeingGiven.StackSize} " : "")}{(itemBeingGiven.StackSize > 1 ? itemBeingGiven.GetPluralName() : itemBeingGiven.Name)}.", ChatMessageType.Broadcast);
Session.Network.EnqueueSend(msg);
return false;
}

if (!(giver.GetProperty(PropertyBool.NpcInteractsSilently) ?? false))
{
Expand Down
86 changes: 47 additions & 39 deletions Source/ACE.Server/WorldObjects/Player_Skills.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ public bool TrainSkill(Skill skill, int creditsSpent, bool applyCreationBonusXP

AvailableSkillCredits -= creditsSpent;

// Tinkering skills can be reset at Asheron's Castle and Enlightenment, so if player has the augmentation when they train the skill again immediately specialize it again.
if (IsSkillSpecializedViaAugmentation(skill, out var playerHasAugmentation) && playerHasAugmentation)
SpecializeSkill(skill, 0, false);

return true;
}

Expand Down Expand Up @@ -599,9 +603,34 @@ public static bool IsSkillUntrainable(Skill skill)
return !AlwaysTrained.Contains(skill);
}

public static bool IsSkillSpecializedViaAugmentation(Skill skill)
public bool IsSkillSpecializedViaAugmentation(Skill skill, out bool playerHasAugmentation)
{
return !AugSpecSkills.Contains(skill);
playerHasAugmentation = false;

switch (skill)
{
case Skill.ArmorTinkering:
playerHasAugmentation = AugmentationSpecializeArmorTinkering > 0;
break;

case Skill.ItemTinkering:
playerHasAugmentation = AugmentationSpecializeItemTinkering > 0;
break;

case Skill.MagicItemTinkering:
playerHasAugmentation = AugmentationSpecializeMagicItemTinkering > 0;
break;

case Skill.WeaponTinkering:
playerHasAugmentation = AugmentationSpecializeWeaponTinkering > 0;
break;

case Skill.Salvaging:
playerHasAugmentation = AugmentationSpecializeSalvaging > 0;
break;
}

return AugSpecSkills.Contains(skill);
}

public override bool GetHeritageBonus(WorldObject weapon)
Expand Down Expand Up @@ -804,7 +833,7 @@ public void HandleSkillTemplesReset()
/// <summary>
/// Resets the skill, refunds all experience and skill credits, if allowed.
/// </summary>
public bool ResetSkill(Skill skill)
public bool ResetSkill(Skill skill, bool refund = true)
{
var creatureSkill = GetCreatureSkill(skill, false);

Expand All @@ -818,67 +847,46 @@ public bool ResetSkill(Skill skill)
return false;

// salvage / tinkering skills specialized via augmentations
// cannot be untrained or unspecialized
bool specAug = false;

switch (creatureSkill.Skill)
{
case Skill.ArmorTinkering:
specAug = AugmentationSpecializeArmorTinkering > 0;
break;

case Skill.ItemTinkering:
specAug = AugmentationSpecializeItemTinkering > 0;
break;

case Skill.MagicItemTinkering:
specAug = AugmentationSpecializeMagicItemTinkering > 0;
break;

case Skill.WeaponTinkering:
specAug = AugmentationSpecializeWeaponTinkering > 0;
break;

case Skill.Salvaging:
specAug = AugmentationSpecializeSalvaging > 0;
break;
}

//if (specAug)
// return false; // send message?
// Salvaging cannot be untrained or unspecialized => skillIsSpecializedViaAugmentation && !untrainable
IsSkillSpecializedViaAugmentation(creatureSkill.Skill, out var skillIsSpecializedViaAugmentation);

var typeOfSkill = creatureSkill.AdvancementClass.ToString().ToLower() + " ";
var untrainable = IsSkillUntrainable(skill);
var creditRefund = creatureSkill.AdvancementClass == SkillAdvancementClass.Specialized || untrainable;
var creditRefund = (creatureSkill.AdvancementClass == SkillAdvancementClass.Specialized && !(skillIsSpecializedViaAugmentation && !untrainable)) || untrainable;

if (creatureSkill.AdvancementClass == SkillAdvancementClass.Specialized && !specAug)
if (creatureSkill.AdvancementClass == SkillAdvancementClass.Specialized && !(skillIsSpecializedViaAugmentation && !untrainable))
{
creatureSkill.AdvancementClass = SkillAdvancementClass.Trained;
creatureSkill.InitLevel = 0;
AvailableSkillCredits += skillBase.UpgradeCostFromTrainedToSpecialized;
if (!skillIsSpecializedViaAugmentation) // Tinkering skills can be unspecialized, but do not refund upgrade cost.
AvailableSkillCredits += skillBase.UpgradeCostFromTrainedToSpecialized;
}

// temple untraining 'always trained' skills:
// cannot be untrained, but skill XP can be recovered
if (untrainable && !specAug)
if (untrainable)
{
creatureSkill.AdvancementClass = SkillAdvancementClass.Untrained;
creatureSkill.InitLevel = 0;
AvailableSkillCredits += skillBase.TrainedCost;
}

RefundXP(creatureSkill.ExperienceSpent);
if (refund)
RefundXP(creatureSkill.ExperienceSpent);

creatureSkill.ExperienceSpent = 0;
creatureSkill.Ranks = 0;

var updateSkill = new GameMessagePrivateUpdateSkill(this, creatureSkill);
var availableSkillCredits = new GameMessagePrivateUpdatePropertyInt(this, PropertyInt.AvailableSkillCredits, AvailableSkillCredits ?? 0);

var msg = $"Your {(untrainable && !specAug ? $"{typeOfSkill}" : "")}{skill.ToSentence()} skill has been {(untrainable && !specAug ? "removed" : "reset")}. ";
msg += $"All the experience {(creditRefund && !specAug ? "and skill credits " : "")}that you spent on this skill have been refunded to you.";
var msg = $"Your {(untrainable ? $"{typeOfSkill}" : "")}{skill.ToSentence()} skill has been {(untrainable ? "removed" : "reset")}. ";
msg += $"All the experience {(creditRefund ? "and skill credits " : "")}that you spent on this skill have been refunded to you.";

Session.Network.EnqueueSend(updateSkill, availableSkillCredits, new GameMessageSystemChat(msg, ChatMessageType.Broadcast));
if (refund)
Session.Network.EnqueueSend(updateSkill, availableSkillCredits, new GameMessageSystemChat(msg, ChatMessageType.Broadcast));
else
Session.Network.EnqueueSend(updateSkill, new GameMessageSystemChat(msg, ChatMessageType.Broadcast));

return true;
}
Expand Down
29 changes: 2 additions & 27 deletions Source/ACE.Server/WorldObjects/SkillAlterationDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,33 +129,8 @@ public bool VerifyRequirements(Player player, CreatureSkill skill, SkillBase ski
}

// salvage / tinkering skills specialized via augmentations
// cannot be untrained or unspecialized
bool specAug = false;

switch (skill.Skill)
{
case Skill.ArmorTinkering:
specAug = player.AugmentationSpecializeArmorTinkering > 0;
break;

case Skill.ItemTinkering:
specAug = player.AugmentationSpecializeItemTinkering > 0;
break;

case Skill.MagicItemTinkering:
specAug = player.AugmentationSpecializeMagicItemTinkering > 0;
break;

case Skill.WeaponTinkering:
specAug = player.AugmentationSpecializeWeaponTinkering > 0;
break;

case Skill.Salvaging:
specAug = player.AugmentationSpecializeSalvaging > 0;
break;
}

if (specAug)
// Salvaging cannot be untrained or unspecialized, specialized tinkering skills can be reset at Asheron's Castle only.
if (player.IsSkillSpecializedViaAugmentation(skill.Skill, out var playerHasAugmentation) && playerHasAugmentation)
{
player.Session.Network.EnqueueSend(new GameMessageSystemChat($"You cannot lower your {skill.Skill.ToSentence()} augmented skill.", ChatMessageType.Broadcast));
return false;
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1.7.{build}
version: 1.8.{build}
pull_requests:
do_not_increment_build_number: true
skip_tags: true
Expand Down

0 comments on commit 929c307

Please sign in to comment.