Jump to content

correct code for debuff


Recommended Posts

hi

anyone can help me have the correct setting for the fight class im making please. my FC doesn't cast Corruption because it already sees another lock's corruption as it's own. I highlighted the possible line that needs to be changed to it will buff Corruption to it's target. Thank you.

 

if (Corruption.IsSpellUsable && Corruption.KnownSpell && Corruption.IsDistanceGood && SpellManager.GlobalCooldownTimeLeft() == 0 && !ObjectManager.Target.Rooted 
            && !ObjectManager.Target.HaveBuff("Corruption") && ObjectManager.Me.HaveBuff("Life Tap"))
        {
            Corruption.Launch();
            return;
        }

Link to comment
Share on other sites

13 minutes ago, jiraiyasm said:

hi

anyone can help me have the correct setting for the fight class im making please. my FC doesn't cast Corruption because it already sees another lock's corruption as it's own. I highlighted the possible line that needs to be changed to it will buff Corruption to it's target. Thank you.

 

if (Corruption.IsSpellUsable && Corruption.KnownSpell && Corruption.IsDistanceGood && SpellManager.GlobalCooldownTimeLeft() == 0 && !ObjectManager.Target.Rooted 
            && !ObjectManager.Target.HaveBuff("Corruption") && ObjectManager.Me.HaveBuff("Life Tap"))
        {
            Corruption.Launch();
            return;
        }

Add something like this, but you should think about moving all the casting checks into one Function and do the Checks only once.
 

