Hzqvkr8aTLw4rv 4 Posted August 7, 2017 Share Posted August 7, 2017 Hi! When creating a spell like new Spell("Regrowth", false) it'll get the first rank of the spell. So i thought id list all spellid's and iterate through tem and get the highest one by checking KnownSpell, but it seems to always be returning true. Is this intended behavior? This is kinda related to the Mana issue i faced in another thread. (I've implemented reading DBC files extracted from the client, so i can get all spellinfo available, but now i must know the highest rank (spellid) known to the player) When this starts to look like something somewhat useful i'm thinking that i'll opensource this and make a fightclass (hopefully together with other people) that'll work good for all classes! :) Best Regards Carl Link to comment https://wrobot.eu/forums/topic/6722-spellknownspell-always-returns-true/ Share on other sites More sharing options...
reapler 154 Posted August 7, 2017 Share Posted August 7, 2017 Hello @LilleCarl, i don't think that's the actual behavior of "new Spell("Regrowth", false).Id" to get the first rank and ".KnownSpell" shouldn't return always true. Maybe @Droidz can look into it. On 3.3.5a i have only experienced the second issue. But you may try this: public List<uint> GetKnownSpellIds(string name) { return new Spell(name).Ids.Where(SpellManager.KnowSpell).OrderBy(i => i).Distinct().ToList(); } public uint GetHighestKnownSpell(string name) { return new Spell(name).Ids.Where(SpellManager.KnowSpell).OrderByDescending(i => i).FirstOrDefault(); } Usage: var s = GetKnownSpellIds("Regrowth"); for (var i = 0; i < s.Count; i++) { robotManager.Helpful.Logging.Write("\nId: "+s[i] +" Rank: "+(i+1)); } robotManager.Helpful.Logging.Write("Id: "+GetHighestKnownSpell("Regrowth")); Link to comment https://wrobot.eu/forums/topic/6722-spellknownspell-always-returns-true/#findComment-30494 Share on other sites More sharing options...
Hzqvkr8aTLw4rv 4 Posted August 7, 2017 Author Share Posted August 7, 2017 11 minutes ago, reapler said: Hello @LilleCarl, i don't think that's the actual behavior of "new Spell("Regrowth", false).Id" to get the first rank and ".KnownSpell" shouldn't return always true. Maybe @Droidz can look into it. On 3.3.5a i have only experienced the second issue. But you may try this: public List<uint> GetKnownSpellIds(string name) { return new Spell(name).Ids.Where(SpellManager.KnowSpell).OrderBy(i => i).Distinct().ToList(); } public uint GetHighestKnownSpell(string name) { return new Spell(name).Ids.Where(SpellManager.KnowSpell).OrderByDescending(i => i).FirstOrDefault(); } Usage: var s = GetKnownSpellIds("Regrowth"); for (var i = 0; i < s.Count; i++) { robotManager.Helpful.Logging.Write("\nId: "+s[i] +" Rank: "+(i+1)); } robotManager.Helpful.Logging.Write("Id: "+GetHighestKnownSpell("Regrowth")); Aah thanks, i didn't even know SpellManager.KnowSpell existed, nice snippet there! =) Link to comment https://wrobot.eu/forums/topic/6722-spellknownspell-always-returns-true/#findComment-30495 Share on other sites More sharing options...
Hzqvkr8aTLw4rv 4 Posted August 7, 2017 Author Share Posted August 7, 2017 2.4.3 DBC (fightclass will create DBC folder in bot root)https://mega.nz/#!Fl1nVRyC!w6szGtAhEGUvho1Du5n1ZMB834L28Fg08oFYgOcjU6U FightClass that loads Spell DBC files and a child class to Spell where you easily can access this spelldata from https://github.com/Lillecarl/FightClass1 That's all i've got for now, thanks for your help reapler! :) reapler 1 Link to comment https://wrobot.eu/forums/topic/6722-spellknownspell-always-returns-true/#findComment-30496 Share on other sites More sharing options...
reapler 154 Posted August 7, 2017 Share Posted August 7, 2017 15 minutes ago, LilleCarl said: 2.4.3 DBC (fightclass will create DBC folder in bot root)https://mega.nz/#!Fl1nVRyC!w6szGtAhEGUvho1Du5n1ZMB834L28Fg08oFYgOcjU6U FightClass that loads Spell DBC files and a child class to Spell where you easily can access this spelldata from https://github.com/Lillecarl/FightClass1 That's all i've got for now, thanks for your help reapler! :) It looks excellent Carl. I'm looking forward that this will be added soon to the WRobot's lib ;) Link to comment https://wrobot.eu/forums/topic/6722-spellknownspell-always-returns-true/#findComment-30497 Share on other sites More sharing options...
Matenia 630 Posted August 8, 2017 Share Posted August 8, 2017 I might be too late here, but I use this helper class, that allows me to easily iterate over ranks and break the loop if (highest to lowest) I know a spell or (lowest to highest) I don't know a spell anymore. class RotationSpell { public Spell Spell; private string Name; private int? Rank; public RotationSpell(string name, int? rank = null) { this.Name = name; this.Rank = rank; this.Spell = new Spell(name); } public bool IsUsable() { return Spell.IsSpellUsable; //return Lua.LuaDoString<bool>("usable = (IsUsableSpell(\"" + Name + "\") and true or false)", "usable"); } public bool CanCast() { return Lua.LuaDoString<bool>("return (IsUsableSpell(\"" + FullName() + "\") and GetSpellCooldown(\"" + FullName() + "\") == 0)"); } public float GetCooldown() { string luaString = @" cooldownLeft = 0; local start, duration, enabled = GetSpellCooldown(""{0}""); if enabled == 1 and start > 0 and duration > 0 then cooldownLeft = duration - (GetTime() - start) end"; return Lua.LuaDoString<float>(string.Format(luaString, FullName()), "cooldownLeft"); } public void UpdateRank(int rank) { this.Rank = rank; } public string FullName() { return Rank != null ? (Name + "(Rank " + Rank + ")") : Name; } public bool IsKnown() { return Lua.LuaDoString<bool>("return (GetSpellInfo(\"" + FullName() + "\") ~= nil)"); } } Link to comment https://wrobot.eu/forums/topic/6722-spellknownspell-always-returns-true/#findComment-30521 Share on other sites More sharing options...
Hzqvkr8aTLw4rv 4 Posted August 8, 2017 Author Share Posted August 8, 2017 9 hours ago, Matenia said: I might be too late here, but I use this helper class, that allows me to easily iterate over ranks and break the loop if (highest to lowest) I know a spell or (lowest to highest) I don't know a spell anymore. class RotationSpell { public Spell Spell; private string Name; private int? Rank; public RotationSpell(string name, int? rank = null) { this.Name = name; this.Rank = rank; this.Spell = new Spell(name); } public bool IsUsable() { return Spell.IsSpellUsable; //return Lua.LuaDoString<bool>("usable = (IsUsableSpell(\"" + Name + "\") and true or false)", "usable"); } public bool CanCast() { return Lua.LuaDoString<bool>("return (IsUsableSpell(\"" + FullName() + "\") and GetSpellCooldown(\"" + FullName() + "\") == 0)"); } public float GetCooldown() { string luaString = @" cooldownLeft = 0; local start, duration, enabled = GetSpellCooldown(""{0}""); if enabled == 1 and start > 0 and duration > 0 then cooldownLeft = duration - (GetTime() - start) end"; return Lua.LuaDoString<float>(string.Format(luaString, FullName()), "cooldownLeft"); } public void UpdateRank(int rank) { this.Rank = rank; } public string FullName() { return Rank != null ? (Name + "(Rank " + Rank + ")") : Name; } public bool IsKnown() { return Lua.LuaDoString<bool>("return (GetSpellInfo(\"" + FullName() + "\") ~= nil)"); } } That Lua thingy was useful to know though (How you call Lua) :) Link to comment https://wrobot.eu/forums/topic/6722-spellknownspell-always-returns-true/#findComment-30533 Share on other sites More sharing options...
Hzqvkr8aTLw4rv 4 Posted August 8, 2017 Author Share Posted August 8, 2017 On 8/8/2017 at 0:28 AM, reapler said: It looks excellent Carl. I'm looking forward that this will be added soon to the WRobot's lib ;) Yes it would be really cool if the dbcreader was implemented into wrobot, but the loading was optional (because distributing DBC files isn't very legal iirc) I'm also looking into exporting data about all items (from TBC-DB) into a CSV or smth, and another table that handles "classlevelstats" or whatever it's called. Maybe you can get this with Lua, but my idea is that with this we could implement a way to predict things better (damage to be caused by a spell before it's casted, healing done by a spell). With this one could eliminate "all" (not taking criticals into account probably) overhealing, start popping rogue finishing moves when they're predicted to kill (good to optimize leveling classes). I'm really shit with the actual AI part, since i barely can play WoW. But this could be a fun project! :) Link to comment https://wrobot.eu/forums/topic/6722-spellknownspell-always-returns-true/#findComment-30534 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