Error with Events, numerical parses.

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

JP5
a lesser mummy
a lesser mummy
Posts: 70
Joined: Tue Jul 06, 2004 10:32 pm

Error with Events, numerical parses.

Post by JP5 » Sat Aug 14, 2004 6:16 pm

With the following macro, I have problems with:

#event HitSlow "#1# slows down."
Not registering when it occurs.

Also, having problems with the Sub Event_Resist.
The error is as follows:

Failed to parse /if condition '(1=1)', non numerical encountered.
encmsg.mac@140(Event_Resist): /if (${ResistVar}=1) {

I can't see why this happens, because ResistVar is declared an int.
Perhaps when comparing ints, you should use:

/if ${ResistVar}=1

Without ( ) enclosing the conditions.



Any ideas on either of these issues?

Macro follows:

Code: Select all

|--------------------------------------|
|encmsg.mac                            |
|By: JP5                               |
|                                      |
|Usage: /macro encmsg ChatType         |
|                                      |
|Description:                          |
| Announces                            |
| -Resists and the spell resisted      |
| -Casts and the spell being casted    |
| -Spell hits and the spell that hit   |
|                                      |
| Other Notes:                         |
| -Macro ended with /endmacro by user. |
|--------------------------------------|




|Misc Events

#event Resist "Your target resist#*#"
#event CharmWear "Your charm spell has worn off."
#event Interrupted "Your spell is interrupted."

|Slow
#event CastSlow "You begin casting Tepid Deeds."
#event CastSlow "You begin casting Forlorn Deeds."
#event CastSlow "You begin casting Shiftless Deeds."

#event HitSlow "#1# slows down."

|Mez
#event CastMez "You begin casting Entrance."
#event CastMez "You begin casting Bliss of the Nihil."
#event CastMez "You begin casting Bliss."
#event CastMez "You begin casting Sleep."
#event CastMez "You begin casting Word of Morell."
#event CastMez "You begin casting Apathy."
#event CastMez "You begin casting Ancient Eternal Rapture."
#event CastMez "You begin casting Rapture."
#event CastMez "You begin casting Glamour of Kintaz."
#event CastMez "You begin casting Fascination."
#event CastMez "You begin casting Dazzle."
#event CastMez "You begin casting Entracing Lights."
#event CastMez "You begin casting Enthrall."
#event CastMez "You begin casting Mesmerize."

#event HitMez "#1# has been entranced."
#event HitMez "#1# stares at the ground quietly."
#event HitMez "#1#'s jaw falls as they begin to drool."
#event HitMez "#1# falls asleep."
#event HitMez "#1# begins to dream."
#event HitMez "#1# stares off into the distance."
#event HitMez "#1# swoons in raptured bliss."
#event HitMez "#1# has been mesmerized by the Glamour of Kintaz."
#event HitMez "#1# has been fascinated."
#event HitMez "#1# has been mesmerized."
#event HitMez "#1# gawks at the glowing lights."
#event HitMez "#1# has been enthralled."
#event HitMez "#1# has been mesmerized."

|Buffs
#event Quickness "You begin casting Quickness."
#event Alacrity "You begin casting Alacrity."
#event SLTW "You begin casting Swift like the Wind."
#event AQ "You begin casting Aanya's Quickening."
#event WR "You begin casting Wonderous Rapidity."
#event SoV "You begin casting Speed of Vallon."
#event VQ "You begin casting Vallon's Quickening."
#event Celerity "You begin casting Celerity."
#event Clarity "You begin casting Clarity."
#event C2 "You begin casting Clarity II."
#event Clarity "You begin casting Boon of the Clear Mind."
#event KEI "You begin casting Koadic's Endless Intellect."
#event Tranq "You begin casting Tranquility."
#event VoQ "You begin casting Voice of Quellious."
#event Garou "You begin casting Boon of the Garou."
#event Imp "You begin casting Trickster's Augmentation."
#event NDT "You begin casting Night's Dark Terror."








|Main Functions
Sub Main

/if (${Me.Class.Name.NotEqual[Enchanter]}) /endmacro

/if (${Defined[Param0]}) {
	/declare CT string outer
	/varset CT ${Param0}
	/echo Announcing enc messages using /${CT}.
	} else {
	/echo Define a Chat Type.
	/endmacro
	}


/declare ResistVar int outer
/declare ResistLast string outer
/call ResistReset

/call DoEvents


/return






Sub ResistReset
/varset ResistVar 0
/varset ResistLast --
/return





Sub DoEvents
:loop
/doevents
/goto :loop

/return





|MISC events
| 1 is waiting for spell hit or resist, 0 is no current spells.
Sub Event_Resist
/if (${ResistVar}=1) {
	/docommand /${CT} ${ResistLast} resisted.
	/call ResistReset
	/return
	} else {
	/return
	}


Sub Event_Interrupted
/call ResistReset
/return


Sub Event_CharmWear
/docommand /${CT} Charm wore off! Stun Snare Mez Debuff.
/return





| Spell Events

Sub Event_CastSlow
/varset ResistVar 1
/varset ResistLast Slow
/docommand /${CT} Casting: Slow on ${Target.CleanName}.
/return

Sub Event_HitSlow(string Line, string Tar)
/echo HELLO???? Testing ${Tar} should be target that it hit on.
/call ResistReset
/return

Sub Event_CastMez
/varset ResistVar 1
/varset ResistLast Mez
/docommand /${CT} Casting: Mez on ${Target.CleanName}
/return

Sub Event_HitMez(string Line, string Tar)
/call ResistReset
/docommand /${CT} ${Tar} mezzed.
/return





|Buffs
Sub Event_Quickness
/docommand /${CT1} Casting: Quickness on ${Target.CleanName}.
/return

Sub Event_Alacrity
/docommand /${CT1} Casting: Alacrity on ${Target.CleanName}.
/return

Sub Event_SLTW
/docommand /${CT1} Casting: Swift like the Wind on ${Target.CleanName}.
/return

Sub Event_AQ
/docommand /${CT1} Casting: Aanya's Quickening on ${Target.CleanName}.
/return

Sub Event_WR
/docommand /${CT1} Casting: Wonderous Rapidity on ${Target.CleanName}.
/return

Sub Event_SoV
/docommand /${CT1} Casting: Speed of Vallon on ${Target.CleanName}.
/return

Sub Event_VQ
/docommand /${CT1} Casting: Vallon's Quickening on ${Target.CleanName}.
/return

Sub Event_Celerity
/docommand /${CT1} Casting: Celerity on ${Target.CleanName}.
/return

Sub Event_Clarity
/docommand /${CT1} Casting: Clarity on ${Target.CleanName}.
/return

Sub Event_KEI
/docommand /${CT1} Casting: Koadic's Endless Intellect on ${Target.CleanName}.
/return

Sub Event_Tranq
/docommand /${CT1} Casting: Tranquility on ${Target.CleanName}.
/return

Sub Event_VoQ
/docommand /${CT1} Casting: VoQ on ${Target.CleanName}.
/return

Sub Event_Garou
/docommand /${CT1} Casting: Boon of the Garou (werewolf) on ${Target.CleanName}.
/return

Sub Event_Imp
/docommand /${CT1} Casting: Trickster's Augmentation (imp) on ${Target.CleanName}.
/return

Sub Event_NDT
/docommand /${CT1} Casting: Night's Dark Terror (scarecrow) on ${Target.CleanName}.
/return



User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Sat Aug 14, 2004 8:25 pm

When comparing numbers like that you use two =. /if (${MyVar}==1) ...

Don't know why the event doesn't fire. Do the others work?

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Sat Aug 14, 2004 8:52 pm

I don't see anything obviously wrong with HitSlow, perhaps it's just not being parsed in due to some bad syntax (like the if) elsewhere? Try moving the sub higher up and see if it fires.

User avatar
Night Hawk
a grimling bloodguard
a grimling bloodguard
Posts: 590
Joined: Fri Aug 13, 2004 4:56 pm

Post by Night Hawk » Sat Aug 14, 2004 9:15 pm

Don't the events need #*#'s in them?

JP5
a lesser mummy
a lesser mummy
Posts: 70
Joined: Tue Jul 06, 2004 10:32 pm

Post by JP5 » Sat Aug 14, 2004 10:02 pm

Thanks for the tip on ==

As far as #*#, you don't need them before and after. You only need #*# in something like:

#event Missing "You are missing#*#"

Also, all my other events work. I'll try changing the name of the event, making a simpler Sub Event for testing purposes, and adding #*# where nee--... everwhere.

JP5
a lesser mummy
a lesser mummy
Posts: 70
Joined: Tue Jul 06, 2004 10:32 pm

Post by JP5 » Sat Aug 14, 2004 10:23 pm

I changed the event for testing purposes, and it seemed to work, although some funky stuff happened. Once, I got spammed. The other time, it did Sub Event_HitSlow in pairs.

I put: "/echo HitSlow worked" under Sub Event_HitSlow.

When typing /1 blehbleh slows down blehbleh, to initiate the event, MQ2 returned:

[MQ2]HitSlow worked
[MQ2]HitSlow worked

........

not sure why one "slows down" should give me two /echo from MQ2.

Will test some more.

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Sat Aug 14, 2004 11:57 pm

Not sure without seeing the full code..I'm still tempted to say it's something not getting parsed in right.

Also, why don't you collapse all of those casting events that do the same thing into one generic event, and then put a handler in there for the mezzes?

Code: Select all

#event StartCast "You begin casting #1#."
and then something like

Code: Select all

Sub Event_StartCast
/varset MezStrings Entrance Bliss of the Nihil Sleep Word of Morell Apathy Ancient Eternal Rapture Glamour of Kintaz Fascination Dazzle Entrancing Lights Enthrall Mesmerize
if (${MezStrings.Find[${param1}]} {
  |handle mez stuff
} else blah blah blah
You could also walk an array if you're afraid partial-matching the wrong stuff.

JP5
a lesser mummy
a lesser mummy
Posts: 70
Joined: Tue Jul 06, 2004 10:32 pm

Post by JP5 » Sun Aug 15, 2004 4:17 pm

I like the idea of an array. The reason I'd be doing this is for the pure joy of writing and learning new macro coding. =)

I'm curious about:

Code: Select all

/if (${MezStrings.Find[${Param1}]}) {
If this code works, then I'd know this about it. The line will search for Param1 (#1#) in the MezStrings variable.. pretty simple and works well.

Would the same thing work for something like:

Code: Select all

${Spell["Tepid Deeds"].SpellType.Find[Detrimental]}
If Find is as universal as .Equal or .NotEqual for string parsing, you've just showed me a powerful tool =)

Thanks for help.

JP5
a lesser mummy
a lesser mummy
Posts: 70
Joined: Tue Jul 06, 2004 10:32 pm

Post by JP5 » Sun Aug 15, 2004 4:34 pm

Instead of having 20 different events for casting beneficial spells, I could do this:

Code: Select all

Sub Event_StartCast
/if (${Spell[${Param1}].SpellType.Find[Beneficial]}) {
    /docommand /${CT} Casting: ${Param1} on ${Target.CleanName}
    }

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Sun Aug 15, 2004 4:54 pm

Code: Select all

int Find[text] 
 Looks for the given text, gives position (currently NULL if not found)  
Find just searches for [text] in whatever string you use it on. You COULD use it the way you described, but .Equal would do the same thing without the overhead of a text-search routine. Also be aware that Target.CleanName will return the # in front of the names of some "named" NPCs, so if there's a chance of the world at large seeing your message use something like:

Code: Select all

${If[${Target.CleanName.Left[1].Equal[#]},${Target.CleanName.Right[-1]},${Target.CleanName}]}
I got bit by this once when my incoming message was announcing to the world that "#Joebob MacDermit" was hella-pissed and ready for slayage :) Personally I'd call that a bug in CleanName, but what do I know?

JP5
a lesser mummy
a lesser mummy
Posts: 70
Joined: Tue Jul 06, 2004 10:32 pm

Post by JP5 » Sun Aug 15, 2004 5:39 pm

Using your advice I refined the code a little bit. Much simpler. I'm trying to think up a simpler way of doing #event HitMez and #event HitSlow, so I haven't included them in code yet.

Code: Select all

|***************************|
| encmsg.mac version 2.0    |
| by: JP5                   |
|                           |
| Usage:                    |
| /macro encmsg [ChatType]  |
|                           |
| Description:              |
| - Announces mez and slow  |
| - Announces resists and   |
|   the spell resisted.     |
| - Announces buff casts.   |
|                           |
|***************************|

#event StartCast "You begin casting #1#."
#event Resisted "Your target resisted the #1# spell."

Sub Main

/declare CT string outer
/declare LastSpell string outer
/declare ResistVar int outer 0
/declare CastMez[13] string outer
/declare CastBuff[17] string outer
/declare CastSlow[3] string outer

/if (${Defined[Param0]}) {
	/varset CT ${Param0}
	/echo Announcing spells using /${CT}
	} else {
	/echo Define a Chat Type. Ex: /macro encmsg g
	}

/varset CastMez[1] "Entrance"
/varset CastMez[2] "Bliss of the Nihil"
/varset CastMez[3] "Bliss"
/varset CastMez[4] "Sleep"
/varset CastMez[5] "Word of Morell"
/varset CastMez[6] "Apathy"
/varset CastMez[7] "Ancient Eternal Rapture"
/varset CastMez[8] "Rapture"
/varset CastMez[9] "Glamour of Kintaz"
/varset CastMez[10] "Fascination"
/varset CastMez[11] "Dazzle"
/varset CastMez[12] "Entracing Lights"
/varset CastMez[13] "Enthrall"
/varset CastMez[14] "Mesmerize"

/varset CastBuff[1] "Quickness"
/varset CastBuff[2] "Alacrity"
/varset CastBuff[3] "Swift like the Wind"
/varset CastBuff[4] "Aanya's Quickening"
/varset CastBuff[5] "Wonderous Rapidity"
/varset CastBuff[6] "Speed of Vallon"
/varset CastBuff[7] "Vallon's Quickening"
/varset CastBuff[8] "Celerity"
/varset CastBuff[9] "Clarity"
/varset CastBuff[10] "Clarity II"
/varset CastBuff[11] "Boon of the Clear Mind"
/varset CastBuff[12] "Koadic's Endless Intellect"
/varset CastBuff[13] "Tranquility"
/varset CastBuff[14] "Voice of Quellious"
/varset CastBuff[15] "Boon of the Garou"
/varset CastBuff[16] "Trickster's Augmentation"
/varset CastBuff[17] "Night's Dark Terror"

/varset CastSlow[1] "Forlorn Deeds"
/varset CastSlow[2] "Shifltess Deeds"
/varset CastSlow[3] "Tepid Deeds"

/call Reset
/call DoEvents

Sub Reset
/varset LastSpell .
/varset ResistVar 0
/return

Sub DoEvents
:loop
/doevents
/goto :loop

Sub Event_StartCast
| Resets LastSpell and ResistVar at start of cast.
/call Reset

| #1 -- Instructions for CastMez
/if (${CastMez.Find[${Param1}]}) {
	/docommand /${CT} Casting Mezz on ${Target.CleanName}.
	/varset LastSpell Mezz
	/varset ResistVar 1
	}

| #2 -- Instructions for CastBuff
/if (${CastBuff.Find[${Param1}]}) {
	/docommand /${CT} Casting ${Param1} on ${Target.CleanName}.
	/call Reset
	}

| #3 -- Instructions for CastSlow
/if (${CastSlow.Find[${Param1}]}) {
	/docommand /${CT} Casting Slow on ${Target.CleanName}.
	/varset LastSpell Slow
	/varset ResistVar 1
	}
/return

Sub Event_Resisted
/if (${ResistVar}==1) {
	/docommand /${CT} ${LastSpell} Resisted.
	}
/return

JP5
a lesser mummy
a lesser mummy
Posts: 70
Joined: Tue Jul 06, 2004 10:32 pm

Post by JP5 » Sun Aug 15, 2004 5:45 pm

Code: Select all

/if (${Target.CleanName.Find[#]}) {
    /call DoEvents
    }
That would fix it but your slow and mez messages wouldn't be announced.

Edit:
Erm will try that out--didn't see--thanks.
I also remember something about "Arg" when doing some light manual reading that might provide a simpler way to fix the problem.

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Sun Aug 15, 2004 5:53 pm

Hrm, does

Code: Select all

/if (${CastMez.Find[${Param1}]}) { 
Actually work? After reading the FM, I was under the impression that ${somearray} by itself would return null. (fm indicates To String has no return type) and that you'd have to do something like this

Code: Select all

/declare index int local
/declare IfCastMez bool local false
/for index 1 to ${CastMez.Size}
  /if (${CastMez[${index}].Equal[${Param1}]}) /varset IfCastMez true
/next index
to make it work.

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Sun Aug 15, 2004 5:56 pm

That would fix it but your slow and mez messages wouldn't be announced.
Fix what? I'm not sure what you're talking about here. I was just pointing out a way to clean up text strings that might be sent to the outside world. (ie. So people don't see you talking about #somemob and know you're running MQ2)

JP5
a lesser mummy
a lesser mummy
Posts: 70
Joined: Tue Jul 06, 2004 10:32 pm

Post by JP5 » Sun Aug 15, 2004 7:38 pm

Aye, I messed up with arrays.
array

Members

int Dimensions
Number of dimensions this array stores

int Size
Total number of elements this array stores

int Size[n]
Total number of elements stored in the nth dimension of this array

To String
None
Nothing related listed in the MQ2Data part.. just /varset 'ing arrays.

Is there not a way to refer to all the elements of an array?

Like...
if I had

/declare SomeVar[2] string outer
/varset SomeVar[1] lookforthis1
/varset SomeVar[2] lookforthis2

Could I make an if statement cycle through all the array elements individually, without having to type out each array element multiple times in multiple instances of the same /if statement?

I don't want this:

Code: Select all

/if (${SomeVar[1].Equal[somestringoranother]}) {
     do this
     }

/if (${SomeVar[2].Equal[somestringoranother]}) {
        do this
     }
I want something like this:

Code: Select all

/if (${SomeVar[1-2].Equal[somestringoranother]}) {
     do this
      }

Fix What?
Fix having people see the # in MQ2 sent strings.


----------------------------

With the macro running I did

/echo ${CastMez[1]}
[MQ2] "Entrance"

/echo ${CastMez[1sdlfjksdlkjfsdlkfjdlkjfd]}
[MQ2] "Entrance"

And because that's what MQ2 returns now, that's what it's going to return in a macro. so my ${CastMez} and ${CastMez[1-10]} is screwed.

Is the point of an array to minimize the number of variable names you have to think up? Or to organize the data in a way that makes more sense?