Player switch issue

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
slaskfittan
Posts: 6
Joined: Sun May 02, 2010 6:00 am

Player switch issue

#1 Post by slaskfittan » Sun May 02, 2010 3:09 pm

Hi.
I got this problem: I start the bot with one char, and then switch player while the bot is on pause, and then i unpause the bot. but when i level up with the new char the bot doesnt follow the things i put in <onLevelup>. Is it possible to fix that problem?

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Player switch issue

#2 Post by Administrator » Sun May 02, 2010 4:39 pm

You shouldn't be switching characters like that. Press CTRL+L, press UP arrow (it'll type in rom/bot.lua for you), and ENTER. Don't just pause and resume after switching.

slaskfittan
Posts: 6
Joined: Sun May 02, 2010 6:00 am

Re: Player switch issue

#3 Post by slaskfittan » Sun May 02, 2010 4:54 pm

I need that switch tho for some reason. But its ok i fixed it by borrowing some code from the bot.lua. I just have one problem tho, appreciate alot for any help. The bot cant use any pots after the switch, it keeps saying "NOTICE: Item mismatch (~=Simple First Aid Potion); updating item info (don't panic).". If that problem is sovled this is gonna be awesome :).

would also like to take the time to thank for a wonderfull bot program! :>

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Player switch issue

#4 Post by Administrator » Sun May 02, 2010 5:19 pm

Code: Select all

inventory:update();

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

Re: Player switch issue

#5 Post by rock5 » Tue May 11, 2010 4:09 pm

Sorry for resurrecting an old post but I'm having this problem too.

A shame the OP never said how he fixed it.

Anyway, finally got my multi-player scripts going but like the OP said, it doesn't level up skills or open giftbags. I'm not sure yet about pots.

What do I have to do to reset player?
  • 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

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Player switch issue

#6 Post by Administrator » Tue May 11, 2010 6:54 pm

rock5 wrote: What do I have to do to reset player?
You could try completely re-creating the player object after switching.

Code: Select all

	local playerAddress = memoryReadIntPtr(getProc(), addresses.staticbase_char, addresses.charPtr_offset);
	player = CPlayer(playerAddress);
	player:initialize();
	player:update();

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

Re: Player switch issue

#7 Post by rock5 » Tue May 11, 2010 11:00 pm

Administrator wrote:
rock5 wrote: What do I have to do to reset player?
You could try completely re-creating the player object after switching.

Code: Select all

	local playerAddress = memoryReadIntPtr(getProc(), addresses.staticbase_char, addresses.charPtr_offset);
	player = CPlayer(playerAddress);
	player:initialize();
	player:update();
This didn't work. Still not opening bags and, for some reason, wont attack any mobs. I assume it is some sort of player level issue.

Any other ideas?

Edit: Sorry, it is opening bags. I think it was just confused because the first bag is usually opened when loading the profile. I'll have to do it manually.

But it's still not attacking mobs. If I exit the script and restart it, it works fine so there's nothing wrong with the script..
  • 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

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

Re: Player switch issue

#8 Post by rock5 » Wed May 12, 2010 11:52 pm

I thought of something when I woke this morning. profile settings I'd already changed would still be changed so I need to change them back to the profile settings.

Instead of changing all the settings back what I need is a command that reloads the profile.

I found this. I'll try it.

Code: Select all

settings.loadProfile(load_profile_name);
Assuming load_profile_name hasn't lost it's value, it should work.
  • 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

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

Re: Player switch issue

#9 Post by rock5 » Thu May 13, 2010 2:24 am

Code: Select all

settings.loadProfile(load_profile_name);
Looks like this doesn't work so I tried this;

Code: Select all

