public void OnTakeHeal(Unit Caster, UInt32 DamageCount) { ResetFightingState(TCPManager.GetTimeStampMS()); AddHealReceive(Caster.Oid, Caster.IsPlayer(), DamageCount); _Owner.EvtInterface.Notify(EventName.ON_RECEIVE_HEAL, Caster, null); if (_Owner.IsPlayer() && Caster.IsPlayer()) { ResetPvpTime(); } }
// Draw Damages Text public void SendSpellDamage(Unit Target, uint Damage, bool Heal) { if (Caster.IsPlayer()) { PacketOut Out = new PacketOut((byte)Opcodes.F_CAST_PLAYER_EFFECT); Out.WriteUInt16(Caster.Oid); Out.WriteUInt16(Target.Oid); Out.WriteUInt16(Info.Entry); // 00 00 07 D D Out.WriteByte(0); Out.WriteByte(0); Out.WriteByte(7); Out.WriteByte((byte)((128 + (Damage % 64) * 2) + (Heal ? 0 : 1))); Out.WriteByte((byte)(Damage / 64)); Out.WriteByte(0xCE); Out.WriteByte(0x07); Caster.DispatchGroup(Out); } if (Caster != Target && Target.IsPlayer()) { PacketOut Out = new PacketOut((byte)Opcodes.F_CAST_PLAYER_EFFECT); Out.WriteUInt16(Caster.Oid); Out.WriteUInt16(Target.Oid); Out.WriteUInt16(Info.Entry); // 00 00 07 D D Out.WriteByte(0); Out.WriteByte(0); Out.WriteByte(7); Out.WriteByte((byte)((128 + (Damage % 64) * 2) + (Heal ? 0 : 1))); Out.WriteByte((byte)(Damage / 64)); Out.WriteByte(0xCE); Out.WriteByte(0x07); Target.DispatchGroup(Out); } }
static public void GenerateXP(Unit Killer, Unit Victim) { UInt32 KLvl = Killer.Level; UInt32 VLvl = Victim.Level; if (KLvl > VLvl + 8) { return; } UInt32 XP = VLvl * 60; XP += (UInt32)Victim.Rank * 20; if (KLvl > VLvl) { XP -= (UInt32)(((float)XP / (float)100) * (KLvl - VLvl + 1)) * 5; } if (Program.Config.XpRate > 0) { XP *= (UInt32)Program.Config.XpRate; } if (Killer.IsPlayer()) { Killer.GetPlayer().AddXp(XP); } }
public override GameData.AbilityResult CanCast(bool IsStart) { GameData.AbilityResult Result = GameData.AbilityResult.ABILITYRESULT_OK; if (Target == null || !Target.IsPlayer()) //nonplayer Chars are illegal too { Result = GameData.AbilityResult.ABILITYRESULT_ILLEGALTARGET; } else if (Target.IsDead) { Result = GameData.AbilityResult.ABILITYRESULT_ILLEGALTARGET_DEAD; } else if (Ab.Caster.GetDistanceTo(Target) > Ab.Info.Info.MaxRange) { Result = GameData.AbilityResult.ABILITYRESULT_OUTOFRANGE; } else if (IsStart && Ab.Caster.GetDistanceTo(Target) < Ab.Info.Info.MinRange) { Result = GameData.AbilityResult.ABILITYRESULT_TOOCLOSE; } else if (IsStart && Ab.Info.Info.MinRange <= 5 && !Ab.Caster.IsObjectInFront(Target, 110)) { Result = GameData.AbilityResult.ABILITYRESULT_OUT_OF_ARC; } else if (!CombatInterface.IsFriend(Ab.Caster.GetUnit(), Target)) { Result = GameData.AbilityResult.ABILITYRESULT_ILLEGALTARGET_NOT_ALLY; } //Log.Info("SimpleHeal", Result.ToString()); return(Result); }
public int CalculDamage() { if (!HasUnit()) { return(0); } Unit Me = GetUnit(); if (Me.IsPlayer()) { float Str = GetTotalStat((byte)GameData.Stats.STATS_STRENGTH); float Tou = GetTotalStat((byte)GameData.Stats.STATS_TOUGHNESS); float Wdps = Me.ItmInterface.GetAttackDamage(EquipSlot.MAIN_DROITE) / 10; float WSpeed = Me.ItmInterface.GetAttackTime(EquipSlot.MAIN_DROITE); WSpeed /= 100; return((int)(((Str / 10) + Wdps) * WSpeed)); } else if (Me.IsCreature()) { int Dmg = 10 + 10 * Me.Level + (Me.Rank * 15); return(Dmg); } return(1); }
public int CalculReduce() { if (!HasUnit()) { return(0); } Unit Me = GetUnit(); int Reduce = 0; if (Me.IsPlayer()) { UInt16 Tou = GetTotalStat((byte)GameData.Stats.STATS_TOUGHNESS); Reduce += Tou / 5; UInt16 Armor = Me.ItmInterface.GetEquipedArmor(); Reduce += (int)(Armor / (Me.Level * 1.1)); // TODO : Parry Skill et autre } else if (Me.IsCreature()) { Reduce += 25; } return(Reduce); }
/* * // Group LOOT : Pass , accept, cancel * Out.WritePacketString(@"|07 19 0A 00 00 00 00 03 2E 56 22 B9 00 |............V..| |00 00 00 00 00 00 00 00 24 00 00 00 00 00 01 00 |........$.......| |00 00 00 00 00 00 00 00 00 00 00 00 00 09 C4 00 |................| |01 00 00 00 00 00 00 00 00 00 00 00 00 09 57 61 |..............Wa| |72 20 43 72 65 73 74 00 00 00 00 00 00 71 50 72 |r Crest......qPr| |6F 6F 66 20 6F 66 20 79 6F 75 72 20 76 61 6C 6F |oof of your valo| |72 20 6F 6E 20 74 68 65 20 66 69 65 6C 64 20 6F |r on the field o| |66 20 62 61 74 74 6C 65 2E 20 54 68 65 73 65 20 |f battle. These | |6D 61 79 20 62 65 20 75 73 65 64 20 74 6F 20 74 |may be used to t| |72 61 64 65 20 66 6F 72 20 65 71 75 69 70 6D 65 |rade for equipme| |6E 74 20 66 72 6F 6D 20 76 61 72 69 6F 75 73 20 |nt from various | |51 75 61 72 74 65 72 6D 61 73 74 65 72 73 2E 01 |Quartermasters..| |00 00 00 03 06 00 08 00 00 00 00 00 00 00 00 00 |................| |00 00 00 00 00 00 00 00 00 00 |.......... |"); */ public override void SetDeath(Unit Killer) { if (Killer.IsPlayer()) { Player Plr = Killer.GetPlayer(); PQuestObject pq = Plr.QtsInterface.GetPublicQuest(); if (pq != null) { pq.HandleEvent(Objective_Type.QUEST_KILL_MOB, Spawn.Entry, 1); } } Killer.QtsInterface.HandleEvent(Objective_Type.QUEST_KILL_MOB, Spawn.Entry, 1); base.SetDeath(Killer); if (Spawn.Entry == 28432 || Spawn.Entry == 34357 || Spawn.Entry == 5780) // Lair Bosses 2 hour spawn time { EvtInterface.AddEvent(RezUnit, (7200000 + RandomMgr.Next(0, 3600000)), 1); // 2 hours seconds Rez } else { EvtInterface.AddEvent(RezUnit, 50000 + Level * 1000, 1); // 30 seconds Rez } }
public void SendCastEffect(Unit Target, ushort AbilityEntry, GameData.CombatEvent Event, uint Count) { if (IsPlayer()) { PacketOut Out = new PacketOut((byte)Opcodes.F_CAST_PLAYER_EFFECT); Out.WriteUInt16(Oid); Out.WriteUInt16(Target.Oid); Out.WriteUInt16(AbilityEntry); Out.WriteByte(0); Out.WriteByte((byte)Event); Out.WriteByte(0x13); Out.WriteByte((byte)((128 + (Count % 64) * 2) + 1)); Out.WriteByte((byte)(Count / 64)); Out.WriteByte(0); DispatchGroup(Out); } if (Target != this && Target.IsPlayer()) { PacketOut Out = new PacketOut((byte)Opcodes.F_CAST_PLAYER_EFFECT); Out.WriteUInt16(Oid); Out.WriteUInt16(Target.Oid); Out.WriteUInt16(AbilityEntry); Out.WriteByte(0); Out.WriteByte((byte)Event); Out.WriteByte(0x13); Out.WriteByte((byte)((128 + (Count % 64) * 2) + 1)); Out.WriteByte((byte)(Count / 64)); Out.WriteByte(0); Target.DispatchGroup(Out); } }
public static Loot GenerateLoot(Unit Corps, Unit Looter) { if (!Looter.IsPlayer()) return null; if (Corps.IsCreature()) { Creature Crea = Corps.GetCreature(); List<Creature_loot> CreatureLoots = WorldMgr.GetLoots(Crea.Entry); if (CreatureLoots.Count <= 0) return null; List<LootInfo> Loots = new List<LootInfo>(); foreach (Creature_loot Loot in CreatureLoots) { float Pct = Loot.Pct * Program.Config.GlobalLootRate; if (Pct <= 0) Pct = 0.01f; switch ((SystemData.ItemRarity)Loot.Info.Rarity) { case SystemData.ItemRarity.ITEMRARITY_COMMON: Pct *= Program.Config.CommonLootRate; break; case SystemData.ItemRarity.ITEMRARITY_UNCOMMON: Pct *= Program.Config.UncommonLootRate; break; case SystemData.ItemRarity.ITEMRARITY_RARE: Pct *= Program.Config.RareLootRate; break; case SystemData.ItemRarity.ITEMRARITY_VERY_RARE: Pct *= Program.Config.VeryRareLootRate; break; case SystemData.ItemRarity.ITEMRARITY_ARTIFACT: Pct *= Program.Config.ArtifactLootRate; break; }; if(Pct > 100.0f || RandomMgr.Next(10000) < (Pct*100)) Loots.Add(new LootInfo(Loot.Info)); } UInt32 Money = (UInt32)(Corps.Level * (UInt32)7) + (Corps.Rank * (UInt32)50); if (Loots.Count > 0 || Money > 0) { Log.Success("LootMgr", "Generate Loot : " + Loots.Count); Loot Lt = new Loot(); Lt.Money = Money; Lt.Loots = Loots.ToArray(); return Lt; } } return null; }
public void OnDealHeal(Unit Target, UInt32 DamageCount) { ResetFightingState(TCPManager.GetTimeStampMS()); _Owner.EvtInterface.Notify(EventName.ON_DEAL_HEAL, Target, null); if (_Owner.IsPlayer() && Target.IsPlayer() && Target.GetPlayer().CbtInterface.IsPvp) { ResetPvpTime(); } }
static public bool CanAttack(Unit A, Unit Victim) { /*if (A.IsCreature() && B.IsCreature()) * return false;*/ if (A == null || Victim == null) { return(false); } if (A.IsDisposed || Victim.IsDisposed) { return(false); } if (A == Victim) { return(false); } if (A.IsDead || Victim.IsDead) { return(false); } if (!IsEnemy(A, Victim)) { return(false); } if (!A.IsInWorld() || !Victim.IsInWorld()) { return(false); } if (!A.IsVisible || A.IsInvinsible) { return(false); } if (!Victim.IsVisible || Victim.IsInvinsible) { return(false); } if (A.IsPlayer() && Victim.IsPlayer()) { if (!Victim.CbtInterface.IsPvp) { return(false); } } return(true); }
public void GenerateLoot(Unit Killer) { if (Killer == null) { return; } Loots = LootsMgr.GenerateLoot(this, Killer); if (Loots != null && Killer.IsPlayer()) { SetLootable(true, Killer.GetPlayer()); } }
public override void SetDeath(Unit Killer) { Killer.QtsInterface.HandleEvent(Objective_Type.QUEST_KILL_PLAYERS, 0, 1); base.SetDeath(Killer); if (Killer.IsPlayer()) { WorldMgr.GenerateRenown(Killer.GetPlayer(), this); } EvtInterface.AddEvent(RespawnPlayer, 20000, 1); SendDialog((ushort)5, (ushort)20); }
public void OnTakeDamage(Unit Fighter, UInt32 DamageCount) { switch (AI.State) { case AiState.STANDING: CombatStart(Fighter); break; case AiState.MOVING: CombatStart(Fighter); break; } ; ResetFightingState(TCPManager.GetTimeStampMS()); AddDamageReceive(Fighter.Oid, Fighter.IsPlayer(), DamageCount); _Owner.EvtInterface.Notify(EventName.ON_RECEIVE_DAMAGE, Fighter, null); if (_Owner.IsPlayer() && Fighter.IsPlayer()) { ResetPvpTime(); } }
public void ProcessTakeDamage(Unit fighter, uint damage, float hatredMod, uint mitigation = 0) { switch (State) { case AiState.STANDING: case AiState.MOVING: ProcessCombatStart(fighter); break; } uint hateCaused = (uint)((damage + mitigation) * hatredMod * fighter.StsInterface.GetStatPercentageModifier(Stats.HateCaused)); fighter.BuffInterface.CheckGuardHate(CurrentBrain, ref hateCaused); CurrentBrain?.AddHatred(fighter, fighter.IsPlayer(), hateCaused); }
public Unit GetNextTarget() { Unit Me = GetUnit(); Unit Target = null; if (!Me.IsPlayer()) { AggroInfo Info = GetMaxAggroHate(true); if (Info == null) { Info = GetMaxAggroHate(false); } if (Info != null) { Target = _Owner.Region.GetObject(Info.Oid) as Unit; } } else { Target = GetTarget(GameData.TargetTypes.TARGETTYPES_TARGET_ENEMY); } if (Target == null) { return(null); } if (!Target.IsInWorld()) { return(null); } if (Target.IsDead) { if (AI.State == AiState.FIGHTING) { OnTargetDie(Target); } return(null); } return(Target); }
public Unit GetNextTarget() { Unit Me = GetUnit(); Unit Target = null; if (!Me.IsPlayer()) { AggroInfo Info = GetMaxAggroHate(); if (Info != null) { Target = Obj.Region.GetObject(Info.Oid) as Unit; } } else { if (CurrentTarget.Type != GameData.TargetTypes.TARGETTYPES_TARGET_ALLY) { Target = CurrentTarget.Target; } } if (Target == null) { return(null); } if (!Target.IsInWorld()) { return(null); } if (Target.IsDead) { if (State == AiState.FIGHTING) { OnTargetDie(Target); } return(null); } return(Target); }
public int CalculDamage(EquipSlot Slot, Unit Target) { if (!HasUnit()) { return(0); } Unit Me = GetUnit(); if (Me.IsPlayer()) { float Str = GetTotalStat((byte)GameData.Stats.STATS_STRENGTH); float Tou = GetTotalStat((byte)GameData.Stats.STATS_TOUGHNESS); float Wdps = (float)Me.ItmInterface.GetAttackDamage(Slot) / 10f; if (Slot == EquipSlot.MAIN_DROITE) { Wdps = (Wdps * 45f) * 0.01f; } float WSpeed = Me.ItmInterface.GetAttackTime(Slot); WSpeed /= 100; return((int)(((Str / 10) + Wdps) * WSpeed)); } else if (Me.IsCreature()) { float Damage = (int)(20f + (5f * (float)Me.Level + (float)Me.Rank * 10f)); if (Me.Level > Target.Level) { Damage += ((float)Me.Level - (float)Target.Level) * 8f; } else if (Target.Level > Me.Level) { Damage = Damage - ((float)Target.Level - (float)Me.Level) * 3f; } return((int)Damage); } return(1); }
public override void SetDeath(Unit Killer) { UInt16 Time = 600; // Time to AutoResurrect in Seconds. 10 Minutes in Official Servers Killer.QtsInterface.HandleEvent(Objective_Type.QUEST_KILL_PLAYERS, 0, 1); base.SetDeath(Killer); if (Killer.IsPlayer()) { WorldMgr.GenerateRenown(Killer.GetPlayer(), this); } PacketOut Out = new PacketOut((byte)Opcodes.F_PLAYER_DEATH); Out.WriteUInt16(Oid); Out.WriteUInt16(Time); SendPacket(Out); EvtInterface.AddEvent(AutomaticRespawnPlayer, Time * 1000, 1); // If the player don't resurrect. autoresurrect in 10 Minutes. }
public void OnDealDamage(Unit Victim, UInt32 DamageCount) { switch (AI.State) { case AiState.STANDING: CombatStart(Victim); break; case AiState.MOVING: CombatStart(Victim); break; } ; ResetFightingState(TCPManager.GetTimeStampMS()); _Owner.EvtInterface.Notify(EventName.ON_DEAL_DAMAGE, Victim, null); if (_Owner.IsPlayer() && Victim.IsPlayer()) { ResetPvpTime(); } }
public bool AddRange(Unit unit) { if (!HasUnit()) { return(false); } if (CombatInterface.IsEnemy(GetUnit(), unit)) { if ((unit.Realm == Realms.REALMS_REALM_NEUTRAL && !unit.Aggressive) || (!unit.IsPlayer() && !unit.Aggressive) || (!GetUnit().IsPlayer() && !GetUnit().Aggressive) || (unit is Creature && ((Creature)unit).Entry == 47) /*|| (unit is Creature && !unit.IsPlayer() && !unit.IsGameObject() && IsNeutralFaction(unit as Creature))*/) { return(true); } lock (RangedEnemies) RangedEnemies.Add(unit.GetUnit()); } else { lock (RangedAllies) RangedAllies.Add(unit.GetUnit()); } return(true); }
static public bool CanAttack(Unit A, Unit Victim) { /*if (A.IsCreature() && B.IsCreature()) * return false;*/ ///// GM: MOBS DONT ATTACK GM FIX \\\\\ Player Plr = Victim.GetPlayer(); if (Plr != null && Plr.GmLevel > 0) { return(false); } ///////////////////////////////// if (A == null || Victim == null) { return(false); } if (A.IsDisposed || Victim.IsDisposed) { return(false); } if (A == Victim) { return(false); } if (A.IsDead || Victim.IsDead) { return(false); } if (!IsEnemy(A, Victim)) { return(false); } if (!A.IsInWorld() || !Victim.IsInWorld()) { return(false); } if (!A.IsVisible || A.IsInvinsible) { return(false); } if (!Victim.IsVisible || Victim.IsInvinsible) { return(false); } if (A.IsPlayer() && Victim.IsPlayer()) { if (!Victim.CbtInterface.IsPvp) { return(false); } } return(true); }
public void CombatStart(Unit Fighter) { //Log.Success("CombatStart", Obj.Name + " Start combat with " + Fighter.Name); AI.State = AiState.FIGHTING; GetAggro(Fighter.Oid, Fighter.IsPlayer()).DamagesReceive += 100; }
static public bool CanAttack(Unit A, Unit Victim) { /*if (A.IsCreature() && B.IsCreature()) return false;*/ if (A == null || Victim == null) return false; if (A.IsDisposed || Victim.IsDisposed) return false; if (A == Victim) return false; if (A.IsDead || Victim.IsDead) return false; if (!IsEnemy(A, Victim)) return false; if (!A.IsInWorld() || !Victim.IsInWorld()) return false; if (!A.IsVisible || A.IsInvinsible) return false; if (!Victim.IsVisible || Victim.IsInvinsible) return false; if (A.IsPlayer() && Victim.IsPlayer()) { if (!Victim.CbtInterface.IsPvp) return false; } return true; }
public void GenerateLoot(Unit Killer) { if (Killer == null) return; Loots = LootsMgr.GenerateLoot(this, Killer); if (Loots != null && Killer.IsPlayer()) SetLootable(true, Killer.GetPlayer()); }
static public Loot GenerateLoot(Unit Corps, Unit Looter) { if (!Looter.IsPlayer()) { return(null); } Player Plr = Looter.GetPlayer(); if (Corps.IsCreature()) { Creature Crea = Corps.GetCreature(); List <Creature_loot> CreatureLoots = WorldMgr.GetLoots(Crea.Entry); if (CreatureLoots.Count <= 0) { return(null); } QuestsInterface Interface = Plr.QtsInterface; List <LootInfo> Loots = new List <LootInfo>(); float Pct; foreach (Creature_loot Loot in CreatureLoots) { if (Loot.Info.MinRank > Corps.Level + 4 || Loot.Info.MinRenown > (Corps.Level + 4) * 2) { continue; } if (Loot.Info.Realm != 0 && Loot.Info.Realm != (byte)Plr.Realm) { continue; } Pct = Loot.Pct * Program.Config.GlobalLootRate; if (Pct <= 0) { Pct = 0.01f; } switch ((SystemData.ItemRarity)Loot.Info.Rarity) { case SystemData.ItemRarity.ITEMRARITY_COMMON: Pct *= Program.Config.CommonLootRate; break; case SystemData.ItemRarity.ITEMRARITY_UNCOMMON: Pct *= Program.Config.UncommonLootRate; break; case SystemData.ItemRarity.ITEMRARITY_RARE: Pct *= Program.Config.RareLootRate; break; case SystemData.ItemRarity.ITEMRARITY_VERY_RARE: Pct *= Program.Config.VeryRareLootRate; break; case SystemData.ItemRarity.ITEMRARITY_ARTIFACT: Pct *= Program.Config.ArtifactLootRate; break; } ; if (Interface != null && Pct != 100.0f) { foreach (KeyValuePair <ushort, Character_quest> Kp in Interface._Quests) { if (!Kp.Value.Done && !Kp.Value.IsDone()) { foreach (Character_Objectives Obj in Kp.Value._Objectives) { if (!Obj.IsDone() && Obj.Objective.Item != null) { if (Obj.Objective.Item.Entry == Loot.ItemId) { Pct = 100; break; } } } } if (Pct >= 100) { break; } } } if (Pct >= 100f || RandomMgr.Next(10000) < (Pct * 100)) { Loots.Add(new LootInfo(Loot.Info)); } } UInt32 Money = (UInt32)(Corps.Level * (UInt32)7) + (Corps.Rank * (UInt32)50); if (Loots.Count > 0 || Money > 0) { Loot Lt = new Loot(); Lt.Money = Money; Lt.Loots = Loots; Corps.EvtInterface.Notify(EventName.ON_GENERATE_LOOT, Looter, Lt); return(Lt); } } else if (Corps.IsGameObject()) { // This will generate gameobject loot. Currently this only shows loot // if a player needs an item it holds for a quest. If an object has // been looted already or has no loot this will return null. // Todo: Currently object loot always is 100%. Make this support // non quest related loot. GameObject GameObj = Corps.GetGameObject(); List <GameObject_loot> GameObjectLoots = WorldMgr.GetGameObjectLoots(GameObj.Spawn.Entry); if (GameObjectLoots.Count <= 0 || GameObj.Looted) { return(null); } QuestsInterface Interface = Plr.QtsInterface; List <LootInfo> Loots = new List <LootInfo>(); foreach (GameObject_loot Loot in GameObjectLoots) { if (Interface != null) { foreach (KeyValuePair <ushort, Character_quest> Kp in Interface._Quests) { if (!Kp.Value.Done && !Kp.Value.IsDone()) { foreach (Character_Objectives Obj in Kp.Value._Objectives) { if (!Obj.IsDone() && Obj.Objective.Item != null) { if (Obj.Objective.Item.Entry == Loot.ItemId) { Loots.Add(new LootInfo(Loot.Info)); break; } } } } } } } Loot Lt = new Loot(); Lt.Money = 0; Lt.Loots = Loots; return(Lt); } return(null); }
public void OnDealDamage(Unit Victim, UInt32 DamageCount) { switch (AI.State) { case AiState.STANDING: CombatStart(Victim); break; case AiState.MOVING: CombatStart(Victim); break; }; ResetFightingState(TCPManager.GetTimeStampMS()); _Owner.EvtInterface.Notify(EventName.ON_DEAL_DAMAGE, Victim, null); if (_Owner.IsPlayer() && Victim.IsPlayer()) ResetPvpTime(); }
static public void GenerateXP(Unit Killer, Unit Victim) { if (Killer.IsPlayer()) { Player Plr = Killer.GetPlayer(); if (Plr.GetGroup() == null) Plr.AddXp(GenerateXPCount(Plr, Victim)); else Plr.GetGroup().AddXp(Plr, Victim); } }
public void OnDealDamage(Unit Victim, UInt32 DamageCount) { switch (State) { case AiState.STANDING: CombatStart(Victim); break; }; Obj.EvtInterface.Notify("OnDealDamage", Victim, null); if (Obj.IsPlayer() && Victim.IsPlayer()) { ResetPvpTime(); } }
public static void GenerateXP(Unit Killer, Unit Victim) { UInt32 KLvl = Killer.Level; UInt32 VLvl = Victim.Level; if (KLvl > VLvl + 8) return; UInt32 XP = VLvl * 60; XP += (UInt32)Victim.Rank * 20; if (KLvl > VLvl) XP -= (UInt32)(((float)XP / (float)100) * (KLvl - VLvl + 1)) * 5; if (Program.Config.XpRate > 0) XP *= (UInt32)Program.Config.XpRate; if (Killer.IsPlayer()) Killer.GetPlayer().AddXp(XP); }
/*private const float DROP_BONUS_CHAMP = 0.2f; * private const float DROP_BONUS_HERO = 0.04f; * * private const float RARITY_COMMON_GEAR = 20f; * * private static readonly float[] RARITIES = { 5f, 0.4f, 0.02f }; * * private const byte MAX_EASE_IN_LEVEL = 7;*/ public static LootContainer GenerateLoot(Unit corpse, Unit looter, float dropMod) { // Declare kill event constants for bitfields const byte KILL_EVENT_SCENARIO = 1; const byte KILL_EVENT_RVR = 2; const byte KILL_EVENT_PVE = 4; // If the killer isn't a player or a pet, don't bother looting. Player player = null; if (looter == null) { return(null); } if (looter.IsPet()) { player = (looter as Pet).Owner; } else if (looter.IsPlayer()) { player = looter as Player; } if (player == null) { return(null); } // Initialize lootgroups we'll be searching through List <Loot_Group> lootGroups; Player deadPlayer = corpse as Player; // If the corpse is a player, and you've made it this far, this was a PVP kill if (deadPlayer != null) { List <LootInfo> lootList = new List <LootInfo>(); uint corpseCareer = (uint)Math.Pow(2, deadPlayer.Info.CareerLine - 1); uint corpseLevel = deadPlayer.AdjustedLevel; uint corpseRenown = deadPlayer.AdjustedRenown; // Scenario zones all have a war_world.zone_infos.type value of 1. // Note - if "1" refers to "instance" instead of "scenario", there could be problems // with players receiving scenario-restricted loot for a PVP kill made in an instance lootGroups = CreatureService.GetLootGroupsByEvent(deadPlayer.Zone.Info.Type == 1 ? KILL_EVENT_SCENARIO : KILL_EVENT_RVR); // This will be our narrowed down list of loot groups that are relevant to the kill in question. List <Loot_Group> candidateLootGroups = new List <Loot_Group>(); // Whittle down the loot groups into a new candidate list, based on the killed player's career, // and whether the kill occurred in the correct zone (if any) and whether the player has the required quest (if any) foreach (Loot_Group lg in lootGroups) { if (lg == null) { continue; } if (lg.ReqActiveQuest > 0) { Character_quest quest = player.QtsInterface.GetQuest(lg.ReqActiveQuest); if (quest == null || quest.IsDone()) { continue; } } if ((corpseCareer & lg.CreatureID) != corpseCareer) { continue; } if (lg.SpecificZone != 0 && deadPlayer.Zone.Info.ZoneId != lg.SpecificZone) { continue; } candidateLootGroups.Add(lg); } // Generate items from remaining loot groups foreach (Loot_Group lg in candidateLootGroups) { if (lg == null) { continue; } // roll for drops. for (int groupIndex = 0; groupIndex < lg.DropCount; groupIndex++) { float roll = (float)StaticRandom.Instance.Next(0, 10000) / 10000; if (roll <= lg.DropChance) { // Assemble valid drops from the group List <Loot_Group_Item> candidateItems = new List <Loot_Group_Item>(); // This whole if is horrible spaghetti, we need to add each new medallion type here if (Constants.DoomsdaySwitch > 0 && lg.Entry == 1 && WorldMgr.WorldSettingsMgr.GetMedallionsSetting() == 1 && looter.GetPlayer().ScnInterface.Scenario == null && deadPlayer.Level > 15) { foreach (Loot_Group_Item lgi in lg.LootGroupItems) { if (lgi == null) { continue; } if (deadPlayer.Level < 40 && deadPlayer.RenownRank < 41 && corpseRenown < looter.GetPlayer().RenownRank&& looter.RenownRank > 40) { if (lgi.ItemID == 1698 || lgi.ItemID == 208402 || lgi.ItemID == 208403) { candidateItems.Add(lgi); } } else { if (corpseLevel < lgi.MinRank || corpseLevel > lgi.MaxRank) { continue; } if (corpseRenown < lgi.MinRenown || corpseRenown > lgi.MaxRenown) { continue; } Item_Info itemDef = ItemService.GetItem_Info(lgi.ItemID); if (itemDef.Realm != 0 && itemDef.Realm != (byte)player.Realm) { continue; } candidateItems.Add(lgi); } } } else { foreach (Loot_Group_Item lgi in lg.LootGroupItems) { if (lgi == null) { continue; } if (corpseLevel < lgi.MinRank || corpseLevel > lgi.MaxRank) { continue; } if (corpseRenown < lgi.MinRenown || corpseRenown > lgi.MaxRenown) { continue; } Item_Info itemDef = ItemService.GetItem_Info(lgi.ItemID); if (itemDef.Realm != 0 && itemDef.Realm != (byte)player.Realm) { continue; } candidateItems.Add(lgi); } } // If the loot group requires that the dropped loot be usable by a member of // the killer's party, then remove non-compatible loot from the candidate list. if (lg.ReqGroupUsable) { List <Player> members; if (player.PriorityGroup != null) { members = player.PriorityGroup.GetPlayerListCopy(); } else { members = new List <Player> { player }; } for (int itemIndex = 0; itemIndex < candidateItems.Count; ++itemIndex) { bool valid = false; Item_Info curItem = ItemService.GetItem_Info(candidateItems[itemIndex].ItemID); foreach (Player member in members) { if (!ItemsInterface.CanUse(curItem, member, true, false)) { continue; } // Usable by at least one member valid = true; break; } if (!valid) { candidateItems.RemoveAt(itemIndex); --itemIndex; } } } // Now roll for an item from the candidate item list, and add it to the loots. if (candidateItems.Count > 0) { Item_Info winningItem = ItemService.GetItem_Info(candidateItems[StaticRandom.Instance.Next(0, candidateItems.Count)].ItemID); lootList.Add(new LootInfo(winningItem)); } } } } // Generate money as normal, and pass the generated loot back to the system. uint money = corpseLevel * 5 + corpseRenown * 5; if (lootList.Count > 0 || money > 0) { LootContainer lt = new LootContainer { Money = money, LootInfo = lootList }; //corpse.EvtInterface.Notify(EventName.ON_GENERATE_LOOT, looter, Lt); return(lt); } } else if (corpse.IsCreature()) { Creature deadCreature = corpse.GetCreature(); List <LootInfo> Loots = new List <LootInfo>(); // All creatures are by definition PVE kills lootGroups = CreatureService.GetLootGroupsByEvent(KILL_EVENT_PVE); // This will be our narrowed down list of loot groups that are relevant to the kill in question. List <Loot_Group> candidateLootGroups = new List <Loot_Group>(); // Whittle down the loot groups into a new candidate list, based on the killed creature's ID, // or the CreatureSubType if the loot group's CreatureID is 0. foreach (Loot_Group lg in lootGroups) { if (lg == null) { continue; } if (lg.ReqActiveQuest != 0 && !player.QtsInterface.HasQuest(lg.ReqActiveQuest)) { continue; } if (lg.SpecificZone != 0 && deadCreature.Zone.Info.ZoneId != lg.SpecificZone) { continue; } if (lg.CreatureID != 0) { if (deadCreature.Entry == lg.CreatureID) { candidateLootGroups.Add(lg); } } else { if (lg.CreatureSubType == 0 || CreatureService.GetCreatureProto(deadCreature.Entry).CreatureSubType == lg.CreatureSubType) { candidateLootGroups.Add(lg); } } } // Generate items from remaining loot groups foreach (Loot_Group lg in candidateLootGroups) { try { if (lg == null) { continue; } // roll for drops. for (int groupIndex = 0; groupIndex < lg.DropCount; groupIndex++) { float roll = (float)StaticRandom.Instance.Next(0, 10000) / 10000; if (roll <= lg.DropChance) { // Assemble valid drops from the group List <Loot_Group_Item> candidateItems = new List <Loot_Group_Item>(); int effectiveLevel = Math.Min(Program.Config.RankCap, deadCreature.Level); if (lg.LootGroupItems != null) { foreach (Loot_Group_Item lgi in lg.LootGroupItems) { try { if (lgi == null) { continue; } if (effectiveLevel < lgi.MinRank || effectiveLevel > lgi.MaxRank) { continue; } Item_Info itemDef = ItemService.GetItem_Info(lgi.ItemID); if (itemDef.Realm != 0 && itemDef.Realm != (byte)player.Realm) { continue; } candidateItems.Add(lgi); } catch { continue; } } } // If the loot group requires that the dropped loot be usable by a member of // the killer's party, then remove non-compatible loot from the candidate list. if (lg.ReqGroupUsable) { List <Player> members; if (player.PriorityGroup != null) { members = player.PriorityGroup.GetPlayerListCopy(); } else { members = new List <Player> { player } }; for (int itemIndex = 0; itemIndex < candidateItems.Count; ++itemIndex) { bool valid = false; Item_Info curItem = ItemService.GetItem_Info(candidateItems[itemIndex].ItemID); foreach (Player member in members) { if (!ItemsInterface.CanUse(curItem, member, true, false)) { continue; } valid = true; break; } if (!valid) { candidateItems.RemoveAt(itemIndex); --itemIndex; } } } // Now roll for an item from the candidate item list, and add it to the loots. if (candidateItems.Count > 0) { Item_Info winningItem = ItemService.GetItem_Info(candidateItems[StaticRandom.Instance.Next(0, candidateItems.Count)].ItemID); Loots.Add(new LootInfo(winningItem)); } } } } catch { continue; } } // Generate money as normal, and pass the generated loot back to the system. uint money = corpse.Level * (uint)7 + corpse.Rank * (uint)50; if (Loots.Count > 0 || money > 0) { LootContainer lt = new LootContainer { Money = money, LootInfo = Loots }; //corpse.EvtInterface.Notify(EventName.ON_GENERATE_LOOT, looter, Lt); return(lt); } } else if (corpse.IsGameObject()) { // This will generate gameobject loot. Currently this only shows loot // if a player needs an item it holds for a quest. If an object has // been looted already or has no loot this will return null. // Todo: Currently object loot always is 100%. Make this support non quest related loot. GameObject gameObj = corpse.GetGameObject(); List <GameObject_loot> gameObjectLoots = GameObjectService.GetGameObjectLoots(gameObj.Spawn.Entry); if (gameObjectLoots.Count <= 0 || gameObj.Looted) { return(null); } QuestsInterface Interface = looter.QtsInterface; if (Interface == null) { return(null); } List <LootInfo> lootInfo = new List <LootInfo>(); foreach (GameObject_loot loot in gameObjectLoots) { foreach (KeyValuePair <ushort, Character_quest> kp in Interface.Quests) { if (kp.Value.Done || kp.Value.IsDone()) { continue; } foreach (Character_Objectives obj in kp.Value._Objectives) { if (obj.IsDone() || obj.Objective.Item == null || obj.Objective.Item.Entry != loot.ItemId) { continue; } lootInfo.Add(new LootInfo(loot.Info)); break; } } } LootContainer lt = new LootContainer { Money = 0, LootInfo = lootInfo }; return(lt); } return(null); }
public void OnTakeHeal(Unit Caster, UInt32 DamageCount) { ResetFightingState(TCPManager.GetTimeStampMS()); AddHealReceive(Caster.Oid, Caster.IsPlayer(), DamageCount); _Owner.EvtInterface.Notify(EventName.ON_RECEIVE_HEAL, Caster, null); if (_Owner.IsPlayer() && Caster.IsPlayer()) ResetPvpTime(); }
public void OnDealHeal(Unit Target, UInt32 DamageCount) { ResetFightingState(TCPManager.GetTimeStampMS()); _Owner.EvtInterface.Notify(EventName.ON_DEAL_HEAL, Target, null); if (_Owner.IsPlayer() && Target.IsPlayer() && Target.GetPlayer().CbtInterface.IsPvp) ResetPvpTime(); }
public static void GenerateXP(Unit Killer, Unit Victim) { if (!Killer.IsPlayer()) return; Player player = Killer.GetPlayer(); if (player.GetGroup() == null) { player.AddXp(GenerateXPCount(player, Victim)); } else { player.GetGroup().AddXp(player, Victim); } }
public void OnTakeDamage(Unit Fighter, UInt32 DamageCount) { switch (State) { case AiState.STANDING: CombatStart(Fighter); break; }; AddDamageReceive(Fighter.Oid, DamageCount); Obj.EvtInterface.Notify("OnTakeDamage", Fighter, null); if (Obj.IsPlayer() && Fighter.IsPlayer()) { ResetPvpTime(); } }
public void OnTakeDamage(Unit Fighter, UInt32 DamageCount) { switch (AI.State) { case AiState.STANDING: CombatStart(Fighter); break; case AiState.MOVING: CombatStart(Fighter); break; }; ResetFightingState(TCPManager.GetTimeStampMS()); AddDamageReceive(Fighter.Oid, Fighter.IsPlayer(), DamageCount); _Owner.EvtInterface.Notify(EventName.ON_RECEIVE_DAMAGE, Fighter, null); if (_Owner.IsPlayer() && Fighter.IsPlayer()) ResetPvpTime(); }
public override void SetDeath(Unit Killer) { UInt16 Time = 600; // Time to AutoResurrect in Seconds. 10 Minutes in Official Servers Killer.QtsInterface.HandleEvent(Objective_Type.QUEST_KILL_PLAYERS, 0, 1); base.SetDeath(Killer); if(Killer.IsPlayer()) WorldMgr.GenerateRenown(Killer.GetPlayer(), this); PacketOut Out = new PacketOut((byte)Opcodes.F_PLAYER_DEATH); Out.WriteUInt16(Oid); Out.WriteUInt16(Time); SendPacket(Out); EvtInterface.AddEvent(AutomaticRespawnPlayer, Time * 1000, 1); // If the player don't resurrect. autoresurrect in 10 Minutes. }
public static Loot GenerateLoot(Unit Corps, Unit Looter) { if (!Looter.IsPlayer()) return null; if (Corps.IsCreature()) { Creature Crea = Corps.GetCreature(); List<Creature_loot> CreatureLoots = WorldMgr.GetLoots(Crea.Entry); if (CreatureLoots.Count <= 0) return null; List<LootInfo> Loots = new List<LootInfo>(); foreach (Creature_loot Loot in CreatureLoots) { float Pct = Loot.Pct * Program.Config.GlobalLootRate; if (Pct <= 0) Pct = 0.01f; switch ((SystemData.ItemRarity)Loot.Info.Rarity) { case SystemData.ItemRarity.ITEMRARITY_COMMON: Pct *= Program.Config.CommonLootRate; break; case SystemData.ItemRarity.ITEMRARITY_UNCOMMON: Pct *= Program.Config.UncommonLootRate; break; case SystemData.ItemRarity.ITEMRARITY_RARE: Pct *= Program.Config.RareLootRate; break; case SystemData.ItemRarity.ITEMRARITY_VERY_RARE: Pct *= Program.Config.VeryRareLootRate; break; case SystemData.ItemRarity.ITEMRARITY_ARTIFACT: Pct *= Program.Config.ArtifactLootRate; break; }; // Je Fawk | 14 April 2014 | Declined fix #region <Commented> // Fixing the drop rate so that a mob can drop the same item type more than once based on drop % Pct // If the drop percentage is lower than 100% //if (Pct < 100.0f) //{ // if (RandomMgr.Next(10000) <= (Pct*100)) // { // Loots.Add(new LootInfo(Loot.Info)); // } //} //else // // If the drop percentage is between 100% and 999% // if ((Pct > 100.0f) && (Pct < 1000.0f)) // { // // For each 100 percentage give the player 1 item // for (byte i = 0; i < Math.Floor((Pct / 100.0f)); i++) // { // Loots.Add(new LootInfo(Loot.Info)); // } // // For the rest that's below 100 do a roll for a new item // if (RandomMgr.Next(10000) <= ((Pct % 100) * 100)) // { // Loots.Add(new LootInfo(Loot.Info)); // } // } // else // // For the extreme case where we want the item to drop more than 10 per mob // if (( Pct > 1000.0f) && (Pct < 10000.0f)) // { // // For each 100 percentage give the player 1 item // for (int i = 0; i < Math.Floor((Pct / 100.0f)); i++) // { // Loots.Add(new LootInfo(Loot.Info)); // } // // For the rest that's below 100 do a roll for a new item // if (RandomMgr.Next(10000) <= ((Pct % 1000) * 100)) // { // Loots.Add(new LootInfo(Loot.Info)); // } // } #endregion if (Pct > 100.0f || RandomMgr.Next(10000) < (Pct * 100)) Loots.Add(new LootInfo(Loot.Info)); } UInt32 Money = (UInt32)(Corps.Level * (UInt32)7) + (Corps.Rank * (UInt32)50); if (Loots.Count > 0 || Money > 0) { Log.Success("LootMgr", "Generate Loot : " + Loots.Count); Loot Lt = new Loot(); Lt.Money = Money; Lt.Loots = Loots.ToArray(); return Lt; } } return null; }
static public Loot GenerateLoot(Unit Corps, Unit Looter) { if (!Looter.IsPlayer()) return null; Player Plr = Looter.GetPlayer(); if (Corps.IsCreature()) { Creature Crea = Corps.GetCreature(); List<Creature_loot> CreatureLoots = WorldMgr.GetLoots(Crea.Entry); if (CreatureLoots.Count <= 0) return null; QuestsInterface Interface = Plr.QtsInterface; List<LootInfo> Loots = new List<LootInfo>(); float Pct; foreach (Creature_loot Loot in CreatureLoots) { if (Loot.Info.MinRank > Corps.Level + 4 || Loot.Info.MinRenown > (Corps.Level + 4) * 2) continue; if (Loot.Info.Realm != 0 && Loot.Info.Realm != (byte)Plr.Realm) continue; Pct = Loot.Pct * Program.Config.GlobalLootRate; if (Pct <= 0) Pct = 0.01f; switch ((SystemData.ItemRarity)Loot.Info.Rarity) { case SystemData.ItemRarity.ITEMRARITY_COMMON: Pct *= Program.Config.CommonLootRate; break; case SystemData.ItemRarity.ITEMRARITY_UNCOMMON: Pct *= Program.Config.UncommonLootRate; break; case SystemData.ItemRarity.ITEMRARITY_RARE: Pct *= Program.Config.RareLootRate; break; case SystemData.ItemRarity.ITEMRARITY_VERY_RARE: Pct *= Program.Config.VeryRareLootRate; break; case SystemData.ItemRarity.ITEMRARITY_ARTIFACT: Pct *= Program.Config.ArtifactLootRate; break; }; if (Interface != null && Pct != 100.0f) { foreach (KeyValuePair<ushort, Character_quest> Kp in Interface._Quests) { if (!Kp.Value.Done && !Kp.Value.IsDone()) { foreach (Character_Objectives Obj in Kp.Value._Objectives) { if (!Obj.IsDone() && Obj.Objective.Item != null) { if (Obj.Objective.Item.Entry == Loot.ItemId) { Pct = 100; break; } } } } if (Pct >= 100) break; } } if(Pct >= 100f || RandomMgr.Next(10000) < (Pct*100)) Loots.Add(new LootInfo(Loot.Info)); } UInt32 Money = (UInt32)(Corps.Level * (UInt32)7) + (Corps.Rank * (UInt32)50); if (Loots.Count > 0 || Money > 0) { Loot Lt = new Loot(); Lt.Money = Money; Lt.Loots = Loots; Corps.EvtInterface.Notify(EventName.ON_GENERATE_LOOT, Looter, Lt); return Lt; } } else if (Corps.IsGameObject()) { // This will generate gameobject loot. Currently this only shows loot // if a player needs an item it holds for a quest. If an object has // been looted already or has no loot this will return null. // Todo: Currently object loot always is 100%. Make this support // non quest related loot. GameObject GameObj = Corps.GetGameObject(); List<GameObject_loot> GameObjectLoots = WorldMgr.GetGameObjectLoots(GameObj.Spawn.Entry); if (GameObjectLoots.Count <= 0 || GameObj.Looted) return null; QuestsInterface Interface = Plr.QtsInterface; List<LootInfo> Loots = new List<LootInfo>(); foreach (GameObject_loot Loot in GameObjectLoots) { if (Interface != null) { foreach (KeyValuePair<ushort, Character_quest> Kp in Interface._Quests) { if (!Kp.Value.Done && !Kp.Value.IsDone()) { foreach (Character_Objectives Obj in Kp.Value._Objectives) { if (!Obj.IsDone() && Obj.Objective.Item != null) { if (Obj.Objective.Item.Entry == Loot.ItemId) { Loots.Add(new LootInfo(Loot.Info)); break; } } } } } } } Loot Lt = new Loot(); Lt.Money = 0; Lt.Loots = Loots; return Lt; } return null; }
/// <summary> /// This method assigns aggro from heals and selects new target, based on current max hate /// </summary> private void ProcessAggro() { if (!_unit.IsPet()) { ulong maxHatred = 0; int nextTargetOid = 0; Unit nextTarget = null; foreach (Player player in _unit.PlayersInRange.ToList()) { if (player != null && CombatInterface.CanAttack(_unit, player)) { if (player.IsDead) { Aggros[player.Oid].Hatred = 0; } else { if (player.CbtInterface.IsInCombat) { foreach (KeyValuePair <ushort, AggroInfo> healAggro in player.HealAggros) { foreach (KeyValuePair <ushort, AggroInfo> aggro in Aggros) { if (!(_unit is Pet) && healAggro.Key == aggro.Key && _combatStart < healAggro.Value.HealingReceivedTime && aggro.Value.HealingReceivedTime != healAggro.Value.HealingReceivedTime) { aggro.Value.Hatred += (ulong)((healAggro.Value.HealingReceived) * GetDetaunt(healAggro.Key)); healAggro.Value.HealingReceivedTime = aggro.Value.HealingReceivedTime; } } } } } } } foreach (Object obj in _unit.ObjectsInRange.ToList()) { Unit u = obj as Unit; if (u != null && (!u.IsDead && !u.PendingDisposal && !u.IsDisposed) && CombatInterface.CanAttack(_unit, u)) { foreach (KeyValuePair <ushort, AggroInfo> aggro in Aggros) { if (aggro.Key == obj.Oid) { if (aggro.Value.Hatred > maxHatred) { maxHatred = aggro.Value.Hatred; nextTargetOid = obj.Oid; nextTarget = u; } } } } } if (nextTarget != null && _pet == null) { AddHatred(nextTarget, nextTarget.IsPlayer(), 0); } } }