Page 1 of 1

Param issues with combat text

Posted: Mon Apr 19, 2010 10:25 am
by SentientDETH
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.

Re: Param issues with combat text

Posted: Mon Apr 19, 2010 4:00 pm
by drzoon
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 #*#."

Re: Param issues with combat text

Posted: Mon Apr 19, 2010 4:40 pm
by SentientDETH
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

Re: Param issues with combat text

Posted: Tue Apr 20, 2010 3:20 am
by matadormix
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.

Re: Param issues with combat text

Posted: Tue Apr 20, 2010 7:31 am
by SentientDETH
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 !$.

Re: Param issues with combat text

Posted: Wed Apr 21, 2010 8:24 am
by fearless
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

Re: Param issues with combat text

Posted: Wed Jan 14, 2026 1:32 am
by xyilla