settings.loadProfile("myProfileName);
but it says you can't assign another macro to '0'.

Looks like it won't over-write an already loaded profile. Actually it looks like the profile is reset to default before the new one is loaded. So maybe the problem is with the 'settings' variable. Maybe reset the settings before loading the profile?

Is there an easy way to reload the profile or should I just change all the values I've changed back to their original values manually?
  • 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

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Player switch issue

#10 Post by Administrator » Thu May 13, 2010 4:12 am

I just noticed as I was about to post the quick solution to reload all settings that the default settings table was being overwritten.

Find this in settings.lua:

Code: Select all

settings = settings_default;
Change to:

Code: Select all

function table.copy(_other)
	local t = {};
	for i,v in pairs(_other) do
		t[i] = v;
	end

	return t;
end

settings = table.copy(settings_default);

Now, you can use that last line to reset to default settings. Let me know if this works.

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

Re: Player switch issue

#11 Post by rock5 » Thu May 13, 2010 4:56 am

Administrator wrote: Find this in settings.lua:

Code: Select all

settings = settings_default;
Change to:

Code: Select all

function table.copy(_other)
	local t = {};
	for i,v in pairs(_other) do
		t[i] = v;
	end

	return t;
end

settings = table.copy(settings_default);
So after making the above change I use this to reset my profile?

Code: Select all

	local playerAddress = memoryReadIntPtr(getProc(), addresses.staticbase_char, addresses.charPtr_offset);
	player = CPlayer(playerAddress);
	player:initialize();
	player:update();
	settings = table.copy(settings_default);
	settings.loadProfile("MyProfile");
Edit: Looks like not. loadProfile is now a nil value.
  • 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

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Player switch issue

#12 Post by Administrator » Thu May 13, 2010 2:57 pm

Go to line 537 and you will have to add the table.copy() call there, as well. After that, you shouldn't need to explicitly call it in your profile as you are doing. If you do, though, it should be called before recreating the character object.

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

Re: Player switch issue

#13 Post by rock5 » Thu May 13, 2010 3:22 pm

Administrator wrote:Go to line 537 and you will have to add the table.copy() call there, as well. After that, you shouldn't need to explicitly call it in your profile as you are doing. If you do, though, it should be called before recreating the character object.
You've confused me a bit.

Line 537, I'm assuming you are talking about settings.lua. I should put

Code: Select all

settings = table.copy(settings_default);
before?

Code: Select all

settings.profile = settings_default.profile;
What do you mean by "you shouldn't need to explicitly call it in your profile"? Do you mean my waypoint file? Because that is where I was trying to reset the profile.

So are you saying that if I add the line above, I don't have to do anything to reset the profile when I change characters or are you saying I don't have to do one of the commands?

Could you clarify exactly what I need to put in my waypoint file to reset my profile values once the above changes have been made to the settings.lua file?
  • 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

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Player switch issue

#14 Post by Administrator » Thu May 13, 2010 5:13 pm

rock5 wrote:
Line 537, I'm assuming you are talking about settings.lua. I should put

Code: Select all

settings = table.copy(settings_default);
before?

Code: Select all

settings.profile = settings_default.profile;

Code: Select all

	settings.profile = table.copy(settings_default.profile);

What do you mean by "you shouldn't need to explicitly call it in your profile"? Do you mean my waypoint file? Because that is where I was trying to reset the profile.
I mean, you don't need this:

Code: Select all

settings = table.copy(settings_default);
In your waypoint script. Shouldn't, anyways.

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

Re: Player switch issue

#15 Post by rock5 » Fri May 14, 2010 12:36 am

You didn't answer "exactly what I need to put in my waypoint file".

What I did was remove

Code: Select all

settings = table.copy(settings_default);
and

Code: Select all

settings.loadProfile("MyProfile");
from the waypoint file. It didn't attack the mobs (The reason is because the following options were changed in a previous waypoint file TARGET_LEVELDIF_ABOVE and TARGET_LEVELDIF_BELOW and are not being reset to default) .

I tried putting

Code: Select all

settings.loadProfile("MyProfile");
back in but got the "You assigned the key '0' double" error.

Just to remind you what we are trying to do here. We are trying to reset the profile after changing characters in the middle of a waypoint file.

Here is a recap of what I've done so far.
1. I have the following in my waypoint file onLoad event;

Code: Select all

	local playerAddress = memoryReadIntPtr(getProc(), addresses.staticbase_char, addresses.charPtr_offset);
	player = CPlayer(playerAddress);
	player:initialize();
	player:update();
2. I've changed

Code: Select all

settings = settings_default;
to:

Code: Select all

function table.copy(_other)
   local t = {};
   for i,v in pairs(_other) do
      t[i] = v;
   end

   return t;
end

settings = table.copy(settings_default);
3. I've changed

Code: Select all

settings.profile = settings_default.profile;
to:

Code: Select all

settings.profile = table.copy(settings_default.profile);
Set up like this , it is still not attacking the mobs.
  • 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

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Player switch issue

#16 Post by Administrator » Fri May 14, 2010 1:07 am

Code: Select all

	local playerAddress = memoryReadIntPtr(getProc(), addresses.staticbase_char, addresses.charPtr_offset);
	player = CPlayer(playerAddress);
	player:initialize();
	player:update();
	settings.load();
	settings.loadProfile("profilenamehere");
This should do it. Apparently settings.load() also needs to be called to flush the old key data out.

I'm also going to add a new function to the player class to do the first 4 lines for you. I just committed this. In player.lua:

Code: Select all

function CPlayer.new()
	local playerAddress = memoryReadIntPtr(getProc(), addresses.staticbase_char, addresses.charPtr_offset);
	local np = CPlayer(playerAddress);
	np:initialize();
	np:update();

	return np;
end

Now, in your profile you can use:

Code: Select all

player = CPlayer.new();
settings.load();
settings.loadProfile("profilenamehere");

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

Re: Player switch issue

#17 Post by rock5 » Fri May 14, 2010 1:44 am

Yep, it's working now. Thanks.
  • 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

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests