Skip to content

Commit

Permalink
implemented magic skill override
Browse files Browse the repository at this point in the history
  • Loading branch information
patri0t86 committed Feb 10, 2021
1 parent d768f05 commit 75ba56d
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 21 deletions.
6 changes: 3 additions & 3 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ACManager")]
[assembly: AssemblyProduct("ACManager")]
[assembly: AssemblyCopyright("Copyright © ACManager 2020")]
[assembly: AssemblyCopyright("Copyright © ACManager 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.0.1.73")]
[assembly: AssemblyFileVersion("3.0.1.73")]
[assembly: AssemblyVersion("3.1.0")]
[assembly: AssemblyFileVersion("3.1.0")]
3 changes: 3 additions & 0 deletions Settings/BotSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public class BotSettings
[XmlElement(IsNullable = false)]
public bool Level7Self;

[XmlElement(IsNullable = false)]
public int SkillOverride;

public List<GemSetting> GemSettings = new List<GemSetting>();

public List<Advertisement> Advertisements = new List<Advertisement>();
Expand Down
5 changes: 5 additions & 0 deletions StateMachine/Machine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ internal class Machine
/// </summary>
public SpellTable SpellTable { get; set; }

/// <summary>
/// Manual override of magic skills for determining skill checks.
/// </summary>
public int SkillOverride { get; set; } = 0;

