Page 1 of 1

onLevelup curiosity

Posted: Wed Jan 12, 2011 12:00 pm
by lisa
I have noticed that the on onLevelup doesn't register/work if you change class and lvl the second lower class.
I do 1-10 main class and while still in same session the bot doesn't do anything from onLevelup for the 1-10 of the second class.

Code: Select all

		sendMacro("ExchangeClass(EXCHANGECLASS_SUBCLASS, EXCHANGECLASS_MAINCLASS)");
		yrest(1000);
		player:update();
I assume it tracks player lvl and so therefore wouldn't think the character lvled until it hits lvl 11 after the first class hit 10 even though 1-2 is still lvling as such.
Any options/functions to make it reload it's settings? The player:update(); doesn't seem to affect it.

Re: onLevelup curiosity

Posted: Wed Jan 12, 2011 1:24 pm
by Administrator
You shouldn't just be calling player:update(). Do this, instead:

Code: Select all

player = CPlayer.new();
player.level_detect_levelup = player.Level;
I'm actually not sure why player.level_detect_levelup isn't part of CPlayer's constructor. rock5, any idea why this might be?

Re: onLevelup curiosity

Posted: Wed Jan 12, 2011 6:36 pm
by rock5
Administrator wrote:You shouldn't just be calling player:update(). Do this, instead:

Code: Select all

player = CPlayer.new();
player.level_detect_levelup = player.Level;
I'm actually not sure why player.level_detect_levelup isn't part of CPlayer's constructor. rock5, any idea why this might be?
Um... what? I've never seen that variable before. Maybe it's because I've never worked on the levelup code. I've never used it before because i only ever used what you told me to use.

Ideally, though, player:update() should detect class changes and do these automatically. Also reload new skill set and rerun setupmacros(). It's on my todo list but it's a biggish job so I probably won't do it for awhile.

Re: onLevelup curiosity

Posted: Thu Jan 13, 2011 3:44 am
by lisa
It worked for the last character I did, it was already 10/1 when I started bot though. Not sure if it sets the player level after it levels up for first time or when it starts bot. If it's when bot starts then it should be working fine. If it sets the lvl after the first time it levels then it still needs testing. Probably take me an hour to run a fresh char to test it properly.

Running a new char now to do 1-10/1 and see if it works or not.

Code: Select all

		sendMacro("ExchangeClass(EXCHANGECLASS_SUBCLASS, EXCHANGECLASS_MAINCLASS)");
		yrest(1000);

		player = CPlayer.new();
		player.level_detect_levelup = player.Level;
		yrest(1000);

		sendMacro("SwapEquipmentItem();");
		yrest(1000);

		setactionbar();
		setranged();
		yrest(1000);
		checkskilllvl();
		yrest(1000);
		setupMacros();

Re: onLevelup curiosity

Posted: Thu Jan 13, 2011 3:56 am
by rock5
setupMacros() should be one of the first things done after changing class because if the macro isn't set up then any RoMScript or sendMacro commands wont work.

Re: onLevelup curiosity

Posted: Thu Jan 13, 2011 4:06 am
by lisa
well spotted, lol I did have it right after the swap but then added all the other stuff in between without thinking.

Code: Select all

		sendMacro("ExchangeClass(EXCHANGECLASS_SUBCLASS, EXCHANGECLASS_MAINCLASS)");
		yrest(1000);

		setupMacros();
		yrest(1000);

		player = CPlayer.new();
		player.level_detect_levelup = player.Level;

		sendMacro("SwapEquipmentItem();");
		setactionbar();
		setranged();
		checkskilllvl();

Re: onLevelup curiosity

Posted: Thu Jan 13, 2011 6:14 am
by lisa
hmm weird, it does the swap, doesn't set up MACRO though, anything changed in last revision?

the

Code: Select all

		setupMacros();
Used to work fine but now it won't do anything. Might need to try a debug thingy.

Edit:
I think I was just trying to do much at once, I added in more WP and just had a couple things in each WP. Seems to be doing ok now.

Update Edit:

I was trying to do all of it in a function but it seemed to have issues with that, currently I have it setup to do each part in a different waypoint and seems to be working, it works but not as streamlined as I had hoped. Seemed to be an issue with me putting so much together ina function and purhaps the time involved for each task.

The following WP does everything I need to be done, including the reset of the lvl for onlevelup

