Page 1 of 1

my bot gets his first reputation points :-)

Posted: Fri Jun 19, 2009 9:07 am
by d003232
it is nice to see, that my bot was the winner against one other player. And I not really want to be engaged in such trouble with my bot. Is there a way to detect the target type = 'Player' and skit that from targeting? It is okay to fight them, if the aggro me, but I dont want to do the first strike.

Re: my bot gets his first reputation points :-)

Posted: Fri Jun 19, 2009 9:46 am
by 3cmSailorfuku
d003232 wrote:it is nice to see, that my bot was the winner against one other player. And I not really want to be engaged in such trouble with my bot. Is there a way to detect the target type = 'Player' and skit that from targeting? It is okay to fight them, if the aggro me, but I dont want to do the first strike.
You could create another section like the friend detection and name it blacklist instead, if targetname ~= profilename[] and make it skip the target (Check for inbattle?).
You would have to insert all Monsters that appear in your reach, if you suddenly start targetting a Player it will then skip it and wait till you are in battle with that person.

Flawed Idea of mine though.

Re: my bot gets his first reputation points :-)

Posted: Fri Jun 19, 2009 7:12 pm
by Administrator
It can be done. CPlayer:haveTarget() can be modified to check for this, I suppose. It won't necessarily be 100% effective, but it should be pretty close. You'll have to check if target.Type is PT_PLAYER and self.Battling, then that person is a valid target. If it is a player, and you are not in battle, then it is not a valid target.

Re: my bot gets his first reputation points :-)

Posted: Mon Jun 22, 2009 2:12 pm
by d003232
Administrator wrote:It can be done. CPlayer:haveTarget() can be modified to check for this
I did it with the check in CPlayer:haveTarget()

Code: Select all

if( target.Type == PT_PLAYER  and	-- Player are type == 1
    self.Battling == false ) then	-- if he dont fight us, then
	return false;			-- he is not a valid target
end;
and it seems to work find. thx. I think on check more if we are in battle, could be to check if we also are the target of the PK player. But the more importent part is, that we dont select the PK player and attack it first.

Re: my bot gets his first reputation points :-)

Posted: Mon Jun 22, 2009 5:34 pm
by Administrator
You can check the PKers target and see if it is you. This is done like this:

Code: Select all

if( target.TargetPtr == self.TargetPtr ) then
  -- he is targeting us
end

Re: my bot gets his first reputation points :-)

Posted: Mon Jun 22, 2009 8:30 pm
by d003232
That's my additional code now within 'function CPlayer:haveTarget()'. Seems to work very well

Code: Select all

if( target.Type == PT_PLAYER ) then		-- Player are type == 1
	if ( self.Battling == false ) then	-- if we don't have aggro then
		return false;			-- he is not a valid target
	end;

	if( self.Battling == true  and			-- we have aggro
	    target.TargetPtr ~= self.Address ) then	-- but not from the PK player
		return false;			
	end;
end;
I placed it directly after

Code: Select all

		if( target == nil ) then
			return false;
		end;