本文整理汇总了C#中Aura.Channel.World.Entities.Creature.UpdateTool方法的典型用法代码示例。如果您正苦于以下问题:C# Creature.UpdateTool方法的具体用法?C# Creature.UpdateTool怎么用?C# Creature.UpdateTool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aura.Channel.World.Entities.Creature
的用法示例。
在下文中一共展示了Creature.UpdateTool方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateWeapon
/// <summary>
/// Reduces weapon's durability and increases its proficiency.
/// Only updates weapon type items that are not null.
/// </summary>
/// <param name="creature"></param>
/// <param name="weapon"></param>
public static void UpdateWeapon(Creature attacker, Creature target, params Item[] weapons)
{
if (attacker == null)
return;
var rnd = RandomProvider.Get();
foreach (var weapon in weapons.Where(a => a != null && a.IsTrainableWeapon))
{
// Durability
if (!ChannelServer.Instance.Conf.World.NoDurabilityLoss)
{
var reduce = rnd.Next(1, 30);
// Half dura loss if blessed
if (weapon.IsBlessed)
reduce = Math.Max(1, reduce / 2);
attacker.UpdateTool(weapon, reduce);
weapon.Durability -= reduce;
Send.ItemDurabilityUpdate(attacker, weapon);
}
// Proficiency
// Only if the weapon isn't broken and the target is not "Weakest".
if (weapon.Durability != 0 && attacker != null && attacker.GetPowerRating(target) >= PowerRating.Weak)
{
short prof = 0;
if (attacker.Age >= 10 && attacker.Age <= 12)
prof = 48;
else if (attacker.Age >= 13 && attacker.Age <= 19)
prof = 60;
else
prof = 72;
weapon.Proficiency += prof;
Send.ItemExpUpdate(attacker, weapon);
}
}
}
示例2: OnResponse
/// <summary>
/// Called once ready to pull the fish out.
/// </summary>
/// <remarks>
/// When you catch something just before running out of bait,
/// and you send MotionCancel2 from Cancel, there's a
/// visual bug on Aura, where the item keeps flying to you until
/// you move. This does not happen on NA for unknown reason.
/// The workaround: Check for cancellation in advance and only
/// send the real in effect if the skill wasn't canceled.
/// </remarks>
/// <param name="creature"></param>
/// <param name="method">Method used on this try</param>
/// <param name="success">Success of manual try</param>
public void OnResponse(Creature creature, FishingMethod method, bool success)
{
// Get skill
var skill = creature.Skills.Get(SkillId.Fishing);
if (skill == null)
{
Log.Error("Fishing.OnResponse: Missing skill.");
return;
}
var rnd = RandomProvider.Get();
// Update prop state
// TODO: update prop state method
creature.Temp.FishingProp.SetState("empty");
// Get auto success
if (method == FishingMethod.Auto)
success = rnd.NextDouble() < skill.RankData.Var3 / 100f;
// Perfect fishing
if (ChannelServer.Instance.Conf.World.PerfectFishing)
success = true;
// Check fishing ground
if (creature.Temp.FishingDrop == null)
{
Send.ServerMessage(creature, "Error: No items found.");
Log.Error("Fishing.OnResponse: Failing, no drop found.");
success = false;
}
// Check equipment
if (!this.CheckEquipment(creature))
{
Send.ServerMessage(creature, "Error: Missing equipment.");
Log.Error("Fishing.OnResponse: Failing, Missing equipment.");
// TODO: Security violation once we're sure this can't happen
// without modding.
success = false;
}
var cancel = false;
// Reduce durability
if (creature.RightHand != null && !ChannelServer.Instance.Conf.World.NoDurabilityLoss)
{
var reduce = 15;
// Half dura loss if blessed
if (creature.RightHand.IsBlessed)
reduce = Math.Max(1, reduce / 2);
creature.UpdateTool(creature.RightHand, reduce);
creature.RightHand.Durability -= reduce;
Send.ItemDurabilityUpdate(creature, creature.RightHand);
// Check rod durability
if (creature.RightHand.Durability == 0)
{
cancel = true;
}
}
// Remove bait
if (creature.Magazine != null && !ChannelServer.Instance.Conf.World.InfiniteBait)
{
creature.Inventory.Decrement(creature.Magazine);
// Check if bait was removed because it was empty
if (creature.Magazine == null)
cancel = true;
}
// Fail
Item item = null;
if (!success)
{
Send.Notice(creature, Localization.Get("I was hesistating for a bit, and it got away...")); // More responses?
Send.Effect(creature, Effect.Fishing, (byte)FishingEffectType.Fall, true);
}
// Success
else
{
var propName = "prop_caught_objbox_01";
//.........这里部分代码省略.........
示例3: Complete
/// <summary>
/// Completes skill, handling the whole item gathering process.
/// </summary>
/// <param name="creature"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
public void Complete(Creature creature, Skill skill, Packet packet)
{
var entityId = packet.GetLong();
var collectId = packet.GetInt();
var rnd = RandomProvider.Get();
// Check data
var collectData = AuraData.CollectingDb.Find(collectId);
if (collectData == null)
{
Log.Warning("Gathering.Complete: Unknown collect id '{0}'", collectId);
this.DoComplete(creature, entityId, collectId, false, 1);
return;
}
// Check tools
if (!this.CheckHand(collectData.RightHand, creature.RightHand) || !this.CheckHand(collectData.LeftHand, creature.LeftHand))
{
Log.Warning("Gathering.Complete: Collecting using invalid tool.", collectId);
this.DoComplete(creature, entityId, collectId, false, 1);
return;
}
// Reduce tool's durability
if (creature.RightHand != null && collectData.DurabilityLoss > 0)
{
var reduce = collectData.DurabilityLoss;
// Half dura loss if blessed
if (creature.RightHand.IsBlessed)
reduce = Math.Max(1, reduce / 2);
creature.UpdateTool(creature.RightHand, reduce);
creature.RightHand.Durability -= reduce;
Send.ItemExpUpdate(creature, creature.RightHand);
}
// Get target (either prop or creature)
var targetEntity = this.GetTargetEntity(creature.Region, entityId);
// Check target
if (targetEntity == null || !targetEntity.HasTag(collectData.Target))
{
Log.Warning("Gathering.Complete: Collecting from invalid entity '{0:X16}'", entityId);
this.DoComplete(creature, entityId, collectId, false, 1);
return;
}
// Check position
var creaturePosition = creature.GetPosition();
var targetPosition = targetEntity.GetPosition();
if (!creaturePosition.InRange(targetPosition, MaxDistance))
{
Send.Notice(creature, Localization.Get("Your arms are too short to reach that from here."));
this.DoComplete(creature, entityId, collectId, false, 1);
return;
}
// Check if moved
if (creature.Temp.GatheringTargetPosition.GetDistance(targetPosition) > MaxMoveDistance)
{
this.DoComplete(creature, entityId, collectId, false, 3);
return;
}
// Determine success
var successChance = this.GetSuccessChance(creature, collectData);
var collectSuccess = rnd.NextDouble() * 100 < successChance;
// Get reduction
var reduction = collectData.ResourceReduction;
if (ChannelServer.Instance.Weather.GetWeatherType(creature.RegionId) == WeatherType.Rain)
reduction += collectData.ResourceReductionRainBonus;
// Check resource
if (targetEntity is Prop)
{
var targetProp = (Prop)targetEntity;
// Check if prop was emptied
if (targetProp.State == "empty")
{
this.DoComplete(creature, entityId, collectId, false, 2);
return;
}
// Regenerate resources
targetProp.Resource += (float)((DateTime.Now - targetProp.LastCollect).TotalMinutes * collectData.ResourceRecovering);
// Fail if currently no resources available
//.........这里部分代码省略.........