Param issues with combat text

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

Moderator: MacroQuest Developers

SentientDETH
decaying skeleton
decaying skeleton
Posts: 4
Joined: Mon Apr 19, 2010 4:09 am

Param issues with combat text

Post by SentientDETH » Mon Apr 19, 2010 10:25 am

I'm having issues with detecting combat in my macro. It seems to all be stemming from the params in this event.

Code: Select all

#event hit "#1# #2# YOU for #3# points of damage."
It seems to only take the first word of the attacker-name as #1# and lumps all the other info into #2#. Is there a way I could just do:

Code: Select all

#event hit "#1# YOU for #2# points of damage."
and remove the "punches/slashes/pierces" from the string?

This is making my brain hurt. Thanks in advance.

Code: Select all

#event hit "#1# tries to #2# YOU, but misses!"
#event hit "#1# #2# YOU for #3# points of damage."
#event hit "#1# tries to #2# YOU, but YOUR magical skin absorbs the blow!"

	|---getting hit--------------------|
	Sub Event_hit
		/if (${assist}==0) /return
		/if (${fol}==1) {
			/g Canceling follow, Master.  I'm being attacked.
			/varset fol 0
		} 
		/if (${hita}==0) {
			/varset hitarg ${Param1}
			/varset hita 1
			/varset hitb 1
			/target ${hitarg}
			/delay 10
			/if (${sil}==0) /g %t is attacking me, Master
			/varset atktarg ${Param1}
		/doevents
		/return
		}
	/doevents
	/return
Other snippet included for reference... the main thing is I need the mob's name so I can have my character target it.

drzoon
a hill giant
a hill giant
Posts: 239
Joined: Tue May 04, 2004 5:38 pm

Re: Param issues with combat text

Post by drzoon » Mon Apr 19, 2010 4:00 pm

I use the following events in my macro to grab the name of the mob hitting me:

Code: Select all

#event UnderAttack "#1# tries to #*# YOU, but #*#"
#event UnderAttack "#1# bashes YOU for #*#."
#event UnderAttack "#1# crushes YOU for #*#."
#event UnderAttack "#1# hits YOU for #*#."
#event UnderAttack "#1# kicks YOU for #*#."
#event UnderAttack "#1# punches YOU for #*#."
#event UnderAttack "#1# slashes YOU for #*#."

SentientDETH
decaying skeleton
decaying skeleton
Posts: 4
Joined: Mon Apr 19, 2010 4:09 am

Re: Param issues with combat text

Post by SentientDETH » Mon Apr 19, 2010 4:40 pm

I found another workaround, haven't tested it yet, but it should work just fine. Thanks a lot for the reply, though.

Code: Select all

|---Combat-Detect--------------------------|
	|---getting hit--------------------|
	|untested
	Sub Event_hit
		/if (${assist}==0) /return
		/if (${fol}==1) {
			/g Canceling follow.
			/varset fol 0
		} 
		/if (${hita}==0) {
			/keypress esc
			/delay 5
		        /if (${sil}==0) /g %t is attacking me, Master
			/varset hita 1
			/varset hitb 1
			/varset atktarg ${Target}
		/doevents
		/return
		}
	/doevents
	/return

matadormix
a ghoul
a ghoul
Posts: 132
Joined: Sun Dec 14, 2008 8:31 am

Re: Param issues with combat text

Post by matadormix » Tue Apr 20, 2010 3:20 am

Instead of testing a variable against 0 (==0), you could use !${varName} instead. That also fires if the variable is not declared. Just a hint.

SentientDETH
decaying skeleton
decaying skeleton
Posts: 4
Joined: Mon Apr 19, 2010 4:09 am

Re: Param issues with combat text

Post by SentientDETH » Tue Apr 20, 2010 7:31 am

Oh, I know about the isnot operator, it's just much easier to see ==0 when reading a bunch of code, too easy to miss !$.

User avatar
fearless
Not a Psychic
Posts: 2684
Joined: Wed Mar 10, 2004 3:52 pm

Re: Param issues with combat text

Post by fearless » Wed Apr 21, 2010 8:24 am

If you are having problems with data being available in the event, echo out the variables that you are trying to pass.

Code: Select all

#event UnderAttack "#1# tries to #*# YOU, but #*#"
#event UnderAttack "#1# bashes YOU for #*#."
#event UnderAttack "#1# crushes YOU for #*#."
#event UnderAttack "#1# hits YOU for #*#."
#event UnderAttack "#1# kicks YOU for #*#."
#event UnderAttack "#1# punches YOU for #*#."
#event UnderAttack "#1# slashes YOU for #*#."

|notice the declare of the variables passed to the event sub
Sub Event_UnderAttack(string line,string WhoHitMe)
  |This should print out the mob name
  /echo ${WhoHitMe}
  /do some shit with ${WhoHitMe}
/return
To troubleshoot your code, I would suggest starting with

Code: Select all

#event hit "#1# YOU for #2# points of damage."

Sub Event_hit(string line,string WhoHitMe,int DamageTaken)
  |This should print out the mob name
  /echo ${WhoHitMe}
  |This should print out the damage taken
  /echo ${DamageTaken}
  
/return
Reading . . . it's not just for me.

[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
[quote="Ccomp5950"]Fearless showed me the light, you too shall learn.[/quote]