Stresse 2 Posted January 20, 2020 Share Posted January 20, 2020 Howdy y'all! My C# is finally at the point where I am starting to be able to develop full products (profiles, fightclasses, etc.). I'm working on a fightclass template (which I'll post once functional) that people can adapt for any class they want (I'm developing it for my Disc Priest, so it already has to be able to do some niche stuff). @Smokie gave some great code in this post on how to cast spells on yourself and party members (maybe other players, too, I haven't tested). SpellManager.CastSpellByNameOn("Rejuvenation", p.Name); SpellManager.CastSpellByNameOn("Rejuvenation","PlayerName"); SpellManager.CastSpellByNameOn("Rejuvenation", ObjectManager.Me.Name); "Really any code with a name string will work" That code works fantastically for players! But mobs share names and so require us to use their LuaId, which, to my knowledge, isn't retrievable using Wrobot methods/properties (if I'm wrong, please set me straight). I actually can't even figure out how to get the LuaId using Lua and the only way I've seen anyone attempt to implement this functionality did so (a long time ago, most of the code is unusable, actually). public static bool CastSpell(Spell spell, WoWUnit unit, bool force) { // Handle bullshit units if (unit == null || !unit.IsValid || unit.IsDead || !spell.KnownSpell || !spell.IsSpellUsable) { return false; } // Check If Toon is Wanding if (spell.Name == "Shoot" && IsAutoRepeating("Shoot")) { return true; } // Fuck off if toon is already casting and (force == false) if (ObjectManager.Me.Casting() && !force) return false; // Stop moving if spell needs to be cast if (spell.CastTime > 0) MovementManager.StopMoveTo(false, Usefuls.Latency + 500); // Force cast spell if (force == true) if (force) Lua.LuaDoString("SpellStopCasting();"); // Cast AoE spells by location if (AreaSpells.Contains(spell.Name)) { Lua.LuaDoString("CastSpellByName(\"" + spell.Name + "\")"); ClickOnTerrain.Pulse(unit.Position); } else { // Rely on Auto Self Cast WoWUnit temp = ObjectManager.Target; bool onSelf= unit.Guid == ObjectManager.Me.Guid; // Face unit to cast if (!onSelf) { MovementManager.Face(unit); _disableTargeting= true; TargetUnit(unit); } // Default to self casting SpellManager.CastSpellByNameOn(spell, ObjectManager.Me.Name); // Handle non-self targets if (!onSelf) { if (temp.Guid == 0 || !temp.IsValid) { Lua.LuaDoString("ClearTarget();"); // This clears the current target...which defeats the purpose, yea? } else { TargetUnit(temp); } // Interact.InteractObjectis also given as a possibility, but, as I understand it, that would also change targets _disableTargeting= false; } } return true; } I don't understand the use of Locktargeting and so can't figure out how to remove code rot or whether or not this should actually work as a "Mouseover Cast"- type cast (for classes/situation where focusing on a new WoWUnit would be undesirable but applying a dot or whatever is necessary). Hoping someone can help me figure it out! Link to comment Share on other sites More sharing options...
TheSmokie 242 Posted January 20, 2020 Share Posted January 20, 2020 For that method to work, you need to set Pacific wowunit as unit1, unit 2 etc in your code, I don’t have my laptop on my so I can’t really help but give each wowunit it’s own number and go from there. Ps: I don’t remember you at all, I don’t remember a lot ..... I was drunk a lot more then I thought. Link to comment Share on other sites More sharing options...
Stresse 2 Posted January 20, 2020 Author Share Posted January 20, 2020 Hahaha, it was someone else's topic, I've just been cannibalizing code from all over for a couple months now. "Learning C# By Botting", I'm here to say, should be developed as a teaching technique. Link to comment Share on other sites More sharing options...
Stresse 2 Posted January 20, 2020 Author Share Posted January 20, 2020 7 minutes ago, Smokie said: For that method to work, you need to set Pacific wowunit as unit1, unit 2 etc in your code, I don’t have my laptop on my so I can’t really help but give each wowunitit’s own number and go from there. If I give them designations in my code, don't I run into the same issue (that I can't get their LuaId to use for the CastSpellOn method? Link to comment Share on other sites More sharing options...
Droidz 2737 Posted January 20, 2020 Share Posted January 20, 2020 No tested, but use code like: public static bool CastSpell(Spell spell, WoWUnit unit, bool force) { // Handle bullshit units if (unit == null || !unit.IsValid || unit.IsDead || !spell.KnownSpell || !spell.IsSpellUsable) { return false; } // Check If Toon is Wanding if (spell.Name == "Shoot" && IsAutoRepeating("Shoot")) { return true; } // Fuck off if toon is already casting and (force == false) if (ObjectManager.Me.IsCast && !force) return false; // Stop moving if spell needs to be cast if (spell.CastTime > 0) MovementManager.StopMoveTo(false, Usefuls.Latency + 500); // Force cast spell if (force == true) if (force) Lua.LuaDoString("SpellStopCasting();"); // Cast AoE spells by location if (AreaSpells.Contains(spell.Name)) { Lua.LuaDoString("CastSpellByName(\"" + spell.NameInGame + "\")"); ClickOnTerrain.Pulse(unit.Position); } else { // Face unit to cast if (!unit.IsLocalPlayer) MovementManager.Face(unit); if (unit.IsLocalPlayer || unit.Type == WoWObjectType.Player) SpellManager.CastSpellByNameOn(spell.NameInGame, unit.Name); if (unit.IsMyTarget) SpellManager.CastSpellByNameOn(spell.NameInGame, "target"); else { var old = ObjectManager.Me.MouseOverGuid; ObjectManager.Me.MouseOverGuid = unit.Guid; SpellManager.CastSpellByNameOn(spell.NameInGame, "mouseover"); ObjectManager.Me.MouseOverGuid = old; } } return true; } Stresse 1 Link to comment Share on other sites More sharing options...
Weer36 3 Posted January 30, 2022 Share Posted January 30, 2022 What's the difference between SpellManager.CastSpellByNameOn("Rejuvenation", p.Name); and Interact.InteractGameObject(player.GetBaseAddress); Spell.Launch(); Interact.ClearTarget(); ? Link to comment Share on other sites More sharing options...
Weer36 3 Posted February 1, 2022 Share Posted February 1, 2022 Where did You seen Enumerable in my question? 😄 Link to comment Share on other sites More sharing options...
Weer36 3 Posted February 5, 2022 Share Posted February 5, 2022 So what inside of CastSpellByNameOn ? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now