/// <summary> /// Sets the controlled object for this player /// </summary> /// <param name="controlledNpc"></param> public override void SetControlledBrain(IControlledBrain controlledNpcBrain) { m_savedPetHealthPercent = (Player.ControlledBrain != null) ? (int)Player.ControlledBrain.Body.HealthPercent : 0; base.SetControlledBrain(controlledNpcBrain); if (controlledNpcBrain == null) { OnPetReleased(); } }
/// <summary> /// Determines if a given controlled brain is part of the commanders subpets /// </summary> /// <param name="brain">The brain to check</param> /// <returns>True if found, else false</returns> public bool FindPet(IControlledBrain brain) { if (Body.ControlledNpcList != null) { lock (Body.ControlledNpcList) { foreach (IControlledBrain icb in Body.ControlledNpcList) if (brain == icb) return true; } } return false; }
/// <summary> /// Determines if a given controlled brain is part of the commanders subpets /// </summary> /// <param name="brain">The brain to check</param> /// <returns>True if found, else false</returns> public bool FindPet(IControlledBrain brain) { if (Body.ControlledNpcList != null) { lock (Body.ControlledNpcList) { foreach (IControlledBrain icb in Body.ControlledNpcList) { if (brain == icb) { return(true); } } } } return(false); }
protected override void OnNpcReleaseCommand(DOLEvent e, object sender, EventArgs arguments) { if (!(sender is GameNPC) || !((sender as GameNPC).Brain is IControlledBrain)) { return; } GameNPC pet = sender as GameNPC; IControlledBrain brain = pet.Brain as IControlledBrain; GameEventMgr.RemoveHandler(pet, GameLivingEvent.PetReleased, new DOLEventHandler(OnNpcReleaseCommand)); DOL.GS.Effects.GameSpellEffect effect = FindEffectOnTarget(pet, this); if (effect != null) { effect.Cancel(false); } }
/// <summary> /// Stops the duel if player attack or is attacked by anything other that duel target /// </summary> /// <param name="e"></param> /// <param name="sender"></param> /// <param name="arguments"></param> protected virtual void DuelOnAttack(DOLEvent e, object sender, EventArgs arguments) { AttackData ad = null; GameLiving target = null; var afea = arguments as AttackFinishedEventArgs; var abeea = arguments as AttackedByEnemyEventArgs; if (afea != null) { ad = afea.AttackData; target = ad.Target; } else if (abeea != null) { ad = abeea.AttackData; target = ad.Attacker; } if (ad == null) { return; } // check pets owner for my and enemy attacks GameNPC npc = target as GameNPC; if (npc != null) { IControlledBrain brain = npc.Brain as IControlledBrain; if (brain != null) { target = brain.GetPlayerOwner(); } } // Duel should end if players join group and trys to attack if (ad.Attacker.Group != null && ad.Attacker.Group.IsInTheGroup(ad.Target)) { Stop(); } if (ad.IsHit && target != Target) { Stop(); } }
public override void TakeDamage(GameObject source, eDamageType damageType, int damageAmount, int criticalAmount) { //Check if this encounter mob is tethered and if so, ignore any damage done both outside of or too far from it's tether range. if (this.TetherRange > 100) { // if controlled NPC - do checks for owner instead if (source is GameNPC) { IControlledBrain controlled = ((GameNPC)source).Brain as IControlledBrain; if (controlled != null) { source = controlled.GetPlayerOwner(); } } if (IsOutOfTetherRange) { if (source is GamePlayer) { GamePlayer player = source as GamePlayer; player.Out.SendMessage("The " + this.Name + " is too far from its encounter area, your damage fails to have an effect on it!", eChatType.CT_Important, eChatLoc.CL_ChatWindow); return; } return; } else { if (IsWithinRadius(source, this.TetherRange)) { base.TakeDamage(source, damageType, damageAmount, criticalAmount); return; } if (source is GamePlayer) { GamePlayer player = source as GamePlayer; player.Out.SendMessage("You are too far from the " + this.Name + ", your damage fails to effect it!", eChatType.CT_Important, eChatLoc.CL_ChatWindow); } return; } } else { base.TakeDamage(source, damageType, damageAmount, criticalAmount); } }
public override int CalcValue(GameLiving living, eProperty property) { if (living is GamePlayer) { // GamePlayer player = (GamePlayer)living; return(living.Level + living.ItemBonus[(int)property] + living.BaseBuffBonusCategory[(int)property]); } else if (living is GameNPC) { IControlledBrain brain = ((GameNPC)living).Brain as IControlledBrain; if (brain != null) { return(brain.Owner.Level + living.ItemBonus[(int)property] + living.BaseBuffBonusCategory[(int)property]); } return(living.Level + living.ItemBonus[(int)property] + living.BaseBuffBonusCategory[(int)property]); } return(0); }
/// <summary> /// Releases controlled object /// </summary> public virtual void CommandNpcRelease() { IControlledBrain controlledBrain = Player.ControlledBrain; if (controlledBrain == null) { return; } GameNPC npc = controlledBrain.Body; if (npc == null) { return; } Player.Notify(GameLivingEvent.PetReleased, npc); }
/// <summary> /// execute direct effect /// </summary> /// <param name="target">target that gets the damage</param> /// <param name="effectiveness">factor from 0..1 (0%-100%)</param> public override void OnDirectEffect(GameLiving target, double effectiveness) { if (target == null) { return; } bool spellOK = !(Spell.Target == "Frontal" || Spell.Target == "Enemy" && Spell.Radius > 0 && Spell.Range == 0); if (!spellOK || CheckLOS(Caster)) { GamePlayer player = null; if (target is GamePlayer gamePlayer) { player = gamePlayer; } else { if (Caster is GamePlayer player1) { player = player1; } else if ((Caster as GameNPC)?.Brain is IControlledBrain) { IControlledBrain brain = ((GameNPC)Caster).Brain as IControlledBrain; player = brain.GetPlayerOwner(); } } if (player != null) { player.TempProperties.setProperty(LOSEFFECTIVENESS, effectiveness); player.Out.SendCheckLOS(Caster, target, new CheckLOSResponse(DealDamageCheckLOS)); } else { DealDamage(target, effectiveness); } } else { DealDamage(target, effectiveness); } }
/// <summary> /// execute direct effect /// </summary> /// <param name="target">target that gets the damage</param> /// <param name="effectiveness">factor from 0..1 (0%-100%)</param> public override void OnDirectEffect(GameLiving target, double effectiveness) { if (target == null) { return; } bool spellOK = !(Spell.Target.ToLower() == "cone" || Spell.Target == "Enemy" && Spell.Radius > 0 && Spell.Range == 0); if (spellOK == false || MustCheckLOS(Caster)) { GamePlayer checkPlayer = null; if (target is GamePlayer) { checkPlayer = target as GamePlayer; } else { if (Caster is GamePlayer) { checkPlayer = Caster as GamePlayer; } else if ((Caster as GameNPC)?.Brain is IControlledBrain) { IControlledBrain brain = ((GameNPC)Caster).Brain as IControlledBrain; checkPlayer = brain.GetPlayerOwner(); } } if (checkPlayer != null) { checkPlayer.TempProperties.setProperty(LOSEFFECTIVENESS + target.ObjectID, effectiveness); checkPlayer.Out.SendCheckLOS(Caster, target, new CheckLOSResponse(DealDamageCheckLOS)); } else { DealDamage(target, effectiveness); } } else { DealDamage(target, effectiveness); } }
/// <summary> /// Removes the brain from /// </summary> /// <param name="controlledNpc">The brain to find and remove</param> /// <returns>Whether the pet was removed</returns> public override bool RemoveControlledNpc(IControlledBrain controlledNpc) { bool found = false; lock (ControlledNpcList) { if (controlledNpc == null) { return(false); } IControlledBrain[] brainlist = ControlledNpcList; int i = 0; // Try to find the minion in the list for (; i < brainlist.Length; i++) { // Found it if (brainlist[i] == controlledNpc) { found = true; break; } } // Found it, lets remove it if (found) { // First lets store the brain to kill it IControlledBrain tempBrain = m_controlledBrain[i]; // Lets get rid of the brain asap m_controlledBrain[i] = null; // Only decrement, we just lost one pet PetCount--; return(base.RemoveControlledNpc(controlledNpc)); } } return(found); }
/// <summary> /// Called when owner release NPC /// </summary> /// <param name="e"></param> /// <param name="sender"></param> /// <param name="arguments"></param> protected virtual void OnNpcReleaseCommand(DOLEvent e, object sender, EventArgs arguments) { if (!((sender as GameNPC)?.Brain is IControlledBrain)) { return; } GameNPC pet = sender as GameNPC; IControlledBrain brain = pet.Brain as IControlledBrain; GameLiving living = brain.Owner; living.SetControlledBrain(null); GameEventMgr.RemoveHandler(pet, GameLivingEvent.PetReleased, new DOLEventHandler(OnNpcReleaseCommand)); GameSpellEffect effect = FindEffectOnTarget(pet, this); effect?.Cancel(false); }
/// <summary> /// Adds a pet to the current array of pets /// </summary> /// <param name="controlledNpc">The brain to add to the list</param> /// <returns>Whether the pet was added or not</returns> public override bool AddControlledNpc(IControlledBrain controlledNpc) { IControlledBrain[] brainlist = ControlledNpcList; if (brainlist == null) { return(false); } foreach (IControlledBrain icb in brainlist) { if (icb == controlledNpc) { return(false); } } if (controlledNpc.Owner != this) { throw new ArgumentException("ControlledNpc with wrong owner is set (player=" + Name + ", owner=" + controlledNpc.Owner.Name + ")", "controlledNpc"); } // Find the next spot for this new pet int i = 0; for (; i < brainlist.Length; i++) { if (brainlist[i] == null) { break; } } // If we didn't find a spot return false if (i >= m_controlledBrain.Length) { return(false); } m_controlledBrain[i] = controlledNpc; PetCount++; return(base.AddControlledNpc(controlledNpc)); }
public override System.Collections.IList SelectTargets(GameObject castTarget) { ArrayList list = new ArrayList(); GameLiving target = castTarget as GameLiving; if (Caster is GamePlayer) { GamePlayer casterPlayer = (GamePlayer)Caster; Group group = casterPlayer.Group; if (group == null) { return(list); // Should not appen since it is checked in ability handler } int spellRange = CalculateSpellRange(); if (group != null) { lock (group) { foreach (GamePlayer groupPlayer in casterPlayer.GetPlayersInRadius((ushort)m_spell.Radius)) { if (casterPlayer.Group.IsInTheGroup(groupPlayer)) { if (groupPlayer != casterPlayer && groupPlayer.IsAlive) { list.Add(groupPlayer); IControlledBrain npc = groupPlayer.ControlledBrain; if (npc != null) { if (casterPlayer.IsWithinRadius(npc.Body, spellRange)) { list.Add(npc.Body); } } } } } } } } return(list); }
protected override IControlledBrain GetPetBrain(GameLiving owner) { IControlledBrain controlledBrain = null; BDSubPet.SubPetType type = (BDSubPet.SubPetType)(byte) this.Spell.DamageType; owner = owner.ControlledBrain.Body; switch (type) { case BDSubPet.SubPetType.Melee: controlledBrain = new BDMeleeBrain(owner); break; case BDSubPet.SubPetType.Healer: controlledBrain = new BDHealerBrain(owner); break; case BDSubPet.SubPetType.Caster: controlledBrain = new BDCasterBrain(owner); break; case BDSubPet.SubPetType.Debuffer: controlledBrain = new BDDebufferBrain(owner); break; case BDSubPet.SubPetType.Buffer: controlledBrain = new BDBufferBrain(owner); break; case BDSubPet.SubPetType.Archer: controlledBrain = new BDArcherBrain(owner); break; default: controlledBrain = new ControlledNpcBrain(owner); break; } return(controlledBrain); }
/// <summary> /// Releases controlled object /// </summary> public virtual void CommandNpcRelease() { IControlledBrain controlledBrain = Player.ControlledBrain; if (controlledBrain == null) { return; } GameNPC npc = controlledBrain.Body; if (npc == null) { return; } else if (npc is GamePet) { GamePet pet = npc as GamePet; pet.StripOwnerBuffs(pet.Owner); } Player.Notify(GameLivingEvent.PetReleased, npc); }
public override void SetControlledBrain(IControlledBrain controlledBrain) { if (ControlledBrain == null) InitControlledBrainArray(1); ControlledBrain = controlledBrain; }
public override bool IsSameRealm(GameLiving source, GameLiving target, bool quiet) { if (source == null || target == null) { return(false); } // if controlled NPC - do checks for owner instead if (source is GameNPC) { IControlledBrain controlled = ((GameNPC)source).Brain as IControlledBrain; if (controlled != null) { source = controlled.GetLivingOwner(); quiet = true; // silence all attacks by controlled npc } } if (target is GameNPC) { IControlledBrain controlled = ((GameNPC)target).Brain as IControlledBrain; if (controlled != null) { target = controlled.GetLivingOwner(); } } if (source == target) { return(true); } // clients with priv level > 1 are considered friendly by anyone if (target is GamePlayer && ((GamePlayer)target).Client.Account.PrivLevel > 1) { return(true); } // checking as a gm, targets are considered friendly if (source is GamePlayer && ((GamePlayer)source).Client.Account.PrivLevel > 1) { return(true); } //Peace flag NPCs are same realm if (target is GameNPC) { if ((((GameNPC)target).Flags & GameNPC.eFlags.PEACE) != 0) { return(true); } } if (source is GameNPC) { if ((((GameNPC)source).Flags & GameNPC.eFlags.PEACE) != 0) { return(true); } } if (source.Realm != target.Realm) { if (quiet == false) { MessageToLiving(source, target.GetName(0, true) + " is not a member of your realm!"); } return(false); } return(true); }
protected virtual void SetBrainToOwner(IControlledBrain brain) { Caster.SetControlledBrain(brain); }
public override void SendNPCCreate(GameNPC npc) { if (m_gameClient.Player == null || npc.IsVisibleTo(m_gameClient.Player) == false) { return; } //Added by Suncheck - Mines are not shown to enemy players if (npc is GameMine) { if (GameServer.ServerRules.IsAllowedToAttack((npc as GameMine).Owner, m_gameClient.Player, true)) { return; } } if (npc is GameMovingObject) { SendMovingObjectCreate(npc as GameMovingObject); return; } using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.NPCCreate))) { int speed = 0; ushort speedZ = 0; if (npc == null) { return; } if (!npc.IsAtTargetPosition) { speed = npc.CurrentSpeed; speedZ = (ushort)npc.TickSpeedZ; } pak.WriteShort((ushort)npc.ObjectID); pak.WriteShort((ushort)(speed)); pak.WriteShort(npc.Heading); pak.WriteShort((ushort)npc.Z); pak.WriteInt((uint)npc.X); pak.WriteInt((uint)npc.Y); pak.WriteShort(speedZ); pak.WriteShort(npc.Model); pak.WriteByte(npc.Size); byte level = npc.GetDisplayLevel(m_gameClient.Player); if ((npc.Flags & GameNPC.eFlags.STATUE) != 0) { level |= 0x80; } pak.WriteByte(level); byte flags = (byte)(GameServer.ServerRules.GetLivingRealm(m_gameClient.Player, npc) << 6); if ((npc.Flags & GameNPC.eFlags.GHOST) != 0) { flags |= 0x01; } if (npc.Inventory != null) { flags |= 0x02; //If mob has equipment, then only show it after the client gets the 0xBD packet } if ((npc.Flags & GameNPC.eFlags.PEACE) != 0) { flags |= 0x10; } if ((npc.Flags & GameNPC.eFlags.FLYING) != 0) { flags |= 0x20; } if ((npc.Flags & GameNPC.eFlags.TORCH) != 0) { flags |= 0x04; } pak.WriteByte(flags); pak.WriteByte(0x20); //TODO this is the default maxstick distance string add = ""; byte flags2 = 0x00; IControlledBrain brain = npc.Brain as IControlledBrain; if (m_gameClient.Version >= GameClient.eClientVersion.Version187) { if (brain != null) { flags2 |= 0x80; // have Owner } } if ((npc.Flags & GameNPC.eFlags.CANTTARGET) != 0) { if (m_gameClient.Account.PrivLevel > 1) { add += "-DOR"; // indicates DOR flag for GMs } else { flags2 |= 0x01; } } if ((npc.Flags & GameNPC.eFlags.DONTSHOWNAME) != 0) { if (m_gameClient.Account.PrivLevel > 1) { add += "-NON"; // indicates NON flag for GMs } else { flags2 |= 0x02; } } if ((npc.Flags & GameNPC.eFlags.STEALTH) > 0) { flags2 |= 0x04; } eQuestIndicator questIndicator = npc.GetQuestIndicator(m_gameClient.Player); if (questIndicator == eQuestIndicator.Available) { flags2 |= 0x08; //hex 8 - quest available } if (questIndicator == eQuestIndicator.Finish) { flags2 |= 0x10; //hex 16 - quest finish } //flags2 |= 0x20;//hex 32 - water mob? //flags2 |= 0x40;//hex 64 - unknown //flags2 |= 0x80;//hex 128 - has owner pak.WriteByte(flags2); // flags 2 byte flags3 = 0x00; if (questIndicator == eQuestIndicator.Lesson) { flags3 |= 0x01; } if (questIndicator == eQuestIndicator.Lore) { flags3 |= 0x02; } pak.WriteByte(flags3); // new in 1.71 (region instance ID from StoC_0x20) OR flags 3? pak.WriteShort(0x00); // new in 1.71 unknown string name = npc.Name; string guildName = npc.GuildName; LanguageDataObject translation = LanguageMgr.GetTranslation(m_gameClient, npc); if (translation != null) { if (!Util.IsEmpty(((DBLanguageNPC)translation).Name)) { name = ((DBLanguageNPC)translation).Name; } if (!Util.IsEmpty(((DBLanguageNPC)translation).GuildName)) { guildName = ((DBLanguageNPC)translation).GuildName; } } if (name.Length + add.Length + 2 > 47) // clients crash with too long names { name = name.Substring(0, 47 - add.Length - 2); } if (add.Length > 0) { name = string.Format("[{0}]{1}", name, add); } pak.WritePascalString(name); if (guildName.Length > 47) { pak.WritePascalString(guildName.Substring(0, 47)); } else { pak.WritePascalString(guildName); } pak.WriteByte(0x00); SendTCP(pak); } // Update Cache m_gameClient.GameObjectUpdateArray[new Tuple <ushort, ushort>(npc.CurrentRegionID, (ushort)npc.ObjectID)] = 0; }
public override void Start(GameLiving living) { m_living = living; //Send messages if (m_living is GamePlayer) { ((GamePlayer)m_living).Out.SendMessage("You begin to charge wildly!", eChatType.CT_Spell, eChatLoc.CL_SystemWindow); } else if (m_living is GameNPC) { IControlledBrain icb = ((GameNPC)m_living).Brain as IControlledBrain; if (icb != null && icb.Body != null) { GamePlayer playerowner = icb.GetPlayerOwner(); if (playerowner != null) { playerowner.Out.SendMessage("The " + icb.Body.Name + " charges its prey!", eChatType.CT_Say, eChatLoc.CL_SystemWindow); } } } else { return; } m_startTick = living.CurrentRegion.Time; foreach (GamePlayer t_player in living.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { t_player.Out.SendSpellEffectAnimation(living, living, 7035, 0, false, 1); } //sets player into combat mode living.LastAttackTickPvP = m_startTick; ArrayList speedSpells = new ArrayList(); lock (living.EffectList) { foreach (IGameEffect effect in living.EffectList) { if (effect is GameSpellEffect == false) { continue; } if ((effect as GameSpellEffect).Spell.SpellType == "SpeedEnhancement") { speedSpells.Add(effect); } } } foreach (GameSpellEffect spell in speedSpells) { spell.Cancel(false); } m_living.BuffBonusMultCategory1.Set((int)eProperty.MaxSpeed, this, PropertyCalc.MaxSpeedCalculator.SPEED3); m_living.TempProperties.setProperty("Charging", true); if (m_living is GamePlayer) { ((GamePlayer)m_living).Out.SendUpdateMaxSpeed(); } StartTimers(); m_living.EffectList.Add(this); }
public override LootList GenerateLoot(GameNPC mob, GameObject killer) { LootList loot = base.GenerateLoot(mob, killer); List <LootOTD> lootOTDs = null; try { if (m_mobOTDList.ContainsKey(mob.Name.ToLower())) { lootOTDs = m_mobOTDList[mob.Name.ToLower()]; } if (lootOTDs != null) { foreach (GameObject gainer in mob.XPGainers.Keys) { GamePlayer player = null; if (gainer is GamePlayer) { player = gainer as GamePlayer; } else if (gainer is GameNPC) { IControlledBrain brain = ((GameNPC)gainer).Brain as IControlledBrain; if (brain != null) { player = brain.GetPlayerOwner(); } } if (player != null) { foreach (LootOTD drop in lootOTDs) { if (drop.MinLevel <= player.Level) { CharacterXOneTimeDrop hasDrop = GameServer.Database.SelectObject <CharacterXOneTimeDrop>("CharacterID = '" + GameServer.Database.Escape(player.QuestPlayerID) + "' AND ItemTemplateID = '" + GameServer.Database.Escape(drop.ItemTemplateID) + "'"); if (hasDrop == null) { ItemTemplate item = GameServer.Database.FindObjectByKey <ItemTemplate>(drop.ItemTemplateID); if (item != null) { if (player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, GameInventoryItem.Create <ItemTemplate>(item))) { CharacterXOneTimeDrop charXDrop = new CharacterXOneTimeDrop(); charXDrop.CharacterID = player.QuestPlayerID; charXDrop.ItemTemplateID = drop.ItemTemplateID; GameServer.Database.AddObject(charXDrop); player.Out.SendMessage(string.Format("You receive {0} from {1}!", item.GetName(1, false), mob.GetName(1, false)), eChatType.CT_Loot, eChatLoc.CL_SystemWindow); InventoryLogging.LogInventoryAction(mob, player, eInventoryActionType.Loot, item); } else { // do not drop, player will have to try again player.Out.SendMessage("Your inventory is full and a one time drop cannot be added!", eChatType.CT_Important, eChatLoc.CL_SystemWindow); log.DebugFormat("OTD Failed, Inventory full: {0} from mob {1} for player {2}.", drop.ItemTemplateID, drop.MobName, player.Name); break; } } else { log.ErrorFormat("Error trying to drop ItemTemplate {0} from {1}. Item not found.", drop.ItemTemplateID, drop.MobName); } } } } } } } } catch (Exception ex) { log.Error("LootGeneratorOneTimeDrop exception for mob " + mob.Name + ":", ex); } return(loot); }
public override int CalcValue(GameLiving living, eProperty property) { if (living.IsMezzed || living.IsStunned) { return(0); } double speed = living.BuffBonusMultCategory1.Get((int)property); if (living is GamePlayer) { GamePlayer player = (GamePlayer)living; // Since Dark Age of Camelot's launch, we have heard continuous feedback from our community about the movement speed in our game. The concerns over how slow // our movement is has continued to grow as we have added more and more areas in which to travel. Because we believe these concerns are valid, we have decided // to make a long requested change to the game, enhancing the movement speed of all players who are out of combat. This new run state allows the player to move // faster than normal run speed, provided that the player is not in any form of combat. Along with this change, we have slightly increased the speed of all // secondary speed buffs (see below for details). Both of these changes are noticeable but will not impinge upon the supremacy of the primary speed buffs available // to the Bard, Skald and Minstrel. // - The new run speed does not work if the player is in any form of combat. All combat timers must also be expired. // - The new run speed will not stack with any other run speed spell or ability, except for Sprint. // - Pets that are not in combat have also received the new run speed, only when they are following, to allow them to keep up with their owners. double horseSpeed = (player.IsOnHorse ? player.ActiveHorse.Speed * 0.01 : 1.0); if (speed > horseSpeed) { horseSpeed = 1.0; } if (ServerProperties.Properties.ENABLE_PVE_SPEED) { if (speed == 1 && !player.InCombat && !player.IsStealthed && !player.CurrentRegion.IsRvR) { speed *= 1.25; // new run speed is 125% when no buff } } if (player.IsOverencumbered && player.Client.Account.PrivLevel < 2 && ServerProperties.Properties.ENABLE_ENCUMBERANCE_SPEED_LOSS) { double Enc = player.Encumberance; // calculating player.Encumberance is a bit slow with all those locks, don't call it much if (Enc > player.MaxEncumberance) { speed *= ((((player.MaxSpeedBase * 1.0 / GamePlayer.PLAYER_BASE_SPEED) * (-Enc)) / (player.MaxEncumberance * 0.35f)) + (player.MaxSpeedBase / GamePlayer.PLAYER_BASE_SPEED) + ((player.MaxSpeedBase / GamePlayer.PLAYER_BASE_SPEED) * player.MaxEncumberance / (player.MaxEncumberance * 0.35))); if (speed <= 0) { speed = 0; player.Out.SendMessage("You are encumbered and cannot move.", eChatType.CT_System, eChatLoc.CL_SystemWindow); } } else { player.IsOverencumbered = false; } } if (player.IsStealthed) { MasteryOfStealthAbility mos = player.GetAbility <MasteryOfStealthAbility>(); GameSpellEffect bloodrage = SpellHandler.FindEffectOnTarget(player, "BloodRage"); VanishEffect vanish = player.EffectList.GetOfType <VanishEffect>(); double stealthSpec = player.GetModifiedSpecLevel(Specs.Stealth); if (stealthSpec > player.Level) { stealthSpec = player.Level; } speed *= 0.3 + (stealthSpec + 10) * 0.3 / (player.Level + 10); if (vanish != null) { speed *= vanish.SpeedBonus; } if (mos != null) { speed *= 1 + MasteryOfStealthAbility.GetSpeedBonusForLevel(mos.Level); } if (bloodrage != null) { speed *= 1 + (bloodrage.Spell.Value * 0.01); // 25 * 0.01 = 0.25 (a.k 25%) value should be 25. } } if (GameRelic.IsPlayerCarryingRelic(player)) { if (speed > 1.0) { speed = 1.0; } horseSpeed = 1.0; } if (player.IsSprinting) { speed *= 1.3; } speed *= horseSpeed; } else if (living is GameNPC) { if (!living.InCombat) { IControlledBrain brain = ((GameNPC)living).Brain as IControlledBrain; if (brain != null) { GameLiving owner = brain.GetLivingOwner(); if (owner != null) { if (owner == brain.Body.CurrentFollowTarget) { speed *= 1.25; double ownerSpeedAdjust = (double)owner.MaxSpeed / (double)GamePlayer.PLAYER_BASE_SPEED; if (ownerSpeedAdjust > 1.0) { speed *= ownerSpeedAdjust; } if (owner is GamePlayer && (owner as GamePlayer).IsOnHorse) { speed *= 1.45; } } } } } double healthPercent = living.Health / (double)living.MaxHealth; if (healthPercent < 0.33) { speed *= 0.2 + healthPercent * (0.8 / 0.33); //33%hp=full speed 0%hp=20%speed } } speed = living.MaxSpeedBase * speed + 0.5; // 0.5 is to fix the rounding error when converting to int so root results in speed 2 (191*0.01=1.91+0.5=2.41) GameSpellEffect iConvokerEffect = SpellHandler.FindEffectOnTarget(living, "SpeedWrap"); if (iConvokerEffect != null && living.EffectList.GetOfType <ChargeEffect>() == null) { if (living.EffectList.GetOfType <SprintEffect>() != null && speed > 248) { return(248); } else if (speed > 191) { return(191); } } if (speed < 0) { return(0); } return((int)speed); }
public virtual void SetControlledBrain(IControlledBrain controlledBrain) { if (controlledBrain == Player.ControlledBrain) return; if (controlledBrain == null) { Player.Out.SendPetWindow(null, ePetWindowAction.Close, 0, 0); Player.Out.SendMessage(LanguageMgr.GetTranslation(Player.Client.Account.Language, "GamePlayer.SetControlledNpc.ReleaseTarget2", Player.ControlledBrain.Body.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow); Player.Out.SendMessage(LanguageMgr.GetTranslation(Player.Client.Account.Language, "GamePlayer.SetControlledNpc.ReleaseTarget"), eChatType.CT_System, eChatLoc.CL_SystemWindow); } else { if (controlledBrain.Owner != Player) throw new ArgumentException("ControlledNpc with wrong owner is set (player=" + Player.Name + ", owner=" + controlledBrain.Owner.Name + ")", "controlledNpc"); if (Player.ControlledBrain == null) Player.InitControlledBrainArray(1); Player.Out.SendPetWindow(controlledBrain.Body, ePetWindowAction.Open, controlledBrain.AggressionState, controlledBrain.WalkState); if (controlledBrain.Body != null) { Player.Out.SendNPCCreate(controlledBrain.Body); // after open pet window again send creation NPC packet if (controlledBrain.Body.Inventory != null) Player.Out.SendLivingEquipmentUpdate(controlledBrain.Body); } } Player.ControlledBrain = controlledBrain; }
/// <summary> /// These pets aren't controllable! /// </summary> /// <param name="brain"></param> protected override void SetBrainToOwner(IControlledBrain brain) { }
/// <summary> /// Removes the brain from /// </summary> /// <param name="controlledNpc">The brain to find and remove</param> /// <returns>Whether the pet was removed</returns> public virtual bool RemoveControlledNpc(IControlledBrain controlledNpc) { return true; }
public override bool IsAllowedToAttack(GameLiving attacker, GameLiving defender, bool quiet) { if (!base.IsAllowedToAttack(attacker, defender, quiet)) { return(false); } // if controlled NPC - do checks for owner instead if (attacker is GameNPC) { IControlledBrain controlled = ((GameNPC)attacker).Brain as IControlledBrain; if (controlled != null) { attacker = controlled.GetLivingOwner(); quiet = true; // silence all attacks by controlled npc } } if (defender is GameNPC) { IControlledBrain controlled = ((GameNPC)defender).Brain as IControlledBrain; if (controlled != null) { defender = controlled.GetLivingOwner(); } } // can't attack self if (attacker == defender) { if (quiet == false) { MessageToLiving(attacker, "You can't attack yourself!"); } return(false); } //ogre: sometimes other players shouldn't be attackable GamePlayer playerAttacker = attacker as GamePlayer; GamePlayer playerDefender = defender as GamePlayer; if (playerAttacker != null && playerDefender != null) { //check group if (playerAttacker.Group != null && playerAttacker.Group.IsInTheGroup(playerDefender)) { if (!quiet) { MessageToLiving(playerAttacker, "You can't attack your group members."); } return(false); } if (playerAttacker.DuelTarget != defender) { //check guild if (playerAttacker.Guild != null && playerAttacker.Guild == playerDefender.Guild) { if (!quiet) { MessageToLiving(playerAttacker, "You can't attack your guild members."); } return(false); } // Player can't hit other members of the same BattleGroup BattleGroup mybattlegroup = (BattleGroup)playerAttacker.TempProperties.getProperty <object>(BattleGroup.BATTLEGROUP_PROPERTY, null); if (mybattlegroup != null && mybattlegroup.IsInTheBattleGroup(playerDefender)) { if (!quiet) { MessageToLiving(playerAttacker, "You can't attack a member of your battlegroup."); } return(false); } // Safe regions if (m_safeRegions != null) { foreach (int reg in m_safeRegions) { if (playerAttacker.CurrentRegionID == reg) { if (quiet == false) { MessageToLiving(playerAttacker, "You're currently in a safe zone, you can't attack other players here."); } return(false); } } } // Players with safety flag can not attack other players if (playerAttacker.Level < m_safetyLevel && playerAttacker.SafetyFlag) { if (quiet == false) { MessageToLiving(attacker, "Your PvP safety flag is ON."); } return(false); } // Players with safety flag can not be attacked in safe regions if (playerDefender.Level < m_safetyLevel && playerDefender.SafetyFlag) { bool unsafeRegion = false; foreach (int regionID in m_unsafeRegions) { if (regionID == playerDefender.CurrentRegionID) { unsafeRegion = true; break; } } if (unsafeRegion == false) { //"PLAYER has his safety flag on and is in a safe area, you can't attack him here." if (quiet == false) { MessageToLiving(attacker, playerDefender.Name + " has " + playerDefender.GetPronoun(1, false) + " safety flag on and is in a safe area, you can't attack " + playerDefender.GetPronoun(2, false) + " here."); } return(false); } } } } if (attacker.Realm == 0 && defender.Realm == 0) { return(FactionMgr.CanLivingAttack(attacker, defender)); } //allow confused mobs to attack same realm if (attacker is GameNPC && (attacker as GameNPC).IsConfused && attacker.Realm == defender.Realm) { return(true); } // "friendly" NPCs can't attack "friendly" players if (defender is GameNPC && defender.Realm != 0 && attacker.Realm != 0 && defender is GameKeepGuard == false && defender is GameFont == false) { if (quiet == false) { MessageToLiving(attacker, "You can't attack a friendly NPC!"); } return(false); } // "friendly" NPCs can't be attacked by "friendly" players if (attacker is GameNPC && attacker.Realm != 0 && defender.Realm != 0 && attacker is GameKeepGuard == false) { return(false); } #region Keep Guards //guard vs guard / npc if (attacker is GameKeepGuard) { if (defender is GameKeepGuard) { return(false); } if (defender is GameNPC && (defender as GameNPC).Brain is IControlledBrain == false) { return(false); } } //player vs guard if (defender is GameKeepGuard && attacker is GamePlayer && GameServer.KeepManager.IsEnemy(defender as GameKeepGuard, attacker as GamePlayer) == false) { if (quiet == false) { MessageToLiving(attacker, "You can't attack a friendly NPC!"); } return(false); } //guard vs player if (attacker is GameKeepGuard && defender is GamePlayer && GameServer.KeepManager.IsEnemy(attacker as GameKeepGuard, defender as GamePlayer) == false) { return(false); } #endregion return(true); }
/// <summary> /// Adds a pet to the current array of pets /// </summary> /// <param name="controlledNpc">The brain to add to the list</param> /// <returns>Whether the pet was added or not</returns> public override bool AddControlledNpc(IControlledBrain controlledNpc) { IControlledBrain[] brainlist = ControlledNpcList; if (brainlist == null) return false; foreach (IControlledBrain icb in brainlist) { if (icb == controlledNpc) return false; } if (controlledNpc.Owner != this) throw new ArgumentException("ControlledNpc with wrong owner is set (player=" + Name + ", owner=" + controlledNpc.Owner.Name + ")", "controlledNpc"); //Find the next spot for this new pet int i = 0; for (; i < brainlist.Length; i++) { if (brainlist[i] == null) break; } //If we didn't find a spot return false if (i >= m_controlledBrain.Length) return false; m_controlledBrain[i] = controlledNpc; PetCount++; return base.AddControlledNpc(controlledNpc); }
public override bool IsSameRealm(GameLiving source, GameLiving target, bool quiet) { if (source == null || target == null) { return(false); } // if controlled NPC - do checks for owner instead if (source is GameNPC) { IControlledBrain controlled = ((GameNPC)source).Brain as IControlledBrain; if (controlled != null) { source = controlled.GetLivingOwner(); quiet = true; // silence all attacks by controlled npc } } if (target is GameNPC) { IControlledBrain controlled = ((GameNPC)target).Brain as IControlledBrain; if (controlled != null) { target = controlled.GetLivingOwner(); } } if (source == target) { return(true); } // clients with priv level > 1 are considered friendly by anyone if (target is GamePlayer && ((GamePlayer)target).Client.Account.PrivLevel > 1) { return(true); } // checking as a gm, targets are considered friendly if (source is GamePlayer && ((GamePlayer)source).Client.Account.PrivLevel > 1) { return(true); } // mobs can heal mobs, players heal players/NPC if (source.Realm == 0 && target.Realm == 0) { return(true); } //keep guards if (source is GameKeepGuard && target is GamePlayer) { if (!GameServer.KeepManager.IsEnemy(source as GameKeepGuard, target as GamePlayer)) { return(true); } } if (target is GameKeepGuard && source is GamePlayer) { if (!GameServer.KeepManager.IsEnemy(target as GameKeepGuard, source as GamePlayer)) { return(true); } } //doors need special handling if (target is GameKeepDoor && source is GamePlayer) { return(GameServer.KeepManager.IsEnemy(target as GameKeepDoor, source as GamePlayer)); } if (source is GameKeepDoor && target is GamePlayer) { return(GameServer.KeepManager.IsEnemy(source as GameKeepDoor, target as GamePlayer)); } //components need special handling if (target is GameKeepComponent && source is GamePlayer) { return(GameServer.KeepManager.IsEnemy(target as GameKeepComponent, source as GamePlayer)); } //Peace flag NPCs are same realm if (target is GameNPC) { if ((((GameNPC)target).Flags & GameNPC.eFlags.PEACE) != 0) { return(true); } } if (source is GameNPC) { if ((((GameNPC)source).Flags & GameNPC.eFlags.PEACE) != 0) { return(true); } } if (source is GamePlayer && target is GamePlayer) { return(true); } if (source is GamePlayer && target is GameNPC && target.Realm != 0) { return(true); } if (quiet == false) { MessageToLiving(source, target.GetName(0, true) + " is not a member of your realm!"); } return(false); }
protected override void SetBrainToOwner(IControlledBrain brain) { Caster.ControlledBrain.Body.AddControlledNpc(brain); }
/// <summary> /// Removes the brain from /// </summary> /// <param name="controlledNpc">The brain to find and remove</param> /// <returns>Whether the pet was removed</returns> public override bool RemoveControlledNpc(IControlledBrain controlledNpc) { bool found = false; lock (ControlledNpcList) { if (controlledNpc == null) return false; IControlledBrain[] brainlist = ControlledNpcList; int i = 0; //Try to find the minion in the list for (; i < brainlist.Length; i++) { //Found it if (brainlist[i] == controlledNpc) { found = true; break; } } //Found it, lets remove it if (found) { //First lets store the brain to kill it IControlledBrain tempBrain = m_controlledBrain[i]; //Lets get rid of the brain asap m_controlledBrain[i] = null; //Only decrement, we just lost one pet PetCount--; return base.RemoveControlledNpc(controlledNpc); } } return found; }
/// <summary> /// Grants credit for the encounter to the killer/player and /// optionally his group or battlegroup mates. /// </summary> public static void GrantEncounterCredit(GameObject killer, bool group, bool battlegroup, string artifactid) { List <GamePlayer> creditPlayerList = new List <GamePlayer>(); // if controlled NPC - do checks for owner instead if (killer is GameNPC) { IControlledBrain controlled = ((GameNPC)killer).Brain as IControlledBrain; if (controlled != null) { killer = controlled.GetPlayerOwner(); } } GamePlayer player = killer as GamePlayer; //add the killer player to the list. if (!creditPlayerList.Contains(player)) { creditPlayerList.Add(player); } //if killing player has a group, let's add those players to the list to receive credit. if (player.Group != null && group) { //player is grouped, let's add the group to the list to recieve credit. foreach (GamePlayer groupplayer in (player.Group.GetPlayersInTheGroup())) { if (!creditPlayerList.Contains(groupplayer)) { //only add players are near enough that they would have earned XP from the kill. if (groupplayer.IsWithinRadius(killer, WorldMgr.MAX_EXPFORKILL_DISTANCE)) { creditPlayerList.Add(groupplayer); } } } } //if killing player has a battlegroup, let's add those players to the list to receive credit. if (player.isInBG && battlegroup) { BattleGroup bg = (BattleGroup)player.TempProperties.getProperty <object>(BattleGroup.BATTLEGROUP_PROPERTY, null); HybridDictionary bgplayers = bg.Members; foreach (GamePlayer eachplayer in bgplayers.Keys) { if (!creditPlayerList.Contains(eachplayer)) { //only add players who are near enough that they would have earned XP from the kill. if (eachplayer.IsWithinRadius(killer, WorldMgr.MAX_EXPFORKILL_DISTANCE)) { creditPlayerList.Add(eachplayer); } } } } //List should now contain the killer, plus optionally the players in his group, and optionally his battlegroup if (creditPlayerList.Count > 0) { foreach (GamePlayer creditplayer in creditPlayerList) { creditplayer.Out.SendMessage("The " + artifactid + " encounter has been completed, you should have received credit, if you were eligible.", eChatType.CT_Important, eChatLoc.CL_ChatWindow); ArtifactMgr.GrantArtifactCredit(creditplayer, artifactid); } } return; }
public override bool IsAllowedToAttack(GameLiving attacker, GameLiving defender, bool quiet) { if (!base.IsAllowedToAttack(attacker, defender, quiet)) { return(false); } // if controlled NPC - do checks for owner instead if (attacker is GameNPC) { IControlledBrain controlled = ((GameNPC)attacker).Brain as IControlledBrain; if (controlled != null) { attacker = controlled.GetPlayerOwner(); quiet = true; // silence all attacks by controlled npc } } if (defender is GameNPC) { IControlledBrain controlled = ((GameNPC)defender).Brain as IControlledBrain; if (controlled != null) { defender = controlled.GetPlayerOwner(); } } //"You can't attack yourself!" if (attacker == defender) { if (quiet == false) { MessageToLiving(attacker, "You can't attack yourself!"); } return(false); } // Pet release might cause one of these to be null if (attacker == null || defender == null) { return(false); } if (attacker.Realm != eRealm.None && defender.Realm != eRealm.None) { if (attacker is GamePlayer && ((GamePlayer)attacker).DuelTarget == defender) { return(true); } if (quiet == false) { MessageToLiving(attacker, "You can not attack other players on this server!"); } return(false); } //allow attacks on same realm only under the following circumstances if (attacker.Realm == defender.Realm) { //allow confused mobs to attack same realm if (attacker is GameNPC && (attacker as GameNPC).IsConfused) { return(true); } // else, don't allow mobs to attack mobs if (attacker.Realm == eRealm.None) { return(FactionMgr.CanLivingAttack(attacker, defender)); } if (quiet == false) { MessageToLiving(attacker, "You can't attack a member of your realm!"); } return(false); } return(true); }
/// <summary> /// Adds a pet to the current array of pets /// </summary> /// <param name="controlledNpc">The brain to add to the list</param> /// <returns>Whether the pet was added or not</returns> public virtual bool AddControlledNpc(IControlledBrain controlledNpc) { return true; }
/// <summary> /// Handler fired whenever effect target is attacked /// </summary> /// <param name="e"></param> /// <param name="sender"></param> /// <param name="arguments"></param> protected override void EventHandler(DOLEvent e, object sender, EventArgs arguments) { AttackedByEnemyEventArgs args = arguments as AttackedByEnemyEventArgs; if (args == null) { return; } if (args.AttackData.AttackResult != GameLiving.eAttackResult.HitUnstyled && args.AttackData.AttackResult != GameLiving.eAttackResult.HitStyle) { return; } if (!args.AttackData.IsMeleeAttack) { return; } GameLiving attacker = sender as GameLiving; //sender is target of attack, becomes attacker for damage shield if (attacker == null) { return; } if (attacker.ObjectState != GameObject.eObjectState.Active) { return; } if (attacker.IsAlive == false) { return; } GameLiving target = args.AttackData.Attacker; //attacker becomes target for damage shield if (target == null) { return; } if (target.ObjectState != GameObject.eObjectState.Active) { return; } if (target.IsAlive == false) { return; } int spread = m_minDamageSpread; spread += Util.Random(50); double damage = Spell.Damage * target.AttackSpeed(target.AttackWeapon) * spread * 0.00001; double damageResisted = damage * target.GetResist(Spell.DamageType) * -0.01; if (Spell.Damage < 0) { damage = args.AttackData.Damage * Spell.Damage / -100.0; damageResisted = damage * target.GetResist(Spell.DamageType) * -0.01; } AttackData ad = new AttackData(); ad.Attacker = attacker; ad.Target = target; ad.Damage = (int)(damage + damageResisted); ad.Modifier = (int)damageResisted; ad.DamageType = Spell.DamageType; ad.SpellHandler = this; ad.AttackType = AttackData.eAttackType.Spell; ad.AttackResult = GameLiving.eAttackResult.HitUnstyled; GamePlayer owner = null; GameClient attackerClient = null; if (attacker is GamePlayer) { attackerClient = ((GamePlayer)attacker).Client; } if (ad.Attacker is GameNPC) { IControlledBrain brain = ((GameNPC)ad.Attacker).Brain as IControlledBrain; if (brain != null) { owner = brain.GetPlayerOwner(); if (owner != null && owner.ControlledBrain != null && ad.Attacker == owner.ControlledBrain.Body) { MessageToLiving(owner, String.Format(LanguageMgr.GetTranslation(owner.Client, "DamageAddAndShield.EventHandlerDS.YourHitFor"), ad.Attacker.Name, target.GetName(0, false), ad.Damage), eChatType.CT_Spell); } } } else if (attackerClient != null) { MessageToLiving(attacker, String.Format(LanguageMgr.GetTranslation(attackerClient, "DamageAddAndShield.EventHandlerDS.YouHitFor"), target.GetName(0, false), ad.Damage), eChatType.CT_Spell); } GameClient targetClient = null; if (target is GamePlayer) { targetClient = ((GamePlayer)target).Client; } if (targetClient != null) { MessageToLiving(target, String.Format(LanguageMgr.GetTranslation(targetClient, "DamageAddAndShield.EventHandlerDS.DamageToYou"), attacker.GetName(0, false), ad.Damage), eChatType.CT_Spell); } target.OnAttackedByEnemy(ad); attacker.DealDamage(ad); foreach (GamePlayer player in attacker.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { if (player == null) { continue; } player.Out.SendCombatAnimation(null, target, 0, 0, 0, 0, 0x14, target.HealthPercent); } // Log.Debug(String.Format("spell damage: {0}; damage: {1}; resisted damage: {2}; damage type {3}; minSpread {4}.", Spell.Damage, ad.Damage, ad.Modifier, ad.DamageType, m_minDamageSpread)); // Log.Debug(String.Format("dmg {0}; spread: {4}; resDmg: {1}; atkSpeed: {2}; resist: {3}.", damage, damageResisted, target.AttackSpeed(null), ad.Target.GetResist(Spell.DamageType), spread)); }
protected override void SetBrainToOwner(IControlledBrain brain) { }
/// <summary> /// Handler fired on every melee attack by effect target /// </summary> /// <param name="e"></param> /// <param name="sender"></param> /// <param name="arguments"></param> protected override void EventHandler(DOLEvent e, object sender, EventArgs arguments) { AttackFinishedEventArgs atkArgs = arguments as AttackFinishedEventArgs; if (atkArgs == null) { return; } if (atkArgs.AttackData.AttackResult != GameLiving.eAttackResult.HitUnstyled && atkArgs.AttackData.AttackResult != GameLiving.eAttackResult.HitStyle) { return; } GameLiving target = atkArgs.AttackData.Target; if (target == null) { return; } if (target.ObjectState != GameObject.eObjectState.Active) { return; } if (target.IsAlive == false) { return; } if (target is GameKeepComponent || target is GameKeepDoor) { return; } GameLiving attacker = sender as GameLiving; if (attacker == null) { return; } if (attacker.ObjectState != GameObject.eObjectState.Active) { return; } if (attacker.IsAlive == false) { return; } int spread = m_minDamageSpread; spread += Util.Random(50); double dpsCap = DPSCap(attacker.Level); double dps = IgnoreDamageCap ? Spell.Damage : Math.Min(Spell.Damage, dpsCap); double damage = dps * atkArgs.AttackData.WeaponSpeed * spread * 0.001; // attack speed is 10 times higher (2.5spd=25) double damageResisted = damage * target.GetResist(Spell.DamageType) * -0.01; // log.DebugFormat("dps: {0}, damage: {1}, damageResisted: {2}, minDamageSpread: {3}, spread: {4}", dps, damage, damageResisted, m_minDamageSpread, spread); if (Spell.Damage < 0) { damage = atkArgs.AttackData.Damage * Spell.Damage / -100.0; damageResisted = damage * target.GetResist(Spell.DamageType) * -0.01; } AttackData ad = new AttackData(); ad.Attacker = attacker; ad.Target = target; ad.Damage = (int)(damage + damageResisted); ad.Modifier = (int)damageResisted; ad.DamageType = Spell.DamageType; ad.AttackType = AttackData.eAttackType.Spell; ad.SpellHandler = this; ad.AttackResult = GameLiving.eAttackResult.HitUnstyled; if (ad.Attacker is GameNPC) { IControlledBrain brain = ((GameNPC)ad.Attacker).Brain as IControlledBrain; if (brain != null) { GamePlayer owner = brain.GetPlayerOwner(); if (owner != null) { MessageToLiving(owner, String.Format(LanguageMgr.GetTranslation(owner.Client, "DamageAddAndShield.EventHandlerDA.YourHitFor"), ad.Attacker.Name, target.GetName(0, false), ad.Damage), eChatType.CT_Spell); } } } else { GameClient attackerClient = null; if (attacker is GamePlayer) { attackerClient = ((GamePlayer)attacker).Client; } if (attackerClient != null) { MessageToLiving(attacker, String.Format(LanguageMgr.GetTranslation(attackerClient, "DamageAddAndShield.EventHandlerDA.YouHitExtra"), target.GetName(0, false), ad.Damage), eChatType.CT_Spell); } } GameClient targetClient = null; if (target is GamePlayer) { targetClient = ((GamePlayer)target).Client; } if (targetClient != null) { MessageToLiving(target, String.Format(LanguageMgr.GetTranslation(targetClient, "DamageAddAndShield.EventHandlerDA.DamageToYou"), attacker.GetName(0, false), ad.Damage), eChatType.CT_Spell); } target.OnAttackedByEnemy(ad); attacker.DealDamage(ad); foreach (GamePlayer player in ad.Attacker.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { if (player == null) { continue; } player.Out.SendCombatAnimation(null, target, 0, 0, 0, 0, 0x0A, target.HealthPercent); } }
/// <summary> /// Apply effect on target or do spell action if non duration spell /// </summary> /// <param name="target">target that gets the effect</param> /// <param name="effectiveness">factor from 0..1 (0%-100%)</param> public override void ApplyEffectOnTarget(GameLiving target, double effectiveness) { INpcTemplate template = NpcTemplateMgr.GetTemplate(Spell.LifeDrainReturn); if (template == null) { if (log.IsWarnEnabled) { log.WarnFormat("NPC template {0} not found! Spell: {1}", Spell.LifeDrainReturn, Spell.ToString()); } MessageToCaster("NPC template " + Spell.LifeDrainReturn + " not found!", eChatType.CT_System); return; } GameSpellEffect effect = CreateSpellEffect(target, effectiveness); IControlledBrain brain = null; if (template.ClassType != null && template.ClassType.Length > 0) { Assembly asm = Assembly.GetExecutingAssembly(); brain = (IControlledBrain)asm.CreateInstance(template.ClassType, true); if (brain == null && log.IsWarnEnabled) { log.Warn($"ApplyEffectOnTarget(): ClassType {template.ClassType} on NPCTemplateID {template.TemplateId} not found, using default ControlledBrain"); } } if (brain == null) { brain = GetPetBrain(Caster); } m_pet = GetGamePet(template); //brain.WalkState = eWalkState.Stay; m_pet.SetOwnBrain(brain as AI.ABrain); m_pet.SummonSpellDamage = Spell.Damage; m_pet.SummonSpellValue = Spell.Value; int x, y, z; ushort heading; Region region; GetPetLocation(out x, out y, out z, out heading, out region); m_pet.X = x; m_pet.Y = y; m_pet.Z = z; m_pet.Heading = heading; m_pet.CurrentRegion = region; m_pet.CurrentSpeed = 0; m_pet.Realm = Caster.Realm; if (m_isSilent) { m_pet.IsSilent = true; } m_pet.AddToWorld(); //Check for buffs if (brain is ControlledNpcBrain) { (brain as ControlledNpcBrain).CheckSpells(StandardMobBrain.eCheckSpellType.Defensive); } AddHandlers(); SetBrainToOwner(brain); m_pet.SetPetLevel(); m_pet.Health = m_pet.MaxHealth; if (DOL.GS.ServerProperties.Properties.PET_SCALE_SPELL_MAX_LEVEL > 0) { m_pet.Spells = template.Spells; // Have to scale spells again now that the pet level has been assigned } effect.Start(m_pet); Caster.OnPetSummoned(m_pet); }