Events, /doevents, Sub Events_eventname (parameter) problem

Chatwiththisname

Learning2Code
Joined
Sep 28, 2008
Messages
1,234
Reaction score
54
Points
48
Location
Texas
So I was looking at the wiki Getting Started - Macro Creation - MMOBugs Wiki

I'm having trouble getting something to work correctly as I imagined it would. This does in fact trigger. However, it triggers regardless of what is done/said, it triggers repeatedly, nonstop, until you end the mac and start it again.

Please explain what I am doing wrong as I've never used events before and I've searched for a deeper explaination within the forums and I have been unable to grasp a better understanding of the way #Event works.

As I understand it,
Code:
#Event
is like
Code:
/declare
and Blightfire is the Variable, #*# means any test, be it before or after. Naturally you need a Sub Main, but for the even you need a Sub Event_EventVariableName, which in this case is Blightfire the parameters for the sub routine are line and player. which allegedly line will save the line reference and player would pull the player who said/did it automatically. However when I do ${player} it fails to pull anything but null. and line doesn't seem to give two shits what line the word was, and it spams the commands, thus can't find target NULL repeats over and over again. If I type /who then it pulls from the who list

It's failing badly. Any assistance would be greatly appreciated.

Code:
#Event Blightfire #*# Translocate Blightfire #*#

Sub Main
	:MainLoop
	/doevents
	/goto :MainLoop
/return

Sub Event_Blightfire(line, player)
	/target ${player}
	/delay 5
	/if (${Target.ID} || ${Target.LineOfSight}) {
		/cast "Translocate: Blightfire Moors"
	} 
	/return
/end
 
Per bot.mac (i cut out what you don't need):
Code:
#event CastSpell                "#1# tells the group#*#, '#2# on #3#'"
#event CastSpell                "#1# tells the group#*#, '#2#'"
#event CastSpell                  "#1# tells you#*#, '#2# on #3#'"
#event CastSpell                  "#1# tells you#*#, '#2#'"
#event CastSpell                  "#1# told you, '#2#'"
#event CastSpell                "#1# told you, '#2# on #3#'"

Code:
Sub Event_CastSpell(string line,string ChatSender,string SName,string TName)
/if (!${Defined[ChatSenderHold ]}) /declare ChatSenderHold string outer
/varset ChatSenderHold ${ChatSender}
 /if (${ChatSender.Left[1].Compare[ ]} < 0) /varset ChatSenderHold ${ChatSender.Right[-2].Left[-1]}
/declare casttype string local NULL
/if (${Me.Book[${SName}]}) /varset casttype gem1
/if (${Me.AltAbilityReady[${SName}]}) /varset casttype alt
/if (${FindItem[${SName}].ItemSlot}) /varset casttype item

    /if (!${line.Find[ on ]}) {
                /if (${SpawnCount[pc ${ChatSenderHold}]}) {
            /squelch /tar id ${Spawn[pc ${ChatSenderHold}].ID}
            /call Cast "${SName}" "casttype"
            }
                /if (!${SpawnCount[pc ${ChatSenderHold}]}) {
            /squelch /tar id ${Spawn[${ChatSenderHold}].ID}
            /call Cast "${SName}" "casttype"
            }
    }
    /if (${TName.Length}) {
        /if (${SpawnCount[pc ${TName}]}) {
            /squelch /tar id ${Spawn[pc ${ChatSenderHold}].ID}
            /call Cast "${SName}" "casttype"
            }
                /if (!${SpawnCount[pc ${TName}]}) {
            /squelch /tar id ${Spawn[${ChatSenderHold}].ID}
            /call Cast "${SName}" "casttype"
            }
    }


/return

So now if "Pete tells the group, 'Translocate: Blightfire'" it will check if i have the spell "Translocate: Blightfire," and if i do, cast it via gem1.

If "Pete tells the group, 'Aegolism on chatwiththisname'" it will check if i have the spell aegolism and if so, cast it on chatwiththisname.

make sense?
 
_Partially Redacted_

So now if "Pete tells the group, 'Translocate: Blightfire'" it will check if i have the spell "Translocate: Blightfire," and if i do, cast it via gem1.

If "Pete tells the group, 'Aegolism on chatwiththisname'" it will check if i have the spell aegolism and if so, cast it on chatwiththisname.

make sense?

Ran into a couple of issues with that code. But I understood where it was going. Fixed and am reposting for others.

Note: Must cast the spell exactly as it appears on the gem. Also, I'm apparently missing something as it simply told me "You don't appear to have that spell memorized"

Code:
#event CastSpell                "#1# tells the group#*#, '#2# on #3#'"
#event CastSpell                "#1# tells the group#*#, '#2#'"
#event CastSpell                "#1# tells you#*#, '#2# on #3#'"
#event CastSpell                "#1# tells you#*#, '#2#'"
#event CastSpell                "#1# told you, '#2#'"
#event CastSpell                "#1# told you, '#2# on #3#'"

Sub Main
	:MainLoop
	/doevents
	/goto :MainLoop
/return

Sub Event_CastSpell(string line,string ChatSender,string SName,string TName)
	/if (!${Defined[ChatSenderHold]}) /declare ChatSenderHold string outer
	/varset ChatSenderHold ${ChatSender}
	/echo ${ChatSender} is asking you to cast ${SName} on ${TName}
	/if (${ChatSender.Left[1].Compare[ ]} < 0) /varset ChatSenderHold ${ChatSender.Right[-2].Left[-1]}
	/declare casttype string local NULL
	/if (${Me.Book[${SName}]}) /varset casttype gem1
	/if (${Me.AltAbilityReady[${SName}]}) /varset casttype alt
	/if (${FindItem[${SName}].ItemSlot}) /varset casttype item

    /if (!${line.Find[ on ]}) {
                /if (${SpawnCount[pc ${ChatSenderHold}]}) {
            /squelch /tar id ${Spawn[pc ${ChatSenderHold}].ID}
            /Cast "${SName}" "casttype"
            }
                /if (!${SpawnCount[pc ${ChatSenderHold}]}) {
            /squelch /tar id ${Spawn[${ChatSenderHold}].ID}
            /call Cast "${SName}" "casttype"
            }
    }
    /if (${TName.Length}) {
        /if (${SpawnCount[pc ${TName}]}) {
            /squelch /tar id ${Spawn[pc ${ChatSenderHold}].ID}
            /call Cast "${SName}" "casttype"
            }
                /if (!${SpawnCount[pc ${TName}]}) {
            /squelch /tar id ${Spawn[${ChatSenderHold}].ID}
            /call Cast "${SName}" "casttype"
            }
    }
/return
/end
 
Last edited: