My little helper

Additional botting resources. Addons may be either for the game itself or for the RoM bot.
Forum rules
Only post additional bot resources here. Please do not ask unrelated questions.
Message
Author
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: My little helper

#21 Post by rock5 » Sat Jan 15, 2011 10:38 pm

jduartedj wrote:rock5 shouldn't this thread be moved to addons?
Yes it should.

Moved.
  • 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

j19861986
Posts: 37
Joined: Sun Jan 16, 2011 1:01 am

Re: My little helper

#22 Post by j19861986 » Fri Jan 21, 2011 9:40 am

When the lifepoints gets lower than 20, Assist healer move to target player and do Soul Source
then is this script correct??? (look below)

Code: Select all

			--change HP-settings to your needs
			if (20 > partymember[i].HP/partymember[i].MaxHP*100 and partymember[i].HP/partymember[i].MaxHP*100 > 20) then 
				player:target(partymember[i])
				if ( distance(player.X, player.Z, partymember[i].X, partymember[i].Z) > 100) then 
				player:moveTo(CWaypoint(partymember[i].X, partymember[i].Z), true)
				yrest(300)
				player:cast("PRIEST_SOUL_SOURCE") --change skills to your needs
				yrest(300)
Put code line
Last edited by j19861986 on Fri Jan 21, 2011 10:37 am, edited 1 time in total.

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

Re: My little helper

#23 Post by rock5 » Fri Jan 21, 2011 10:01 am

j19861986 wrote:When the lifepoints gets lower than 20, Assist healer move to target player and do Soul Source
then is this script correct??? (look below)
--change HP-settings to your needs
if (20 > partymember.HP/partymember.MaxHP*100 and partymember.HP/partymember.MaxHP*100 > 20) then
player:target(partymember)
if ( distance(player.X, player.Z, partymember.X, partymember.Z) > 100) then
player:moveTo(CWaypoint(partymember.X, partymember.Z), true)
yrest(300)
player:cast("PRIEST_SOUL_SOURCE") --change skills to your needs
yrest(300)

How can the partymember hp be both below and above 20? I think you just want,

Code: Select all

			if 20 > partymember[i].HP/partymember[i].MaxHP*100 then 
Also it's in the forum rules that, when posting code in a post, that you have to surround it in 'code' tags like I did in the line above.
  • 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

swietlowka
Posts: 316
Joined: Wed Jun 16, 2010 8:16 am

Re: My little helper

#24 Post by swietlowka » Fri Jan 21, 2011 9:44 pm

JackBlonder wrote:Short solution without buff communication

Code: Select all

		lootBodies()
		yrest(100)
		
		partyleader:update()
		if ( distance(player.X, player.Z, partyleader.X, partyleader.Z) > 200) then
				player:moveTo(CWaypoint(partyleader.X, partyleader.Z), true)
		end
		RoMScript("FollowUnit('party1');");
The buff communication is a nice idea though.
looking at this it seems ok, but hey, theres no partyleader so it gives an error ;d or maybe im not getting it well... should go to sleep about4h ago :o

User avatar
jduartedj
Posts: 599
Joined: Sat Dec 19, 2009 12:18 am
Location: Lisbon
Contact:

Re: My little helper

#25 Post by jduartedj » Fri Jan 21, 2011 10:39 pm

I've been working on optimizing this script will post as soon as I have something concrete ;)
Thanks for reading! :D

Some of you might find this useful: RoM-bot Wiki
User Functions Repository (and other useful files): Addon Repo
Latest SVN updates: SVN updates

JackBlonder
Posts: 99
Joined: Sat Dec 18, 2010 6:55 am

Re: My little helper

#26 Post by JackBlonder » Sun Jan 23, 2011 1:53 am

looking at this it seems ok, but hey, theres no partyleader so it gives an error ;d or maybe im not getting it well... should go to sleep about4h ago :o
try to add this at top of the wp-file

Code: Select all

	local partyleaderIndex
		local partyleader
		local partyleaderName
		local partyleaderObj

		partyleaderIndex = RoMScript("GetPartyLeaderIndex()")
		if partyleaderIndex~=nil then
			printf("Found partyleaderIndex: %d \n",partyleaderIndex)
			partyleaderName = RoMScript("UnitName('party"..partyleaderIndex.."')")
			printf("Partyleader: %s \n",partyleaderName)
			partyleaderObj = player:findNearestNameOrId(partyleaderName)
			partyleader = CPawn(partyleaderObj.Address)
		end

sdude13
Posts: 76
Joined: Thu Aug 19, 2010 9:36 am

Re: My little helper

#27 Post by sdude13 » Tue Jan 25, 2011 10:25 am

I'm trying to change this script to merge with some rbassist functions.

I think I read it is not possible on some posts, but don't find a conrete answer for:
1. Is it possible to target a player not in your group/raid.
2. Can we get the HP of a targeted player (not in our group/raid)

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

Re: My little helper

#28 Post by rock5 » Tue Jan 25, 2011 10:39 am

sdude13 wrote:I'm trying to change this script to merge with some rbassist functions.

I think I read it is not possible on some posts, but don't find a conrete answer for:
1. Is it possible to target a player not in your group/raid.
2. Can we get the HP of a targeted player (not in our group/raid)
Of course you can, they are pawns like any other.
  • 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

sdude13
Posts: 76
Joined: Thu Aug 19, 2010 9:36 am

Re: My little helper

#29 Post by sdude13 » Tue Jan 25, 2011 12:33 pm

rock5 wrote:
sdude13 wrote:I'm trying to change this script to merge with some rbassist functions.

I think I read it is not possible on some posts, but don't find a conrete answer for:
1. Is it possible to target a player not in your group/raid.
2. Can we get the HP of a targeted player (not in our group/raid)
Of course you can, they are pawns like any other.
As I'm at work i don't have ROM here.

So I guess something like this will get the wanted player XXX into target of the bot:

Code: Select all

 local playertoassist= player:findNearestNameOrId("XXX")
 local targetplayer = CPawn(playertoassist.Address)

for the HP check:
targetplayer:update()
if (80 >targetplayer.HP/targetplayer.MaxHP*100 and targetplayer.HP/targetplayer.MaxHP*100 > 50) then 
				player:target(targetplayer)
		... some more code
end
RoMScript("FollowUnit(targetplayert);");

the player:findNearestNameOrId("XXX") returns NIL...
I don't know how I can get the char follow the other not being in the group

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

Re: My little helper

#30 Post by rock5 » Tue Jan 25, 2011 7:01 pm

sdude13 wrote:the player:findNearestNameOrId("XXX") returns NIL...
Maybe the player is out of range. You would need to check that it's not nil before continuing with the other commands or you will get an error.
sdude13 wrote:I don't know how I can get the char follow the other not being in the group
You could just use player:moveInRange() whenever you get out of range. So you would need to continuously check if you are out of range.
  • 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

swietlowka
Posts: 316
Joined: Wed Jun 16, 2010 8:16 am

Re: My little helper

#31 Post by swietlowka » Wed Jan 26, 2011 6:03 am

rock5 wrote:
sdude13 wrote:the player:findNearestNameOrId("XXX") returns NIL...
Maybe the player is out of range. You would need to check that it's not nil before continuing with the other commands or you will get an error.
sdude13 wrote:I don't know how I can get the char follow the other not being in the group
You could just use player:moveInRange() whenever you get out of range. So you would need to continuously check if you are out of range.

if u check if player:findNearestNameOrId("XXX") is nil and it gets true i'd add a loop to constantly check for it since from my experience it happends that one of the characters gets stuck or dies and when running u can unstuck it later or get from res point when having a good waypoint

sdude13
Posts: 76
Joined: Thu Aug 19, 2010 9:36 am

Re: My little helper

#32 Post by sdude13 » Sun Jan 30, 2011 5:43 am

getting the player to assist seems to work now:

Code: Select all

repeat playertoassist = player:findNearestNameOrId("PlayerB") until playertoassist ~= nil
targetplayer = CPawn(playertoassist.Address)
print (targetplayer)
this prints the adress, but it changes every time (is this good ??)

trying
player:moveInRange(targetplayer)

after those lines (to get the char PLayerA follow the Player B) it quits with:
table: 03156F30
scripts/rom/classes/player.lua:1932: attempt to compare nil with number

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

Re: My little helper

#33 Post by rock5 » Sun Jan 30, 2011 7:38 am

sdude13 wrote:trying
player:moveInRange(targetplayer)

scripts/rom/classes/player.lua:1932: attempt to compare nil with number
You need to specify a range, ie how close you want to get to the target;

Code: Select all

player:moveInRange(targetplayer,100)
  • 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

sdude13
Posts: 76
Joined: Thu Aug 19, 2010 9:36 am

Re: My little helper

#34 Post by sdude13 » Sun Jan 30, 2011 12:47 pm

thx rock5

this seems to work! it follows now on the given distance.

however, when moving for some time
the bot stands still and gives :
"Stopping waypoint: Target acquired before moving.\n",

when moving closer to the char who should follow, it starts following again.

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

Re: My little helper

#35 Post by rock5 » Sun Jan 30, 2011 10:19 pm

If you don't want it to look for targets while moving to the target then use

Code: Select all

player:moveInRange(targetplayer, 100, true)
  • 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

sdude13
Posts: 76
Joined: Thu Aug 19, 2010 9:36 am

Re: My little helper

#36 Post by sdude13 » Mon Jan 31, 2011 7:32 am

thx rock5 again. works as it should.

JackBlonder
Posts: 99
Joined: Sat Dec 18, 2010 6:55 am

Re: My little helper

#37 Post by JackBlonder » Mon Jan 31, 2011 2:48 pm

