findBestClickPoint changes

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

findBestClickPoint changes

#1 Post by BlubBlab »

I think it is better to make a spinoff thread for that the other is already very long.
Okay I stated to made a changed version of findBestClickPoint even I don't like it very much and at the end I was forced to review to code again.

So first I changed the header, so I can overwrite with an custom evalFunc :

Code: Select all

function CPawn:findBestClickPoint(aoerange, skillrange, onlyaggro, evalFunc)
	-- Finds best place to click to get most mobs including this pawn.
	self:updateXYZ()

	player:updateXYZ()
	local MobList = {}
	local EPList = {}
	
    if( type(evalFunc) ~= "function" ) then
		--default func
		evalFunc = function (address,pawn)
         	if pawn.Alive and pawn.HP >=1 and pawn.Attackable and pawn.Level > 1 then
				return true
			else
			    return false
			end

		end;
	end
then I have found something strange:

Code: Select all

	-- Check if user wants to bypass this function
	-- Blubblab:c I'dont need that for AndorTraining
--	if settings.profile.options.FORCE_BETTER_AOE_TARGETING == false then
--		return countmobs, self.X, self.Z
--	end
that itself isn't strange but it make the follow code pointless because if I remember correctly if something is nil its also false.

Code: Select all

	if obj ~= nil and obj.Type == PT_MONSTER and (settings.profile.options.FORCE_BETTER_AOE_TARGETING == true or 0.5 > math.abs(obj.Y - self.Y)) 

that or 0.5 > math.abs(obj.Y - self.Y) will never make a difference, because it will be never reached in case if (settings.profile.options.FORCE_BETTER_AOE_TARGETING is nil or false.

Best compromises would be(so you can have on/off/deactivated):

Code: Select all

if settings.profile.options.FORCE_BETTER_AOE_TARGETING~=nil and settings.profile.options.FORCE_BETTER_AOE_TARGETING == false then
		return countmobs, self.X, self.Z
end

I personal would use instead of "0.5 > math.abs(obj.Y - self.Y) "use multiply layers so I can see if their are groups of mobs on the some high level and choose the layer with the most mobs at the end.
Attachments
click.lua
(5.74 KiB) Downloaded 74 times
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: findBestClickPoint changes

#2 Post by rock5 »

Sorry but what exactly are you trying to accomplish with your changes?
  • 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
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: findBestClickPoint changes

#3 Post by BlubBlab »

Like I said for Andor Training I needed a modified version so I can overwrite the attackable flag and I wanted to make sure that I don't hit only a single mop. Thats the reason I did this, by searching the reason why the function only returns mobcount == 0 in my case I reviewed it.

I can only say the function works perfectly fine this version and the older, I'm using it in KS and now in Andor Training with the new version. I know you said it has problems in ramps and between hills but I know in fight() the bot looks that the high difference is not too much.. the rest is a bug of the game

Okay maybe I was hoping you can copy&paste this version in the official bot but if not no problem I will simple but it in the Andor Training Waypoint file.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: findBestClickPoint changes

#4 Post by rock5 »

There is a lot of code that goes into selecting the next mob to attack. At the moment AOE skills will still hit the selected mob. If we introduce your code, if I understand correctly, it would ignore the selected mob and aim the spell at the best group regardless of where it is. I don't see any reason to ignore all that good code that goes into choosing the best target, so I'd rather leave it as it is.
  • 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
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: findBestClickPoint changes

#5 Post by BlubBlab »

Okay thats the reason Its looked for my somehow unfinished at standard it is completely deactivated and when you activated it,its deactivated another part.

Wouldn't it then not the best going through the list an take a look which possible is the best that include the original mop?
Edit: Something like this:

Code: Select all

local function CountMobsInRangeOfCoords(x,z)
		local c = 0
		local foundself = false;
		local list = {}
		for k,mob in ipairs(MobList) do
			if distance(x,z,mob.X,mob.Z) <= aoerange then
				if(mob.Address == self.Address)then
					 foundself = true;
				end
				table.insert(list,k)
				c=c+1
			end
		end
		if( settings.profile.options.FORCE_BETTER_AOE_TARGETING )then
			return c, list
		else
			if(foundself == true)then
				return c, list
			else
				return 0, list
			end
		end
	end
This way all possibilities in which the original isn't in it will be ignored, because it got a zero score.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: findBestClickPoint changes

#6 Post by rock5 »

That's done elsewhere. It's done where it uses that function.

Code: Select all

			if aoerange >= distance(ep1, self) then -- EP doesn't miss primary target(self)
				local tmpcount, tmplist = CountMobsInRangeOfCoords(ep1.X, ep1.Z)
I'm not sure why you are checking FORCE_BETTER_AOE_TARGETING. It already works as intended. I think it is set to have 3 meanings. If set to false then it disables "better AOE targeting". If it's true then it always uses "better AOE targeting. If it's not set then the default behavior is to only use "better AOE targeting" if the mobs are nearly level but not in hilly areas where you would expect unusual behavior if it was used.
  • 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
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: findBestClickPoint changes

#7 Post by BlubBlab »

Okay what I'm saying is that default behavior will never be true, because:
From Reference:
In Lua, both nil and false make a condition false; any other value makes it true.
Otherwise if you compare a nil value it would give a error, so it must be interpreted to something else(false) and it give existence for this construct:

Code: Select all

if(notNilandnotFalse)then
do_something
end
The solution is easy:

Code: Select all

if settings.profile.options.FORCE_BETTER_AOE_TARGETING~=nil and settings.profile.options.FORCE_BETTER_AOE_TARGETING == false then
      return countmobs, self.X, self.Z
end
To round it up its also the behavior I saw in KS even when all mobs are on the some altitude the result is extremely different in compare when I activate settings.profile.options.FORCE_BETTER_AOE_TARGETING = true or more simpler said my observation match's with my logic.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: findBestClickPoint changes

#8 Post by rock5 »

nil and false are not exactly the same. If you say "if not somevariable then", it will only do the following code if somevariable is nil or false, so it treats them the same. But if you use "if somevariable == false then" it will only do the code if somevariable is false, not nil.

The current code says "if settings.profile.options.FORCE_BETTER_AOE_TARGETING == false then". When it's false it just returns pawn:countMobs so it bypasses the better targeting.

Then when it's going through the object list it uses "(settings.profile.options.FORCE_BETTER_AOE_TARGETING == true or 0.5 > math.abs(obj.Y - self.Y))". At this point it can only equal true or nil. What this code means is, if FORCE_BETTER_AOE_TARGETING == true then it will always do the better targeting. Or if FORCE_BETTER_AOE_TARGETING == nil then it will only use better targeting if the Y height difference is less than 0.5, ie. only on a flat area.

So if it's false it bypasses it, if it's true it always does it and if it's nil it only does it if on a flat area.

Maybe if you can describe a particular problem with the option that happens during normal bot usage I could have a look at it. But if the option is working correctly during normal bot usage but you can't get it working with Andors training then I don't see it as a problem with the option.
  • 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