forked from DrewKestell/BloogBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuffSelfState.cs
54 lines (46 loc) · 1.77 KB
/
BuffSelfState.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using BloogBot.AI;
using BloogBot.Game;
using BloogBot.Game.Objects;
using System.Collections.Generic;
namespace ArcaneMageBot
{
class BuffSelfState : IBotState
{
const string ArcaneIntellect = "Arcane Intellect";
const string FrostArmor = "Frost Armor";
const string IceArmor = "Ice Armor";
const string DampenMagic = "Dampen Magic";
readonly Stack<IBotState> botStates;
readonly IDependencyContainer container;
readonly LocalPlayer player;
public BuffSelfState(Stack<IBotState> botStates, IDependencyContainer container)
{
this.botStates = botStates;
this.container = container;
player = ObjectManager.Player;
}
public void Update()
{
if ((!player.KnowsSpell(ArcaneIntellect) || player.HasBuff(ArcaneIntellect)) && (player.HasBuff(FrostArmor) || player.HasBuff(IceArmor)) && (!player.KnowsSpell(DampenMagic) || player.HasBuff(DampenMagic)))
{
botStates.Pop();
botStates.Push(new ConjureItemsState(botStates, container));
return;
}
TryCastSpell(ArcaneIntellect, castOnSelf: true);
if (player.KnowsSpell(IceArmor))
TryCastSpell(IceArmor);
else
TryCastSpell(FrostArmor);
TryCastSpell(DampenMagic, castOnSelf: true);
}
void TryCastSpell(string name, bool castOnSelf = false)
{
if (!player.HasBuff(name) && player.KnowsSpell(name) && player.IsSpellReady(name))
{
var castOnSelfString = castOnSelf ? ",1" : "";
player.LuaCall($"CastSpellByName('{name}'{castOnSelfString})");
}
}
}
}