public void OnLeave(bool raidWon, bool raidTimedOut) { this.InRaid = false; if (raidWon) { var proc = this.gameManager.Raid.GetParticipationPercentage(raidEnterTime); //var expAmount = var ratio = 549.8123f * proc; var raidBossCombatLevel = this.gameManager.Raid.Boss.Enemy.Stats.CombatLevel; var exp = GameMath.CombatExperience(raidBossCombatLevel / 25) * proc; //var combatType = player.GetCombatTypeFromArgs(player.GetTaskArguments()); //if (combatType >= 0) //{ // if (combatType == 3) // { // var distributedExp = exp / 3f; // } //} player.AddExp((decimal)exp, Skill.Slayer); var woodCuttingRatio = ratio; var miningRatio = ratio; var fishingRatio = ratio; var farmingRatio = ratio; player.AddResource(Resource.Currency, (int)(player.Stats.CombatLevel * ratio)); player.AddResource(Resource.Woodcutting, (int)(player.Stats.Woodcutting.Level * woodCuttingRatio)); player.AddResource(Resource.Mining, (int)(player.Stats.Mining.Level * miningRatio)); player.AddResource(Resource.Fishing, (int)(player.Stats.Fishing.Level * fishingRatio)); player.AddResource(Resource.Farming, (int)(player.Stats.Farming.Level * farmingRatio)); ++player.Statistics.RaidsWon; var itemDrop = this.gameManager.Raid.Boss.GetComponent <ItemDropHandler>(); if (itemDrop) { itemDrop.DropItem(this.player); } } if (raidTimedOut) { ++player.Statistics.RaidsLost; } if (raidTimedOut || raidWon) { player.Stats.Health.Reset(); } player.attackers.Clear(); Debug.Log($"{player.PlayerName} left the raid"); }
public void OnLeave(bool raidWon, bool raidTimedOut) { InRaid = false; if (raidWon) { var proc = (decimal)gameManager.Raid.GetParticipationPercentage(raidEnterTime); var raidBossCombatLevel = gameManager.Raid.Boss.Enemy.Stats.CombatLevel; var exp = GameMath.CombatExperience(raidBossCombatLevel / 15) * proc; var yieldExp = exp / 2m; player.AddExp(yieldExp, Skill.Slayer); if (!player.AddExpToCurrentSkill(yieldExp)) { player.AddExp(yieldExp, Skill.Slayer); } ++player.Statistics.RaidsWon; var itemDrop = gameManager.Raid.Boss.GetComponent <ItemDropHandler>(); if (itemDrop) { itemDrop.DropItem(player); } } if (raidTimedOut) { ++player.Statistics.RaidsLost; } if (raidTimedOut || raidWon) { player.Stats.Health.Reset(); } player.attackers.Clear(); if (teleported) { teleported = false; player.Teleporter.Teleport(prevPosition); player.Chunk = prevChunk; player.taskTarget = null; } Debug.Log($"{player.PlayerName} left the raid"); }
internal void RewardPlayer(PlayerController player) { if (!ItemDrops) { return; } var exp = GameMath.CombatExperience(bossCombatLevel / 5); var yieldExp = exp / 2m; player.AddExp(yieldExp, Skill.Slayer); if (!player.AddExpToCurrentSkill(yieldExp)) { player.AddExp(yieldExp, Skill.Slayer); } for (var i = 0; i < itemRewardCount; ++i) { ItemDrops.DropItem(player, true); } }
internal void RewardPlayer(PlayerController player, bool generateMagicAttributes) { if (!ItemDrops) { return; } var exp = GameMath.CombatExperience(bossCombatLevel / 5); var yieldExp = exp / 2m; player.AddExp(yieldExp, Skill.Slayer); if (!player.AddExpToCurrentSkill(yieldExp)) { player.AddExp(yieldExp, Skill.Slayer); } var type = generateMagicAttributes ? DropType.MagicRewardGuaranteed : DropType.StandardGuaranteed; for (var i = 0; i < itemRewardCount; ++i) { ItemDrops.DropItem(player, type); } }
private bool OnPlayerAfflictDamage( Player player, NpcInstance npc, TimeSpan totalTime, TimeSpan deltaTime) { var attackType = playerState.GetAttackType(player); if (!playerState.InCombat(player, npc)) { ExitCombat(player, npc, attackType); return(false); } var npcRecord = gameData.GetNpc(npc.NpcId); var npcAttributes = gameData.GetAttributes(npcRecord.AttributesId); var playerAttributes = gameData.GetAttributes(player.AttributesId); var session = sessionManager.Get(player); var damage = CalculateDamage(playerAttributes, npcAttributes); var trainingSkill = SkillAttack; npc.Health -= damage; worldProcessor.DamageNpc(player, npc, damage, npc.Health, npcAttributes.Health); if (npc.Health <= 0) { session.Npcs.States.ExitCombat(npc); // he ded worldProcessor.KillNpc(player, npc); // note(zerratar): action that kills the enemy shouldn't be the one responsible for respawning // this should be moved to a INpcProcessor or similar called from the WorldProcessor Update worldProcessor.SetEntityTimeout(gameData.GetNpc(npc.NpcId).RespawnTimeMs, player, npc, OnRespawn); var experience = GameMath.CombatExperience(npcRecord.Level); int levelsGaiend = playerStatsProvider.AddExperience(player.Id, trainingSkill, experience); var newExp = playerStatsProvider.GetExperience(player.Id, trainingSkill); var newLevel = playerStatsProvider.GetLevel(player.Id, trainingSkill); //var itemDrops = npcProvider.GetItemDrops(npc); //foreach (var itemDrop in itemDrops) //{ // if (random.NextDouble() > itemDrop.DropChance) // continue; // worldProcessor.AddPlayerItem(player, gameData.GetItem(itemDrop.ItemId)); //} worldProcessor.UpdatePlayerStat(player, trainingSkill, newLevel, newExp); if (levelsGaiend > 0) { worldProcessor.PlayerStatLevelUp(player, trainingSkill, levelsGaiend); } ExitCombat(player, npc, attackType); return(true); } PlayerAttack(player, npc, attackType); return(false); }