Mod MQ2Cast to find best spell version

A forum for feature requests/discussions and user submitted patches that improve MQ2

Moderator: MacroQuest Developers

dewey2461
Contributing Member
Contributing Member
Posts: 1759
Joined: Sun Apr 17, 2005 1:53 am

Mod MQ2Cast to find best spell version

Post by dewey2461 » Wed Aug 02, 2017 8:57 am

Problem: MQ2Cast requires specific spell ranks to cast.

Solution: Make it do the right thing. If you ask to cast "Ardent Light" but have "Ardent Light Rk. II" ready ...

Huge side effect of this mod, would be to make MQ2Melee holy/down shits a lot easier to maintain since most are written using MQ2Cast and require you to go through all the shits looking for spell versions.

JudgeD
a snow griffon
a snow griffon
Posts: 354
Joined: Sat Aug 18, 2012 8:07 pm

Re: Mod MQ2Cast to find best spell version

Post by JudgeD » Wed Aug 02, 2017 11:34 am

+1

I feel like there's room to improve on the spell rank maintenance. Especially if you box a crew it can be hard to notice you're casting the wrong version of something.

User avatar
warlock45
a grimling bloodguard
a grimling bloodguard
Posts: 881
Joined: Sat Oct 06, 2007 8:32 pm

Re: Mod MQ2Cast to find best spell version

Post by warlock45 » Wed Aug 02, 2017 5:22 pm

It can be an issue when you fall back to silver/FTP and have the spell, but can't cast it.

Though to put it out there for other posters, I have made it a habit to go ahead and make my holy/downshits with /cast "${Spell[SomeSpell].RankName}" for that exact reason. That and when I get time I like to consolidate the "best" set ups between toons of the same class and update all of them to use the same set up (and they of course will have different ranks of X spell lines)

But aye, it would make things much nicer if MQ2Cast itself recognized ranks, if it could also figure out to only use rank1 in the process when needed.

User avatar
MacQ
Macro Author
Macro Author
Posts: 674
Joined: Sat Apr 02, 2005 2:39 pm

Re: Mod MQ2Cast to find best spell version

Post by MacQ » Thu Aug 03, 2017 12:59 pm

I don't use MQ2Cast, so I don't know it well. I use a modified version of SpellCast.inc that does not require the "rank" of a spell. You just call the subroutine with the spell name and the subroutine deals with the rank. If that is not true with MQ2Cast, I can see it can be a hassle.

demonstar55
a snow griffon
a snow griffon
Posts: 314
Joined: Fri Nov 28, 2008 6:31 am

Re: Mod MQ2Cast to find best spell version

Post by demonstar55 » Thu Aug 03, 2017 2:21 pm

/casting "${Spell[foo].SpellRank}" doesn't work?

dewey2461
Contributing Member
Contributing Member
Posts: 1759
Joined: Sun Apr 17, 2005 1:53 am

Re: Mod MQ2Cast to find best spell version

Post by dewey2461 » Thu Aug 03, 2017 7:02 pm

demonstar55 wrote:/casting "${Spell[foo].SpellRank}" doesn't work?
I'm sure that is the correct way to work around the issue. If only everyone wrote all their holyshit/downshits that way.

Having /casting "foo" just work would be a lot easier to maintain - IMHO

SwiftyMUSE
Developer
Developer
Posts: 1205
Joined: Tue Sep 23, 2003 10:52 pm

Re: Mod MQ2Cast to find best spell version

Post by SwiftyMUSE » Thu Aug 03, 2017 9:47 pm

change the SpellBook routine to:

Code: Select all

PSPELL SpellBook(PCHAR ID)
{
	if (PSPELL pSpell = GetSpellByName(ID)) {
		for (DWORD nSpell = 0; nSpell < NUM_BOOK_SLOTS; nSpell++) {
			if (PCHARINFO2 pChar2 = GetCharInfo2()) {
				if (pChar2->SpellBook[nSpell] != 0xFFFFFFFF) {
					if (PSPELL pFoundSpell = GetSpellByID(pChar2->SpellBook[nSpell])) {
						if (pFoundSpell->SpellGroup == pSpell->SpellGroup && !_strnicmp(pSpell->Name, pFoundSpell->Name, strlen(pSpell->Name)))
						{
							return pFoundSpell;
						}
					}
				}
			}
		}
		return pSpell;
	}
	return NULL;
}
PayPal: Donate to SwiftyMUSE
Bitcoin: 1LuQ6YcEAWxF3fm9yWMiro4K582je7364V
Krono: PM me

