Page 1 of 3

New option idea

Posted: Wed Sep 15, 2010 4:25 am
by jpp
I just thought about possible risk of meeting with GM or having other players trying to caught our bot I realized that may be there is very good method to leave bot for night without any attendance and be sure it is not reported by anyone.
Just one siple question to Admin: Is it possible to detect other players beeing close e.g. in radius of 300 if yes, then just please do add option to stop the bot untill there is someone around! If player is not moving then nobody never asks or worries - does not matten where it stops. If bot is alone then it can do most stupid things - no one will see it.

Re: New option idea

Posted: Wed Sep 15, 2010 5:44 am
by swietlowka
to be honest on the place where i bot theres always ppl (crabs) so it wouldn't work for me, but a simple way to see if ppl are around would be usefull for example i'd make a check that on waypoint # if theres some ppl gor for shop or swithc chanel and if no ppl around go another round :) that would make my bot look more human for sure

Re: New option idea

Posted: Wed Sep 15, 2010 6:41 am
by Administrator
Yes, this is possible. I'm just not entirely sure how it would best be implemented. I suppose the best route would be to continue the current action (if running to a waypoint, continue until you reach it; if fighting, kill any aggressive monsters, etc.) before entering a "resting" state.

This would be disabled by default, of course.

Re: New option idea

Posted: Wed Sep 15, 2010 7:19 am
by swietlowka
just make it possible to check for nearby ppl, and from them we could scirp it to rest on waypoint without a problem imho :)

Re: New option idea

Posted: Wed Sep 15, 2010 3:05 pm
by fred55555
The stop and change channel is a good idea.
You could also call a safe spot waypoint file the character will run to were there is no spawn
Or on detect time to sell/repair the continue

or you could setup al three and setup a random string to select one of them to do on detect

Re: New option idea

Posted: Wed Sep 15, 2010 8:03 pm
by rock5
I think what people choose to do if other players are near by is up to them. What I think is need, as swietlowka said, is just a function that people can run to see if any players are nearby. Maybe with an argument of the range you want to check.

Re: New option idea

Posted: Wed Sep 15, 2010 8:49 pm
by Administrator
Here's an addon for that. Save the file to your userfunctions folder.

Use:

Code: Select all

if( player:isHumanInRange(400) ) then
  -- do something
end

Re: New option idea

Posted: Fri Sep 17, 2010 12:27 am
by redcrux
in the

-- Do Something

part, what option would i have to enable so that the bot would stop moving and stop aquiring targets, but still defend itself if its attacked, kinda like the RUN option but without the running lol

Re: New option idea

Posted: Fri Sep 17, 2010 1:07 pm
by MiesterMan
If that's what you want replace "-- do something" with "player:rest(60);". That way it will rest for 60 seconds only fighting back if attacked and if the person is still there it'll rest for 60 seconds again. Feel free to make it longer, like 300 for 5 minutes. Or if you want it to not move until you get back accept for fighting back against aggros you can use "player:sleep();" which will have your char in rest mode until you resume.

Re: New option idea

Posted: Tue Sep 21, 2010 8:35 am
by jpp
Did it and works perfectly until now.
Used code:

Code: Select all

function pw(_harvest)
   _harvest = _harvest or false;
   if (_harvest) then
      player:harvest();
   end
   restc = 0;
   while ( player:isHumanInRange(400) and restc<5 ) do
      player:rest(60);
      restc = restc + 1;
   end
   return true;
end
so it waits but not forever. Just need to avoid crowded places not to waste too much time.
Every waypoint need to have pw(true); or pw(false); depending if we harvest or not there.
Also did small fix in isHumanInRange:

Code: Select all

	local function isInDist(x1, y1, x2, y2, radius)
		if( x2 >= x1-radius and x2 <= x1+radius and
			y2 >= y1-radius and y2 <= y1+radius ) then
                           return true;
			--if( ((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)) <= radius*radius ) then
			--	return true;
			--else
			--	return false;
			--end
		end

		return false;
	end
that means in this case it does not matter if distance is computed exactly - approx range should be enough and processing time is more decreased.

Re: New option idea

Posted: Sun Jan 20, 2013 9:55 am
by vo2male
Hi! Sorry for reviving an old topic but this is still pretty useful..id just like to ask if someone can update this? it works.. but when i tried my alt to get near to my other character (which are both friends with) the bot still stops.. i thought that this won't stop as long as you are friends with a player which is near you.

Re: New option idea

