Check other bot's Level after combat?

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

Check other bot's Level after combat?

#1 Post by noobbotter » Fri Sep 07, 2012 8:47 am

I have a question on how to do this. I'm making a Forsaken Abbey automated run where two bot will go in on an honor party. One of the many areas I'm having trouble figuring out is this. After the higher level bot leaves combat, he should check the other bot's level, and if the other bot has reached level 29, then it should break party and load a different waypoint (to prevent the other bot from reaching level 30 and thus not being able to do honor with it's other class). Here's the code I'm trying to use on the profile of the higher level bot that's running the honor party:

Code: Select all

<onLeaveCombat><![CDATA[
		-- Additional Lua code to execute after killing an enemy
		-- *****Check for message from player or level of player so i know whether or not to exit 
		RoMScript("TargetUnit('party2');");
        player:update();
        partner = player:getTarget();
        if( partner ) then
			if target.level == 29 then
				SlashCommand("ILG destroy");
				loadPaths("exitmacro");
			end
		end
	]]></onLeaveCombat>
The error I got said something about targeting a global variable or something (should have wrote it down). Maybe this would work better to have the bot that levels up check his own level during an onLevelup event? Either way, I have trouble getting any code to work in the event handlers on the profiles so I'm not sure if my syntax is way off or what. Any help would be much appreciated.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Check other bot's Level after combat?

#2 Post by rock5 » Fri Sep 07, 2012 8:59 am

I don't see anything that would cause an error.

"target.level" should be "target.Level" but it wouldn't cause an error, it would just not destroy the party.

If, after fixing that, you still get an error then I suggest you copy and paste the error here so we can have a look at it.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

Re: Check other bot's Level after combat?

#3 Post by noobbotter » Fri Sep 07, 2012 10:25 am

Thanks Rock5. Tonight I'll try again and if it errors out, I'll post the error. (at work right now so unfortunately, can't test it)

noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

Re: Check other bot's Level after combat?

#4 Post by noobbotter » Fri Sep 07, 2012 11:07 pm

Rock5,

I decided to remove that part of the code so I could proceed with getting the other parts of my files working. I've got my bots communicating with partychat and it started working good. Now I have this really weird error:

Moving to waypoint #42, (1234, 2906)
Leader Monitor started.
Did not find any crashed game clients.
11:46pm - scripts\rom/bot.lua:581: Error in your profile: onLeaveCombat error: [
string "..."]:5: attempt to index global 'Player' (a nil value)


Please enter the script name to run.
Type in 'exit' (without quotes) to exit.
Script>


This error happens at waypoint 42 of the follower bot (waypoint file FAlowclass.xml) but it only happens when the Leader bot says in
partychat "proceed", which is supposed to tell the following bot to continue moving (this happens at waypoint 55 of FAmainclass.xml.
I can't figure out why there is an onLeaveCombat at that time because it happens even if neither party member is in combat at the time,
and there are no instructions in the onLeaveCombat section of either profile.

Here's the relevant code for those sections:
FAlowclass.xml:

Code: Select all

<!-- # 40 --><waypoint x="1321" z="2909" y="318">	</waypoint>
	<!-- # 41 --><waypoint x="1321" z="2909" y="318">	</waypoint>
	<!-- # 42 --><waypoint x="1234" z="2906" y="318">
		sendpartychat("Im ready")
		eventparty("Leader", "start")
		repeat
			yrest(1000)
			until checkeventparty("Leader", "proceed") 
	</waypoint>
	<!-- # 43 --><waypoint x="1225" z="2972" y="321">
		eventparty("Leader", "stop")
	</waypoint>
	<!-- # 44 --><waypoint x="1219" z="3067" y="323">	</waypoint>
Then here's the section of FAmainclass.xml where the leader is supposed to tell him to proceed, which comes up in party chat just before the MM window gives the error.

Code: Select all

<!-- # 52 --><waypoint x="1254" z="3495" y="445">	</waypoint>
	<!-- # 53 --><waypoint x="1313" z="3512" y="464">	</waypoint>
	<!-- # 54 --><waypoint x="1323" z="3441" y="454">	</waypoint>
	<!-- # 55 --><waypoint x="1390" z="3520" y="475">
		sendpartychat("proceed")
	</waypoint>
	<!-- # 56 --><waypoint x="1532" z="3526" y="487">	</waypoint>
The onLeaveCombat section of both files are default:

Code: Select all

<onLeaveCombat><![CDATA[
		-- Additional Lua code to execute after killing an enemy
	]]></onLeaveCombat>
I can't understand why I get that error at that time. If you need the complete files o figure this out, let me know. Thanks for any help you can provide.

**UPDATE**
I tried removing the onLeaveCombat section completely from both profiles. At first I thought it would work but it did the same error when it got to waypoint 70 and received the proceed command. Not sure what's going on.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Check other bot's Level after combat?

#5 Post by rock5 » Sat Sep 08, 2012 12:41 am

Code: Select all

<onLeaveCombat><![CDATA[
		-- Additional Lua code to execute after killing an enemy
		-- *****Check for message from player or level of player so i know whether or not to exit 
		RoMScript("TargetUnit('party2');");
        player:update();
        partner = player:getTarget();
        if( partner ) then
			if target.level == 29 then
				SlashCommand("ILG destroy");
				loadPaths("exitmacro");
			end
		end
	]]></onLeaveCombat>
Wait. I see the error now. You called the pawn 'partner' but then you used 'target.Level'. It should be 'partner.Level'. target hasn't been assigned any value. So the error you got was probably.

Code: Select all

attempt to index global 'target' (a nil value)
noobbotter wrote:11:46pm - scripts\rom/bot.lua:581: Error in your profile: onLeaveCombat error: [
string "..."]:5: attempt to index global 'Player' (a nil value)
First of all that implies that there is a typo somewhere and it's trying to index 'Player' which is suposed to be 'player' ('trying to index' means it's trying to use 'Player.somevalue' which will only work if Player is a table which it isn't, it's nil).

The error message says there is a problem is in the onleavecombat section but line 581 of bot.lua is about onLevelUp. I'd call that a bug. I'll have to fix it. Anyway, look for the error in the onLeavelUp section of your profile.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

Re: Check other bot's Level after combat?

#6 Post by noobbotter » Sat Sep 08, 2012 8:22 am

Awesome! That target instead of player was the issue. I also corrected the Capital P problem. Seems to be going good now. No I need to work on the ending of my script where it resets party and starts over again, and a few spots in between where it had trouble targeting due to walls in the way. Thanks for the help.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 104 guests