Jump to content

Avvi

Members
  • Posts

    397
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Avvi reacted to Droidz in Level Based Repair NPC (Quester)   
    Hello, start to use only NPC of your profile:
    (use step "RunCode" to run all code)
    wManager.Wow.Helpers.NpcDB.AcceptOnlyProfileNpc = true; It is not easy way, but add NPC with C# code like this (use this code when you change zone to select good npc for current level/zone):
    wManager.Wow.Helpers.NpcDB.ListNpc.RemoveAll(n => n.CurrentProfileNpc); // Remove in NPCDB all Npc added on current profile var npcRepair = new wManager.Wow.Class.Npc // Npc repair info { Name = "Npc name", Entry = 1234, Faction = wManager.Wow.Class.Npc.FactionType.Neutral, ContinentId = wManager.Wow.Enums.ContinentId.Azeroth, Position = new robotManager.Helpful.Vector3(1, 2, 3), CanFlyTo = true, Type = wManager.Wow.Class.Npc.NpcType.Repair, }; wManager.Wow.Helpers.NpcDB.AddNpc(npcRepair, false, true); // Add npc repair to npcdb var npcVendor = new wManager.Wow.Class.Npc // Npc vendor info { Name = "Npc name", Entry = 1234, Faction = wManager.Wow.Class.Npc.FactionType.Neutral, ContinentId = wManager.Wow.Enums.ContinentId.Azeroth, Position = new robotManager.Helpful.Vector3(1, 2, 3), CanFlyTo = true, Type = wManager.Wow.Class.Npc.NpcType.Vendor, }; wManager.Wow.Helpers.NpcDB.AddNpc(npcVendor, false, true); // Add npc vendor to npcdb If you want force WRobot to go to vendor/repair:
    wManager.Wow.Bot.States.ToTown.ForceToTown = true;  
  2. Like
    Avvi got a reaction from shoro2 in Avvi's C# Tips & Tricks with Helpful Code Snippets   
    Hi all,
    I figured I'd post some things that I have learned during my time of developing in C#. Perhaps some of this is obvious for some of the more experienced WRobot C# writers, but for me, I had to do a lot of forum searching and experimenting to make progress on any of my work. 
     
    How do I get started?
    Please see this post by @Droidz
     
     
    How can I see what Functions are available to me in the WRobot API?
    I recommend using some sort of decompiler in order to see what functions are available in the WRobot API. That is, use something such as dotPeek from jetbrains. See this URL: https://www.jetbrains.com/decompiler/ . Once you have this downloaded, open  the WRobot Binaries located in the (C:\WRobot\Bin) folder in dotPeek. I cannot even begin to explain how many times the recompiled helped me find useful things I could re-use. As a quick tip, I would suggest taking a look at the wManager.wManager.Wow.Helpers functions that are available. Anything listed as public static <variable type>  will be available to use from a Plugin/Profile/Fightclass etc.
     
    What if WRobot doesn't have an available function that I will need?
    WRobot doesn't have everything instantly available, so you may need to resort to using some Lua Functions to get information back from the WoW Client. An example of this that I ran into at some point was getting the number of Character Macros someone has.. Of course this is very specific, but please bear with me for the sake of this example :).
    WoW Lua Reference:  http://wowprogramming.com/docs/api_categories
    Using Lua in C#:
    This snippet will return a List of integers and set the C# variable numberOfMacros  equal to the returned list of the DoString function. To be more specific, it will provide a list of the number of Global account Macros , and the number of Personal Character Macros.
    var numberOfMacros = Lua.LuaDoString<List<int>>("return numCharacterMacros");  
    The below will return just the number Character Macros someone has.  If you need a specific variable from a Lua Function, then do the following: 
    var numPersonalMacros = Lua.LuaDoString<int>("local numAccountMacros, numCharacterMacros = GetNumMacros(); return numCharacterMacros"); The above snippet will set the C# variable numPersonalMacros equal to numCharacterMacros from the lua return value.
    Using a Variable in the Lua.LuaDoString.  The below will return the text body of the macro that has the id of 121.
    var _macroID = 121 string macroBody = Lua.LuaDoString<string>("return GetMacroBody(" + _macroID + ")");  
     
    Executing Lua Code in C#
    This  will leave the party (if the player is in one).
    wManager.Wow.Helpers.Lua.RunMacroText("/run LeaveParty()");  
    What is the difference between Lua.LuaDoString() and RunMacroText()? 
    The difference is in can be understand in how you think about them. Lua.LuaDoString should be seen as a way to retrieve information.. More specifically, the Lua.LuaDoString's purpose is to have a value returned to it, so that you can assign it to a C# Variable. RunMacroText can be used to do something in game. More specifically, RunMacroText should be used when trying to run some sort of in-game script (such as /cast spell).
     
    Plugin Template C#: Plugin-Template.cs
    I have attached a basic plugin template that can be used. In it, I have provided an example of:
    A Basic Implementation of the wManager.Plugin.IPlugin Class (including Settings/Initialize/Dispose) Basic loop that will occur while WRobot is running Settings that can be configured from Plugin Page A Category/Short Description for the Plugin Settings An example of Watching for Game Events. An example of OnRunState / OnAfterRunState for WRobot States Watching For Game Events
    Sometimes you may find that you need to wait for something to occur in game before you can take a specific action. In WoW / WRobot world, these things are called events. Below are two examples of events. The first event will occur when either the Group Loot Settings change, or a Player Enters/Joins the current Party.The second Event will occur when a System Message is received.  I recommend adding this watchForEvents Function in the Initialize function of a plugin, or somewhere where it will only be called once. For an example of this, please see my Plugin Template.
    private void watchForEvents() { EventsLuaWithArgs.OnEventsLuaWithArgs += (LuaEventsId id, List<string> args) => { if (id == wManager.Wow.Enums.LuaEventsId.PARTY_MEMBERS_CHANGED) { Logging.Write("Joined Group or something about the current group was changed."); } if (id == wManager.Wow.Enums.LuaEventsId.CHAT_MSG_SYSTEM) { Logging.Write("We Received a System Message."); } }; }  
    Finding the list of available Game Events:
    Each version of the game is different here, so this is where you will need to be careful. By that I mean, some versions of the game may have an event type, but a different version may not. Blizzard was not always consistent in their name accross different versions of the game, so please be careful to test against multiple versions of the game. 
     Open DotPeek  Search for "LuaEventsID" Double Click LuaEventsId in the Assembly Explorer Window. A window will open displaying a list of Events. What do each of these Events mean?
    WoW Event Reference:  http://wowwiki.wikia.com/wiki/Event_API 
    (Reminder! Some of these may be different in different versions of the game.)
     
    Watching For WRobot State Changes
    In addition to in game events, there are also WRobot 'states'. Similar to Game Events, WRobot states are the particular condition that WRobot is in at a specific time. For example, there is a state called 'MillingState', and another called 'Looting' that come out with WRobot. States are managed by the WRobot FiniteStateMachineEvents Engine. When a State occurs/changes/ends/etc, an event is passed to the FiniteStateMachine (pardon my wording here if this is not 100% correct). There are three main events that we can use to manage our States.
    State Events that occur:
    OnBeforeCheckIfNeedToRunState - This can be used to CANCEL an event if specific conditions are met. OnRunState - This can be used to do something just as the State is being started. OnAfterRunState - This can be used to do something just as the State has completed.  
    Example of OnRunState and OnAfterRunState
    In this example we are watching for when WRobot starts the ToTown State and when it finishes it. We create a boolean that is set to true when the state is started, and then set it to false when the State is completed. I recommend adding the initializeToTownWatcher() function in the Initialize function of a plugin, or somewhere where it will only be called once. For example of this, please see my Plugin Template.
    bool goToTown = false; private void initializeToTownWatcher() { robotManager.Events.FiniteStateMachineEvents.OnRunState += (engine, state, cancelable) => { if (state != null && state.DisplayName == "To Town") { goToTown = true; Logging.Write("Going to Town State has been initiated."); } }; robotManager.Events.FiniteStateMachineEvents.OnAfterRunState += (engine, state) => { if (state != null && state.DisplayName == "To Town") { goToTown = false; Logging.Write("We have completed going To Town State."); } }; } Example of OnBeforeCheckIfNeedToRunState
    In this example, we catch the state with the name of To Town and cancel it by setting the passed in cancelable parameter to true.
    private void cancelToTownState() { robotManager.Events.FiniteStateMachineEvents.OnBeforeCheckIfNeedToRunState += (engine, state, cancelable) => { if (state != null && state.DisplayName == "To Town") { Logging.Write("We have cancelled the To Town State"); cancelable.Cancel = true; } }; } Where can I find other WRobot States?
    Each version of the WRobot is different, so some versions of WRobot may have a state type, but a different version may not. Please be careful to test against multiple versions of the game/WRobot. 
    Open DotPeek Expand wManager Module Expand wManager.Wow.Bot.States namespace.  
     
    MORE TBA....
    The above is my attempt at trying to help newcomers to WRobot at writing their own plugins / fight classes / etc. If there are any questions , suggestions, or even  corrections, please do let me know in the comments and I'll be sure to add/update things as they come up!
     
    Thanks,
    - Avvi 
     
  3. Thanks
    Avvi got a reaction from aqualian in Bot stop/close when got special Whisp Plugin Request   
    Ok, I will add it to RoboAlert
  4. Like
    Avvi reacted to aqualian in Bot stop/close when got special Whisp Plugin Request   
    i do not use discord. So if u cant do exit or pause its not usefull for me ;c
  5. Like
    Avvi reacted to rakushasu in Utterly frustrated   
    First of all thank you for your reply! I found the maximum target option and it seems the bot is not dying as often anymore. Also seems that it works best with mobs that are of the same level or below. Changing the food value also helped. I am honestly not bothered by paying more for food. So thanks again.
    The selling and mailing issues seem to happen because the bot tried to mail quest items, conjured items and anything else that can't be sold or mailed. So the bot would try over and over for quite some time before stopping to mail or sell altogether. I guess this can be fixed by adding the items in question to the not to mail / sell list.

    In the end I think I was able to fix some of the issues and by pretty much creating my own profiles.

    As for improvements, I think there are too many things you need to set and include / exclude. I know there is often the need for some tweaking with bots, but adding specific types of foods here, what to sell / mail, there and so on. It just seems there are quite a few options that could simply be excluded by the bot in itself (not the option mind you). There were other things, like the bot mailing the skinning knife or the mining pick. It is just frustrating to come back every time and the bot has been doing something weird. I hope you understand what I mean. I think by now I figured most of these things out, but it took my quite some time.
    Another issue are profiles and fight classes. I don't really like to compare the two for obvious reasons, but Honorobuddy came with routine (Singular) and a full fledged set of leveling profiles, making it possible to install the bot, press start and let it run. Now I am well aware that this would probably way too much work for Droidz, but I think the bot should at least include some rudimentary grinding profiles. I know there is the Automaton option, but that too was acting strange at times. In general I think the basic bot should include some more features.
     
    I kinda got things to work by now, but it was very frustrating. I have joined the discord as well and was able to get some answers and some help. By now I got the bot working pretty adequately. I think it really was mostly profile issues and quite a bit of tweaking that was necessary. 
    And I agree, I think a wiki or something would be a great place, but as said again, that would be quite a lot of effort and I can see that Droidz has other priorities.
     
  6. Like
    Avvi reacted to Marsbar in Utterly frustrated   
    I totally understand your frustrations but the bot as a whole is great! 
    Pretty much all of the issues you're explaining can be solved (and have) by people, whether that be via a plugin, fightclass or advanced profiles. The problem is finding all of that information, a wiki doesn't exist so you need to do a lot of forum searching. Another option is raising your questions on discord.
     
  7. Like
    Avvi reacted to aqualian in Bot stop/close when got special Whisp Plugin Request   
    Full exit beacuse sometimes when i do pause it work anyway xd
  8. Like
    Avvi reacted to Matenia in Enemy near "x" yard LUA code   
    ObjectManager.GetWoWUnitHostile().Count(o => o.IsValid && o.IsAlive && o.Guid != ObjectManager.Target.Guid && o.Position.DistanceTo(ObjectManager.Target.Position) <= 15) >= 3
  9. Like
    Avvi got a reaction from Marsbar in Utterly frustrated   
    The bot attacking multiple enemies at the same time to die. :
    There is a setting that can help with that.
    Under General Settings "Max units near target: x" Try setting the value to 0.
     
    Instead of sitting down and eating food / drinking mana he rushes on into the next mobs only to die (again).
    This is likely a fight class issue, but I think you can try setting your minimum hp/mana to a higher value (like 65%). It's not a great workaround, but it solved my problem with it. You'll end up buying more water/food this way though, so that's a con.
     
    The bot not selling things or having trouble
    Can you expand on this more. Is it never selling, or is it only selling some items?
     
    Out of everything you said, what are some ideas that you think would help improve the bot as a whole? Do you think the bot needs more support/features from plugins, or are you mostly frustrated with the things you listed above, and the other issues you've run across?
     
  10. Like
    Avvi reacted to aqualian in Bot stop/close when got special Whisp Plugin Request   
    Yeah do it ;)
  11. Like
    Avvi got a reaction from (̾●̮̮̃̾•̃̾) ̿ ̿ ‘̿’\̵͇̿̿\ in Class trainer   
    Hi Droidz, downloading this plugin by itself does not work in the TBC version of WRobot. Do I need to integrate this into one of my other downloaded questing profiles? Or perhaps I am doing something else wrong?
  12. Thanks
    Avvi reacted to eternalbot in Ramdisk to Improve WRobot Performance on Slower Systems   
    I use AMD's Radeon Ramdisk. I have attached the software user manual for reference.
    Download and install the AMD Radeon RAMDisk Software. Launch the RAMDisk application. If you do not have AMD Memory, the freeware application will be limited to 4GB. A notification will pop up. Click No Thanks to use the freeware version. Select a 1-2GB disk size and click Start RAMDisk. The application will prompt to install the driver. Click OK to install the driver. The application will take a few moments to install the driver and allocate the drive space. Once the process is complete, Windows will prompt you as if a new drive has been connected. Default drive letter is z: Open the blank folder. Copy your WRobot installation over to the new drive. Launch the WRobot from the new drive. NOTE: Be sure to save the RAMDisk on the load/save tab of the RAMDisk Configuration Utility after you save your configurations, profiles, or fight classes in WRobot. Otherwise you'll lose any changes you make. I personally make a backup of my wrobot folder after I end my sessions on my primary hard drive.
    I'm not promising everything will run perfect, but I have experience a significant performance improvement. A ramdisk runs about 15-20 times faster than an SSD. This helps reduce the I/O latency within your computer and is particularly useful when 2 applications need to work together quickly.
     
    AMD_Radeon_RAMDisk_User_Manual.pdf
  13. Like
    Avvi got a reaction from Matenia in Ramdisk to Improve WRobot Performance on Slower Systems   
    For anyone that is unfamiliar with ramdisk configuration, can you provide some steps or a URL that describes the process?
  14. Like
    Avvi reacted to eternalbot in Ramdisk to Improve WRobot Performance on Slower Systems   
    I had been struggling with wrobot performance on my older gaming PC. It should be noted,  my motherboard is limited to SATA 2 speeds even with an SSD. It was fast for its' generation, but is showing its' age. I have recently started running wrobot on a ramdisk to improve the application performance. I have experienced major improvements in the bot performance. I no longer have delays in combat rotations or loading profiles.
    It might me a viable solution for those experiencing some delays due to I/O lag on older systems.
     
  15. Like
    Avvi got a reaction from Razzue in Avvi's C# Tips & Tricks with Helpful Code Snippets   
    Hi all,
    I figured I'd post some things that I have learned during my time of developing in C#. Perhaps some of this is obvious for some of the more experienced WRobot C# writers, but for me, I had to do a lot of forum searching and experimenting to make progress on any of my work. 
     
    How do I get started?
    Please see this post by @Droidz
     
     
    How can I see what Functions are available to me in the WRobot API?
    I recommend using some sort of decompiler in order to see what functions are available in the WRobot API. That is, use something such as dotPeek from jetbrains. See this URL: https://www.jetbrains.com/decompiler/ . Once you have this downloaded, open  the WRobot Binaries located in the (C:\WRobot\Bin) folder in dotPeek. I cannot even begin to explain how many times the recompiled helped me find useful things I could re-use. As a quick tip, I would suggest taking a look at the wManager.wManager.Wow.Helpers functions that are available. Anything listed as public static <variable type>  will be available to use from a Plugin/Profile/Fightclass etc.
     
    What if WRobot doesn't have an available function that I will need?
    WRobot doesn't have everything instantly available, so you may need to resort to using some Lua Functions to get information back from the WoW Client. An example of this that I ran into at some point was getting the number of Character Macros someone has.. Of course this is very specific, but please bear with me for the sake of this example :).
    WoW Lua Reference:  http://wowprogramming.com/docs/api_categories
    Using Lua in C#:
    This snippet will return a List of integers and set the C# variable numberOfMacros  equal to the returned list of the DoString function. To be more specific, it will provide a list of the number of Global account Macros , and the number of Personal Character Macros.
    var numberOfMacros = Lua.LuaDoString<List<int>>("return numCharacterMacros");  
    The below will return just the number Character Macros someone has.  If you need a specific variable from a Lua Function, then do the following: 
    var numPersonalMacros = Lua.LuaDoString<int>("local numAccountMacros, numCharacterMacros = GetNumMacros(); return numCharacterMacros"); The above snippet will set the C# variable numPersonalMacros equal to numCharacterMacros from the lua return value.
    Using a Variable in the Lua.LuaDoString.  The below will return the text body of the macro that has the id of 121.
    var _macroID = 121 string macroBody = Lua.LuaDoString<string>("return GetMacroBody(" + _macroID + ")");  
     
    Executing Lua Code in C#
    This  will leave the party (if the player is in one).
    wManager.Wow.Helpers.Lua.RunMacroText("/run LeaveParty()");  
    What is the difference between Lua.LuaDoString() and RunMacroText()? 
    The difference is in can be understand in how you think about them. Lua.LuaDoString should be seen as a way to retrieve information.. More specifically, the Lua.LuaDoString's purpose is to have a value returned to it, so that you can assign it to a C# Variable. RunMacroText can be used to do something in game. More specifically, RunMacroText should be used when trying to run some sort of in-game script (such as /cast spell).
     
    Plugin Template C#: Plugin-Template.cs
    I have attached a basic plugin template that can be used. In it, I have provided an example of:
    A Basic Implementation of the wManager.Plugin.IPlugin Class (including Settings/Initialize/Dispose) Basic loop that will occur while WRobot is running Settings that can be configured from Plugin Page A Category/Short Description for the Plugin Settings An example of Watching for Game Events. An example of OnRunState / OnAfterRunState for WRobot States Watching For Game Events
    Sometimes you may find that you need to wait for something to occur in game before you can take a specific action. In WoW / WRobot world, these things are called events. Below are two examples of events. The first event will occur when either the Group Loot Settings change, or a Player Enters/Joins the current Party.The second Event will occur when a System Message is received.  I recommend adding this watchForEvents Function in the Initialize function of a plugin, or somewhere where it will only be called once. For an example of this, please see my Plugin Template.
    private void watchForEvents() { EventsLuaWithArgs.OnEventsLuaWithArgs += (LuaEventsId id, List<string> args) => { if (id == wManager.Wow.Enums.LuaEventsId.PARTY_MEMBERS_CHANGED) { Logging.Write("Joined Group or something about the current group was changed."); } if (id == wManager.Wow.Enums.LuaEventsId.CHAT_MSG_SYSTEM) { Logging.Write("We Received a System Message."); } }; }  
    Finding the list of available Game Events:
    Each version of the game is different here, so this is where you will need to be careful. By that I mean, some versions of the game may have an event type, but a different version may not. Blizzard was not always consistent in their name accross different versions of the game, so please be careful to test against multiple versions of the game. 
     Open DotPeek  Search for "LuaEventsID" Double Click LuaEventsId in the Assembly Explorer Window. A window will open displaying a list of Events. What do each of these Events mean?
    WoW Event Reference:  http://wowwiki.wikia.com/wiki/Event_API 
    (Reminder! Some of these may be different in different versions of the game.)
     
    Watching For WRobot State Changes
    In addition to in game events, there are also WRobot 'states'. Similar to Game Events, WRobot states are the particular condition that WRobot is in at a specific time. For example, there is a state called 'MillingState', and another called 'Looting' that come out with WRobot. States are managed by the WRobot FiniteStateMachineEvents Engine. When a State occurs/changes/ends/etc, an event is passed to the FiniteStateMachine (pardon my wording here if this is not 100% correct). There are three main events that we can use to manage our States.
    State Events that occur:
    OnBeforeCheckIfNeedToRunState - This can be used to CANCEL an event if specific conditions are met. OnRunState - This can be used to do something just as the State is being started. OnAfterRunState - This can be used to do something just as the State has completed.  
    Example of OnRunState and OnAfterRunState
    In this example we are watching for when WRobot starts the ToTown State and when it finishes it. We create a boolean that is set to true when the state is started, and then set it to false when the State is completed. I recommend adding the initializeToTownWatcher() function in the Initialize function of a plugin, or somewhere where it will only be called once. For example of this, please see my Plugin Template.
    bool goToTown = false; private void initializeToTownWatcher() { robotManager.Events.FiniteStateMachineEvents.OnRunState += (engine, state, cancelable) => { if (state != null && state.DisplayName == "To Town") { goToTown = true; Logging.Write("Going to Town State has been initiated."); } }; robotManager.Events.FiniteStateMachineEvents.OnAfterRunState += (engine, state) => { if (state != null && state.DisplayName == "To Town") { goToTown = false; Logging.Write("We have completed going To Town State."); } }; } Example of OnBeforeCheckIfNeedToRunState
    In this example, we catch the state with the name of To Town and cancel it by setting the passed in cancelable parameter to true.
    private void cancelToTownState() { robotManager.Events.FiniteStateMachineEvents.OnBeforeCheckIfNeedToRunState += (engine, state, cancelable) => { if (state != null && state.DisplayName == "To Town") { Logging.Write("We have cancelled the To Town State"); cancelable.Cancel = true; } }; } Where can I find other WRobot States?
    Each version of the WRobot is different, so some versions of WRobot may have a state type, but a different version may not. Please be careful to test against multiple versions of the game/WRobot. 
    Open DotPeek Expand wManager Module Expand wManager.Wow.Bot.States namespace.  
     
    MORE TBA....
    The above is my attempt at trying to help newcomers to WRobot at writing their own plugins / fight classes / etc. If there are any questions , suggestions, or even  corrections, please do let me know in the comments and I'll be sure to add/update things as they come up!
     
    Thanks,
    - Avvi 
     
  16. Like
    Avvi reacted to Droidz in Intercepting gathering movement with plugin?   
    Hello, do you have try with this events 
    wManager.Events.MovementEvents.OnPulseStuckResolver += delegate(CancelEventArgs cancelable) { }; wManager.Events.MovementEvents.OnSeemStuck += delegate { }; You can try to check status if you want run this code only when you farming
    if (robotManager.Helpful.Logging.Status == "Farming") (you can also read last log)
  17. Like
    Avvi reacted to KnightRyder in Is it safe to use for how many hours?   
  18. Like
    Avvi reacted to Matenia in Nearby Totem?   
    It's not a game object, it's an NPC.
    So check WoWUnits. If you wanna confirm it's yours, try unit.IsMyPet or unit.SummonedBy == ObjectManager.Me.Guid
  19. Like
    Avvi reacted to ScripterQQ in Vampiric Touch cast twice   
    Sorry for bumping, but I was looking for the solution of this problem so I reply here instead of opening another topic.
    The problem with double cast happens to me too, not everytime but let's say 50% of times. I don't know if this can be avoided with changing the fps of the fight class, or other settings. So as other users said (and on other similar topics too), you can implement some C# code to prevent the double cast. But if you don't know about C# code (like me), you can use this simple lua script
    1) Spell Name:
    SpellStopCasting() 2) Conditions:
    LUA script: Lua Script stop = "no" if UnitCastingInfo("player") == "Vampiric Touch" then stop = "yes" end             Return Value Research: yes
                Return Value Var: stop
    Target Buff Casted By Me: Vampiric Touch (true) 3) Set on top right corner:
    Not Spell, is Lua script: true
    Put the spell with an higher priority than Vampiric Touch and you're done.
    Tested and working. Greetings.
     
  20. Haha
    Avvi got a reaction from wlhr in Wow   
    Unfortunately, ALL system processes are suspended when the system goes into sleep mode (with a few exceptions for operating system operations).
  21. Sad
    Avvi reacted to wlhr in Wow   
    can you play world of warcraft when your pc is in sleep mode?
  22. Like
    Avvi reacted to PierreDeRosette in wRotation doesn't work in duels OR against players of the same faction in arena   
    A Topic of the same problem was opened in this link (french)
    A workaround was found to solve this.
    I use this Mix to be almost sure to fight with another player of my faction.
    if (Lua.LuaDoString<bool>("return UnitCanAttack('player', 'target')") || (ObjectManager.Me.InCombatFlagOnly) || ObjectManager.Me.InCombat) Combat = true;  
  23. Like
    Avvi reacted to penumbra in Totown state?   
    Thank you both!
    Avvi I have purchased your plugin, seems to do the trick
  24. Like
    Avvi reacted to Bullybone in Plugins API   
    Thank you very much for your answers! The link was very helpful.
  25. Thanks
    Avvi got a reaction from vanbotter in Avvi's C# Tips & Tricks with Helpful Code Snippets   
    Hi all,
    I figured I'd post some things that I have learned during my time of developing in C#. Perhaps some of this is obvious for some of the more experienced WRobot C# writers, but for me, I had to do a lot of forum searching and experimenting to make progress on any of my work. 
     
    How do I get started?
    Please see this post by @Droidz
     
     
    How can I see what Functions are available to me in the WRobot API?
    I recommend using some sort of decompiler in order to see what functions are available in the WRobot API. That is, use something such as dotPeek from jetbrains. See this URL: https://www.jetbrains.com/decompiler/ . Once you have this downloaded, open  the WRobot Binaries located in the (C:\WRobot\Bin) folder in dotPeek. I cannot even begin to explain how many times the recompiled helped me find useful things I could re-use. As a quick tip, I would suggest taking a look at the wManager.wManager.Wow.Helpers functions that are available. Anything listed as public static <variable type>  will be available to use from a Plugin/Profile/Fightclass etc.
     
    What if WRobot doesn't have an available function that I will need?
    WRobot doesn't have everything instantly available, so you may need to resort to using some Lua Functions to get information back from the WoW Client. An example of this that I ran into at some point was getting the number of Character Macros someone has.. Of course this is very specific, but please bear with me for the sake of this example :).
    WoW Lua Reference:  http://wowprogramming.com/docs/api_categories
    Using Lua in C#:
    This snippet will return a List of integers and set the C# variable numberOfMacros  equal to the returned list of the DoString function. To be more specific, it will provide a list of the number of Global account Macros , and the number of Personal Character Macros.
    var numberOfMacros = Lua.LuaDoString<List<int>>("return numCharacterMacros");  
    The below will return just the number Character Macros someone has.  If you need a specific variable from a Lua Function, then do the following: 
    var numPersonalMacros = Lua.LuaDoString<int>("local numAccountMacros, numCharacterMacros = GetNumMacros(); return numCharacterMacros"); The above snippet will set the C# variable numPersonalMacros equal to numCharacterMacros from the lua return value.
    Using a Variable in the Lua.LuaDoString.  The below will return the text body of the macro that has the id of 121.
    var _macroID = 121 string macroBody = Lua.LuaDoString<string>("return GetMacroBody(" + _macroID + ")");  
     
    Executing Lua Code in C#
    This  will leave the party (if the player is in one).
    wManager.Wow.Helpers.Lua.RunMacroText("/run LeaveParty()");  
    What is the difference between Lua.LuaDoString() and RunMacroText()? 
    The difference is in can be understand in how you think about them. Lua.LuaDoString should be seen as a way to retrieve information.. More specifically, the Lua.LuaDoString's purpose is to have a value returned to it, so that you can assign it to a C# Variable. RunMacroText can be used to do something in game. More specifically, RunMacroText should be used when trying to run some sort of in-game script (such as /cast spell).
     
    Plugin Template C#: Plugin-Template.cs
    I have attached a basic plugin template that can be used. In it, I have provided an example of:
    A Basic Implementation of the wManager.Plugin.IPlugin Class (including Settings/Initialize/Dispose) Basic loop that will occur while WRobot is running Settings that can be configured from Plugin Page A Category/Short Description for the Plugin Settings An example of Watching for Game Events. An example of OnRunState / OnAfterRunState for WRobot States Watching For Game Events
    Sometimes you may find that you need to wait for something to occur in game before you can take a specific action. In WoW / WRobot world, these things are called events. Below are two examples of events. The first event will occur when either the Group Loot Settings change, or a Player Enters/Joins the current Party.The second Event will occur when a System Message is received.  I recommend adding this watchForEvents Function in the Initialize function of a plugin, or somewhere where it will only be called once. For an example of this, please see my Plugin Template.
    private void watchForEvents() { EventsLuaWithArgs.OnEventsLuaWithArgs += (LuaEventsId id, List<string> args) => { if (id == wManager.Wow.Enums.LuaEventsId.PARTY_MEMBERS_CHANGED) { Logging.Write("Joined Group or something about the current group was changed."); } if (id == wManager.Wow.Enums.LuaEventsId.CHAT_MSG_SYSTEM) { Logging.Write("We Received a System Message."); } }; }  
    Finding the list of available Game Events:
    Each version of the game is different here, so this is where you will need to be careful. By that I mean, some versions of the game may have an event type, but a different version may not. Blizzard was not always consistent in their name accross different versions of the game, so please be careful to test against multiple versions of the game. 
     Open DotPeek  Search for "LuaEventsID" Double Click LuaEventsId in the Assembly Explorer Window. A window will open displaying a list of Events. What do each of these Events mean?
    WoW Event Reference:  http://wowwiki.wikia.com/wiki/Event_API 
    (Reminder! Some of these may be different in different versions of the game.)
     
    Watching For WRobot State Changes
    In addition to in game events, there are also WRobot 'states'. Similar to Game Events, WRobot states are the particular condition that WRobot is in at a specific time. For example, there is a state called 'MillingState', and another called 'Looting' that come out with WRobot. States are managed by the WRobot FiniteStateMachineEvents Engine. When a State occurs/changes/ends/etc, an event is passed to the FiniteStateMachine (pardon my wording here if this is not 100% correct). There are three main events that we can use to manage our States.
    State Events that occur:
    OnBeforeCheckIfNeedToRunState - This can be used to CANCEL an event if specific conditions are met. OnRunState - This can be used to do something just as the State is being started. OnAfterRunState - This can be used to do something just as the State has completed.  
    Example of OnRunState and OnAfterRunState
    In this example we are watching for when WRobot starts the ToTown State and when it finishes it. We create a boolean that is set to true when the state is started, and then set it to false when the State is completed. I recommend adding the initializeToTownWatcher() function in the Initialize function of a plugin, or somewhere where it will only be called once. For example of this, please see my Plugin Template.
    bool goToTown = false; private void initializeToTownWatcher() { robotManager.Events.FiniteStateMachineEvents.OnRunState += (engine, state, cancelable) => { if (state != null && state.DisplayName == "To Town") { goToTown = true; Logging.Write("Going to Town State has been initiated."); } }; robotManager.Events.FiniteStateMachineEvents.OnAfterRunState += (engine, state) => { if (state != null && state.DisplayName == "To Town") { goToTown = false; Logging.Write("We have completed going To Town State."); } }; } Example of OnBeforeCheckIfNeedToRunState
    In this example, we catch the state with the name of To Town and cancel it by setting the passed in cancelable parameter to true.
    private void cancelToTownState() { robotManager.Events.FiniteStateMachineEvents.OnBeforeCheckIfNeedToRunState += (engine, state, cancelable) => { if (state != null && state.DisplayName == "To Town") { Logging.Write("We have cancelled the To Town State"); cancelable.Cancel = true; } }; } Where can I find other WRobot States?
    Each version of the WRobot is different, so some versions of WRobot may have a state type, but a different version may not. Please be careful to test against multiple versions of the game/WRobot. 
    Open DotPeek Expand wManager Module Expand wManager.Wow.Bot.States namespace.  
     
    MORE TBA....
    The above is my attempt at trying to help newcomers to WRobot at writing their own plugins / fight classes / etc. If there are any questions , suggestions, or even  corrections, please do let me know in the comments and I'll be sure to add/update things as they come up!
     
    Thanks,
    - Avvi 
     
×
×
  • Create New...