Page 1 of 1

Swapping Classes

Posted: Mon Nov 22, 2010 6:38 pm
by jduartedj
Hi,

I was wondering if has any1 ever done a script to change the class, I was wanting to put that in my project but I could search the forum because "class" and "Change" and too common words and the search just won't take them!

So is there a way to change classes already?

Thanks in advance

Re: Swapping Classes

Posted: Mon Nov 22, 2010 10:09 pm
by rock5
Obviously to change class all you need to do is talk to your house maid and select the right option.

Unfortunately rombot doesn't normally change it's skill set. You could probably reload the profile like you do when you relog although I haven't tried it. Do a search for posts about reloging or changing character.

The good news is, my latest update has me thinking about changing class, so I will be working on an update that will change the skill set and recheck the action keys when it detects a change in class.

Re: Swapping Classes

Posted: Sun Nov 28, 2010 8:51 pm
by raff
I tried a profile change with:

Code: Select all

player = CPlayer.new();
settings.load();
settings.loadProfile("priest");
and it works, but it will use all skills twice, and when it's switch again, it will use skills triple times etc.

Re: Swapping Classes

Posted: Sun Nov 28, 2010 9:32 pm
by rock5
I tested it, you are right.

I don't understand why, but this doesn't work. I would have thought resetting the skills would work.

Code: Select all

player = CPlayer.new();
settings.load();
settings.profile.skills = {}
settings.loadProfile("priest");
The only way I could get it to work was to add the "settings.profile.skills = {}" to the actual part of the loadprofile function in settings.lua that loads the skills.

Add it between these 2 lines around line 670. I'll include it the next time I commit changes.

Code: Select all

	local loadSkills = function(node)
		settings.profile.skills = {}
		local elements = node:getElements();

Re: Swapping Classes

Posted: Sun Nov 28, 2010 11:38 pm
by raff
I have just tested it, and it works now, thank you :)

Re: Swapping Classes

Posted: Mon Nov 29, 2010 10:03 am
by jduartedj
raff wrote:I have just tested it, and it works now, thank you :)
Nice! dudely noted!

Re: Swapping Classes

Posted: Tue Nov 30, 2010 2:17 pm
by raff
I have just noticed, that the <onLevelup> code in the new loaded profile won't work

Re: Swapping Classes

Posted: Tue Nov 30, 2010 6:37 pm
by rock5
raff wrote:I have just noticed, that the <onLevelup> code in the new loaded profile won't work
I have to admit I'm getting a little annoyed with comments like this. "won't work" could mean anything. Did it just not execute the code? Did it do an error? Did it do some other unexpected behavior? What happened when you noticed it didn't work?

I think maybe the administrator need to add a new forum rule for this. He already has one for creating informative titles, he should also have one saying "When reporting a problem, be informative. Was there an error message? What were you doing at the time? What happened? etc. Don't just put 'this isn't working'".

Sorry, raff, for bringing this up on your post.

Re: Swapping Classes

Posted: Wed Dec 01, 2010 12:31 am
by jduartedj
rock5 wrote:
raff wrote:I have just noticed, that the <onLevelup> code in the new loaded profile won't work
I have to admit I'm getting a little annoyed with comments like this. "won't work" could mean anything. Did it just not execute the code? Did it do an error? Did it do some other unexpected behavior? What happened when you noticed it didn't work?

I think maybe the administrator need to add a new forum rule for this. He already has one for creating informative titles, he should also have one saying "When reporting a problem, be informative. Was there an error message? What were you doing at the time? What happened? etc. Don't just put 'this isn't working'".

Sorry, raff, for bringing this up on your post.
Totally agree!

Re: Swapping Classes

Posted: Wed Dec 01, 2010 4:20 am
by raff
Sorry, in my <onLevelup>..</onLevelup> code in the switched profile, I have:

Code: Select all

...
elseif( player.Level == 2 ) then
		elseif( player.Level == 2 ) then
			sendMacro("SetSpellPoint( 2, 2 );");
			sendMacro("SetSpellPoint( 2, 2 );");
			printf("Adding skill points to Urgent Heal\n");
So, I let the bot ran this night, he leveled the first class to level 10, switches the class and levels the second class also to lvl 10, and when I woke up and checked, the second class has not level up the skills. When I load the priest profile manually, it will level up the skills without problems.

But I found out, that you can "pre skill" your skills with SetSpellPoint( 2, 2 ), so I let the bot run this command 10 times on a specific waypoint as a workaround for this. When the priest then level ups, the skill is instantly maxed, without doing anything.

Re: Swapping Classes

Posted: Wed Dec 01, 2010 5:41 am
by rock5
raff wrote:Sorry, in my <onLevelup>..</onLevelup> code in the switched profile, I have:

