Skip to content

Commit

Permalink
cleanup, gathering engine, combat tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jnnshschl committed Feb 27, 2020
1 parent a981e7e commit 709157d
Show file tree
Hide file tree
Showing 218 changed files with 3,409 additions and 3,056 deletions.
376 changes: 184 additions & 192 deletions AmeisenBotX.Core/AmeisenBot.cs

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions AmeisenBotX.Core/AmeisenBotConfig.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using AmeisenBotX.Memory.Win32;
using System;
using System.Collections.Generic;
using System.IO;

namespace AmeisenBotX.Core
Expand Down Expand Up @@ -75,4 +74,4 @@ public class AmeisenBotConfig

public Rect WowWindowRect { get; set; } = new Rect() { Left = -1, Top = -1, Right = -1, Bottom = -1 };
}
}
}
47 changes: 38 additions & 9 deletions AmeisenBotX.Core/AmeisenBotX.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,23 @@
<Compile Include="AmeisenBot.cs" />
<Compile Include="Battleground\BattlegroundEngine.cs" />
<Compile Include="Battleground\Enums\BattlegroundType.cs" />
<Compile Include="Battleground\Objectives\AttackEnemyPlayers.cs" />
<Compile Include="Battleground\Objectives\CaptureFlagObjective.cs" />
<Compile Include="Battleground\Objectives\CarryFlagToBaseObjective.cs" />
<Compile Include="Battleground\Objectives\IBattlegroundObjective.cs" />
<Compile Include="Battleground\Objectives\RetrieveOwnFlagObjective.cs" />
<Compile Include="Battleground\Profiles\IBattlegroundProfile.cs" />
<Compile Include="Battleground\Profiles\ICtfBattlegroundProfile.cs" />
<Compile Include="Battleground\Profiles\WarsongGulchProfile.cs" />
<Compile Include="Battleground\States\AssistOwnFlagCarrierBgState.cs" />
<Compile Include="Battleground\States\BattlegroundState.cs" />
<Compile Include="Battleground\States\BasicBattlegroundState.cs" />
<Compile Include="Battleground\States\DefendMyselfBgState.cs" />
<Compile Include="Battleground\States\ExitBattlegroundBgState.cs" />
<Compile Include="Battleground\States\MoveToEnemyBaseBgState.cs" />
<Compile Include="Battleground\States\MoveToEnemyFlagCarrierBgState.cs" />
<Compile Include="Battleground\States\MoveToOwnBaseBgState.cs" />
<Compile Include="Battleground\States\PickupBuffBgState.cs" />
<Compile Include="Battleground\States\PickupEnemyFlagBgState.cs" />
<Compile Include="Battleground\States\PickupOwnFlagBgState.cs" />
<Compile Include="Battleground\States\WaitingForStartBgState.cs" />
<Compile Include="Character\CharacterManager.cs" />
<Compile Include="Character\ClickToMoveType.cs" />
<Compile Include="Character\Enums\ClickToMoveType.cs" />
<Compile Include="Character\Comparators\AssassinationItemComparator.cs" />
<Compile Include="Character\Comparators\BasicAgilityComparator.cs" />
<Compile Include="Character\Comparators\BasicIntellectComparator.cs" />
Expand Down Expand Up @@ -139,9 +147,18 @@
<Compile Include="Data\Objects\WowObject\WowUnitFlags.cs" />
<Compile Include="Data\Persistence\InMemoryBotCache.cs" />
<Compile Include="Data\Persistence\IAmeisenBotCache.cs" />
<Compile Include="Dungeon\DungeonEngine.cs" />
<Compile Include="Dungeon\Profiles\IDungeonProfile.cs" />
<Compile Include="Event\EventHookManager.cs" />
<Compile Include="Event\Objects\WowEvent.cs" />
<Compile Include="Hook\HookManager.cs" />
<Compile Include="Jobs\Enums\JobEngineStatus.cs" />
<Compile Include="Jobs\Enums\JobType.cs" />
<Compile Include="Jobs\JobEngine.cs" />
<Compile Include="Jobs\Profiles\Crafting\ICraftingProfile.cs" />
<Compile Include="Jobs\Profiles\Gathering\IGatheringProfile.cs" />
<Compile Include="Jobs\Profiles\Grinding\IGrindingProfile.cs" />
<Compile Include="Jobs\Profiles\IJobProfile.cs" />
<Compile Include="LoginHandler\DefaultLoginHandler.cs" />
<Compile Include="LoginHandler\ILoginHandler.cs" />
<Compile Include="Movement\DefaultMovementEngine.cs" />
Expand All @@ -157,6 +174,8 @@
<Compile Include="Personality\Enums\UnitRelationship.cs" />
<Compile Include="Personality\Enums\Scale.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Raid\RaidEngine.cs" />
<Compile Include="Raid\Profiles\IRaidProfile.cs" />
<Compile Include="StateMachine\AmeisenBotStateMachine.cs" />
<Compile Include="StateMachine\CombatClasses\DeathknightBlood.cs" />
<Compile Include="StateMachine\CombatClasses\Jannis\BasicCombatClass.cs" />
Expand All @@ -180,15 +199,16 @@
<Compile Include="StateMachine\CombatClasses\Jannis\PriestShadow.cs" />
<Compile Include="StateMachine\CombatClasses\Jannis\RogueAssassination.cs" />
<Compile Include="StateMachine\Enums\CombatClassRole.cs" />
<Compile Include="StateMachine\States\StateJob.cs" />
<Compile Include="StateMachine\Utils\AuraManager.cs" />
<Compile Include="StateMachine\Utils\CooldownManager.cs" />
<Compile Include="StateMachine\CombatClasses\Jannis\WarlockDestruction.cs" />
<Compile Include="StateMachine\CombatClasses\Jannis\WarlockDemonology.cs" />
<Compile Include="StateMachine\CombatClasses\Jannis\WarlockAffliction.cs" />
<Compile Include="StateMachine\CombatClasses\WarriorArms.cs" />
<Compile Include="StateMachine\CombatClasses\RogueAssassination2.cs" />
<Compile Include="StateMachine\States\AmeisenBotState.cs" />
<Compile Include="StateMachine\States\State.cs" />
<Compile Include="StateMachine\States\BotState.cs" />
<Compile Include="StateMachine\States\BasicState.cs" />
<Compile Include="StateMachine\States\StateAttacking.cs" />
<Compile Include="StateMachine\States\StateDead.cs" />
<Compile Include="StateMachine\States\StateFollowing.cs" />
Expand Down Expand Up @@ -225,6 +245,15 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="Dungeon\Profiles\Classic\" />
<Folder Include="Dungeon\Profiles\TBC\" />
<Folder Include="Dungeon\Profiles\WotLK\" />
<Folder Include="Jobs\Profiles\Gathering\Herbs\" />
<Folder Include="Jobs\Profiles\Gathering\Mining\" />
<Folder Include="Raid\Profiles\Classic\" />
<Folder Include="Raid\Profiles\TBC\" />
<Folder Include="Raid\Profiles\WotLK\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
117 changes: 61 additions & 56 deletions AmeisenBotX.Core/Battleground/BattlegroundEngine.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using AmeisenBotX.Core.Battleground.Objectives;
using AmeisenBotX.Core.Battleground.Profiles;
using AmeisenBotX.Core.Battleground.Profiles;
using AmeisenBotX.Core.Battleground.States;
using AmeisenBotX.Core.Data;
using AmeisenBotX.Core.Data.Objects.WowObject;
using AmeisenBotX.Core.Hook;
using AmeisenBotX.Core.Movement;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AmeisenBotX.Core.Battleground
{
Expand All @@ -18,54 +16,70 @@ public BattlegroundEngine(HookManager hookManager, ObjectManager objectManager,
HookManager = hookManager;
ObjectManager = objectManager;
MovementEngine = movementEngine;

ForceCombat = false;
CurrentObjectiveName = "None";
}

public string CurrentObjectiveName { get; private set; }

public bool ForceCombat { get; set; }
public IBattlegroundProfile BattlegroundProfile { get; private set; }

private IBattlegroundProfile BattlegroundProfile { get; set; }
public KeyValuePair<BattlegroundState, BasicBattlegroundState> CurrentState { get; private set; }

private ObjectManager ObjectManager { get; set; }
public BattlegroundState LastState { get; private set; }

private HookManager HookManager { get; set; }

private IMovementEngine MovementEngine { get; set; }

private IBattlegroundObjective LastObjective { get; set; }
private ObjectManager ObjectManager { get; set; }

public void AllianceFlagWasDropped(string playername)
{
if (BattlegroundProfile.GetType() == typeof(WarsongGulchProfile))
{
((WarsongGulchProfile)BattlegroundProfile).AllianceFlagWasDropped(playername);
}
}

public void AllianceFlagWasPickedUp(string playername)
{
if (BattlegroundProfile.GetType() == typeof(WarsongGulchProfile))
{
((WarsongGulchProfile)BattlegroundProfile).AllianceFlagWasPickedUp(playername);
}
}

public void Execute()
{
if (BattlegroundProfile == null)
{
TryLoadProfile(ObjectManager.MapId);
CurrentState = BattlegroundProfile.States.First();
}
else
{
CurrentState.Value.Execute();
}
}

public void HordeFlagWasDropped(string playername)
{
if (BattlegroundProfile.GetType() == typeof(WarsongGulchProfile))
{
((WarsongGulchProfile)BattlegroundProfile).HordeFlagWasDropped(playername);
}
}

if (BattlegroundProfile != null)
public void HordeFlagWasPickedUp(string playername)
{
if (BattlegroundProfile.GetType() == typeof(WarsongGulchProfile))
{
foreach (IBattlegroundObjective objective in BattlegroundProfile.Objectives.OrderByDescending(e => e.Priority))
{
if (!objective.IsAvailable)
{
continue;
}

if(CurrentObjectiveName != objective.GetType().Name)
{
LastObjective?.Exit();
objective.Enter();
}

objective.Execute();
CurrentObjectiveName = objective.GetType().Name;
return;
}
((WarsongGulchProfile)BattlegroundProfile).HordeFlagWasPickedUp(playername);
}
}

public void Reset()
{
BattlegroundProfile = null;
}

public bool TryLoadProfile(int mapId)
{
switch (mapId)
Expand All @@ -75,7 +89,7 @@ public bool TryLoadProfile(int mapId)
return false;

case 489:
BattlegroundProfile = new WarsongGulchProfile(ObjectManager.Player.IsAlliance(), HookManager, ObjectManager, MovementEngine, ForceCombat);
BattlegroundProfile = new WarsongGulchProfile(ObjectManager.Player.IsAlliance(), HookManager, ObjectManager, MovementEngine, this);
return true;

case 529:
Expand All @@ -95,36 +109,27 @@ public bool TryLoadProfile(int mapId)
}
}