I'm trying to improve it little bit but I have a weird problem.
Everytime the group is in battle and the leader is moving away from healer, the healer doesn't move in range of the leader.
BUT, when leaving combat the healer moves to his leader
Here's my current code

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
	<onLoad>
		local maxBattleDistToLeader = 50	--Change to your needs 
		local maxDistToLeader = 250	--Change to your needs (for example if you want use lootBodies)
		local partymember={}
		local partymemberName={}
		local partymemberObj={}
		local partyleaderIndex
		local partyleader
		local partyleaderName
		local partyleaderObj
		local noofpartymembers
		local i

		repeat buff_regen=RoMScript("TEXT('Sys500469_name')"); yrest(500) until buff_regen --Get local name of regen buff

		
--********************************************************
--get all partymembers
--********************************************************
	if RoMScript("UnitExists('party1')") then
	
		partyleaderIndex = RoMScript("GetPartyLeaderIndex()")
		if partyleaderIndex~=nil then
			printf("Found partyleaderIndex: %d \n",partyleaderIndex)
			partyleaderName = RoMScript("UnitName('party"..partyleaderIndex.."')")
			printf("Partyleader: %s \n",partyleaderName)
			partyleaderObj = player:findNearestNameOrId(partyleaderName)
			partyleader = CPawn(partyleaderObj.Address)
		end
					
	
		table.insert(partymemberName, RoMScript("UnitName('player')"))

		i = 1
		while not(i >= 7 ) do
			if RoMScript("UnitIsPlayer('party"..i.."');") then
				table.insert(partymemberName,i+1, RoMScript("UnitName('party"..i.."')"))

			end
			i = i + 1

		end
		
		--show table
		for i,v in ipairs(partymemberName) do print(i,v) end

		noofpartymembers = #partymemberName
		--print(noofpartymembers)
		
		for i,v in ipairs(partymemberName) do
			table.insert(partymemberObj,i,player:findNearestNameOrId(partymemberName[i]))
			table.insert(partymember,i,CPawn(partymemberObj[i].Address))
		end
		
		--****DEBUGGING
		--for i,v in ipairs(partymemberObj) do print(i,v) end
		--for i,v in ipairs(partymember) do print(i,v) end

		--*************
	end
	
--********************************************************************
--Look at partymember health and return partymember with lowest health 	
--********************************************************************	
	function get_LeastHpPlayer(party)
		
		local minHpPlayer=player
		local i=1

		for i,v in ipairs(party) do
			party[i]:update()
			if (minHpPlayer.HP/minHpPlayer.MaxHP*100 > party[i].HP/party[i].MaxHP*100) then
				minHpPlayer=party[i]
			end
		end
		
		return minHpPlayer
	end
			
--********************************************************
--Main loop	
--********************************************************
	while(true) do
		player:update()
		partyleader:update()
		if (player.Battling and distance(player.X, player.Z, partyleader.X, partyleader.Z) > maxBattleDistToLeader) then
				player:moveInRange(partyleader, maxBattleDistToLeader, true)
		elseif (not player.Battling and distance(player.X, player.Z, partyleader.X, partyleader.Z) > maxDistToLeader) then
				player:moveInRange(partyleader, maxBattleDistToLeader, true)
		else
			local healTarget
			healTarget = get_LeastHpPlayer(partymember)
			
			if (90 > healTarget.HP/healTarget.MaxHP*100 and 
				healTarget.HP/healTarget.MaxHP*100 > 70 and 
				not healTarget:hasBuff(buff_regen) ) then
					player:target(healTarget)
					player:cast("PRIEST_REGENERATE")
			elseif (70 > healTarget.HP/healTarget.MaxHP*100 and 
					healTarget.HP/healTarget.MaxHP*100 > 50) then
						player:target(healTarget)
						player:cast("PRIEST_URGENT_HEAL")
			elseif (50 > healTarget.HP/healTarget.MaxHP*100) then
						player:target(healTarget)
						player:cast("PRIEST_HEAL")
			end
		end
		yrest(1000)
	end

	</onLoad>
</waypoints>
Anyone has a good idea on this?

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

Re: My little helper

#38 Post by rock5 » Mon Jan 31, 2011 7:08 pm

It's pretty clear, the first thing you check is if it is in battle and the distance is too far, then move closer. I'm not sure why it wouldn't do it. Maybe it is getting caught up doing something else? I think it's important to see what it's doing when it doesn't follow the leader.
  • 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

JackBlonder
Posts: 99
Joined: Sat Dec 18, 2010 6:55 am

Re: My little helper

#39 Post by JackBlonder » Tue Feb 01, 2011 1:32 am

I'll try to get some more information after work.

[Edit]
Did some testing.
It's definitely stick here while the party is in battle. But it just stands/doesn't move.
I have no idea why.
Is there any distance check (to target or anything else) when player is in battle in rombots routine that hinders the player to move?

Code: Select all

		if (player.Battling and distance(player.X, player.Z, partyleader.X, partyleader.Z) > maxBattleDistToLeader) then
				printf("in battle\n")  --added for debugging
				player:moveInRange(partyleader, maxBattleDistToLeader, true)

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

Re: My little helper

#40 Post by lisa » Sat Mar 26, 2011 3:07 am

Played around with this today for a bit, it doesn't seem to heal while in combat for some reason. Did anyone look to find out why?
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

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 0 guests