ace/Source/ACE.Server/WorldObjects/Bindstone.cs
Ty Conner 046ec2df0e
More OlthoiPlay support (#3709)
* Adjust CharacterOption defaults

These changes match client enums and pcaps

* Update Player_Character.cs

* Updates for OlthoiPlay

- Handle OIthoi creation defaults
- Handle Olthoi talking
- Handle Olthoi global chat

* .

* Adjust tells from/to Olthoi

* More IsOlthoiPlayer blocks

* Update Player.cs

* Bit o' refactor

* Update AppraiseInfo.cs

* Update TurbineChatHandler.cs

* Update TurbineChatHandler.cs

* Update Player_Inventory.cs

* Update Player_Inventory.cs

* Revert IsOlthoiPlayer to get/set

* Update Player_Xp.cs

* Update Player.cs

* Update Player_Death.cs

* Update Player.cs

* Update Player_Allegiance.cs

* Update Player_Fellowship.cs

* Update Player_Character.cs

* Update WorldObject_Use.cs

* Update WorldObject_Magic.cs

* Update DamageHistoryInfo.cs

* Update Creature_Death.cs

* Update Player_Death.cs

* Update Player_Trade.cs
2021-10-18 21:14:12 -04:00

94 lines
3.4 KiB
C#

using System;
using ACE.Entity;
using ACE.Entity.Enum;
using ACE.Entity.Enum.Properties;
using ACE.Entity.Models;
using ACE.Server.Entity;
using ACE.Server.Entity.Actions;
using ACE.Server.Network.GameEvent.Events;
using ACE.Server.Network.GameMessages.Messages;
namespace ACE.Server.WorldObjects
{
public class Bindstone : WorldObject
{
/// <summary>
/// A new biota be created taking all of its values from weenie.
/// </summary>
public Bindstone(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
{
SetEphemeralValues();
}
/// <summary>
/// Restore a WorldObject from the database.
/// </summary>
public Bindstone(Biota biota) : base(biota)
{
SetEphemeralValues();
}
private void SetEphemeralValues()
{
ObjectDescriptionFlags |= ObjectDescriptionFlag.BindStone;
SetProperty(PropertyInt.ShowableOnRadar, (int)ACE.Entity.Enum.RadarBehavior.ShowAlways);
SetProperty(PropertyInt.RadarBlipColor, (int)ACE.Entity.Enum.RadarColor.LifeStone);
}
/// <summary>
/// This is raised by Player.HandleActionUseItem.<para />
/// The item does not exist in the players possession.<para />
/// If the item was outside of range, the player will have been commanded to move using DoMoveTo before ActOnUse is called.<para />
/// When this is called, it should be assumed that the player is within range.
/// </summary>
public override void ActOnUse(WorldObject worldObject)
{
if (!(worldObject is Player player))
return;
// check if player is in an allegiance
if (player.Allegiance == null)
{
player.Session.Network.EnqueueSend(new GameEventWeenieError(player.Session, WeenieError.YouAreNotInAllegiance));
return;
}
if (player.AllegiancePermissionLevel < AllegiancePermissionLevel.Seneschal)
{
player.Session.Network.EnqueueSend(new GameEventWeenieError(player.Session, WeenieError.YouDoNotHaveAuthorityInAllegiance));
return;
}
var actionChain = new ActionChain();
if (player.CombatMode != CombatMode.NonCombat)
{
var stanceTime = player.SetCombatMode(CombatMode.NonCombat);
actionChain.AddDelaySeconds(stanceTime);
player.LastUseTime += stanceTime;
}
actionChain.AddAction(this, () => EnqueueBroadcastMotion(new Motion(MotionStance.NonCombat, MotionCommand.Twitch1)));
// player animation?
player.LastUseTime += player.EnqueueMotion(actionChain, MotionCommand.Sanctuary);
actionChain.AddAction(this, () =>
{
if (player.IsWithinUseRadiusOf(this))
{
player.Allegiance.Sanctuary = new Position(player.Location);
player.Allegiance.SaveBiotaToDatabase();
player.Session.Network.EnqueueSend(new GameMessageSystemChat(GetProperty(PropertyString.UseMessage), ChatMessageType.Magic));
}
else
player.Session.Network.EnqueueSend(new GameEventWeenieError(player.Session, WeenieError.YouHaveMovedTooFar));
});
actionChain.EnqueueChain();
}
}
}