Page 1 of 1

Problems on targeting :/

Posted: Sun Nov 04, 2012 4:04 pm
by dr-nuker
Hello honeypuffs!

Here is what i have:

Code: Select all

        <!-- #  1 --><waypoint x="-3905" z="6153" y="55" tag="notfinished">
        -- the point at which we wait until pumpkin spawn

        local queststate = getQuestStatus("Pumpkin Pranksters")
        if queststate == "complete" then
                __WPL:setDirection(WPT_BACKWARD);
        else
                -- questing starts here
                cprintf(cli.yellow,"We park here and wait for Spooky pumpkin...\n")
                settings.profile.options.HARVEST_DISTANCE=300
                player:update();
                while (true) do
                        yrest(50)
                        --player:target_Object("Spooky Pumpkin");
                        player:findTarget("Spooky Pumpkin"); -- spooky or empty one
                        local target = player:getTarget();
                        target:update();
                        if ((target.id == 116032) or (target.id == 115349)) then -- spooky pumpkin
                        -- found at least one so we can start the farm
                                player:clearTarget();
                                settings.profile.options.HARVEST_DISTANCE=50
                                player:update();
                                yrest(100)
                                break
                        end
                end
                checkdebuff(-3905,6153,55)
                prankster()
        end
        </waypoint>
basically the waypoint lets us stay a a spot in a resting mode. Once a pumpkin spawns it should detect it and go on with all the following waypoints.
But basically it doesnt do it.

The problem is:
There are false pumpkins and real ones. No matter which kind spawns the bot should start but has to target the pumpkin at the correct waypoint not anotherone because then it will crash into walls and look very bottish...

The function checkdebuff() is a dirty code to check if we have panic debuff. If so it will teleport the char abck to the coords as long as panic runs.
Prankster is a small function to click the pumpkins and all. this works... but im lacking the right method to start the script...


any ideas?

br,
nuker

Re: Problems on targeting :/

Posted: Sun Nov 04, 2012 10:03 pm
by lisa
you don't want finTarget()

Code: Select all

function CPlayer:findTarget()
firstly it doesn't use an argument so adding the name to it would do nothing.
secondly that function just basically does a tab keypress and then checks if it targeted anything.

The function you want is

Code: Select all

function CPlayer:findNearestNameOrId(_objtable, ignore, evalFunc)
So you will be looking at something like this

Code: Select all

                        spooky = player:findNearestNameOrId("Spooky Pumpkin")
                        if spooky then
                               player:clearTarget();
                                settings.profile.options.HARVEST_DISTANCE=50
                                player:update();
                                yrest(100)
                                break
                        end


Re: Problems on targeting :/

Posted: Mon Nov 05, 2012 7:23 am
by dr-nuker
I'll give that a try ;)