Tutorials » Combat Rotation » Step 5: Combat Approach
CombatApproach determines the character's behavior between the moment the target is detected
and the start of the combat, within the range of 10 to 30 yards. A distinction is made here between
IUnit (NPC) and IPlayer. This allows for different rotation behaviors to be implemented.
Note that spells cast while standing still will not work here.
In this example we want to approach the target in Stealth using a Rogue.
However, this is only possible as long as we are not in combat and Stealth is not already active.
Optionally, you can set the Distance yourself.
public async Task CombatApproach(IUnit Target)
{
var Distance = Target.Distance3D;
await GC.SM.TryCastAsync("Stealth", new()
{
() => !GC.OM.Me.IsInCombat,
() => !GC.OM.Me.IsInShapeshiftForm(Constants.ShapeshiftForm.Stealth),
() => Distance >= 20,
() => Distance <= 30,
});
// More spells here ...
}
As a Mage, you could use this to activate the Ice Barrier early if it isn't already active.
public async Task CombatApproach(IUnit Target)
{
var Distance = Target.Distance3D;
await GC.SM.TryCastAsync("Ice Barrier", new()
{
() => !GC.OM.Me.HasAura("Ice Barrier"),
});
// More spells here ...
}
Further information on the functions shown in this example:
Manager → ObjectManager → Models → IUnit → Distance3D
Manager → SpellManager → Cast Spell → TryCastAsync
Manager → ObjectManager → Models → IMe → IsInCombat
Manager → ObjectManager → Models → IUnit → IsInShapeshiftForm
Manager → ObjectManager → Models → IUnit → HasAura
The procedure for creating the CombatApproach method is the same.
Keep in mind that combat behavior against a real player is different. Stealth as rogue
would perform significantly better in the CombatRotation method under different conditions.
More on this in the next step: Step 6: Combat Rotation
If you want to use a single rotation for both types, you can do so as follows.
public async Task CombatApproach(IUnit Target)
{
var Model = GC.OM.CreateModel(Target);
await CombatApproach(Model);
}
public async Task CombatApproach(IPlayer Target)
{
var Model = GC.OM.CreateModel(Target);
await CombatApproach(Model);
}
// Add this to your template.
private async Task CombatApproach(IModel Model)
{
// My rotation ...
}
Use different combat approaches for different opponents.
public async Task CombatApproach(IUnit Target)
{
switch (Target.Name)
{
case "Boss name": MeVsBossApproach(Target); return;
case "Evil enemy name 1": MeVsEvilEnemy1Approach(Target); return;
case "Evil enemy name 2": MeVsEvilEnemy2Approach(Target); return;
default: MyDefaultApproach(Target); return;
}
}
private async Task MeVsBossApproach(IUnit Target)
{
// Me vs. Boss Approach...
}
private async Task MeVsEvilEnemy1Approach(IUnit Target)
{
// Me vs. Evil Enemy Approach 1...
}
private async Task MeVsEvilEnemy2Approach(IUnit Target)
{
// Me vs. Evil Enemy Approach 2...
}
private async Task MyDefaultApproach(IUnit Target)
{
// My Default Approach...
}
The examples shown are not guidelines. They are intended to serve as food for thought.
Take a look at the Spell Manager
to understand the differences between Cast and TryCast
and to get an overview of your options.