updating player position when "pushed" by a mob

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
CNKTHoward
Posts: 32
Joined: Thu Jul 12, 2012 8:31 am

updating player position when "pushed" by a mob

#1 Post by CNKTHoward » Sat Jul 14, 2012 7:26 pm

Hi

I've got another question concerning the API and MM. I have a priest who is supposed to heal the group, but he only enables the healing function on a certain waypoint - so the X, Y and Z position is absolute.
If my priest is being pushed away from my teammates whilst he is in healing mode on the X, Y and Z position and out of range for any healspells, he just stands around and waits for the battle to end (that's how the healing mode is programmed. it gets enabled when the priest reaches the waypoint and if he is batteling (player.batteling()).)

So my question is: How can I update my character's position, so he can adjust his position and run back to the waypoint coordinates or even run to the teammembers until he is in healrange again?

Thx in advance!


edit: sorry for offtopic here, but didn't want to create a new thread. Can I check if a partymember has the buff "xy"? I know of the existance of:

Code: Select all

player:hasBuff("BuffName")
but this refers to my own character, not a partymember. F.e. I want to check, if partymember "char1" has "regeneration" on it, and if not casting regeneration on him.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: updating player position when "pushed" by a mob

#2 Post by lisa » Sat Jul 14, 2012 8:58 pm

pretty hard to give advice on this 1 unless I could see the code at that waypoint.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

CNKTHoward
Posts: 32
Joined: Thu Jul 12, 2012 8:31 am

Re: updating player position when "pushed" by a mob

#3 Post by CNKTHoward » Sun Jul 15, 2012 5:12 am

Waypoint code:

Code: Select all

censored
BossFightHeal():

Code: Select all

censored
Last edited by CNKTHoward on Wed Jul 18, 2012 5:53 am, edited 1 time in total.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: updating player position when "pushed" by a mob

#4 Post by lisa » Sun Jul 15, 2012 5:21 am

That actually looks familiar ;)

Anyway so the issue is you go into a loop and only leave the loop when you leave combat, so in order to keep the character at that exact spot you will need to add moving code into the loop.

You have a player:update() which means the bot knows the characters exact position, it is now just a matter of making the bot move the character to the coords you want.

Since I am guessing this is inside an instance I would concider using teleport, if you don't have the teleport userfunction then you can just use player:moveTo({X=x#,Z=z#},true)
obviously you will need to replace the x# and z# with the coords you want.

I would probably add it after this in the code
if (not player.Battling) then
return
end
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

CNKTHoward
Posts: 32
Joined: Thu Jul 12, 2012 8:31 am

Re: updating player position when "pushed" by a mob

#5 Post by CNKTHoward » Sun Jul 15, 2012 5:29 am

Code: Select all

if (not player.Battling) then
	player:moveTo({X=2282,Z=2418},true)
	return
end	
Hm, that makes my character move back to the WP AFTER the fight. I need him to be in range for healing the other partymembers though.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: updating player position when "pushed" by a mob

#6 Post by lisa » Sun Jul 15, 2012 5:46 am

Code: Select all

if (not player.Battling) then
   return
end
player:moveTo({X=2282,Z=2418},true) 
Ok so you don't want to go back to coords then.
Do you have the teleport userfunction?

untested and just ports to the same spot as other party member, not ideal and I don't know how many party members you have to worry about, if just 1 then porting next to them is probably fine.

Code: Select all

		for i,v in ipairs(partymemberpawn) do
			player:target(partymemberpawn[i])
			player:update()
			partymemberpawn[i]:update()
			partymemberpawn[i]:updateBuffs()
			target = player:getTarget();
			if target.HP/target.MaxHP*100 > 10 then
				if distance(player.X, player.Z, partymemberpawn[i].X, partymemberpawn[i].Z) > 150 then
					teleport(partymemberpawn[i].X,partymemberpawn[i].Z)
				end			
				player:checkSkills(true);
			end
			if (not player.Battling) then return end   
		end
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

CNKTHoward
Posts: 32
Joined: Thu Jul 12, 2012 8:31 am

Re: updating player position when "pushed" by a mob

#7 Post by CNKTHoward » Sun Jul 15, 2012 5:49 am

Thx! I'll try this later. I use the player:moveTo function for now, since I don't have the teleport userfunction.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: updating player position when "pushed" by a mob

#8 Post by lisa » Sun Jul 15, 2012 5:53 am

I edited it to move it to only move if the character needs to heal someone, otherwise it would move every time to them.

just replace
teleport(partymemberpawn.X,partymemberpawn.Z)
with
player:moveTo({X=partymemberpawn.X,Z=partymemberpawn.Z},true)
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

CNKTHoward
Posts: 32
Joined: Thu Jul 12, 2012 8:31 am

Re: updating player position when "pushed" by a mob

#9 Post by CNKTHoward » Sun Jul 15, 2012 3:59 pm

I get this MM error when using the code.
player.lua:2307 attempt to perform arithmetic on field 'Z' (a nil value)

Code: Select all

					if target.HP/target.MaxHP*100 > 10 then
						if distance(player.X, player.Z, partymemberpawn[i].X, partymemberpawn[i].Z) > 150 then
							player:moveTo({partymemberpawn[i].X, partymemberpawn[i].Z}, true)
						end
						player:checkSkills(true);
					end

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: updating player position when "pushed" by a mob

#10 Post by lisa » Sun Jul 15, 2012 7:15 pm

line 2307 has this

Code: Select all

	end
What rombot version are you using?
If current version then why is your player.lua different?

Also the issue is this.
you have
player:moveTo({partymemberpawn.X, partymemberpawn.Z}, true)
I posted this
player:moveTo({X=partymemberpawn.X,Z=partymemberpawn.Z},true)
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

CNKTHoward
Posts: 32
Joined: Thu Jul 12, 2012 8:31 am

Re: updating player position when "pushed" by a mob

#11 Post by CNKTHoward » Tue Jul 17, 2012 6:01 am

What rombot version are you using?
latest
If current version then why is your player.lua different?
It's slightly edited to disable PvPing

that's why line 2307 is

Code: Select all

local angle = math.atan2(waypoint.Z - self.Z, waypoint.X - self.X);
for me.

Since it's a mistake in the table definition

Code: Select all

[color=#FF0000]player:moveTo({partymemberpawn[i].X, partymemberpawn[i].Z}, true)[/color]

Code: Select all

[color=#00FF00]player:moveTo({X=partymemberpawn[i].X,Z=partymemberpawn[i].Z},true)[/color]
there is nothing wrong with the player.lua.

Your correct code of the moveTo call fixed my problem though, so no need for further support.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 23 guests