Jump to content

Snippets C# codes for Fight Classes


Droidz

Recommended Posts

Check if character/target have or not buff/debuff by spell id:

Use condition type "C Sharp Code" with Value:

wManager.Wow.ObjectManager.ObjectManager.Me.HaveBuff(69369)
  • Replace "69369" by your buff/debuff ID.
  • Replace "Me" by "Target" to check buff/debuff on current target (you can also replace "Me" by "Pet" to check on the pet).
  • Add "!" before this code to check if not have (de)buff ( http://www.tutorialspoint.com/csharp/csharp_logical_operators.htm ).
  • To get list of player/target (de)buff id, you can go to tab "Tools" > "Development Tools" > (if you want check your target (de)buff select npc in game) > click on "Player/target buff/debuff".
Link to comment
Share on other sites

Check if character/target buff/debuff stack count by spell id:

Use condition type "C Sharp Code" with Value:

wManager.Wow.ObjectManager.ObjectManager.Me.BuffStack(44544) >= 1
  • Replace "44544" by your buff/debuff ID.
  • Replace "Me" by "Target" to check buff/debuff on current target (you can also replace "Me" by "Pet" to check on the pet).
  • ">= 1" check if stack count is "Bigger or Equal at 1", you can replace "1" by required stack count. You can also replace ">=" by "<=" to check if "Smaller or Equal", or by "==" to check if "Equal" - http://www.tutorialspoint.com/csharp/csharp_relational_operators.htm ).
  • To get list of player/target (de)buff id, you can go to tab "Tools" > "Development Tools" > (if you want check your target (de)buff select npc in game) > click on "Player/target buff/debuff".
Link to comment
Share on other sites

Check character/target buff/debuff time left by spell id:

Use condition type "C Sharp Code" with Value:

wManager.Wow.ObjectManager.ObjectManager.Me.BuffTimeLeft(new List<uint> { 69369 }) >= 1000
  • Replace "69369" by your buff/debuff ID.
  • Replace "Me" by "Target" to check buff/debuff on current target (you can also replace "Me" by "Pet" to check on the pet).
  • ">= 1000" check if time left is "Bigger or Equal at 1000 millisecond", you can replace "1000" by required time left in millisacond. You can also replace ">=" by "<=" to check if "Smaller or Equal", or by "==" to check if "Equal" - http://www.tutorialspoint.com/csharp/csharp_relational_operators.htm ).
  • To get list of player/target (de)buff id, you can go to tab "Tools" > "Development Tools" > (if you want check your target (de)buff select npc in game) > click on "Player/target buff/debuff".
Link to comment
Share on other sites

  • Droidz pinned this topic
  • 1 year later...
On 8/7/2016 at 12:30 PM, Droidz said:

Check character/target buff/debuff time left by spell id:

Use condition type "C Sharp Code" with Value:


wManager.Wow.ObjectManager.ObjectManager.Me.BuffTimeLeft(new List<uint> { 69369 }) >= 1000
  • Replace "69369" by your buff/debuff ID.
  • Replace "Me" by "Target" to check buff/debuff on current target (you can also replace "Me" by "Pet" to check on the pet).
  • ">= 1000" check if time left is "Bigger or Equal at 1000 millisecond", you can replace "1000" by required time left in millisacond. You can also replace ">=" by "<=" to check if "Smaller or Equal", or by "==" to check if "Equal" - http://www.tutorialspoint.com/csharp/csharp_relational_operators.htm ).
  • To get list of player/target (de)buff id, you can go to tab "Tools" > "Development Tools" > (if you want check your target (de)buff select npc in game) > click on "Player/target buff/debuff".

If I use this, the time left is always zero. The development Tools output also shows:

PLAYER Buff/Debuff:

Retribution Aura: ID=7294, Stack=1, TimeLeft=0 ms, Owner=0
Blessing of Might: ID=19834, Stack=1, TimeLeft=0 ms, Owner=0
Seal of the Crusader: ID=20162, Stack=1, TimeLeft=0 ms, Owner=0

Link to comment
Share on other sites

3 hours ago, DrSeltsam said:

If I use this, the time left is always zero. The development Tools output also shows:

PLAYER Buff/Debuff:

Retribution Aura: ID=7294, Stack=1, TimeLeft=0 ms, Owner=0
Blessing of Might: ID=19834, Stack=1, TimeLeft=0 ms, Owner=0
Seal of the Crusader: ID=20162, Stack=1, TimeLeft=0 ms, Owner=0

Funny I recently came back after a couple of months off and had to remove the TimeLeft check in my cc because it would always be 0. Thought the bug was on my side. Using vanilla.

Link to comment
Share on other sites

13 hours ago, pasdoy said:

Funny I recently came back after a couple of months off and had to remove the TimeLeft check in my cc because it would always be 0. Thought the bug was on my side. Using vanilla.

I am using Vanilla too.

Link to comment
Share on other sites

... vanilla doesn't have a timer on buffs/debuffs, with the exception of your own. But they don't fall under the regular aura API so you have to use Lua to get specific timers.

Link to comment
Share on other sites

  • 9 months later...
1 hour ago, someshit said:

need to calculate number of opponents within 8 yards of current target. any tips?

if(ObjectManager.GetWoWUnitAttackables().Any(x=> x.Position.DistanceTo(ObjectManager.Me.Position) < 20))
{
    MovementManager.StopMove();
    Fight.StartFight(ObjectManager.GetWoWUnitAttackables().OrderBy(x => x.Position.DistanceTo(ObjectManager.Me.Position)).FirstOrDefault().Guid);
}

 

Link to comment
Share on other sites

5 minutes ago, someshit said:

so,


if(ObjectManager.GetWoWUnitAttackables().Any(x=> x.Position.DistanceTo(ObjectManager.Target.Position) <= 8 ))

should work?

Yeah

Link to comment
Share on other sites

  • 1 year later...

WoWUnit Extension "IsAutoAttacking" (WOTLK)

        /// <summary>
        /// Gets the flag if the unit is auto attacking.
        /// </summary>
        /// <returns>Returns true if the unit is auto attacking, otherwise false.</returns>
        public static bool IsAutoAttacking(this WoWUnit instance)
        {
            // Read
            bool result = Memory.WowMemory.Memory.ReadBoolean(address: instance.GetBaseAddress + (uint)0xA20);

            // Return
            return result;
        }

I'm not sure about the other extension offsets.

Link to comment
Share on other sites

  • 1 month later...
1 hour ago, Talamin said:

You can check this out, really good Base for a Fightclass!

https://github.com/Schaka/wRobotFightclassFrameworkEnhanced

I was more looking for something implemented into the wrobot api itself so I wouldn't have to rewrite my whole fight class sorry, but that looks real nice!

Maybe there's something I can use with ObjectManager like unit count that's in range of me or something?

Link to comment
Share on other sites

On 2/12/2021 at 8:12 PM, Sleepwalker said:

Is there any snippets for having more than 1 target? I'd like to use Swipe in AoE 2+ targets and Shred in single target

UnitExtension:

        /// <summary>
        /// Gets the units around our unit in the given range.
        /// </summary>
        /// <param name="range">The range we are looking in.</param>
        /// <param name="objectType">The object type we are looking for.</param>
        /// <returns>Returns a list of units if we found one, otherwise a empty list.</returns>
        public static IEnumerable<WoWUnit> GetAttackableUnits(this WoWUnit instance, int range, WoWObjectType objectType = WoWObjectType.Unit)
        {
            // Get units
            IEnumerable<WoWUnit> results = ObjectManager.GetObjectWoWUnit().Where(u => u.Type == objectType && u.IsAlive && u.MaxHealth > 500 && (u.Position.DistanceTo2D(instance.Position) <= range) && u.IsAttackable && !TraceLine.TraceLineGo(u.Position));

            // Return
            return results;
        }

 

Sample:

bool useSwipe = (ObjectManager.Me.GetAttackableUnits(5).Count() >= 3);

 

Link to comment
Share on other sites

On 2/15/2021 at 10:33 AM, iMod said:

UnitExtension:


        /// <summary>
        /// Gets the units around our unit in the given range.
        /// </summary>
        /// <param name="range">The range we are looking in.</param>
        /// <param name="objectType">The object type we are looking for.</param>
        /// <returns>Returns a list of units if we found one, otherwise a empty list.</returns>
        public static IEnumerable<WoWUnit> GetAttackableUnits(this WoWUnit instance, int range, WoWObjectType objectType = WoWObjectType.Unit)
        {
            // Get units
            IEnumerable<WoWUnit> results = ObjectManager.GetObjectWoWUnit().Where(u => u.Type == objectType && u.IsAlive && u.MaxHealth > 500 && (u.Position.DistanceTo2D(instance.Position) <= range) && u.IsAttackable && !TraceLine.TraceLineGo(u.Position));

            // Return
            return results;
        }

 

Sample:


bool useSwipe = (ObjectManager.Me.GetAttackableUnits(5).Count() >= 3);

 

Thanks for this, seems way more neat than what I have going on at the min. Another issue I've ran into though is when there's more than 1 feral in the group it doesn't keep up rake anymore since it can see his rake debuff on the boss. Is there any way to make it use my personal applied debuffs rather than everyones? 

Here's my rake snippet:

        // Rake
        if (Rake.KnownSpell && Rake.IsSpellUsable && Rake.IsDistanceGood && !ObjectManager.Target.HaveBuff(9904) && ObjectManager.Target.BuffTimeLeft(new List<uint> { 9904 }) < 1000)
        {
			Rake.Launch();
            Lua.LuaDoString(@"dRotationFrame.text:SetText(""Casting Rake"")");

            return;
        }		

 

Link to comment
Share on other sites

  • 3 weeks later...

(Csharp) Return Deadly Postion Stack count.

 

 public static int ReturnDeadlyPosionStacks
        {
            get
            {
                return Lua.LuaDoString<int>(@"
                        local DeadlyPoison = {'Deadly Poison', 'Deadly Poison II', 'Deadly Poison III', 
                        'Deadly Poison IV', 'Deadly Poison V', 'Deadly Poison VI', 
                        'Deadly Poison VII','Deadly Poison VIII', 'Deadly Poison IX'} 
                        local DeadlyPoisonStackCount = 0;
                        for Poison = 1, #DeadlyPoison do
                            for i = 1, 20 do
                                local name, _, _, count = UnitDebuff('target', i);
                                 if name and string.find(name, DeadlyPoison[Poison]) then
                                    DeadlyPoisonStackCount = count;
                                end
                            end
                        end
                return DeadlyPoisonStackCount;");
            }
        }

 

Link to comment
Share on other sites

  • 4 weeks later...

(Csharp) - return all the Glyph a player has. 

private static List<string> Glyphs()
    {
        var GlyphNames = @"
            local Index = {}
            for i = 1, GetNumGlyphSockets() do
                local id = select(3, GetGlyphSocketInfo(i));
                if id ~= nil then
                    local GlyphName  = GetSpellInfo(id);
                    tinsert(Index, GlyphName);
                end
            end
            return unpack(Index);
        ";
        return Lua.LuaDoString<List<string>>(GlyphNames);
    }

or if people do not wanna use .Contain in a list format. here is a boolen.

 

private static bool Glyphs(string GlyphNum)
    {
        var GlyphNames = $@"
            for i = 1, GetNumGlyphSockets() do
                local id = select(3, GetGlyphSocketInfo(i));
                if id ~= nil then
                    local GlyphName  = GetSpellInfo(id);
                    if GlyphName and string.find(GlyphName, ""{GlyphNum}"")
                        return true;
                        break;
                    end
                end
            end
            return false;
        ";
        return Lua.LuaDoString<bool>(GlyphNames);
    }

 

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...