if (Corruption.IsSpellUsable && Corruption.KnownSpell && Corruption.IsDistanceGood && SpellManager.GlobalCooldownTimeLeft() == 0 && !ObjectManager.Target.Rooted && ObjectManager.Me.HaveBuff("Life Tap")) 			
            {
  				if(!DebuffCheckOwner("Corruption")
                   {
                      Corruption.Launch();
                      return;                   
                   }
            }
                   
public static bool DebuffCheckOwner(Spell spell, bool owner = true)
                   {
                     List<Aura> DebuffList = ObjectManager.Target.GetAllBuff();
                     Aura aura = null;
                     if (owner)
                     {
                       aura = DebuffList.FirstOrDefault(s => s.GetSpell.Name == spell.Name && s.Owner == ObjectManager.Me.Guid);
                       if (aura != null)
                       {
                         return true;
                       }
                     }
                     return false;
                   }

 

Link to comment
Share on other sites

Thank you so much for the help. i am still very new to this area.  i tried having my lock to use grand spellstone but it doesn't "Left click" the spellstone to the weapon.

i just based this on the snipets for rogue also. 

private void EnchantWeapon()
    {
        bool hasMainHandEnchant = Lua.LuaDoString<bool>
            (@"local hasMainHandEnchant, _, _, _, _, _, _, _, _ = GetWeaponEnchantInfo()
            if (hasMainHandEnchant) then 
               return '1'
            else
               return '0'
            end");

        if (!hasMainHandEnchant)
        {

            IEnumerable<uint> MP = InstantPoisonDictionary
                .Where(i => i.Key <= ObjectManager.Me.Level && ItemsManager.HasItemById(i.Value))
                .OrderByDescending(i => i.Key)
                .Select(i => i.Value);

            if (MP.Any())
            {
                MHPoison = MP.First();
                ItemsManager.UseItem(MHPoison);
                Thread.Sleep(10);
                Lua.LuaDoString("/click PickupInventoryItem(16)");
                Thread.Sleep(5000);
                return;
            }      
        }
    }
    private static Dictionary<int, uint> InstantPoisonDictionary = new Dictionary<int, uint>
    {       
        { 79, 41196 },
    };    

 

may i ask please how to check if the required item is available in the bag before casting the spell especially needed for casting buffs.

Thank you @Talamin

Link to comment
Share on other sites

@jiraiyasmHello, i went ahead and cleaned up some of your code, this should work. let me know if you need any help.

 

public static void EnchantWeapon()
    {
        try
        {
            if (hasMainHandEnchant || Fight.InFight || ObjectManager.Me.InCombatFlagOnly || ObjectManager.Me.IsDead)
                return;

            IEnumerable<uint> MainHandEnchant = InstantPoisonDictionary
                   .Where(i => i.Key <= ObjectManager.Me.Level && ItemsManager.GetItemCountByIdLUA(i.Value) >= 1)
                   .OrderByDescending(i => i.Key)
                   .Select(i => i.Value);

            if (MainHandEnchant.Any())
            {
                var MHPoison = MainHandEnchant.FirstOrDefault();
                ItemsManager.UseItem(MHPoison);
                Thread.Sleep(10);
                Lua.LuaDoString("PickupInventoryItem(16);");
                Thread.Sleep(5000);
            }
        }
        catch(Exception ex)
        {
            Logging.Write($"{ex}");
        }
    }
    private static Dictionary<int, uint> InstantPoisonDictionary = new Dictionary<int, uint>()
    {
        { 79, 41196 },
    };
    private static Boolean hasMainHandEnchant => Lua.LuaDoString<Int32>("local GetWeaponEnchant = {GetWeaponEnchantInfo()}; return GetWeaponEnchant[1];") == 1;

 

Link to comment
Share on other sites

1 hour ago, Sye24 said:

@jiraiyasmHello, i went ahead and cleaned up some of your code, this should work. let me know if you need any help.

 

public static void EnchantWeapon()
    {
        try
        {
            if (hasMainHandEnchant || Fight.InFight || ObjectManager.Me.InCombatFlagOnly || ObjectManager.Me.IsDead)
                return;

            IEnumerable<uint> MainHandEnchant = InstantPoisonDictionary
                   .Where(i => i.Key <= ObjectManager.Me.Level && ItemsManager.GetItemCountByIdLUA(i.Value) >= 1)
                   .OrderByDescending(i => i.Key)
                   .Select(i => i.Value);

            if (MainHandEnchant.Any())
            {
                var MHPoison = MainHandEnchant.FirstOrDefault();
                ItemsManager.UseItem(MHPoison);
                Thread.Sleep(10);
                Lua.LuaDoString("PickupInventoryItem(16);");
                Thread.Sleep(5000);
            }
        }
        catch(Exception ex)
        {
            Logging.Write($"{ex}");
        }
    }
    private static Dictionary<int, uint> InstantPoisonDictionary = new Dictionary<int, uint>()
    {
        { 79, 41196 },
    };
    private static Boolean hasMainHandEnchant => Lua.LuaDoString<Int32>("local GetWeaponEnchant = {GetWeaponEnchantInfo()}; return GetWeaponEnchant[1];") == 1;

 

Yes it indeed worked. Thank you so much!

Link to comment
Share on other sites

@jiraiyasmDont thank me, you did all the work, all i did was clean it up a little, your code was using "Lua.LuaDoString("/click PickupInventoryItem(16)");" which wont work because LuaDoString doesnt take "/click",

if you want to use "/click" type code you need to use "Lua.RunMacroText("/click codeHere");". good job ! i hope to see your fright class some day. if you need anymore help feel free to reach out. i am always here to help.

Link to comment
Share on other sites

hi @Sye24is it possible for my characters to move away from the ground debuff that doesn't show as a debuff on the player? will this snipet below work?

 

wManager.Events.FightEvents.OnFightLoop += (unit, cancelable) =>
        {
            var me = wManager.Wow.ObjectManager.ObjectManager.Me;
            var target = wManager.Wow.ObjectManager.ObjectManager.Target;
            if (me.IsAlive && target.IsAlive && !me.IsCast && me.HaveBuff("Buff name"))
            {
                wManager.Wow.Helpers.Keybindings.PressKeybindings(wManager.Wow.Enums.Keybindings.STRAFELEFT, 1000 * 3); // strage left during 3 secondes
            }
        };
 

the debuff IDs are 69019 and 68863 which both hits the characters but no debuffs appears on them as they explode from the ground. Thank you.

Link to comment
Share on other sites

 

8 hours ago, jiraiyasm said:

is it okay if i can ask for the code for this plugin? thank you.

Sorry but no, i improved a lot of the code and i am gonna use it in upcoming project.

 

Link to comment
Share on other sites

15 hours ago, Sye24 said:

 

Sorry but no, i improved a lot of the code and i am gonna use it in upcoming project.

 

im making a fightclass for DK, how do i get it to use Death and Decay skills to be casted? it only use the skill but doesn't actually click on the ground.

Link to comment
Share on other sites

11 hours ago, jiraiyasm said:

im making a fightclass for DK, how do i get it to use Death and Decay skills to be casted? it only use the skill but doesn't actually click on the ground.

Simple google search with words Wrobot Aoe Death and Decay will find a lot of help for you.

Link to comment
Share on other sites

14 hours ago, Sye24 said:

Simple google search with words Wrobot Aoe Death and Decay will find a lot of help for you.

tried using these code

SpellManager.CastSpellByIDAndPosition(49936, ObjectManager.Target.Position

ClickOnTerrain.Pulse(ObjectManager.Target.Position);

but i get an error on vstudio. any way to correct these? Thank you.

 

Link to comment
Share on other sites

16 hours ago, jiraiyasm said:

tried using these code

SpellManager.CastSpellByIDAndPosition(49936, ObjectManager.Target.Position

ClickOnTerrain.Pulse(ObjectManager.Target.Position);

but i get an error on vstudio. any way to correct these? Thank you.

 

Are you using 

using wManager.Wow.Helpers;
using wManager.Wow.ObjectManager;

use these references 

Link to comment
Share on other sites

4 hours ago, Sye24 said:

Are you using 

using wManager.Wow.Helpers;
using wManager.Wow.ObjectManager;

use these references 

yes i used those references already but still getting errors.

Link to comment
Share on other sites

Can you post a screenshot of your error? i cant really help without seeing the error.

4 hours ago, jiraiyasm said:

yes i used those references already but still getting errors.

 

Link to comment
Share on other sites

2 hours ago, jiraiyasm said:

 

Screenshot 2021-09-13 011818.jpg

Bool - Boolean structure type that represents a Boolean value, which can be either true or false.

Void - Is a reference type of data type and used to specify the return type of a method in C#.

If you don't understand the above, start here: https://www.youtube.com/watch?v=GhQdlIFylQ8

I do not know what spell 49936 is as it says it has been removed on Wowhead. Remove the SpellManager..... line from the if condition since it's not a boolean (bool).

instead of DnD.Launch(); use ClickOnTerrain.Spell(43265, ObjectManager.Target.Position, false, false);

if you want to check if the Target is on your DnD, then do something like this in the if condition (bool):  ObjectManager.Target.BuffCastedByAll(DnD.Name).Contains(ObjectManager.Me.Guid)

if you want to cast it on the Target if it isn't on your DnD then add a "!" to it. The "!" is a negation. AKA the opposite (bool):  !ObjectManager.Target.BuffCastedByAll(DnD.Name).Contains(ObjectManager.Me.Guid)

I forget if the debuff is the same as the spell. If it is, the last few lines will work.

Link to comment
Share on other sites

On 9/13/2021 at 3:46 AM, Zan said:

Bool - Boolean structure type that represents a Boolean value, which can be either true or false.

Void - Is a reference type of data type and used to specify the return type of a method in C#.

If you don't understand the above, start here: https://www.youtube.com/watch?v=GhQdlIFylQ8

I do not know what spell 49936 is as it says it has been removed on Wowhead. Remove the SpellManager..... line from the if condition since it's not a boolean (bool).

instead of DnD.Launch(); use ClickOnTerrain.Spell(43265, ObjectManager.Target.Position, false, false);

if you want to check if the Target is on your DnD, then do something like this in the if condition (bool):  ObjectManager.Target.BuffCastedByAll(DnD.Name).Contains(ObjectManager.Me.Guid)

if you want to cast it on the Target if it isn't on your DnD then add a "!" to it. The "!" is a negation. AKA the opposite (bool):  !ObjectManager.Target.BuffCastedByAll(DnD.Name).Contains(ObjectManager.Me.Guid)

I forget if the debuff is the same as the spell. If it is, the last few lines will work.

thanks for the help. i haven't tried it yet as i got busy.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...