private static float GetModifiedDamage(Unit unit, float dmg) { float psysicalDamageBonus = CharacterFormulas.CalculatePsysicalDamageBonus(unit.Level, unit.Asda2Agility, unit.Asda2Strength, unit.Class); return(UnitUpdates.GetMultiMod(unit.FloatMods[10], dmg + (float)unit.IntMods[25] + psysicalDamageBonus)); }
/// <summary> /// Calculates the melee critical chance for the class at a specific level, base Agility and added Agility. /// TODO: Implement diminishing returns /// </summary> /// <param name="level">the player's level</param> /// <param name="agility">the player's Agility</param> /// <returns>the total melee critical chance</returns> public float CalculateMeleeCritChance(int level, int agility, int luck) { float psysicCritChance = CharacterFormulas.CalculatePsysicCritChance(Id, level, luck); if (psysicCritChance <= 5.0) { return(5f); } return(psysicCritChance); }
public static void ProcessDig(IRealmClient client) { if (client.ActiveCharacter == null) { return; } var showel = client.ActiveCharacter.MainWeapon as Asda2Item; if (showel == null) { return; } var oilItem = client.ActiveCharacter.Asda2Inventory.Equipment[10]; var isUseOil = oilItem != null && oilItem.Category == Asda2ItemCategory.DigOil; if (isUseOil) { oilItem.Amount--; } var chance = CharacterFormulas.CalculateDiggingChance(showel.Template.ValueOnUse, (byte)(client.ActiveCharacter.SoulmateRecord == null ? 0 : client.ActiveCharacter.SoulmateRecord.FriendShipPoints), client.ActiveCharacter.Asda2Luck); var rnd = Utility.Random(0, 100000); if (rnd > chance && (isUseOil ? client.ActiveCharacter.MapId < (MapId)PremiumMapDiggingTemplates.Count : client.ActiveCharacter.MapId < (MapId)MapDiggingTemplates.Count)) { //dig ok Asda2DiggingHandler.SendDigEndedResponse(client, true, oilItem); var templ = isUseOil ? PremiumMapDiggingTemplates[(byte)client.ActiveCharacter.MapId] : MapDiggingTemplates[(byte)client.ActiveCharacter.MapId]; var itemId = templ.GetRandomItem(); var loot = new Asda2NPCLoot(); var itemTempl = Asda2ItemMgr.GetTemplate(itemId) ?? Asda2ItemMgr.GetTemplate(20622); loot.Items = new[] { new Asda2LootItem(itemTempl, 1, 0) { Loot = loot } }; loot.Lootable = client.ActiveCharacter; loot.Looters.Add(new Asda2LooterEntry(client.ActiveCharacter)); loot.MonstrId = 22222; client.ActiveCharacter.Map.SpawnLoot(loot); client.ActiveCharacter.GainXp(CharacterFormulas.CalcDiggingExp(client.ActiveCharacter.Level, templ.MinLevel), "digging"); client.ActiveCharacter.GuildPoints += CharacterFormulas.DiggingGuildPoints; Asda2TitleChecker.OnSuccessDig(client.ActiveCharacter, itemId, itemTempl.Quality, client); } else { // dig fail Asda2DiggingHandler.SendDigEndedResponse(client, false, oilItem); } client.ActiveCharacter.IsDigging = false; client.ActiveCharacter.Stunned--; }
/// <summary>Re-calculates the mainhand melee damage of this Unit</summary> internal static void UpdateMainAttackTime(this Unit unit) { int attackTime = unit.MainWeapon.AttackTime; int num = UnitUpdates.GetMultiMod( unit.FloatMods[1] - CharacterFormulas.CalculateAtackTimeReduce(unit.Level, unit.Class, unit.Asda2Agility), attackTime); if (num < 30) { num = 30; } unit.MainHandAttackTime = num; }
public void UpdateSpeedFactor() { var bns = CharacterFormulas.CalcSpeedBonus(Level, Class, Asda2Agility); if (bns > 1) { bns = 1; } SpeedFactor = UnitUpdates.GetMultiMod(FloatMods[(int)StatModifierFloat.Speed] + bns, DefaultSpeedFactor); var chr = this as Character; if (chr != null) { GlobalHandler.SendSpeedChangedResponse(chr.Client); } }
/// <summary>Calculated in UnitUpdates.UpdateBlockChance</summary> public int CalcBlockDamage() { if (!(this.Victim is Character)) { return(0); } Asda2Item asda2Item = ((Character)this.Victim).Asda2Inventory.Equipment[8]; if (asda2Item != null) { return((int)((double)this.Damage * CharacterFormulas.CalcShieldBlockPrc(asda2Item.Template.Quality, asda2Item.Template.RequiredLevel))); } return(0); }
protected internal void UpdateMaxPower() { var value = BasePower + IntMods[(int)StatModifierInt.Power] + CharacterFormulas.CalculateManaBonus(Level, Class, Asda2Spirit); /*if (PowerType == PowerType.Mana) * { * value += IntellectManaBonus; * }*/ value += (value * IntMods[(int)StatModifierInt.PowerPct] + 50) / 100; if (value < 0) { value = 0; } MaxPower = value; this.UpdatePowerRegen(); }
/// <summary> /// Calculated in UnitUpdates.UpdateBlockChance /// </summary> public int CalcBlockDamage() { // Mobs should be able to block as well, right? if (!(Victim is Character)) { // mobs can't block return(0); } var target = (Character)Victim; var shield = target.Asda2Inventory.Equipment[(int)Asda2EquipmentSlots.Shild]; if (shield != null) { return((int)(Damage * CharacterFormulas.CalcShieldBlockPrc(shield.Template.Quality, shield.Template.RequiredLevel))); } return(0); }
internal static void UpdateDodgeChance(this Unit unit) { var chr = unit as Character; if (chr != null) { float dodgeChance = 0; if (chr.Asda2Agility == 0) { return; // too early } dodgeChance += unit.IntMods[(int)StatModifierInt.DodgeChance] + CharacterFormulas.CalcDodgeChanceBonus(unit.Level, unit.Class, unit.Asda2Agility); GetMultiMod(unit.FloatMods[(int)StatModifierFloat.Dodge], dodgeChance); chr.DodgeChance = dodgeChance; } }
public ResetStatsEnum ResetStats() { if (this.CurrentAccount == null || this.CurrentAccount.ActiveCharacter == null) { return(ResetStatsEnum.Error); } if (!this.CurrentAccount.ActiveCharacter.SubtractMoney((uint)CharacterFormulas.CalcGoldAmountToResetStats( this.CurrentAccount.ActiveCharacter.Asda2Strength, this.CurrentAccount.ActiveCharacter.Asda2Agility, this.CurrentAccount.ActiveCharacter.Asda2Stamina, this.CurrentAccount.ActiveCharacter.Asda2Spirit, this.CurrentAccount.ActiveCharacter.Asda2Luck, this.CurrentAccount.ActiveCharacter.Asda2Intellect, (byte)this.CurrentAccount.ActiveCharacter.Level, (int)(byte)this.CurrentAccount.ActiveCharacter.Record.RebornCount))) { return(ResetStatsEnum.NotEnoughtMoney); } this.CurrentAccount.ActiveCharacter.ResetStatPoints(); this.CurrentAccount.ActiveCharacter.SendMoneyUpdate(); return(ResetStatsEnum.Ok); }
internal static void UpdateDodgeChance(this Unit unit) { Character character = unit as Character; if (character == null) { return; } float num1 = 0.0f; if (character.Asda2Agility == 0) { return; } float num2 = num1 + ((float)unit.IntMods[13] + CharacterFormulas.CalcDodgeChanceBonus(unit.Level, unit.Class, unit.Asda2Agility)); double multiMod = (double)UnitUpdates.GetMultiMod(unit.FloatMods[30], num2); character.DodgeChance = num2; }
public ResetStatsEnum ResetStats() { if (CurrentAccount == null || CurrentAccount.ActiveCharacter == null) { return(ResetStatsEnum.Error); } var goldToReset = CharacterFormulas.CalcGoldAmountToResetStats(CurrentAccount.ActiveCharacter.Asda2Strength, CurrentAccount.ActiveCharacter.Asda2Agility, CurrentAccount.ActiveCharacter.Asda2Stamina, CurrentAccount.ActiveCharacter.Asda2Spirit, CurrentAccount.ActiveCharacter.Asda2Luck, CurrentAccount.ActiveCharacter.Asda2Intellect, (byte)CurrentAccount.ActiveCharacter.Level, (byte) CurrentAccount.ActiveCharacter.Record.RebornCount); if (!CurrentAccount.ActiveCharacter.SubtractMoney((uint)goldToReset)) { return(ResetStatsEnum.NotEnoughtMoney); } CurrentAccount.ActiveCharacter.ResetStatPoints(); CurrentAccount.ActiveCharacter.SendMoneyUpdate(); return(ResetStatsEnum.Ok); }
public static void TryGuess(string word, Character senderChr) { lock (typeof(Asda2EventMgr)) { if (!Asda2EventMgr.IsGuessWordEventStarted) { return; } string lower = word.ToLower(); float num = 0.0f; for (int index = 0; index < lower.Length && index < Asda2EventMgr._word.Length; ++index) { if ((int)lower[index] == (int)Asda2EventMgr._word[index]) { ++num; } } if ((double)num / (double)Asda2EventMgr._word.Length < (double)Asda2EventMgr._percision) { return; } int experience = CharacterFormulas.CalcExpForGuessWordEvent(senderChr.Level); int eventItems = CharacterFormulas.EventItemsForGuessEvent; Asda2EventMgr.SendMessageToWorld("{0} is winner. Prize is {1} exp and {2} event items.", (object)senderChr.Name, (object)experience, (object)eventItems); senderChr.GainXp(experience, "guess_event", false); ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() => senderChr.Asda2Inventory.AddDonateItem(Asda2ItemMgr.GetTemplate(CharacterFormulas.EventItemId), eventItems, "guess_event", false))); Asda2EventMgr.StopGueesWordEvent(); Log.Create(Log.Types.EventOperations, LogSourceType.Character, senderChr.EntryId) .AddAttribute("win", (double)eventItems, "guess_event").Write(); } }
public static void TryGuess(string word, Character senderChr) { lock (typeof(Asda2EventMgr)) { if (!Started) { return; } var fixedWord = word.ToLower(); float correctHits = 0f; for (int i = 0; i < fixedWord.Length; i++) { if (i >= _word.Length) { break; } if (fixedWord[i] == _word[i]) { correctHits++; } } if (correctHits / _word.Length >= _percision) { //character is winner var exp = CharacterFormulas.CalcExpForGuessWordEvent(senderChr.Level); var eventItems = CharacterFormulas.EventItemsForGuessEvent; Asda2EventMgr.SendMessageToWorld("{0} is winner. Prize is {1} exp and {2} event items.", senderChr.Name, exp, eventItems); senderChr.GainXp(exp, "guess_event"); RealmServer.IOQueue.AddMessage(() => senderChr.Asda2Inventory.AddDonateItem(Asda2ItemMgr.GetTemplate(CharacterFormulas.EventItemId), eventItems, "guess_event")); Stop(); Log.Create(Log.Types.EventOperations, LogSourceType.Character, senderChr.EntryId) .AddAttribute("win", eventItems, "guess_event") .Write(); } } }
public void GuildWaveResultAndItems(Character chr) { if (chr.IsDead) { chr.Resurrect(); } Asda2TitleChecker.OnGuildWaveEnd(chr, LastWinnedWave); Asda2GuildWaveItemRecord waveItem = null; foreach (Asda2GuildWaveItemRecord record in Asda2ItemMgr.GuildWaveRewardRecords) { if (record.Wave == LastWinnedWave + 1 && record.Lvl == (int)Math.Ceiling(chr.Level / 10.0F) * 10 && record.Difficulty == _difficulty) { waveItem = record; break; } } if (waveItem != null) { List <KeyValuePair <int, int> > pairs = new List <KeyValuePair <int, int> >(); pairs.Add(new KeyValuePair <int, int>(1, waveItem.Chance1)); pairs.Add(new KeyValuePair <int, int>(2, waveItem.Chance2)); pairs.Add(new KeyValuePair <int, int>(3, waveItem.Chance3)); pairs.Add(new KeyValuePair <int, int>(4, waveItem.Chance4)); pairs.Add(new KeyValuePair <int, int>(5, waveItem.Chance5)); pairs.Add(new KeyValuePair <int, int>(6, waveItem.Chance6)); pairs.Add(new KeyValuePair <int, int>(7, waveItem.Chance7)); pairs.Add(new KeyValuePair <int, int>(8, waveItem.Chance8)); pairs.Sort((a, b) => a.Value.CompareTo(b.Value)); int templateId1 = getTemplateIdFromIndex(CharacterFormulas.GetWaveRewardItems(pairs), waveItem); int templateId2 = getTemplateIdFromIndex(CharacterFormulas.GetWaveRewardItems(pairs), waveItem); int templateId3 = getTemplateIdFromIndex(CharacterFormulas.GetWaveRewardItems(pairs), waveItem); Asda2Item item1 = Asda2Item.CreateItem(templateId1, chr, 1); Asda2Item wavecoin = null; int amount = getAverageLevel() / CharacterFormulas.WaveCoinsDivider; if (amount > 0) { wavecoin = Asda2Item.CreateItem(33712, chr, amount); chr.Asda2Inventory.TryAdd(33712, amount, true, ref wavecoin); } chr.Asda2Inventory.TryAdd(templateId1, 1, true, ref item1); if (_difficulty > 0) { Asda2Item item2 = Asda2Item.CreateItem(templateId2, chr, 1); chr.Asda2Inventory.TryAdd(templateId2, 1, true, ref item2); if (_difficulty == 2) { Asda2Item item3 = Asda2Item.CreateItem(templateId3, chr, 1); chr.Asda2Inventory.TryAdd(templateId3, 1, true, ref item3); } } Asda2GuildWaveHandler.GuildWaveResult(this, chr, wavecoin == null ? 0 : wavecoin.Amount, templateId1, templateId2, templateId3); } }
private void ProcessEndWar(Character character) { character.Stunned++; GlobalHandler.SendFightingModeChangedResponse(character.Client, character.SessionId, (int)character.AccId, -1); //create db record if (MvpCharacter != null) { RealmServer.IOQueue.AddMessage(() => { var rec = new BattlegroundCharacterResultRecord(CurrentWarResultRecordGuid, character.Name, character.EntityId.Low, character.BattlegroundActPoints, character.BattlegroundKills, character.BattlegroundDeathes); rec.CreateLater(); }); } var honorPoints = WiningFactionId == 2 ? 0 : CharacterFormulas.CalcHonorPoints(character.Level, character.BattlegroundActPoints, LightScores > DarkScores, character.BattlegroundDeathes, character.BattlegroundKills, MvpCharacter == character, Town); var honorCoins = (short)(WiningFactionId == 2 ? 0 : (honorPoints / CharacterFormulas.HonorCoinsDivider)); if (character.BattlegroundActPoints < 5) { character.BattlegroundActPoints = 5; } if (honorPoints <= 0) { honorPoints = 1; } if (honorCoins <= 0) { honorCoins = 1; } Asda2Item itemCoins = null; if (honorCoins > 0) { character.Asda2Inventory.TryAdd( 20614, honorCoins, true, ref itemCoins); Log.Create(Log.Types.ItemOperations, LogSourceType.Character, character.EntryId) .AddAttribute("source", 0, "honor_coins_for_bg") .AddItemAttributes(itemCoins) .AddAttribute("amount", honorCoins) .Write(); } var bonusExp = WiningFactionId == 2 ? 0 : (int)((float)XpGenerator.GetBaseExpForLevel(character.Level) * character.BattlegroundActPoints / 2.5); character.GainXp(bonusExp, "battle_ground"); character.Asda2HonorPoints += honorPoints; Asda2BattlegroundHandler.SendWarEndedResponse(character.Client, (byte)WiningFactionId, LightScores > DarkScores ? LightScores : DarkScores, LightScores > DarkScores ? DarkScores : LightScores, honorPoints, honorCoins, bonusExp, MvpCharacter == null ? "" : MvpCharacter.Name); Asda2BattlegroundHandler.SendWarEndedOneResponse(character.Client, new List <Asda2Item> { itemCoins }); character.SendWarMsg("ÓæÝ íÊã ÅÑÓÇáß Åáì ÇáãÏíäÉ ÈÚÏ 1 ÏÞíÞÉ ãä ÇáÇä."); }
public static void ProcessDig(IRealmClient client) { if (client.ActiveCharacter == null) { return; } Asda2Item mainWeapon = client.ActiveCharacter.MainWeapon as Asda2Item; if (mainWeapon == null) { return; } Asda2Item asda2Item = client.ActiveCharacter.Asda2Inventory.Equipment[10]; bool flag = asda2Item != null && asda2Item.Category == Asda2ItemCategory.DigOil; if (flag) { --asda2Item.Amount; } if (flag) { AchievementProgressRecord progressRecord1 = client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(92U); AchievementProgressRecord progressRecord2 = client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(91U); ++progressRecord1.Counter; if (progressRecord1.Counter >= 1000U || progressRecord2.Counter >= 1000U) { client.ActiveCharacter.GetTitle(Asda2TitleId.Automatic225); } progressRecord1.SaveAndFlush(); } if (Utility.Random(0, 100000) > CharacterFormulas.CalculateDiggingChance(mainWeapon.Template.ValueOnUse, client.ActiveCharacter.SoulmateRecord == null ? (byte)0 : client.ActiveCharacter.SoulmateRecord.FriendShipPoints, client.ActiveCharacter.Asda2Luck) && (flag ? (client.ActiveCharacter.MapId < (MapId)PremiumMapDiggingTemplates.Count ? 1 : 0) : (client.ActiveCharacter.MapId < (MapId)MapDiggingTemplates.Count ? 1 : 0)) != 0) { Asda2DiggingHandler.SendDigEndedResponse(client, true, asda2Item); MineTableRecord mineTableRecord = flag ? PremiumMapDiggingTemplates[(byte)client.ActiveCharacter.MapId] : MapDiggingTemplates[(byte)client.ActiveCharacter.MapId]; int randomItem = mineTableRecord.GetRandomItem(); Asda2NPCLoot asda2NpcLoot = new Asda2NPCLoot(); Asda2ItemTemplate templ = Asda2ItemMgr.GetTemplate(randomItem) ?? Asda2ItemMgr.GetTemplate(20622); asda2NpcLoot.Items = new Asda2LootItem[1] { new Asda2LootItem(templ, 1, 0U) { Loot = asda2NpcLoot } }; asda2NpcLoot.Lootable = client.ActiveCharacter; asda2NpcLoot.Looters.Add(new Asda2LooterEntry(client.ActiveCharacter)); asda2NpcLoot.MonstrId = 22222; if ((int)templ.ItemId >= 33542 && 33601 <= (int)templ.ItemId) { AchievementProgressRecord progressRecord = client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(125U); switch (++progressRecord.Counter) { case 250: client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Astrological292); break; case 500: client.ActiveCharacter.GetTitle(Asda2TitleId.Astrological292); break; } progressRecord.SaveAndFlush(); } if (templ.ItemId == Asda2ItemId.TreasureBox31407 || templ.ItemId == Asda2ItemId.GoldenTreasureBox31408) { AchievementProgressRecord progressRecord1 = client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(126U); switch (++progressRecord1.Counter) { case 25: client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Treasure293); break; case 50: client.ActiveCharacter.GetTitle(Asda2TitleId.Treasure293); break; } progressRecord1.SaveAndFlush(); if (templ.ItemId == Asda2ItemId.GoldenTreasureBox31408) { AchievementProgressRecord progressRecord2 = client.ActiveCharacter.Achievements.GetOrCreateProgressRecord((uint)sbyte.MaxValue); switch (++progressRecord2.Counter) { case 389: client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Lucky295); break; case 777: client.ActiveCharacter.GetTitle(Asda2TitleId.Lucky295); break; } progressRecord2.SaveAndFlush(); } } client.ActiveCharacter.Map.SpawnLoot(asda2NpcLoot); client.ActiveCharacter.GainXp( CharacterFormulas.CalcDiggingExp(client.ActiveCharacter.Level, mineTableRecord.MinLevel), "digging", false); client.ActiveCharacter.GuildPoints += CharacterFormulas.DiggingGuildPoints; } else { Asda2DiggingHandler.SendDigEndedResponse(client, false, asda2Item); } client.ActiveCharacter.IsDigging = false; --client.ActiveCharacter.Stunned; }
private void ProcessEndWar(Character character) { ++character.Stunned; GlobalHandler.SendFightingModeChangedResponse(character.Client, character.SessionId, (int)character.AccId, (short)-1); if (this.MvpCharacter != null) { ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() => new BattlegroundCharacterResultRecord(this.CurrentWarResultRecordGuid, character.Name, character.EntityId.Low, (int)character.BattlegroundActPoints, character.BattlegroundKills, character.BattlegroundDeathes).CreateLater())); } int honorPoints = this.WiningFactionId == 2 ? 0 : CharacterFormulas.CalcHonorPoints(character.Level, character.BattlegroundActPoints, this.LightScores > this.DarkScores, character.BattlegroundDeathes, character.BattlegroundKills, this.MvpCharacter == character, this.Town); short honorCoins = this.WiningFactionId == 2 ? (short)0 : (short)((double)honorPoints / (double)CharacterFormulas.HonorCoinsDivider); if (character.BattlegroundActPoints < (short)5) { character.BattlegroundActPoints = (short)5; } if (honorPoints <= 0) { honorPoints = 1; } if (honorCoins <= (short)0) { honorCoins = (short)1; } Asda2Item asda2Item = (Asda2Item)null; if (honorCoins > (short)0) { int num = (int)character.Asda2Inventory.TryAdd(20614, (int)honorCoins, true, ref asda2Item, new Asda2InventoryType?(), (Asda2Item)null); Log.Create(Log.Types.ItemOperations, LogSourceType.Character, character.EntryId) .AddAttribute("source", 0.0, "honor_coins_for_bg").AddItemAttributes(asda2Item, "") .AddAttribute("amount", (double)honorCoins, "").Write(); } int bonusExp = this.WiningFactionId == 2 ? 0 : (int)((double)XpGenerator.GetBaseExpForLevel(character.Level) * (double)character.BattlegroundActPoints / 2.5); character.GainXp(bonusExp, "battle_ground", false); character.Asda2HonorPoints += honorPoints; AchievementProgressRecord progressRecord = character.Achievements.GetOrCreateProgressRecord(20U); if (character.FactionId == (FactionId)this.WiningFactionId) { switch (++progressRecord.Counter) { case 5: character.DiscoverTitle(Asda2TitleId.Challenger125); break; case 10: character.GetTitle(Asda2TitleId.Challenger125); break; case 25: character.DiscoverTitle(Asda2TitleId.Winner126); break; case 50: character.GetTitle(Asda2TitleId.Winner126); break; case 75: character.DiscoverTitle(Asda2TitleId.Champion127); break; case 100: character.GetTitle(Asda2TitleId.Champion127); break; case 250: character.DiscoverTitle(Asda2TitleId.Conqueror128); break; case 500: character.GetTitle(Asda2TitleId.Conqueror128); break; } progressRecord.SaveAndFlush(); } character.Resurrect(); character.Map.CallDelayed(500, (Action)(() => Asda2BattlegroundHandler.SendWarEndedResponse(character.Client, (byte)this.WiningFactionId, this.LightScores > this.DarkScores ? this.LightScores : this.DarkScores, this.LightScores > this.DarkScores ? this.DarkScores : this.LightScores, honorPoints, honorCoins, (long)bonusExp, this.MvpCharacter == null ? "" : this.MvpCharacter.Name))); Asda2BattlegroundHandler.SendWarEndedOneResponse(character.Client, (IEnumerable <Asda2Item>) new List <Asda2Item>() { asda2Item }); character.SendWarMsg("You will automaticly teleported to town in 1 minute."); }
private static float CalcMagicDamage(Unit unit, float dmg) { return(GetMultiMod(unit.FloatMods[(int)StatModifierFloat.MagicDamage], dmg + unit.IntMods[(int)StatModifierInt.MagicDamage] + CharacterFormulas.CalculateMagicDamageBonus(unit.Level, unit.Class, unit.Asda2Intellect))); }
[PacketHandler(RealmServerOpCode.GuildWaveRegisterRequest)] //4402 public static void GuildWaveRegisterRequest(IRealmClient client, RealmPacketIn packet) { packet.Position += 2; packet.ReadByte(); //{Type act} var difficulty = packet.ReadByte(); //{Difficulty} Asda2GuildWave guildWave = Asda2GuildWaveMgr.GetGuildWaveForId((int)client.ActiveCharacter.GuildId); /* if (guildWave.IsInProgress) * { * GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.Fail); * return; * }*/ if (guildWave == null) { if (client.ActiveCharacter.Guild.WaveLimit >= CharacterFormulas.GetWaveLimit(client.ActiveCharacter.Guild.Level)) { if (CharacterFormulas.GetWaveLimit(client.ActiveCharacter.Guild.Level) > 1) { GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.LimitDay); } else { GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.LimitOneDay); } return; } if (client.ActiveCharacter.Guild.Level < 2) { GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.GuildLevel); } else { guildWave = Asda2GuildWaveMgr.CreateGuildWave((int)client.ActiveCharacter.GuildId, difficulty, client.ActiveCharacter); GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.Ok); GuildWaveoOnResponseToRegisteredPlayers(guildWave.GuildId); } } else { if (guildWave.PlayersRegisteredCount < 20) { if (guildWave.isPlayerRegistered(client.ActiveCharacter)) { GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.AlreadyRegistered); } else { if (guildWave.IsInProgress) { GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.WaveInProgress); } else { guildWave.AddRegisteringPlayer(client.ActiveCharacter); GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.Ok); GuildWaveoOnResponseToRegisteredPlayers((int)client.ActiveCharacter.GuildId); } } } else { GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.Full); } } }
public void UpdateCritDamageBonus() { CritDamageBonusPrc = CharacterFormulas.CalculateCriticalDamageBonus(Level, Class, Asda2Agility, Asda2Luck, Asda2Intellect, Asda2Strength); }
public uint RepairCost() { return(CharacterFormulas.CalculteItemRepairCost(MaxDurability, Durability, Template.SellPrice, Enchant, (byte)Template.AuctionLevelCriterion, (byte)Template.Quality)); }
private static float CalcMagicDamage(Unit unit, float dmg) { return(UnitUpdates.GetMultiMod(unit.FloatMods[11], dmg + (float)unit.IntMods[24] + CharacterFormulas.CalculateMagicDamageBonus(unit.Level, unit.Class, unit.Asda2Intellect))); }
[PacketHandler(RealmServerOpCode.EndFishing)]//6171 public static void EndFishingRequest(IRealmClient client, RealmPacketIn packet) { if (client.ActiveCharacter.CurrentFish == null) { SendFishingEndedResponse(client, Asda2EndFishingStatus.YouAlreadyFishing, 0); return; } var ft = client.ActiveCharacter.CurrentFish; client.ActiveCharacter.CurrentFish = null; if (client.ActiveCharacter.FishReadyTime > (uint)Environment.TickCount) { SendFishingEndedResponse(client, Asda2EndFishingStatus.YouAlreadyFishing, 0); return; } if (client.ActiveCharacter.Asda2Inventory.Equipment[9] == null || !client.ActiveCharacter.Asda2Inventory.Equipment[9].IsRod) { client.ActiveCharacter.YouAreFuckingCheater("Trying to fishing without rod.", 30); SendFishingStartedResponse(client, Asda2StartFishStatus.YouHaveNoFishRod); return; } if (client.ActiveCharacter.Asda2Inventory.Equipment[10] == null || !client.ActiveCharacter.Asda2Inventory.Equipment[10].Template.IsBait) { client.ActiveCharacter.YouAreFuckingCheater("Trying to fishing without bait.", 30); SendFishingStartedResponse(client, Asda2StartFishStatus.YouHaveNoBait); return; } var rod = client.ActiveCharacter.Asda2Inventory.Equipment[9]; if (rod.Category != Asda2ItemCategory.PremiumFishRod && CharacterFormulas.DecraseRodDurability()) { rod.DecreaseDurability(1); } var bait = client.ActiveCharacter.Asda2Inventory.Equipment[10]; bait.ModAmount(-1); if (bait.Category != Asda2ItemCategory.BaitElite && !ft.BaitIds.Contains(bait.ItemId)) { SendFishingEndedResponse(client, Asda2EndFishingStatus.Ok, 0, bait); return; } FishingSpot spot = null; foreach (var fishingSpot in Asda2FishingMgr.FishingSpotsByMaps[(int)client.ActiveCharacter.MapId]) { if (client.ActiveCharacter.Asda2Position.GetDistance(fishingSpot.Position) > fishingSpot.Radius / 2) { continue; } spot = fishingSpot; break; } if (spot == null) { client.ActiveCharacter.YouAreFuckingCheater("Trying to fishing in wrong place.", 30); SendFishingStartedResponse(client, Asda2StartFishStatus.YouCantFishHere); return; } if (client.ActiveCharacter.FishingLevel < spot.RequiredFishingLevel) { SendFishingStartedResponse(client, Asda2StartFishStatus.YourFishingLevelIsToLowToFishHereItMustBe, 0, (uint)spot.RequiredFishingLevel); return; } if (client.ActiveCharacter.Asda2Inventory.FreeRegularSlotsCount < 1) { SendFishingStartedResponse(client, Asda2StartFishStatus.NotEnoughtSpace); return; } var success = CharacterFormulas.CalcFishingSuccess(client.ActiveCharacter.FishingLevel, spot.RequiredFishingLevel, client.ActiveCharacter.Asda2Luck); if (!success) { SendFishingEndedResponse(client, Asda2EndFishingStatus.Ok, 0, bait, null); return; } var fishSize = (short) Util.Utility.Random(ft.MinLength, ft.MaxLength); fishSize = (short)(fishSize + fishSize * client.ActiveCharacter.GetIntMod(StatModifierInt.Asda2FishingGauge) / 100 * (client.ActiveCharacter.GodMode ? 10 : 1)); if (CharacterFormulas.CalcFishingLevelRised(client.ActiveCharacter.FishingLevel) && client.ActiveCharacter.Record.FishingLevel < spot.RequiredFishingLevel + 80) { client.ActiveCharacter.Record.FishingLevel++; } client.ActiveCharacter.GuildPoints += CharacterFormulas.FishingGuildPoints; Asda2Item item = null; var err = client.ActiveCharacter.Asda2Inventory.TryAdd((int)ft.ItemTemplate.ItemId, 1, true, ref item); var resLog = Log.Create(Log.Types.ItemOperations, LogSourceType.Character, client.ActiveCharacter.EntryId) .AddAttribute("source", 0, "fishing") .AddItemAttributes(item) .Write(); client.ActiveCharacter.Map.AddMessage(() => { if (err != Asda2InventoryError.Ok) { SendFishingEndedResponse(client, Asda2EndFishingStatus.NoSpace, 0, bait, null); return; } foreach (var registeredFishingBook in client.ActiveCharacter.RegisteredFishingBooks.Values) { registeredFishingBook.OnCatchFish(item.ItemId, fishSize); } client.ActiveCharacter.GainXp( CharacterFormulas.CalcExpForFishing(client.ActiveCharacter.Level, client.ActiveCharacter.FishingLevel, item.Template.Quality, spot.RequiredFishingLevel, fishSize), "fishing"); SendFishingEndedResponse(client, Asda2EndFishingStatus.Ok, fishSize, bait, item); SendSomeOneStartedFishingResponse(client.ActiveCharacter, (int)ft.ItemTemplate.Id, fishSize); Asda2TitleChecker.OnSuccessFishing(client.ActiveCharacter, (int)ft.ItemTemplate.Id, fishSize); }); }
/// <summary> /// Calculates the melee critical chance for the class at a specific level, base Agility and added Agility. /// TODO: Implement diminishing returns /// </summary> /// <param name="level">the player's level</param> /// <param name="agility">the player's Agility</param> /// <returns>the total melee critical chance</returns> public float CalculateMeleeCritChance(int level, int agility, int luck) { var crit = CharacterFormulas.CalculatePsysicCritChance(Id, level, luck); return(crit > 5 ? crit : 5); // Naked crit is always at least 5% }
[PacketHandler(RealmServerOpCode.PetSyntes)]//6112 public static void PetSyntesRequest(IRealmClient client, RealmPacketIn packet) { var IsSyntes = packet.ReadByte() == 1; //default : 0Len : 1 var pet1Guid = packet.ReadInt32(); //default : 69837Len : 4 var pet2Guid = packet.ReadInt32(); //default : 69831Len : 4 var RankPotionId = packet.ReadInt32(); //default : 37803Len : 4 var rankPotionInv = packet.ReadByte(); //default : 2Len : 1 var rankPotionSlot = packet.ReadInt16(); //default : 27Len : 2 var classPotionItemId = packet.ReadInt32(); //default : -1Len : 4 var classPotionInv = packet.ReadByte(); //default : 0Len : 1 var classPotionSlot = packet.ReadInt16(); //default : -1Len : 2 var premItemId = packet.ReadInt32(); //default : 31Len : 4 var premItemInv = packet.ReadByte(); //default : 1Len : 1 var premItemSlot = packet.ReadInt16(); //default : 12Len : 2 if (!client.ActiveCharacter.OwnedPets.ContainsKey(pet1Guid) || !client.ActiveCharacter.OwnedPets.ContainsKey(pet2Guid)) { client.ActiveCharacter.YouAreFuckingCheater("Tries to sysnes with not existing pets.", 20); SendPetSyntesResultResponse(client, PetSynethisResult.AbnormalPetInfo); return; } if (client.ActiveCharacter.Asda2Pet != null && (client.ActiveCharacter.Asda2Pet.Guid == pet1Guid || client.ActiveCharacter.Asda2Pet.Guid == pet2Guid)) { SendPetSyntesResultResponse(client, PetSynethisResult.CantUseCurrentlySummonedPet); return; } var rankPotionItem = client.ActiveCharacter.Asda2Inventory.GetRegularItem(rankPotionSlot); var classPotionItem = client.ActiveCharacter.Asda2Inventory.GetRegularItem(classPotionSlot); var suplItem = client.ActiveCharacter.Asda2Inventory.GetShopShopItem(premItemSlot); if (rankPotionItem == null || (classPotionItem == null && IsSyntes)) { client.ActiveCharacter.YouAreFuckingCheater("Tries to sysnes with not existing rank or class item.", 20); SendPetSyntesResultResponse(client, PetSynethisResult.AbnormalPetInfo); return; } if (rankPotionItem.Category != Asda2ItemCategory.PetSynesisPotion || (classPotionItem != null && classPotionItem.Category != Asda2ItemCategory.PetPotion)) { client.ActiveCharacter.YouAreFuckingCheater("Tries to sysnes with rank or class potion item with wrong category.", 50); SendPetSyntesResultResponse(client, PetSynethisResult.AbnormalPetInfo); return; } if (suplItem != null && suplItem.Category != Asda2ItemCategory.PetSynthesisSupplementOrPetLevelProtection) { client.ActiveCharacter.YouAreFuckingCheater("Tries to sysnes with supliment potion item with wrong category.", 50); SendPetSyntesResultResponse(client, PetSynethisResult.AbnormalPetInfo); return; } if (rankPotionItem.RequiredLevel > client.ActiveCharacter.Level) { SendPetSyntesResultResponse(client, PetSynethisResult.IncorrectSuplimentLevel); return; } var pet1 = client.ActiveCharacter.OwnedPets[pet1Guid]; var pet2 = client.ActiveCharacter.OwnedPets[pet2Guid]; if (pet1.Level < 5 || (pet2.Level + (suplItem == null ? 0 : 2)) < (IsSyntes ? 5 : 3)) { client.ActiveCharacter.YouAreFuckingCheater("Tries to sysnes with low level pets.", 50); SendPetSyntesResultResponse(client, PetSynethisResult.LowPetLevel); return; } var resultPetRatiry = IsSyntes ? CharacterFormulas.CalcResultSyntesPetRarity(pet1.Template.Rarity, pet2.Template.Rarity) : CharacterFormulas.CalcResultEvolutionPetRarity(pet1.Template.Rarity, pet2.Template.Rarity); if (!Asda2PetMgr.PetTemplatesByRankAndRarity.ContainsKey(rankPotionItem.Template.ValueOnUse)) { client.ActiveCharacter.SendErrorMsg("No data for syntes."); SendPetSyntesResultResponse(client, PetSynethisResult.SuplimentInfoAbnormal); return; } var resultPetTemplate = IsSyntes ? Asda2PetMgr.PetTemplatesByRankAndRarity[rankPotionItem.Template.ValueOnUse][resultPetRatiry].Values. ToArray()[ Util.Utility.Random(0, Asda2PetMgr.PetTemplatesByRankAndRarity[rankPotionItem.Template.ValueOnUse][ resultPetRatiry].Count - 1)] : pet1.Template.GetEvolutionTemplate(resultPetRatiry, rankPotionItem.Template.ValueOnUse); if (resultPetTemplate == null) { if (IsSyntes) { client.ActiveCharacter.YouAreFuckingCheater(string.Format("Tries to sysnes, but result pet template was null. Please report to developers. Rarity {0} Rank {1}.", resultPetRatiry, rankPotionItem.Template.ValueOnUse), 0); } else { client.ActiveCharacter.YouAreFuckingCheater(string.Format("Tries to evalute, but result pet template was null. Please report to developers. Rarity {0} Rank {1}.", resultPetRatiry, rankPotionItem.Template.ValueOnUse), 0); } SendPetSyntesResultResponse(client, PetSynethisResult.LowPetLevel); return; } var resultPet = client.ActiveCharacter.AddAsda2Pet(resultPetTemplate, true); rankPotionItem.ModAmount(-1); if (classPotionItem != null) { classPotionItem.ModAmount(-1); } if (suplItem != null) { suplItem.ModAmount(-1); } client.ActiveCharacter.OwnedPets.Remove(pet1Guid); client.ActiveCharacter.OwnedPets.Remove(pet2Guid); SendPetSyntesResultResponse(client, PetSynethisResult.Ok, resultPet, rankPotionItem, classPotionItem, suplItem, pet1.Guid, pet2.Guid); pet1.DeleteLater(); pet2.DeleteLater(); }
static float GetModifiedDamage(Unit unit, float dmg) { var statsBonus = CharacterFormulas.CalculatePsysicalDamageBonus(unit.Level, unit.Asda2Agility, unit.Asda2Strength, unit.Class); return(GetMultiMod(unit.FloatMods[(int)StatModifierFloat.Damage], dmg + unit.IntMods[(int)StatModifierInt.Damage] + statsBonus)); }
/// <summary> /// Re-calculates the mainhand melee damage of this Unit /// </summary> internal static void UpdateMainAttackTime(this Unit unit) { var baseTime = unit.MainWeapon.AttackTime; baseTime = GetMultiMod(unit.FloatMods[(int)StatModifierFloat.MeleeAttackTime] - CharacterFormulas.CalculateAtackTimeReduce(unit.Level, unit.Class, unit.Asda2Agility), baseTime); if (baseTime < 30) { baseTime = 30; } unit.MainHandAttackTime = baseTime; }
public static bool Initialize() { CharacterFormulas.InitGuildSkills(); return(Instance.Start()); }
[PacketHandler(RealmServerOpCode.BreakPetLvlLimit)]//6148 public static void BreakPetLvlLimitRequest(IRealmClient client, RealmPacketIn packet) { var petGuid = packet.ReadInt32(); //default : 68412Len : 4 var itemId = packet.ReadInt32(); //default : 37813Len : 4 var inv2 = packet.ReadByte(); //default : 2Len : 1 var lvlBreakItemSlot = packet.ReadInt16(); //default : 3Len : 2 var petLevelBreakAmount = packet.ReadInt32(); //default : -1Len : 4 var inv20 = packet.ReadByte(); //default : 0Len : 1 var lsuplItemSlot = packet.ReadInt16(); //default : -1Len : 2 if (!client.ActiveCharacter.OwnedPets.ContainsKey(petGuid)) { client.ActiveCharacter.YouAreFuckingCheater("Trying to break pet lvl limit not existing pet.", 20); SendPetLevelLimitBreakedResponse(client, PetLimitBreakStatus.AbnormalPetInfo); return; } var item = client.ActiveCharacter.Asda2Inventory.GetRegularItem(lvlBreakItemSlot); if (item == null) { client.ActiveCharacter.YouAreFuckingCheater("Trying to break pet lvl limit with not existint break lvl item.", 10); SendPetLevelLimitBreakedResponse(client, PetLimitBreakStatus.PetLimitPotionInfoAbnormal); return; } if (item.Category != Asda2ItemCategory.PetLevelBreakPotion) { client.ActiveCharacter.YouAreFuckingCheater("Trying to resurect pet with not a resurect item.", 50); SendPetLevelLimitBreakedResponse(client, PetLimitBreakStatus.PetLimitPotionInfoAbnormal); return; } var pet = client.ActiveCharacter.OwnedPets[petGuid]; if (item.Template.ValueOnUse != pet.Level) { client.ActiveCharacter.YouAreFuckingCheater("Trying to break pet level limit wrong level item.", 50); SendPetLevelLimitBreakedResponse(client, PetLimitBreakStatus.TheLevelOfLimitBreakItemIsTooLow); return; } if (!pet.IsMaxExpirience) { client.ActiveCharacter.YouAreFuckingCheater("Trying to break pet level limit with not 100prc exp.", 50); SendPetLevelLimitBreakedResponse(client, PetLimitBreakStatus.Not100PrcExp); return; } if (pet.Level != pet.MaxLevel) { client.ActiveCharacter.YouAreFuckingCheater("Trying to break pet level limit with not maxed level.", 50); SendPetLevelLimitBreakedResponse(client, PetLimitBreakStatus.TheLevelOfLimitBreakItemIsTooLow); return; } if (pet.Level >= 10) { client.ActiveCharacter.YouAreFuckingCheater("Trying to break pet level limit more than 10 lvl.", 50); SendPetLevelLimitBreakedResponse(client, PetLimitBreakStatus.MaximumBreakLvlLimitReached); return; } var success = CharacterFormulas.CalcPetLevelBreakSuccess(); var suplItem = client.ActiveCharacter.Asda2Inventory.GetShopShopItem(lsuplItemSlot); if (suplItem != null && suplItem.Category != Asda2ItemCategory.PetLevelProtection) { client.ActiveCharacter.YouAreFuckingCheater("Trying to break pet level limit with incorect category supl.", 50); SendPetLevelLimitBreakedResponse(client, PetLimitBreakStatus.MaximumBreakLvlLimitReached); return; } if (success) { pet.MaxLevel++; pet.Level++; } else { pet.RemovePrcExp(suplItem == null ? 50 : 10); } if (suplItem != null) { suplItem.ModAmount(-1); } item.ModAmount(-1); SendPetLevelLimitBreakedResponse(client, success ? PetLimitBreakStatus.Ok : PetLimitBreakStatus.FailedRedusedBy50, pet, item, suplItem); }