public void AllianceFlagWasPickedUp(string playername)
internal IEnumerable<WowGameobject> GetBattlegroundFlags()
{
if (BattlegroundProfile.GetType() == typeof(WarsongGulchProfile))
{
((WarsongGulchProfile)BattlegroundProfile).AllianceFlagWasPickedUp(playername);
}
}
IEnumerable<WowGameobject> flagObjects = ObjectManager.WowObjects
.OfType<WowGameobject>()
.Where(e => e.GameobjectType == WowGameobjectType.Flagdrop || e.GameobjectType == WowGameobjectType.Flagstand);

public void HordeFlagWasPickedUp(string playername)
{
if (BattlegroundProfile.GetType() == typeof(WarsongGulchProfile))
{
((WarsongGulchProfile)BattlegroundProfile).HordeFlagWasPickedUp(playername);
}
return flagObjects;
}

public void AllianceFlagWasDropped(string playername)
internal void SetState(BattlegroundState state)
{
if (BattlegroundProfile.GetType() == typeof(WarsongGulchProfile))
if (BattlegroundProfile == null || CurrentState.Key == state)
{
((WarsongGulchProfile)BattlegroundProfile).AllianceFlagWasDropped(playername);
// we are already in this state
return;
}
}

public void HordeFlagWasDropped(string playername)
{
if (BattlegroundProfile.GetType() == typeof(WarsongGulchProfile))
{
((WarsongGulchProfile)BattlegroundProfile).HordeFlagWasDropped(playername);
}
LastState = CurrentState.Key;
CurrentState.Value.Exit();
CurrentState = BattlegroundProfile.States.First(s => s.Key == state);
CurrentState.Value.Enter();
}
}
}
}
2 changes: 1 addition & 1 deletion AmeisenBotX.Core/Battleground/Enums/BattlegroundType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ public enum BattlegroundType
Invasion,
Siege
}
}
}
72 changes: 0 additions & 72 deletions AmeisenBotX.Core/Battleground/Objectives/AttackEnemyPlayers.cs

This file was deleted.

Loading

0 comments on commit 709157d

Please sign in to comment.