dont_know_at_all wrote:Gee, if only there was a way to correctly report a crash...

dewey2461
Contributing Member
Contributing Member
Posts: 1759
Joined: Sun Apr 17, 2005 1:53 am

Re: Mod MQ2Cast to find best spell version

Post by dewey2461 » Thu Aug 03, 2017 11:40 pm

Doesn't work for me but its late. I'll check in further tomorrow night.

SwiftyMUSE
Developer
Developer
Posts: 1205
Joined: Tue Sep 23, 2003 10:52 pm

Re: Mod MQ2Cast to find best spell version

Post by SwiftyMUSE » Fri Aug 04, 2017 9:24 am

Give me a few examples. The limited testing I did seemed to work.
PayPal: Donate to SwiftyMUSE
Bitcoin: 1LuQ6YcEAWxF3fm9yWMiro4K582je7364V
Krono: PM me

dont_know_at_all wrote:Gee, if only there was a way to correctly report a crash...

dewey2461
Contributing Member
Contributing Member
Posts: 1759
Joined: Sun Apr 17, 2005 1:53 am

Re: Mod MQ2Cast to find best spell version

Post by dewey2461 » Fri Aug 04, 2017 5:11 pm

User Error 101:

I did not realize ( or had forgotten ) that /cast and /casting are two different things.

/cast must be the core MQ function and /casting is the MQ2Cast version of the function.

So I went ahead and added

Code: Select all

PLUGIN_API VOID InitializePlugin(VOID)
  ...
	AddCommand("/cast", CastCommand);


PLUGIN_API VOID ShutdownPlugin(VOID)
   ...
	RemoveCommand("/casting");
And now /cast is working very well.

Thank you SwiftyMUSE - I'd like to donate a krono to you. How would I go about it?

SwiftyMUSE
Developer
Developer
Posts: 1205
Joined: Tue Sep 23, 2003 10:52 pm

Re: Mod MQ2Cast to find best spell version

Post by SwiftyMUSE » Fri Aug 04, 2017 11:46 pm

You don't need to do that dewey... I have added that to the core code, just wanted someone else to test with MQ2Cast first. It should be included with the release of the next zip.
PayPal: Donate to SwiftyMUSE
Bitcoin: 1LuQ6YcEAWxF3fm9yWMiro4K582je7364V
Krono: PM me

dont_know_at_all wrote:Gee, if only there was a way to correctly report a crash...

User avatar
MacQ
Macro Author
Macro Author
Posts: 674
Joined: Sat Apr 02, 2005 2:39 pm

Re: Mod MQ2Cast to find best spell version

Post by MacQ » Sat Aug 05, 2017 5:00 pm

Swifty,

Are you making a change to /cast in the MQ core?

If so, would that mean /cast "${Spell[${SpellName}].RankName}" would no longer work?

dewey2461
Contributing Member
Contributing Member
Posts: 1759
Joined: Sun Apr 17, 2005 1:53 am

Re: Mod MQ2Cast to find best spell version

Post by dewey2461 » Sat Aug 05, 2017 10:35 pm

Donated a Krono to SwiftyMUSE. Its been a while since I've donated and want to give a small token of appreciation for the changes made to the core compile to make things easier.

SwiftyMUSE
Developer
Developer
Posts: 1205
Joined: Tue Sep 23, 2003 10:52 pm

Re: Mod MQ2Cast to find best spell version

Post by SwiftyMUSE » Sat Aug 05, 2017 11:44 pm

MacQ wrote:Swifty,

Are you making a change to /cast in the MQ core?

If so, would that mean /cast "${Spell[${SpellName}].RankName}" would no longer work?

That will still work, but it should also work with /cast "${Spell[${SpellName}]"
PayPal: Donate to SwiftyMUSE
Bitcoin: 1LuQ6YcEAWxF3fm9yWMiro4K582je7364V
Krono: PM me

dont_know_at_all wrote:Gee, if only there was a way to correctly report a crash...