/// <summary> /// A monster has been killed by magic or combat. Add XP /// </summary> /// <param name="magicUse"></param> private void AddXPPlayerAttack(Monster monster, bool magicUse) { //No XP for summonded creatures if (monster.WasSummoned) { LogFile.Log.LogEntryDebug("No XP for summounded creatures.", LogDebugLevel.Medium); return; } //Magic case if (magicUse) { int monsterXP = monster.GetMagicXP(); double diffDelta = (MagicStat - monsterXP) / (double)MagicStat; if (diffDelta < 0) diffDelta = 0; double xpUpChance = 1 - diffDelta; int xpUpRoll = (int)Math.Floor(xpUpChance * 100.0); int xpUpRollActual = Game.Random.Next(100); LogFile.Log.LogEntryDebug("MagicXP up. Chance: " + xpUpRoll + " roll: " + xpUpRollActual, LogDebugLevel.Medium); if (xpUpRollActual < xpUpRoll) { MagicXP++; LogFile.Log.LogEntryDebug("MagicXP up!", LogDebugLevel.Medium); Game.MessageQueue.AddMessage("You feel your magic grow stronger."); } } //Combat use else { int monsterXP = monster.GetCombatXP(); double diffDelta = (AttackStat - monsterXP) / (double)AttackStat; if (diffDelta < 0) diffDelta = 0; double xpUpChance = 1 - diffDelta; int xpUpRoll = (int)Math.Floor(xpUpChance * 100.0); int xpUpRollActual = Game.Random.Next(100); LogFile.Log.LogEntryDebug("CombatXP up roll. Chance: " + xpUpRoll + " roll: " + xpUpRollActual, LogDebugLevel.Medium); if (xpUpRollActual < xpUpRoll) { CombatXP++; LogFile.Log.LogEntryDebug("CombatXP up!", LogDebugLevel.Medium); Game.MessageQueue.AddMessage("You feel your combat skill increase."); } } }
/// <summary> /// This happens when a charmed creature attacks another or a non-charmed creature fights back /// </summary> /// <param name="attackingMonster"></param> /// <param name="targetMonster"></param> internal void AddXPMonsterAttack(Monster attackingMonster, Monster targetMonster) { //Check this monster was charmed if (!attackingMonster.Charmed) { LogFile.Log.LogEntryDebug("Attacking monster was not charmed, no XP.", LogDebugLevel.Medium); return; } //Add charm XP. Use the target's combat XP against the player's charm stat //This also has the advantage that every creature in the game has a combat XP int monsterXP = targetMonster.GetCombatXP(); double diffDelta = (CharmStat - monsterXP) / (double)CharmStat; if (diffDelta < 0) diffDelta = 0; double xpUpChance = 1 - diffDelta; int xpUpRoll = (int)Math.Floor(xpUpChance * 100.0); int xpUpRollActual = Game.Random.Next(100); LogFile.Log.LogEntryDebug("CharmXP up. Chance: " + xpUpRoll + " roll: " + xpUpRollActual, LogDebugLevel.Medium); if (xpUpRollActual < xpUpRoll) { CharmXP++; LogFile.Log.LogEntryDebug("CharmXP up!", LogDebugLevel.Medium); Game.MessageQueue.AddMessage("You feel more charming."); } }