public void UseSecondWeapon() { if (this.PlayerDetail.SecondWeapon != null && this.m_energy - this.PlayerDetail.SecondWeapon.Template.Property4 >= 0) { if (this.m_secondWeapon <= 0) { if (this.PlayerDetail.SecondWeapon != null) { if (this.AngelCount <= 0) { this.PlayerDetail.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UnusableSecondWeapon", new object[] { this.PlayerDetail.SecondWeapon.Template.Name })); } else { this.m_secondWeapon = this.PlayerDetail.SecondWeapon.Template.Property6; this.m_energy -= this.PlayerDetail.SecondWeapon.Template.Property4; SpellMgr.ExecuteSpell(base.Game, this, this.PlayerDetail.SecondWeapon); this.m_game.SendPlayerUseProp(this, -2, -2, this.PlayerDetail.SecondWeapon.TemplateID); this.AngelCount--; } } } } }
public static void LearnSpell(string[] args, WorldClass session) { if (session.Character.TargetGuid == 0) { ChatHandler.SendMessage(ref session, new ChatMessageValues(MessageType.ChatMessageSystem, "Theres no targeted character to teach.")); return; } var target = new Character(session.Character.TargetGuid); uint spellId = CommandParser.Read <uint>(args, 1); try { SpellMgr.AddSpell(target, spellId); } catch (Exception e) { ChatMessageValues chatMessage = new ChatMessageValues(MessageType.ChatMessageSystem, e.Message); ChatHandler.SendMessage(ref session, chatMessage); } var targetSession = WorldMgr.Sessions.First(o => o.Value.Character.Guid == target.Guid).Value; SpellHandler.HandleLearnedSpells(ref targetSession, new List <uint>() { spellId }); }
public static void HandlePlayerLogin(ref PacketReader packet, ref WorldClass session) { byte[] guidMask = { 6, 3, 0, 5, 7, 2, 1, 4 }; byte[] guidBytes = { 1, 0, 3, 2, 4, 7, 5, 6 }; BitUnpack GuidUnpacker = new BitUnpack(packet); ulong guid = GuidUnpacker.GetGuid(guidMask, guidBytes); Log.Message(LogType.DEBUG, "Character with Guid: {0}, AccountId: {1} tried to enter the world.", guid, session.Account.Id); session.Character = new Character(guid, ref session); WorldMgr.Session = session; SpellMgr.LoadSpells(); WorldMgr.WriteAccountData(AccountDataMasks.CharacterCacheMask, ref session); PacketWriter motd = new PacketWriter(LegacyMessage.MessageOfTheDay); motd.WriteUInt32(3); motd.WriteCString("Arctium MoP test"); motd.WriteCString("Welcome to our MoP server test."); motd.WriteCString("Your development team =)"); session.Send(motd); SpellHandler.SendSendKnownSpells(); UpdateHandler.HandleUpdateObject(ref packet, ref session); }
public bool UseItem(ItemTemplateInfo item) { if (m_energy > item.Property4) { m_energy -= item.Property4; m_delay += item.Property5; GSPacketIn pkg = m_player.Out.SendPropUseRespone(this, -2, -2, item.TemplateID); m_game.SendToAll(pkg, m_player); SpellMgr.ExecuteSpell(m_game, m_game.CurrentPlayer, item); m_player.QuestInventory.CheckUseItem(item.TemplateID); if (item.Property6 == 1 && IsAttacking) { StopAttacking(); m_game.CheckState(0); } return(true); } return(false); }
private void ChangeProperty(Player player) { if (rand.Next(100) < m_probability) { SpellMgr.ExecuteSpell(player.Game, player, ItemMgr.FindItemTemplate(10020)); //player.Game.SendEquipEffect(player, LanguageMgr.GetTranslation("ArmorPiercerEquipEffect.Success")); } }
public SpellInfo GetFirstRankSpell() { if (ChainEntry == null) { return(this); } return(SpellMgr.GetSpellInfo(ChainEntry.first)); }
private void ChangeProperty(Player player) { if (this.rand.Next(100) < this.m_probability) { SpellMgr.ExecuteSpell(player.Game, player, ItemMgr.FindItemTemplate(10022)); player.Game.SendEquipEffect(player, LanguageMgr.GetTranslation("AtomBombEquipEffect.Success", new object[0])); } }
void player_AfterKilledByLiving(Living living, Living target, int damageAmount, int criticalAmount) { if (rand.Next(100) < m_probability) { living.ShootMovieDelay = 50; SpellMgr.ExecuteSpell(living.Game, living as Player, ItemMgr.FindItemTemplate(10021)); // living.Game.SendEquipEffect(living, LanguageMgr.GetTranslation("NoHoleEquipEffect.Success")); } }
private void player_AfterKilledByLiving(Living living, Living target, int damageAmount, int criticalAmount) { if (this.rand.Next(100) < this.m_probability) { living.EffectTrigger = true; SpellMgr.ExecuteSpell(living.Game, living as Player, ItemMgr.FindItemTemplate(10021)); living.Game.SendEquipEffect(living, LanguageMgr.GetTranslation("NoHoleEquipEffect.Success", new object[0])); } }
private void ChangeProperty(Player player) { if (rand.Next(100) < m_probability) { SpellMgr.ExecuteSpell(player.Game, player, ItemMgr.FindItemTemplate(10015)); player.Game.SendEquipEffect(player, LanguageMgr.GetTranslation("IceFronzeEquipEffect.Success")); //player.Game.SendAttackEffect(player, 1);reEn } }
/// <summary> /// Checks the areas for friendlies to heal if we can cast spells /// </summary> private void CheckAreaForHealing() { if (guard == null) { return; } if (guard.CanUseRanged) { SpellMgr.CheckAreaForHeals(guard); } }
private void CheckForNuking() { if (guard == null) { return; } if (guard.CanUseRanged) { SpellMgr.CheckForNuke(guard); } }
private void ChangeProperty(Player player, int ball) { if (AbstractEffect.random.Next(1000000) < this.m_probability * 10000 && !player.AttackEffectTrigger) { this.EffectTrigger = true; player.FlyingPartical = 65; SpellMgr.ExecuteSpell(player.Game, player, ItemMgr.FindItemTemplate(10020)); player.AttackEffectTrigger = true; player.Game.AddAction(new LivingSayAction(player, LanguageMgr.GetTranslation("ArmorPiercerEquipEffect.msg", new object[0]), 9, 0, 1000)); } }
public bool UseItem(ItemTemplateInfo item) { if (this.CanUseItem(item)) { this.m_energy -= item.Property4; this.m_delay += item.Property5; this.m_game.SendPlayerUseProp(this, -2, -2, item.TemplateID); SpellMgr.ExecuteSpell(this.m_game, this.m_game.CurrentLiving as Player, item); return(true); } return(false); }
public bool IsPrimaryProfession() { for (var i = 0; i < SharedConst.MaxSpellEffects; ++i) { if (Effects[i] != null && Effects[i].Effect == (uint)SpellEffects.Skill) { uint skill = (uint)Effects[i].MiscValue; if (SpellMgr.IsPrimaryProfessionSkill(skill)) { return(true); } } } return(false); }
bool IsAbilityLearnedWithProfession() { var bounds = SpellMgr.GetSkillLineAbility(Id); foreach (var pAbility in bounds) { if (pAbility.id == 0 || pAbility.learnOnGetSkill != 1) { continue; } if (pAbility.req_skill_value > 0) { return(true); } } return(false); }
bool IsProfessionOrRiding() { for (var i = 0; i < SharedConst.MaxSpellEffects; ++i) { if (Effects[i] == null) { continue; } if (Effects[i].Effect == (uint)SpellEffects.Skill) { uint skill = (uint)Effects[i].MiscValue; if (SpellMgr.IsProfessionOrRidingSkill(skill)) { return(true); } } } return(false); }
public static void SendSendKnownSpells() { Character pChar = GetSession().Character; if (pChar.SpellList.Count == 0) { SpellMgr.LoadSpells(); } PacketWriter writer = new PacketWriter(LegacyMessage.SendKnownSpells); BitPack BitPack = new BitPack(writer); BitPack.Write(1); BitPack.Write <uint>((uint)pChar.SpellList.Count, 24); BitPack.Flush(); pChar.SpellList.ForEach(spell => writer.WriteUInt32(spell.SpellId)); GetSession().Send(writer); }
public bool UseItem(ItemTemplateInfo item) { if (CanUseItem(item))// && IsUseProp == true) { m_energy -= item.Property4; m_delay += item.Property5; m_game.SendPlayerUseProp(this, -2, -2, item.TemplateID); SpellMgr.ExecuteSpell(m_game, m_game.CurrentLiving as Player, item); //if (item.Property6 == 1 && IsAttacking) //{ // StopAttacking(); // m_game.CheckState(0); //} return(true); } return(false); }
public bool UseItem(ItemTemplateInfo item) { bool result; if (this.CanUseItem(item)) { this.m_energy -= item.Property4; this.m_delay += item.Property5; this.m_game.SendPlayerUseProp(this, -2, -2, item.TemplateID); this.OnPlayerUseProp(this); SpellMgr.ExecuteSpell(this.m_game, this.m_game.CurrentLiving as Player, item); if (item.Property6 == 1 && base.IsAttacking) { this.StopAttacking(); this.m_game.CheckState(0); } result = true; } else { result = false; } return(result); }
public bool HandleCommand(TankGameLogicProcessor process, GamePlayer player, GSPacketIn packet) { //if (player.CurrentGame.Data.CurrentFire != null && player.CurrentGame.Data.CurrentIndex != player && !(player.CurrentGame.Data.Players[player].State == TankGameState.DEAD // && player.CurrentTeamIndex == player.CurrentGame.Data.CurrentIndex.CurrentTeamIndex) && player.CanFly == false) // return false; if (player.CurrentGame.Data.CurrentFire != null) { return(false); } if (player.CurrentGame.Data.CurrentIndex != player || !player.CanFly) { return(false); } player.CanFly = false; GSPacketIn pkg = player.Out.SendPropUseRespone(player, -2, -2, CARRY_TEMPLATE_ID); player.CurrentGame.SendToPlayerExceptSelf(pkg, player); //构造一个CARRY Item //ItemInfo CarryItem; //using (ProduceBussiness db = new ProduceBussiness()) //{ // ItemTemplateInfo[] CarryTemplate = db.GetSingleCategory(10); // foreach (ItemTemplateInfo tmp in CarryTemplate) // { // if (tmp.TemplateID == CARRY_TEMPLATE_ID) // { // CarryItem = ItemInfo.CreateFromTemplate(tmp, 1); // if (CarryItem == null) // { // return false; // } // //if (player.CurrentGame.Data.CurrentIndex == player) // // player.CurrentGame.Data.TotalDelay += CarryItem.Template.Property5; // ISpellHandler spellHandler = SpellMgr.LoadSpellHandler(CarryItem.Template.Property1); // spellHandler.Execute(player.CurrentGame.Data.CurrentIndex, CarryItem); // return true; // } // } //} ItemTemplateInfo templateInfo = Managers.PropItemMgr.FindAllProp(CARRY_TEMPLATE_ID); if (templateInfo != null) { ItemInfo CarryItem = ItemInfo.CreateFromTemplate(templateInfo, 1, (int)ItemAddType.TempProp); ISpellHandler spellHandler = SpellMgr.LoadSpellHandler(CarryItem.Template.Property1); spellHandler.Execute(player.CurrentGame.Data.CurrentIndex, CarryItem); return(true); } return(false); }
public static void HandleTrainerList(ref PacketReader packet, ref WorldSession session) { ulong guid = packet.ReadUInt64(); string str = ObjMgr.GetCypherString(CypherStrings.NpcTrainerHello); Creature unit = session.GetPlayer().GetNPCIfCanInteractWith(guid, NPCFlags.Trainer); if (unit == null) { Log.outDebug("WORLD: SendTrainerList - Unit (GUID: {0}) not found or you can not interact with him.", ObjectGuid.GuidLowPart(guid)); return; } // remove fake death //if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) //GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); // trainer list loaded at check; if (!unit.isTrainerOf(session.GetPlayer(), true)) { return; } CreatureTemplate ci = unit.GetCreatureTemplate(); if (ci == null) { Log.outDebug("WORLD: SendTrainerList - (GUID: {0}) NO CREATUREINFO!", ObjectGuid.GuidLowPart(guid)); return; } TrainerSpellData trainer_spells = unit.GetTrainerSpells(); if (trainer_spells == null) { Log.outDebug("WORLD: SendTrainerList - Training spells not found for creature (GUID: {0} Entry: {1})", ObjectGuid.GuidLowPart(guid), unit.GetEntry()); return; } PacketWriter data = new PacketWriter(Opcodes.SMSG_TrainerList); data.WriteUInt64(guid); data.WriteUInt32(trainer_spells.trainerType); data.WriteUInt32(133); int count_pos = data.wpos(); data.WriteUInt32(trainer_spells.spellList.Count); // reputation discount float fDiscountMod = session.GetPlayer().GetReputationPriceDiscount(unit); bool can_learn_primary_prof = session.GetPlayer().GetFreePrimaryProfessionPoints() > 0; uint count = 0; foreach (var spell in trainer_spells.spellList.Values) { bool valid = true; bool primary_prof_first_rank = false; for (var i = 0; i < 3; ++i) { if (spell.learnedSpell[i] == 0) { continue; } if (!session.GetPlayer().IsSpellFitByClassAndRace(spell.learnedSpell[i])) { valid = false; break; } SpellInfo spellentry = SpellMgr.GetSpellInfo(spell.learnedSpell[i]); if (spellentry.IsPrimaryProfessionFirstRank()) { primary_prof_first_rank = true; } } if (!valid) { continue; } TrainerSpellState state = session.GetPlayer().GetTrainerSpellState(spell); data.WriteUInt32(spell.spellId); // learned spell (or cast-spell in profession case) data.WriteUInt8((byte)(state == TrainerSpellState.GreenDisabled ? TrainerSpellState.Green : state)); data.WriteUInt32((uint)Math.Floor(spell.spellCost * fDiscountMod)); data.WriteUInt8((byte)spell.reqLevel); data.WriteUInt32(spell.reqSkill); data.WriteUInt32(spell.reqSkillValue); //prev + req or req + 0 var maxReq = 0; for (var i = 0; i < 3; ++i) { if (spell.learnedSpell[i] == 0) { continue; } uint prevSpellId = SpellMgr.GetPrevSpellInChain(spell.learnedSpell[i]); if (prevSpellId != 0) { data.WriteUInt32(prevSpellId); maxReq++; } if (maxReq == 2) { break; } //SpellsRequiringSpellMapBounds spellsRequired = sSpellMgr->GetSpellsRequiredForSpellBounds(tSpell->learnedSpell[i]); //for (SpellsRequiringSpellMap::const_iterator itr2 = spellsRequired.first; itr2 != spellsRequired.second && maxReq < 3; ++itr2) { //data.WriteUInt32(itr2->second); //++maxReq; } //if (maxReq == 2) //break; } while (maxReq < 2) { data.WriteUInt32(0); maxReq++; } data.WriteInt32(primary_prof_first_rank && can_learn_primary_prof ? 1 : 0); count++; } data.WriteCString(str); data.Replace <uint>(count_pos, count); session.Send(data); }
public Spell(Unit caster, SpellInfo info, TriggerCastFlags triggerFlags, ulong originalCasterGUID = 0, bool skipCheck = false) { m_spellInfo = SpellMgr.GetSpellForDifficultyFromSpell(info, caster); m_caster = Convert.ToBoolean(info.AttributesEx6 & SpellAttr6.CastByCharmer) ? null : caster;//&& caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : caster m_spellValue = new SpellValue(m_spellInfo); m_customError = SpellCustomErrors.None; m_skipCheck = skipCheck; m_selfContainer = null; m_referencedFromCurrentSpell = false; m_executedCurrently = false; m_needComboPoints = m_spellInfo.NeedsComboPoints(); m_comboPointGain = 0; m_delayStart = 0; m_delayAtDamageCount = 0; m_applyMultiplierMask = 0; m_auraScaleMask = 0; // Get data for type of attack switch (m_spellInfo.DmgClass) { case SpellDmgClass.Melee: if (Convert.ToBoolean(m_spellInfo.AttributesEx3 & SpellAttr3.ReqOffhand)) { m_attackType = WeaponAttackType.OffAttack; } else { m_attackType = WeaponAttackType.BaseAttack; } break; case SpellDmgClass.Ranged: m_attackType = m_spellInfo.IsRangedWeaponSpell() ? WeaponAttackType.RangedAttack : WeaponAttackType.BaseAttack; break; default: // Wands if (Convert.ToBoolean(m_spellInfo.AttributesEx2 & SpellAttr2.AutorepeatFlag)) { m_attackType = WeaponAttackType.RangedAttack; } else { m_attackType = WeaponAttackType.BaseAttack; } break; } m_spellSchoolMask = info.GetSchoolMask(); // Can be override for some spell (wand shoot for example) if (m_attackType == WeaponAttackType.RangedAttack) { if ((m_caster.getClassMask() & SharedConst.ClassMaskWandUsers) != 0 && m_caster.GetTypeId() == ObjectType.Player) { Item pItem = m_caster.ToPlayer().GetWeaponForAttack(WeaponAttackType.RangedAttack); //if (pItem != null) //m_spellSchoolMask = (SpellSchoolMask)(1 << (int)pItem.ItemInfo.ItemSparse.DamageType); } } if (originalCasterGUID != 0) { m_originalCasterGUID = originalCasterGUID; } else { m_originalCasterGUID = m_caster.GetGUID(); } if (m_originalCasterGUID == m_caster.GetGUID()) { m_originalCaster = m_caster; } else { m_originalCaster = ObjMgr.GetObject <Unit>(m_caster, m_originalCasterGUID); if (m_originalCaster != null && !m_originalCaster.IsInWorld) { m_originalCaster = null; } } m_spellState = SpellState.None; _triggeredCastFlags = triggerFlags; if (Convert.ToBoolean(info.AttributesEx4 & SpellAttr4.Triggered)) { _triggeredCastFlags = TriggerCastFlags.FullMask; } m_CastItem = null; m_castItemGUID = 0; unitTarget = null; itemTarget = null; gameObjTarget = null; focusObject = null; m_cast_count = 0; m_glyphIndex = 0; m_preCastSpell = 0; //m_triggeredByAuraSpell = null; //m_spellAura = null; //Auto Shot & Shoot (wand) m_autoRepeat = m_spellInfo.IsAutoRepeatRangedSpell(); m_runesState = 0; m_powerCost = 0; // setup to correct value in Spell::prepare, must not be used before. m_casttime = 0; // setup to correct value in Spell::prepare, must not be used before. m_timer = 0; // will set to castime in prepare //m_channelTargetEffectMask = 0; // Determine if spell can be reflected back to the caster // Patch 1.2 notes: Spell Reflection no longer reflects abilities m_canReflect = m_spellInfo.DmgClass == SpellDmgClass.Magic && !Convert.ToBoolean(m_spellInfo.Attributes & SpellAttr0.Ability) && !Convert.ToBoolean(m_spellInfo.AttributesEx & SpellAttr1.CantBeReflected) && !Convert.ToBoolean(m_spellInfo.Attributes & SpellAttr0.UnaffectedByInvulnerability) && !m_spellInfo.IsPassive() && !m_spellInfo.IsPositive(); CleanupTargetList(); for (var i = 0; i < SharedConst.MaxSpellEffects; ++i) { m_destTargets[i] = new SpellDestination(m_caster); } }