/// <summary>
/// Create the state machine in the StoppedState and begin processing commands on intervals (every time a frame is rendered).
/// </summary>
Expand Down
51 changes: 46 additions & 5 deletions StateMachine/States/Casting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,19 @@ public void Process(Machine machine)
{
if (CastBanes)
{
machine.Core.Actions.CastSpell(machine.SpellsToCast[0].Id, machine.CurrentRequest.RequesterGuid);
if (SkillCheck(machine, machine.SpellsToCast[0]))
{
machine.Core.Actions.CastSpell(machine.SpellsToCast[0].Id, machine.CurrentRequest.RequesterGuid);
}
else
{
Spell fallbackSpell = GetFallbackSpell(machine.SpellTable, machine.SpellsToCast[0]);
machine.SpellsToCast.RemoveAt(0);
if (fallbackSpell != null)
{
machine.SpellsToCast.Insert(0, fallbackSpell);
}
}
}
else
{
Expand All @@ -192,12 +204,24 @@ public void Process(Machine machine)
}
else
{
machine.Core.Actions.CastSpell(machine.SpellsToCast[0].Id, machine.CurrentRequest.RequesterGuid);
if (SkillCheck(machine, machine.SpellsToCast[0]))
{
machine.Core.Actions.CastSpell(machine.SpellsToCast[0].Id, machine.CurrentRequest.RequesterGuid);
}
else
{
Spell fallbackSpell = GetFallbackSpell(machine.SpellTable, machine.SpellsToCast[0]);
machine.SpellsToCast.RemoveAt(0);
if (fallbackSpell != null)
{
machine.SpellsToCast.Insert(0, fallbackSpell);
}
}
}
}
else
{
Spell fallbackSpell = FallbackSpellCheck(machine.SpellTable, machine.SpellsToCast[0]);
Spell fallbackSpell = GetFallbackSpell(machine.SpellTable, machine.SpellsToCast[0]);
machine.SpellsToCast.RemoveAt(0);
if (fallbackSpell != null)
{
Expand All @@ -212,7 +236,7 @@ public void Process(Machine machine)
}
else
{
Spell fallbackSpell = FallbackSpellCheck(machine.SpellTable, machine.SpellsToCast[0]);
Spell fallbackSpell = GetFallbackSpell(machine.SpellTable, machine.SpellsToCast[0]);
machine.SpellsToCast.RemoveAt(0);
if (fallbackSpell != null)
{
Expand Down Expand Up @@ -264,7 +288,7 @@ private bool ContainsBanes(List<Spell> spells)
return false;
}

private Spell FallbackSpellCheck(SpellTable spellTable, Spell spell)
private Spell GetFallbackSpell(SpellTable spellTable, Spell spell)
{
List<Spell> spellFamily = new List<Spell>();
for (int i = 1; i < spellTable.Length; i++)
Expand Down Expand Up @@ -293,5 +317,22 @@ private Spell FallbackSpellCheck(SpellTable spellTable, Spell spell)
}
return fallback;
}

private bool SkillCheck(Machine machine, Spell spell)
{
switch (spell.School.Id)
{
case 2:
return machine.Core.CharacterFilter.EffectiveSkill[CharFilterSkillType.LifeMagic] + machine.SkillOverride >= spell.Difficulty + 20;
case 3:
return machine.Core.CharacterFilter.EffectiveSkill[CharFilterSkillType.ItemEnchantment] + machine.SkillOverride >= spell.Difficulty + 20;
case 4:
return machine.Core.CharacterFilter.EffectiveSkill[CharFilterSkillType.CreatureEnchantment] + machine.SkillOverride >= spell.Difficulty + 20;
default:
// Void or War
return false;
}

}
}
}
22 changes: 11 additions & 11 deletions StateMachine/States/SelfBuffing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ public void Process(Machine machine)
{
if (machine.ComponentChecker.HaveComponents(machine.SpellsToCast[0].Id))
{
//if (machine.Core.CharacterFilter.EffectiveSkill[CharFilterSkillType.CreatureEnchantment] < 400 && !AddedPreBuffs && !machine.Level7Self)
//{
// AddedPreBuffs = true;
// machine.SpellsToCast.Insert(0, machine.SpellTable.GetById(2067)); // focus 7
// machine.SpellsToCast.Insert(0, machine.SpellTable.GetById(2091)); // self 7
// machine.SpellsToCast.Insert(0, machine.SpellTable.GetById(2215)); // creature 7
//}
//else
//{
if (machine.Core.CharacterFilter.EffectiveSkill[CharFilterSkillType.CreatureEnchantment] < 400 && !AddedPreBuffs && !machine.Level7Self)
{
AddedPreBuffs = true;
machine.SpellsToCast.Insert(0, machine.SpellTable.GetById(2067)); // focus 7
machine.SpellsToCast.Insert(0, machine.SpellTable.GetById(2091)); // self 7
machine.SpellsToCast.Insert(0, machine.SpellTable.GetById(2215)); // creature 7
}
else
{
if (machine.Level7Self && machine.SpellsToCast[0].Difficulty > 300)
{
Spell fallbackSpell = FallbackBuffCheck(machine.SpellTable, machine.SpellsToCast[0]);
Expand All @@ -99,8 +99,8 @@ public void Process(Machine machine)
else
{
machine.Core.Actions.CastSpell(machine.SpellsToCast[0].Id, 0);
}
//}
}
}
}
else
{
Expand Down
1 change: 1 addition & 0 deletions StateMachine/States/Stopped.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void Exit(Machine machine)
machine.BuffingCharacter = machine.Utility.BotSettings.BuffingCharacter;
machine.StayBuffed = machine.Utility.BotSettings.StayBuffed;
machine.Level7Self = machine.Utility.BotSettings.Level7Self;
machine.SkillOverride = machine.Utility.BotSettings.SkillOverride;

Debug.ToChat("Started successfully.");
machine.ChatManager.Broadcast($"/me is running ACManager {machine.Utility.Version} found at https://github.com/patri0t86/ACManager. Whisper 'help' to get started.");
Expand Down
28 changes: 28 additions & 0 deletions Views/Tabs/ConfigTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ internal class ConfigTab : IDisposable
private HudCombo BuffingCharacterChoice { get; set; }
private HudCheckBox StayBuffed { get; set; }
private HudCheckBox Level7Self { get; set; }
private HudTextBox SkillOverride { get; set; }
private HudStaticText Version { get; set; }
private bool disposedValue;

Expand Down Expand Up @@ -87,6 +88,9 @@ public ConfigTab(BotManagerView botManagerView)
Level7Self = Parent.View != null ? (HudCheckBox)Parent.View["Level7Self"] : new HudCheckBox();
Level7Self.Change += Level7Self_Change;

SkillOverride = Parent.View != null ? (HudTextBox)Parent.View["SkillOverride"] : new HudTextBox();
SkillOverride.Change += SkillOverride_Change;

Version = Parent.View != null ? (HudStaticText)Parent.View["Version"] : new HudStaticText();
Version.Text = $"V{Parent.Machine.Utility.Version}";

Expand All @@ -113,6 +117,7 @@ private void LoadSettings()
LocationSetpoint.Text = !Parent.Machine.Utility.BotSettings.DesiredLandBlock.Equals(0) ? $"{Parent.Machine.Utility.BotSettings.DesiredLandBlock.ToString("X").Substring(0, 4)} - X: { Math.Round(Parent.Machine.Utility.BotSettings.DesiredBotLocationX, 2)} Y: {Math.Round(Parent.Machine.Utility.BotSettings.DesiredBotLocationY, 2)}" : "No location set";
StayBuffed.Checked = Parent.Machine.Utility.BotSettings.StayBuffed;
Level7Self.Checked = Parent.Machine.Utility.BotSettings.Level7Self;
SkillOverride.Text = Parent.Machine.Utility.BotSettings.SkillOverride.ToString();

if (string.IsNullOrEmpty(Parent.Machine.Utility.BotSettings.BuffingCharacter))
{
Expand Down Expand Up @@ -401,6 +406,28 @@ private void Level7Self_Change(object sender, EventArgs e)
}
}

private void SkillOverride_Change(object sender, EventArgs e)
{
try
{
if (int.TryParse(SkillOverride.Text, out int result))
{
Parent.Machine.SkillOverride = Parent.Machine.Utility.BotSettings.SkillOverride = result;
}
else
{
Parent.Machine.SkillOverride = Parent.Machine.Utility.BotSettings.SkillOverride = 0;
SkillOverride.Text = 0.ToString();
}
Parent.Machine.Utility.SaveBotSettings();
Debug.ToChat($"Your magic casting abilities are now modified by {Parent.Machine.Utility.BotSettings.SkillOverride} when calculating skill.");
}
catch (Exception ex)
{
Debug.LogException(ex);
}
}

private void PopulateCharacterChoice()
{
BuffingCharacterChoice.AddItem("None", null);
Expand Down Expand Up @@ -432,6 +459,7 @@ protected virtual void Dispose(bool disposing)
BuffingCharacterChoice.Change -= BuffingCharacterChoice_Change;
StayBuffed.Change -= StayBuffed_Change;
Level7Self.Change -= Level7Self_Change;
SkillOverride.Change -= SkillOverride_Change;
}
disposedValue = true;
}
Expand Down
8 changes: 6 additions & 2 deletions Views/botManagerView.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

