From d3c70082ca04735047482de364ee4bd2540eafdc Mon Sep 17 00:00:00 2001 From: daneo1989 Date: Fri, 11 Oct 2024 21:38:31 +0100 Subject: [PATCH 1/3] Update Map.cs Changes and fixes to BattleCry --- Server/MirEnvir/Map.cs | 51 +++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/Server/MirEnvir/Map.cs b/Server/MirEnvir/Map.cs index e0d65269e..9c80cf204 100644 --- a/Server/MirEnvir/Map.cs +++ b/Server/MirEnvir/Map.cs @@ -2240,49 +2240,44 @@ private void CompleteMagic(IList data) #endregion #region BattleCry - case Spell.BattleCry: location = (Point)data[2]; - for (int y = location.Y - 2; y <= location.Y + 2; y++) - { - if (y < 0) continue; - if (y >= Height) break; + int startX = Math.Max(location.X - 2, 0); + int endX = Math.Min(location.X + 2, Width - 1); + int startY = Math.Max(location.Y - 2, 0); + int endY = Math.Min(location.Y + 2, Height - 1); - for (int x = location.X - 2; x <= location.X + 2; x++) - { - if (x < 0) continue; - if (x >= Width) break; + int randomValue = Envir.Random.Next(100); + for (int y = startY; y <= endY; y++) + { + for (int x = startX; x <= endX; x++) + { cell = GetCell(x, y); + if (!cell.Valid || cell.Objects == null || cell.Objects.Count == 0) continue; - if (!cell.Valid || cell.Objects == null) continue; - - for (int i = 0; i < cell.Objects.Count; i++) + foreach (var target in cell.Objects) { - MapObject target = cell.Objects[i]; if (target.Race != ObjectType.Monster) continue; - if (magic.Level == 0) - { - if (Envir.Random.Next(60) >= 4) continue; - } - else if (magic.Level == 1) - { - if (Envir.Random.Next(45) >= 3) continue; - } - else if (magic.Level == 2) - { - if (Envir.Random.Next(30) >= 2) continue; - } - else if (magic.Level == 3) + int threshold = magic.Level switch { - if (Envir.Random.Next(15) >= 1) continue; - } + 0 => 90, // 90% chance of failure (10% success) + 1 => 70, // 70% chance of failure (30% success) + 2 => 50, // 50% chance of failure (50% success) + 3 => 30, // 30% chance of failure (70% success) + _ => 100 // Default case, should not occur + }; + + + if (randomValue > threshold) continue; + if (((MonsterObject)target).Info.CoolEye == 100) continue; target.Target = player; target.OperateTime = 0; + train = true; } } From 8d44537c637195ce98d14369322003f45e91ba9c Mon Sep 17 00:00:00 2001 From: daneo1989 Date: Mon, 14 Oct 2024 17:29:41 +0100 Subject: [PATCH 2/3] BattleCry description added + BeastsAscending BattleCry ingame skill desciption added, New Taoist Blood Moon - Beast Ascending attempted to be added. --- Client/MirGraphics/MLibrary.cs | 6 +- Client/MirObjects/PlayerObject.cs | 7 +++ Client/MirScenes/Dialogs/MainDialogs.cs | 8 ++- Server/MirEnvir/Envir.cs | 1 + Server/MirEnvir/Map.cs | 3 +- Server/MirObjects/HumanObject.cs | 75 +++++++++++++++++++++++++ Server/MirObjects/MonsterObject.cs | 44 +++++++++++++++ Shared/Enums.cs | 1 + 8 files changed, 142 insertions(+), 3 deletions(-) diff --git a/Client/MirGraphics/MLibrary.cs b/Client/MirGraphics/MLibrary.cs index e79441a32..e610bdf7c 100644 --- a/Client/MirGraphics/MLibrary.cs +++ b/Client/MirGraphics/MLibrary.cs @@ -30,7 +30,9 @@ public static readonly MLibrary Effect = new MLibrary(Settings.DataPath + "Effect"), MagicC = new MLibrary(Settings.DataPath + "MagicC"), GuildSkill = new MLibrary(Settings.DataPath + "GuildSkill"), - Weather = new MLibrary(Settings.DataPath + "Weather"); + Weather = new MLibrary(Settings.DataPath + "Weather"), + Magic_32bit = new MLibrary(Settings.DataPath + "Magic_32bit"); + public static readonly MLibrary Background = new MLibrary(Settings.DataPath + "Background"); @@ -265,6 +267,8 @@ private static void LoadGameLibraries() Progress++; MagicC.Initialize(); Progress++; + Magic_32bit.Initialize(); + Progress++; Effect.Initialize(); Progress++; diff --git a/Client/MirObjects/PlayerObject.cs b/Client/MirObjects/PlayerObject.cs index c81bf219f..ca4354bc0 100644 --- a/Client/MirObjects/PlayerObject.cs +++ b/Client/MirObjects/PlayerObject.cs @@ -2246,6 +2246,13 @@ public virtual void SetAction() #endregion + #region BeastsAscending + + case Spell.BeastsAscending: + Effects.Add(new Effect(Libraries.Magic3, 200, 8, Frame.Count * FrameInterval, this)); + break; + + #endregion } diff --git a/Client/MirScenes/Dialogs/MainDialogs.cs b/Client/MirScenes/Dialogs/MainDialogs.cs index 1684e017d..2eedf42cb 100644 --- a/Client/MirScenes/Dialogs/MainDialogs.cs +++ b/Client/MirScenes/Dialogs/MainDialogs.cs @@ -3450,6 +3450,10 @@ public void Update(ClientMagic magic) case Spell.BladeAvalanche: SkillButton.Hint = string.Format("Blade Avalanche\n\nActive Skill\nMana Cost {2}\n\nHurls blades in three directions in front of the\ncaster, creating a deadly storm of metal\n\nCurrent Skill Level {0}\nNext Level {1}", Magic.Level, Magic.Level == 0 ? Magic.Level1 : Magic.Level == 1 ? Magic.Level2 : Magic.Level == 2 ? Magic.Level3 : 0, Magic.BaseCost); break; + case Spell.BattleCry: + SkillButton.Hint = string.Format("BattleCry\n\nActive Skill\nMana Cost: {2}\n\nChanges Monsters attacking focus to caster\nSuccess increases with skill level.\n\nCurrent Skill Level {0}\nNext Level {1}", Magic.Level, Magic.Level == 0 ? Magic.Level1 : Magic.Level == 1 ? Magic.Level2 : Magic.Level == 2 ? Magic.Level3 : 0, Magic.BaseCost); + break; + //Wizard case Spell.FireBall: @@ -3607,7 +3611,9 @@ public void Update(ClientMagic magic) case Spell.PetEnhancer: SkillButton.Hint = string.Format("Pet Enhancer\n\nInstant Casting\nMana Cost {2}\n\nStrengthening pets defence and power.\n\nCurrent Skill Level {0}\nNext Level {1}", Magic.Level, Magic.Level == 0 ? Magic.Level1 : Magic.Level == 1 ? Magic.Level2 : Magic.Level == 2 ? Magic.Level3 : 0, Magic.BaseCost); break; - + case Spell.BeastsAscending: + SkillButton.Hint = string.Format("Beast's Ascending\n\nYou will be able to summon all summons at once\nwhile possessing Blood Dragon Beast's energy\nSummons take a damage reduction from Monsters\n\nCurrent Skill Level {0}\nNext Level {1}", Magic.Level, Magic.Level == 0 ? Magic.Level1 : Magic.Level == 1 ? Magic.Level2 : Magic.Level == 2 ? Magic.Level3 : 0, Magic.BaseCost); + break; //Assassin case Spell.FatalSword: SkillButton.Hint = string.Format("Fatal Sword\n\nPassive Skill\n\nIncrease attack damage on the monsters.\nalso increases accuracy a little.\nPassive Skill\n\nCurrent Skill Level {0}\nNext Level {1}", Magic.Level, Magic.Level == 0 ? Magic.Level1 : Magic.Level == 1 ? Magic.Level2 : Magic.Level == 2 ? Magic.Level3 : 0, Magic.BaseCost); diff --git a/Server/MirEnvir/Envir.cs b/Server/MirEnvir/Envir.cs index 370611a50..7f1764b8c 100644 --- a/Server/MirEnvir/Envir.cs +++ b/Server/MirEnvir/Envir.cs @@ -405,6 +405,7 @@ private void FillMagicInfoList() if (!MagicExists(Spell.BattleCry)) MagicInfoList.Add(new MagicInfo { Name = "BattleCry", Spell = Spell.BattleCry, Icon = 42, Level1 = 48, Level2 = 51, Level3 = 55, Need1 = 8000, Need2 = 11000, Need3 = 15000, BaseCost = 22, LevelCost = 10, Range = 0 }); if (!MagicExists(Spell.FireBounce)) MagicInfoList.Add(new MagicInfo { Name = "FireBounce", Spell = Spell.FireBounce, Icon = 4, Level1 = 15, Level2 = 18, Level3 = 21, Need1 = 2000, Need2 = 2700, Need3 = 3500, BaseCost = 5, LevelCost = 1, MPowerBase = 6, PowerBase = 10, Range = 9 }); if (!MagicExists(Spell.MeteorShower)) MagicInfoList.Add(new MagicInfo { Name = "MeteorShower", Spell = Spell.MeteorShower, Icon = 4, Level1 = 15, Level2 = 18, Level3 = 21, Need1 = 2000, Need2 = 2700, Need3 = 3500, BaseCost = 5, LevelCost = 1, MPowerBase = 6, PowerBase = 10, Range = 9 }); + if (!MagicExists(Spell.BeastsAscending)) MagicInfoList.Add(new MagicInfo { Name = "BeastsAscending", Spell = Spell.BeastsAscending, Icon = 16, Level1 = 19, Level2 = 22, Level3 = 26, Need1 = 23600, Need2 = 38900, Need3 = 57900, BaseCost = 12, LevelCost = 4, Range = 0 }); } private string CanStartEnvir() diff --git a/Server/MirEnvir/Map.cs b/Server/MirEnvir/Map.cs index 9c80cf204..c0c856048 100644 --- a/Server/MirEnvir/Map.cs +++ b/Server/MirEnvir/Map.cs @@ -909,7 +909,7 @@ private void CompleteMagic(IList data) #endregion - #region SummonSkeleton, SummonShinsu, SummonHolyDeva, ArcherSummons + #region SummonSkeleton, SummonShinsu, SummonHolyDeva, ArcherSummons, BeastsAscending case Spell.SummonSkeleton: case Spell.SummonShinsu: @@ -917,6 +917,7 @@ private void CompleteMagic(IList data) case Spell.SummonVampire: case Spell.SummonToad: case Spell.SummonSnakes: + case Spell.BeastsAscending: monster = (MonsterObject)data[2]; front = (Point)data[3]; diff --git a/Server/MirObjects/HumanObject.cs b/Server/MirObjects/HumanObject.cs index 316e6883f..08102e64f 100644 --- a/Server/MirObjects/HumanObject.cs +++ b/Server/MirObjects/HumanObject.cs @@ -3740,6 +3740,9 @@ public void Magic(Spell spell, MirDirection dir, uint targetID, Point location, case Spell.FireBounce: if (!FireBounce(target, magic, this)) targetID = 0; break; + case Spell.BeastsAscending: + BeastsAscending(magic); + break; default: cast = false; break; @@ -5732,6 +5735,78 @@ private bool MeteorShower(MapObject target, UserMagic magic) return true; } + + private List summonableMonsters = new List { Settings.SkeletonName, Settings.ShinsuName, Settings.AngelName }; + + private void BeastsAscending(UserMagic magic) + { + ResummonAll(magic); + } + + private void SummonMonster(string monsterName, int amuletType, UserMagic magic) + { + for (int i = 0; i < Pets.Count; i++) + { + var monster = Pets[i]; + if (monster.Info.Name == monsterName && !monster.Dead) + { + return; + } + } + + if (Pets.Count(x => x.Race == ObjectType.Monster) >= 3) return; + + UserItem item = GetAmulet(amuletType); + if (item == null) return; + + MonsterInfo info = Envir.GetMonsterInfo(monsterName); + if (info == null) return; + + LevelMagic(magic); + + ConsumeItem(item, (byte)amuletType); + + var newMonster = MonsterObject.GetMonster(info); + newMonster.PetLevel = magic.Level; + newMonster.Master = this; + + if (monsterName == Settings.SkeletonName) + { + newMonster.MaxPetLevel = (byte)(4 + magic.Level); + } + else + { + newMonster.MaxPetLevel = (byte)(1 + magic.Level * 2); + } + + // Set the damage reduction for summoned monsters + newMonster.DamageReduction = 0.75f; // 25% less damage + + newMonster.Direction = Direction; + newMonster.ActionTime = Envir.Time + 1000; + + DelayedAction action = new DelayedAction(DelayedType.Magic, Envir.Time + 500, this, magic, newMonster, Front); + CurrentMap.ActionList.Add(action); + } + + // Resummon all monsters if any one has died + private void ResummonAll(UserMagic magic) + { + foreach (var monsterName in summonableMonsters) + { + int amuletType = GetAmuletType(monsterName); + SummonMonster(monsterName, amuletType, magic); + } + } + + private int GetAmuletType(string monsterName) + { + if (monsterName == Settings.SkeletonName) return 1; + if (monsterName == Settings.ShinsuName) return 5; + if (monsterName == Settings.AngelName) return 2; + + return 0; + } #endregion diff --git a/Server/MirObjects/MonsterObject.cs b/Server/MirObjects/MonsterObject.cs index c37e8818c..0efbb4e63 100644 --- a/Server/MirObjects/MonsterObject.cs +++ b/Server/MirObjects/MonsterObject.cs @@ -537,11 +537,55 @@ public override sealed PetMode PMode } } + private int hp; + private int level; + public override int Health { get { return HP; } } + public float DamageReduction { get; set; } = 0.75f; // 25% less damage received by default + + public float CalculateDamageReduction(int spellLevel) + { + float baseReduction = 0.25f; + switch (level) + { + case 1: + baseReduction += 0.03f; // Additional 3% + break; + case 2: + baseReduction += 0.05f; // Additional 5% + break; + case 3: + baseReduction += 0.07f; // Additional 7% + break; + } + + baseReduction += 0.02f * spellLevel; // Additional 2% per spell level + if (baseReduction > 1.0f) baseReduction = 1.0f; // Cap at 100% + + return baseReduction; + } + + public void SetHealth(int value) + { + hp = value < 0 ? 0 : value; // Ensure HP cannot be negative + } + + public void TakeDamage(int damage, int spellLevel) + { + float damageReduction = CalculateDamageReduction(spellLevel); + int reducedDamage = (int)(damage * (1 - damageReduction)); + SetHealth(hp - reducedDamage); + + if (Health == 0) + { + Die(); + } + } + public override int MaxHealth { get { return Stats[Stat.HP]; } diff --git a/Shared/Enums.cs b/Shared/Enums.cs index 9e2914751..d92ca1581 100644 --- a/Shared/Enums.cs +++ b/Shared/Enums.cs @@ -1248,6 +1248,7 @@ public enum Spell : byte BattleCry = 153, FireBounce = 154, MeteorShower = 155, + BeastsAscending = 156, //Map Events DigOutZombie = 200, From ca1b6359c1705d16149a69337da97b11bc65f568 Mon Sep 17 00:00:00 2001 From: daneo1989 Date: Fri, 29 Nov 2024 15:10:28 +0000 Subject: [PATCH 3/3] Update MLibrary.cs Removed Magic_32bit --- Client/MirGraphics/MLibrary.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Client/MirGraphics/MLibrary.cs b/Client/MirGraphics/MLibrary.cs index 28df6f752..7c717c8a9 100644 --- a/Client/MirGraphics/MLibrary.cs +++ b/Client/MirGraphics/MLibrary.cs @@ -30,9 +30,7 @@ public static readonly MLibrary Effect = new MLibrary(Settings.DataPath + "Effect"), MagicC = new MLibrary(Settings.DataPath + "MagicC"), GuildSkill = new MLibrary(Settings.DataPath + "GuildSkill"), - Weather = new MLibrary(Settings.DataPath + "Weather"), - Magic_32bit = new MLibrary(Settings.DataPath + "Magic_32bit"); - + Weather = new MLibrary(Settings.DataPath + "Weather"); public static readonly MLibrary Background = new MLibrary(Settings.DataPath + "Background"); @@ -267,9 +265,7 @@ private static void LoadGameLibraries() Progress++; MagicC.Initialize(); Progress++; - Magic_32bit.Initialize(); - Progress++; - + Effect.Initialize(); Progress++;