Code: Select all

...
elseif( player.Level == 2 ) then
		elseif( player.Level == 2 ) then
			sendMacro("SetSpellPoint( 2, 2 );");
			sendMacro("SetSpellPoint( 2, 2 );");
			printf("Adding skill points to Urgent Heal\n");
So, I let the bot ran this night, he leveled the first class to level 10, switches the class and levels the second class also to lvl 10, and when I woke up and checked, the second class has not level up the skills. When I load the priest profile manually, it will level up the skills without problems.

But I found out, that you can "pre skill" your skills with SetSpellPoint( 2, 2 ), so I let the bot run this command 10 times on a specific waypoint as a workaround for this. When the priest then level ups, the skill is instantly maxed, without doing anything.
Are you reloading the profile as part of your script when you change class? That might be the problem because it would have the wrong skill set loaded.

Re: Swapping Classes

Posted: Wed Dec 01, 2010 5:43 am
by botje
any chance of someone making a user function to swap classes?

Botje

Re: Swapping Classes

Posted: Wed Dec 01, 2010 6:58 am
by raff
rock5 wrote: Are you reloading the profile as part of your script when you change class? That might be the problem because it would have the wrong skill set loaded.
ah that could it be

I have a waypointfile that runs to varanas, learns priest, go to logar, and then

Code: Select all

player = CPlayer.new();
settings.load();
settings.profile.skills = {}
settings.loadProfile("priest");
loadPaths("priest_start.xml");
priest_start.xml is:

Code: Select all

<waypoints type="RUN" >
	<!-- # 24 --><waypoint x="-1160" z="-5561">	</waypoint>
	<!-- # 25 --><waypoint x="-1199" z="-5787">	</waypoint>
	<!-- # 26 --><waypoint x="-1165" z="-5906">	</waypoint>
	<!-- # 27 --><waypoint x="-1093" z="-5968">	</waypoint>
	<!-- # 28 --><waypoint x="-934" z="-5977">	</waypoint>
	<!-- # 29 --><waypoint x="-689" z="-5965">	</waypoint>
	<!-- # 30 --><waypoint x="-446" z="-5977">	</waypoint>
	<!-- # 31 --><waypoint x="-437" z="-5963">
		player:target_NPC("Meydo");
if (player.Class2 == CLASS_PRIEST ) then
		sendMacro("ChoiceOption(2);");yrest(3000);
		sendMacro("ExchangeClass(EXCHANGECLASS_SUBCLASS, EXCHANGECLASS_MAINCLASS)");
end
	</waypoint>
...
I will try it with changing class first and then load the new profile, thanks


botje wrote:any chance of someone making a user function to swap classes?

Botje

Code: Select all

sendMacro("ExchangeClass(EXCHANGECLASS_SUBCLASS, EXCHANGECLASS_MAINCLASS)");
this will change the class

Code: Select all

sendMacro("SwapEquipmentItem();");
and this command will swap your equipment

Re: Swapping Classes

Posted: Wed Dec 01, 2010 7:15 am
by rock5
raff wrote:

Code: Select all

player = CPlayer.new();
settings.load();
settings.profile.skills = {}
settings.loadProfile("priest");
loadPaths("priest_start.xml");
Funny, when it came up in a previous post that skills get duplicated when you reload the profile, I tried using "settings.profile.skills = {}" like that but it didn't work. The only way I could make it work was to add it inside the loadprofile function. Are you sure that's working for you?

Re: Swapping Classes

Posted: Wed Dec 01, 2010 9:49 am
by botje
ok, so when we put:

Code: Select all

sendMacro("ExchangeClass(EXCHANGECLASS_SUBCLASS, EXCHANGECLASS_MAINCLASS)");
sendMacro("SwapEquipmentItem();");
in a user function, we can swap both with one easy call?

Botje

Re: Swapping Classes

Posted: Wed Dec 01, 2010 11:04 am
by jduartedj
botje wrote:ok, so when we put:

Code: Select all

sendMacro("ExchangeClass(EXCHANGECLASS_SUBCLASS, EXCHANGECLASS_MAINCLASS)");
sendMacro("SwapEquipmentItem();");
in a user function, we can swap both with one easy call?

Botje
You forgot:

Code: Select all

player:target_NPC("Meydo");
So I guess the answer is Yes, IF you have the correct NPC targeted.

Re: Swapping Classes

Posted: Thu Dec 02, 2010 12:05 pm
by raff
rock5 wrote: Funny, when it came up in a previous post that skills get duplicated when you reload the profile, I tried using "settings.profile.skills = {}" like that but it didn't work. The only way I could make it work was to add it inside the loadprofile function. Are you sure that's working for you?
Yes it seems everthing is working now, my priest_start.xml now looks like this:

Code: Select all

