public TargetCategory GetTargetCategory(uint targetGuid, uint spellId, out WorldObject target) { // fellowship spell var spell = new Spell(spellId); if ((spell.Flags & SpellFlags.FellowshipSpell) != 0) { target = this; return(TargetCategory.Fellowship); } // direct landblock object target = CurrentLandblock?.GetObject(targetGuid); if (target != null) { return(targetGuid == Guid.Full ? TargetCategory.Self : TargetCategory.WorldObject); } // self-wielded target = GetEquippedItem(targetGuid); if (target != null) { return(TargetCategory.Wielded); } // inventory item target = GetInventoryItem(targetGuid); if (target != null) { return(TargetCategory.Inventory); } // other selectable wielded target = CurrentLandblock?.GetWieldedObject(targetGuid, true); if (target != null) { return(TargetCategory.Wielded); } // known trade objects var tradePartner = GetKnownTradeObj(new ObjectGuid(targetGuid)); if (tradePartner != null) { target = tradePartner.GetEquippedItem(targetGuid); if (target != null) { return(TargetCategory.Wielded); } target = tradePartner.GetInventoryItem(targetGuid); if (target != null) { return(TargetCategory.Inventory); } } return(TargetCategory.Undef); }
public void ExamineObject(ObjectGuid examinationId) { // TODO: Throttle this request?. The live servers did this, likely for a very good reason, so we should, too. if (examinationId.Full == 0) { // Deselect the formerly selected Target // selectedTarget = ObjectGuid.Invalid; RequestedAppraisalTarget = null; CurrentAppraisalTarget = null; return; } // The object can be in two spots... on the player or on the landblock // First check the player // search packs WorldObject wo = GetInventoryItem(examinationId); // search wielded items if (wo == null) { wo = GetWieldedItem(examinationId); } // search interactive objects if (wo == null) { if (interactiveWorldObjects.ContainsKey(examinationId)) { wo = interactiveWorldObjects[examinationId]; } } // if local, examine it if (wo != null) { wo.Examine(Session); } else { // examine item on landblock wo = CurrentLandblock?.GetObject(examinationId); if (wo != null) { wo.Examine(Session); } else { // search creature equipped weapons on nearby landblocks wo = CurrentLandblock?.GetWieldedObject(examinationId); if (wo != null) { wo.Examine(Session); } else { log.Warn("${Name} tried to appraise object {examinationId:X8}, couldn't find it"); } } } RequestedAppraisalTarget = examinationId.Full; CurrentAppraisalTarget = examinationId.Full; }
/// <summary> /// Handles player targeted casting message /// </summary> public void HandleActionCastTargetedSpell(uint targetGuid, uint spellId) { var target = CurrentLandblock?.GetObject(targetGuid); var targetCategory = TargetCategory.UnDef; if (target != null) { if (targetGuid == Guid.Full) { targetCategory = TargetCategory.Self; } else { targetCategory = TargetCategory.WorldObject; } } else { target = GetEquippedItem(targetGuid); if (target != null) { targetCategory = TargetCategory.Wielded; } else { target = GetInventoryItem(targetGuid); if (target != null) { targetCategory = TargetCategory.Inventory; } else { target = CurrentLandblock?.GetWieldedObject(targetGuid); if (target != null) { targetCategory = TargetCategory.Wielded; } } } } var spell = new Spell(spellId); if ((spell.Flags & SpellFlags.FellowshipSpell) != 0) { targetCategory = TargetCategory.Fellowship; target = this; } if (target == null) { Session.Network.EnqueueSend(new GameEventUseDone(Session, WeenieError.TargetNotAcquired)); return; } if (targetCategory != TargetCategory.WorldObject && targetCategory != TargetCategory.Wielded) { CreatePlayerSpell(target, targetCategory, spellId); } else { var rotateTarget = target; if (rotateTarget.WielderId != null) { rotateTarget = CurrentLandblock?.GetObject(rotateTarget.WielderId.Value); } // turn if required var rotateTime = Rotate(rotateTarget); var actionChain = new ActionChain(); actionChain.AddDelaySeconds(rotateTime); actionChain.AddAction(this, () => CreatePlayerSpell(target, targetCategory, spellId)); actionChain.EnqueueChain(); } if (UnderLifestoneProtection) { LifestoneProtectionDispel(); } }
public void ExamineObject(uint examinationId) { // TODO: Throttle this request?. The live servers did this, likely for a very good reason, so we should, too. if (examinationId == 0) { // Deselect the formerly selected Target // selectedTarget = ObjectGuid.Invalid; RequestedAppraisalTarget = null; CurrentAppraisalTarget = null; return; } // The object can be in two spots... on the player or on the landblock // First check the player // search packs WorldObject wo = GetInventoryItem(examinationId); // search wielded items if (wo == null) { wo = GetEquippedItem(examinationId); } // search interactive objects if (wo == null) { if (interactiveWorldObjects.ContainsKey(new ObjectGuid(examinationId))) { wo = interactiveWorldObjects[new ObjectGuid(examinationId)]; } } // if local, examine it if (wo != null) { Examine(wo); } else { // examine item on landblock wo = CurrentLandblock?.GetObject(examinationId); if (wo != null) { Examine(wo); } else { // search creature equipped weapons on nearby landblocks wo = CurrentLandblock?.GetWieldedObject(examinationId); if (wo != null) { Examine(wo); } else { // At this point, the object wasn't found. // It could be that the object was teleported away before this request was processed // It could also be a decal plugin requesting information for an object that is no longer in range //log.Warn($"{Name} tried to appraise object {examinationId.Full:X8}, couldn't find it"); } } } RequestedAppraisalTarget = examinationId; CurrentAppraisalTarget = examinationId; }