Posted: Sun Jan 20, 2013 10:09 am
by rock5
I don't see anything about friends.

There is also my countplayers function
http://www.solarstrike.net/phpBB3/viewt ... 781#p36781
but that doesn't consider friends either.

One of them would have to be modified just for you. Although there are probably others that might find it useful too.

Re: New option idea

Posted: Sun Jan 20, 2013 10:31 am
by rock5
I decided it was a useful option so I added it to my function at the above link.

Re: New option idea

Posted: Sun Jan 20, 2013 11:39 am
by vo2male
thanks rock for this.. i got a little idea about it.. so basically what i did is this but i still have to test it.

Code: Select all

function checkcrowd()
		if CountPlayers(300, printnames, ignorefriends) > 1 then
			print("Waiting till it's less crowded")
			repeat
			yrest(5000)
		until 2 > CountPlayers(nil,true) 
	end
end
hmm i think i misinterpreted those arguments..
Arguments:
inrange - The range in which you want to count the players. Optional. If omitted, it will count all players it can detect.
printnames - If true, prints the names of the players. I find this useful if creating a wait loop so I can see how the names change over time while I wait.
ignorefriends - If true, does not include friends in the count. 'Friends' includes names in your profile friends list, party members if in a party and warden pet if you have one.

Code: Select all

if CountPlayers(300, true, true) 
should i put it this way instead?


what does this line mean?

Code: Select all

 until 2 > CountPlayers(nil,true) 
end
can i just add this instead?

Code: Select all

 until 0 == CountPlayers(nil,true) 
end

Re: New option idea

Posted: Sun Jan 20, 2013 1:13 pm
by rock5
vo2male wrote:

Code: Select all

if CountPlayers(300, true, true)

should i put it this way instead?
Correct.
vo2male wrote:what does this line mean?

Code: Select all

 until 2 > CountPlayers(nil,true)
end
The 'until' is the end of the repeat loop. The 'end' is the end of the 'if' statement.

Basically what that code says is, if the number of players is more than 1 then wait until the number of players is less than 2 using a repeat loop.

If you want to wait even when there is only one player then you would use.

Code: Select all

function checkcrowd()
	if CountPlayers(300, nil, true) > 0 then
		print("Waiting till it's less crowded")
		repeat
			yrest(5000)
		until 1 > CountPlayers(300,true,true)
	end
end
Note: I used nil for the second argument in the 'if' statement because I don't want it to print player names until that 'if' statement returns true.
vo2male wrote:can i just add this instead?

Code: Select all

 until 0 == CountPlayers(nil,true)
Well you could use

Code: Select all

		until 0 == CountPlayers(300,true,true)
It's the same thing.

Re: New option idea

Posted: Sun Jan 20, 2013 4:18 pm
by vo2male
i have an error

Code: Select all

0:14am - ...scripts/rom/userfunctions/userfunction_countmobs.lua:38: attempt to
call method 'isFriend' (a nil value)
one more thing, is it right that there should be no spaces b/w these?

Code: Select all

(300,true,true)

Re: New option idea

Posted: Sun Jan 20, 2013 9:45 pm
by rock5
Sorry, 'isFriend' is a new pawn function in RC3. It was an easy way to add a friend check to the userfunction. You could try the RC3 version or wait until I commit it. I should be committing it soon.

Re: New option idea

Posted: Mon Jan 21, 2013 3:38 am
by vo2male
i tried with the RC3 version but still doesnt work

i put my alt there near my bot.. their strangers..and he just keeps going
btw they are both in the same guild..

EDIT***
tried to put my another alt ( different guilds/not friends) does not also work as it should

Re: New option idea

Posted: Mon Jan 21, 2013 4:05 am
by rock5
So were you using this code?

Code: Select all

function checkcrowd()
   if CountPlayers(300, nil, true) > 0 then
      print("Waiting till it's less crowded")
      repeat
         yrest(5000)
      until 1 > CountPlayers(300,true,true)
   end
end
Did you put it in the onload of the waiypoint file? Did you then use 'checkcrowd()' in your waypoints? Did it print any names?

Re: New option idea

Posted: Mon Jan 21, 2013 4:07 am
by vo2male
this is on my onload

Code: Select all

function checkcrowd()
		if CountPlayers(300,true,true) > 1 then
			print("Waiting till it's less crowded")
			repeat
			yrest(3000)
		until 0 == CountPlayers(300,true,true) 
	end
end
this is on my waypoints 1 and 2

Code: Select all

checkcrowd()
it only printed names..but didn't rest