Code: Select all

	<!-- #7   --><waypoint x="-439" z="-5955">


		player:target_NPC("Meydo");
		sendMacro("ChoiceOption(1);");		yrest(1000); 

		player:target_NPC("Meydo");
		sendMacro("ChoiceOption(4);");		yrest(1000);

		sendMacro("ExchangeClass(EXCHANGECLASS_SUBCLASS, EXCHANGECLASS_MAINCLASS)");
	</waypoint>

	<!-- #8   --><waypoint x="-439" z="-5970">
		setupMacros()
	</waypoint>

	<!-- #9   --><waypoint x="-439" z="-5980">
		sendMacro("SwapEquipmentItem();");
	</waypoint>

	<!-- #10   --><waypoint x="-439" z="-5990">
		setactionbar()
	</waypoint>

	<!-- #11   --><waypoint x="-439" z="-6000">
		setranged()
	</waypoint>

	<!-- #12   --><waypoint x="-439" z="-6015">
		player = CPlayer.new()
		player.level_detect_levelup = player.Level;
	</waypoint>

	<!-- #13   --><waypoint x="-439" z="-6025">
		checkskilllvl()
	</waypoint>

	<!-- #14   --><waypoint x="-439" z="-6035">
		loadPaths("ty16");

	</waypoint>

Re: onLevelup curiosity

Posted: Thu Jan 13, 2011 11:16 am
by Administrator
Put them together again, but put a yrest(1000) wherever you need to take a short break.

Re: onLevelup curiosity

Posted: Thu Jan 13, 2011 11:57 am
by lisa
I had yrest(1000); between each line at one stage, even boosted it to 2000 and was still getting issues of not doing what it should.

Quick question though, the ; at the end, would it affect it much. I see it at the end sometimes and not others. even noticed in settings.lua some code had and next line of similar code didn't.

Re: onLevelup curiosity

Posted: Thu Jan 13, 2011 12:12 pm
by Administrator
No, in Lua, semicolons are optional.

Re: onLevelup curiosity

Posted: Sat Jan 15, 2011 9:26 pm
by lisa
Been testing and trying this quite a bit.

Code: Select all

function changeclass()
	sendMacro("ExchangeClass(EXCHANGECLASS_SUBCLASS, EXCHANGECLASS_MAINCLASS)");
yrest(5000);
		setupMacros()
yrest(2000);
		sendMacro("SwapEquipmentItem();");
yrest(2000);	
		setactionbar()
yrest(2000);	
		setranged()
yrest(2000);
		player = CPlayer.new()
		player.level_detect_levelup = player.Level;
yrest(2000);
		checkskilllvl()
yrest(2000);
end
This will always fail to set up the macro key, always.

If I do

Code: Select all

		player:target_NPC("Meydo");
		sendMacro("ChoiceOption(4);");		yrest(1000);

	sendMacro("ExchangeClass(EXCHANGECLASS_SUBCLASS, EXCHANGECLASS_MAINCLASS)");
yrest(5000);
		setupMacros()
yrest(2000);
again it fails every time to set up macro.

Code: Select all

	sendMacro("ExchangeClass(EXCHANGECLASS_SUBCLASS, EXCHANGECLASS_MAINCLASS)");
yrest(5000);

</waypoint>
	<!-- #7   --><waypoint x="-439" z="-5955">

		setupMacros()
yrest(2000);
works everytime, I can't explain it. Maybe you guys can understand better why it works perfectly in different waypoint tags but in same tags or even in same function won't work.

Re: onLevelup curiosity

Posted: Sat Jan 15, 2011 10:35 pm
by rock5
Maybe something gets updated when moving to another waypoint eg. player:update()?

setupMacro would need player.Class to be correct. Try a 'player:update() after changing class.

Re: onLevelup curiosity

Posted: Sat Jan 15, 2011 10:44 pm
by lisa
Seems I misread admin's first post, thought he said not to use playerupdate but he said I shouldn't just be using it. lol

I'll test it out today.

Re: onLevelup curiosity

Posted: Wed Nov 07, 2012 8:44 pm
by Cindy
How will this work with 3 classes?

Re: onLevelup curiosity

Posted: Wed Nov 07, 2012 9:23 pm
by lisa
No idea, this topic is almost 2 years old now.

Re: onLevelup curiosity

Posted: Wed Nov 07, 2012 9:39 pm
by Cindy
Yep, see, I use "search" ;)