<waypoints type="RUN" >
	<!-- # 1 --><waypoint x="-1160" z="-5561">	</waypoint>
	<!-- # 2 --><waypoint x="-1199" z="-5787">	</waypoint>
	<!-- # 3 --><waypoint x="-1165" z="-5906">	</waypoint>
	<!-- # 4 --><waypoint x="-1093" z="-5968">	</waypoint>
	<!-- # 5 --><waypoint x="-934" z="-5977">	</waypoint>
	<!-- # 6 --><waypoint x="-689" z="-5965">	</waypoint>
	<!-- # 7 --><waypoint x="-446" z="-5977">	</waypoint>
	<!-- # 8 --><waypoint x="-437" z="-5963">
		player:target_NPC("Meydo");
if (player.Class2 == CLASS_PRIEST ) then
		sendMacro("ChoiceOption(2);");yrest(3000);
		sendMacro("ExchangeClass(EXCHANGECLASS_SUBCLASS, EXCHANGECLASS_MAINCLASS)");yrest(3000);
		sendMacro("SwapEquipmentItem();");
end

player = CPlayer.new();
settings.load();
settings.profile.skills = {}
settings.loadProfile("priest");
loadPaths("priest_start.xml");
__WPL:setWaypointIndex(9);
	</waypoint>
	<!-- # 9 --><waypoint x="-467" z="-5991">	</waypoint>
...
and I have just started the bot with a different profile and this path, and now he's fighting with the correct skills, also leveling up a skill is working

Code: Select all

Engaging enemy [Fungus] in combat.
Use 1: SCOUT_VAMPIRE_ARROWS=>   Fungus (111/111)
Use 4: PRIEST_BONE_CHILL   =>   Fungus (111/111)
Use 2: SCOUT_SHOT          =>   Fungus (105/111)
Use 3: PRIEST_RISING_TIDE  =>   Fungus (105/111)
Use 6: PRIEST_REGENERATE   =>   Fungus (68/111)
Use 2: SCOUT_SHOT          =>   Fungus (60/111)
Use 3: PRIEST_RISING_TIDE  =>   Fungus (60/111)
Use 2: SCOUT_SHOT          =>   Fungus (14/111)
Use 3: PRIEST_RISING_TIDE  =>   Fungus (12/111)
Use 5: PRIEST_URGENT_HEAL  =>   Fungus (0/111)
Fight finished. Killed 7 Fungus. (fight #7 / runtime 21521816 minutes)
Durability:99.99
Use MACRO: Looting target in distance 10.
Clearing target.
Equipment update took: 1
Use MACRO: Executing RoMScript "SetSpellPoint( 2, 2 );".
Use MACRO: Executing RoMScript "SetSpellPoint( 2, 2 );".
Adding skill points to Urgent Heal.
Moving to waypoint #5, (-3571, -7559)
Stopping waypoint: Target acquired.
botje wrote:ok, so when we put:

Code: Select all

sendMacro("ExchangeClass(EXCHANGECLASS_SUBCLASS, EXCHANGECLASS_MAINCLASS)");
sendMacro("SwapEquipmentItem();");
in a user function, we can swap both with one easy call?

Botje
you can use this for a function:

Code: Select all

function swapClass(npc, choice)
player:target_NPC(npc);yrest(1000)
sendMacro("ChoiceOption("..choice..");");yrest(1000);
sendMacro("ExchangeClass(EXCHANGECLASS_SUBCLASS, EXCHANGECLASS_MAINCLASS)");
sendMacro("SwapEquipmentItem();");
end
usage:

Code: Select all

swapClass("Meydo", 2)
meydo is the npc name and 2 is choiceoption 2, I dont know if its always the same

Re: Swapping Classes

Posted: Thu Dec 02, 2010 6:28 pm
by jduartedj
raff wrote:
you can use this for a function:

Code: Select all

function swapClass(npc, choice)
player:target_NPC(npc);yrest(1000)
sendMacro("ChoiceOption("..choice..");");yrest(1000);
sendMacro("ExchangeClass(EXCHANGECLASS_SUBCLASS, EXCHANGECLASS_MAINCLASS)");
sendMacro("SwapEquipmentItem();");
end
usage:

Code: Select all

swapClass("Meydo", 2)
meydo is the npc name and 2 is choiceoption 2, I dont know if its always the same
Thx this is perfect. One note though, Indent the code! :d

Code: Select all

function swapClass(npc, choice)
	player:target_NPC(npc);yrest(1000)
	sendMacro("ChoiceOption("..choice..");");yrest(1000);
	sendMacro("ExchangeClass(EXCHANGECLASS_SUBCLASS, EXCHANGECLASS_MAINCLASS)");
	sendMacro("SwapEquipmentItem();");
end