event variable

Need help running MacroQuest2? Ask your questions about how to get things to work on your computer.

Moderator: MacroQuest Developers

Bereogar
orc pawn
orc pawn
Posts: 19
Joined: Thu Sep 10, 2009 10:58 am
Location: Spain

event variable

Post by Bereogar » Sun Nov 24, 2013 12:46 am

Using the below code is there a way i can add a variable so I can set ALL sub Events to use this certain variable?

Code: Select all

#event Virtue		"#*##1# tells you, 'virtue'#*#"

Sub Main
/declare x int outer 0

:Start
/if (!${Me.Inventory[17].ID} && !${Me.Inventory[18].ID}) /call Wait4Rez
	/doevents
/goto :Start
/return


Sub Event_Virtue(Line, Sender)
	/target pc ${Sender}
	/if (${Me.CurrentMana}>1200 && ${Target.Distance}<=100 && ${Target.Name.Equal[${Sender}]}) {
		/tell ${Sender} Virtue inc
		/call cast "virtue" gem1 10s
	}
/return
I would like the variable to change the sub Event to:

Code: Select all


Sub Event_Virtue(Line, Sender)
	/target pc ${Sender.Right[-2].Left[-1]}
	/if (${Me.CurrentMana}>1200 && ${Target.Distance}<=100 && ${Target.Name.Equal[${Sender.Right[-2].Left[-1]}]}) {
		/tell ${Sender} Virtue inc
		/call cast "virtue" gem1 10s
	}
/return
So I am changing the target part

User avatar
drkrain
a hill giant
a hill giant
Posts: 215
Joined: Wed Dec 10, 2008 7:03 pm

Re: event variable

Post by drkrain » Sun Nov 24, 2013 1:16 am

Code: Select all

#chat tell

	|------------------------------------------------------------ 
	| REMOVE SPAM LINK
	|------------------------------------------------------------

Sub StripPlayerName(string name) 
	/if (${name.Left[1].Compare[ ]}>=0) /return ${name} 
/return ${name.Right[-2].Left[-1]}

	|------------------------------------------------------------ 
	| CHAT COMMANDS
	|------------------------------------------------------------

Sub Event_Chat(string ChatType,string ChatSender,string ChatText) 
	/if (!${ChatType.Equal[TELL]}) /return
	/call StripPlayerName ${ChatSender}
	/varset ChatSender ${Macro.Return}
	/if (${ChatText.Equal[Virtue]} && ${Me.Book[Virtue]} && ${Me.CurrentMana}>=${Spell[Virtue].Mana}) { 
		/multiline ; /echo Targeting ${ChatSender} for Virtue; /tar ${ChatSender}; /delay 2
		/if (${Target.Type.Equal[PC]} && ${Spawn[${Target} radius ${Spell[Virtue].Range} zradius ${Spell[Virtue].Range} los].ID}) /multiline ; /tell ${ChatSender} Virtue inc; /call cast "virtue" gem1 10s
 		/return 
	}

Bereogar
orc pawn
orc pawn
Posts: 19
Joined: Thu Sep 10, 2009 10:58 am
Location: Spain

Re: event variable

Post by Bereogar » Sun Nov 24, 2013 1:35 am

I really dont want to rename and change everything tho. I have TONS of sub Events and would like to make it so a variable sets the sender in my example. Otherwise I'd have to spend hours and hours to do all of those changes. I appreciate the great code you put up tho.

Bereogar
orc pawn
orc pawn
Posts: 19
Joined: Thu Sep 10, 2009 10:58 am
Location: Spain

Re: event variable

Post by Bereogar » Tue Nov 26, 2013 12:53 pm

Anyone else think of a way to do that easily?

Maskoi

Re: event variable

Post by Maskoi » Tue Nov 26, 2013 1:54 pm

Code: Select all

Sub Event_Virtue(Line, Sender)
    /varset Sender ${Sender.Right[-2].Left[-1]}
    /target pc ${Sender}
    /delay 10 ${Target.ID}={Spawn[pc ${Sender}].ID}
   /if (${Me.CurrentMana}>1200 && ${Target.Distance}<=100 && ${Target.Name.Equal[${Sender}]}) {
      /tell ${Sender} Virtue inc
      /call cast "virtue" gem1 10s
   }
/return