<control progid="DecalControls.CheckBox" name="BotPositioning" left="5" top="43" width="200" height="16" text="Bot Navigation" />

<control progid="DecalControls.Edit" name="AdInterval" left="200" top="62" width="27" height="19" text="" />
<control progid="DecalControls.Edit" name="AdInterval" left="200" top="62" width="30" height="19" text="" />
<control progid="DecalControls.StaticText" left="235" top="63" width="150" height="16" text="Advertisement Interval" />

<control progid="DecalControls.Edit" name="DefaultHeading" left="200" top="85" width="27" height="19" text="" />
<control progid="DecalControls.Edit" name="DefaultHeading" left="200" top="85" width="30" height="19" text="" />
<control progid="DecalControls.StaticText" left="235" top="86" width="110" height="16" text="Default Heading" />
<control progid="DecalControls.PushButton" name="SetHeading" left="200" top="43" width="195" height="19" text="Use Current Heading" />

Expand All @@ -33,6 +33,10 @@

<control progid="DecalControls.CheckBox" name="StayBuffed" left="5" top="232" width="140" height="16" text="Keep Buffs Alive" />
<control progid="DecalControls.CheckBox" name="Level7Self" left="5" top="251" width="140" height="16" text="Level 7 Self Buffs" />

<control progid="DecalControls.StaticText" left="5" top="270" width="150" height="16" text="Magic Skill Override" />
<control progid="DecalControls.Edit" name="SkillOverride" left="5" top="289" width="40" height="19" text="0" />

<control progid="DecalControls.StaticText" name="Version" left="5" top="347" width="390" height="16" text="" />
</control>
</page>
Expand Down

0 comments on commit 75ba56d

Please sign in to comment.