how to script resigning when a NPC is present in zone

04/12/2023 03:47 timtimcharoo#1
Hi all - I've been tinkering with old peacekeeper farming bots and have had some success running them outside of Beetletun.

I recently completed War in Kryta, and with that sometimes Courier Falken appears when zoning into Nebo Terrace. Because his presence changes the spawn pattern, the bot fails the run, and takes a while because it needs to go through a resurrection sequence.

What I'd like to do is add something to the bot script that looks to see if Falken is present maybe 10 seconds after loading into the zone and if he is, resign to restart the loop.

Is there anywhere this code already exists that I could crib from for this purpose or can someone help me understand what functions I could possibly use?

Thanks!
04/12/2023 09:16 nax_gt#2
Hey there! It's great to hear that you've been tinkering with the old peacekeeper farming bots and having some success with them.

Regarding your question, it sounds like you're experiencing some difficulties with Courier Falken appearing when zoning into Nebo Terrace, which is causing the bot to fail its run. It's understandable that this can be frustrating, but I'm happy to help you figure out a solution.

As for adding something to the bot script that looks for Falken's presence, there may be existing code out there that you could use, but I'm not entirely sure. However, one possible solution could be to create a function that checks for Falken's presence using a command like "/target Courier Falken" and then waits for 10 seconds to see if he appears. If he does, the bot can then use the "/resign" command to restart the loop.

On a related note, since you've been doing well with the farming bots, have you considered [Only registered and activated users can see links. Click Here To Register...]them to other players who may be interested in using them? It could be a nice gesture and a way to contribute to the community. Let me know if you have any questions or if there's anything else I can help you with.
04/18/2023 17:23 timtimcharoo#3
Quote:
Originally Posted by nax_gt View Post
Let me know if you have any questions or if there's anything else I can help you with.
I just shot you a DM with a question. I'm almost there, but need an assist.
04/19/2023 17:35 timtimcharoo#4
thought I'd post this question to the masses as well to see if I could get any additional help.

after playing around with scripting, I thought it might make sense to create a function explicitly for checking for Falken. To do that I used this script:

Code:
Func Falken()
    TargetNearestAlly()
	 if  GetNumberOfAlliesInRangeOfAgent(-2,1250) > 0 Then
		Out("Falken Punch!!!")
	    $NoSpawn = $NoSpawn + 1
		GUICtrlSetData($NoSpawnLabel, $NoSpawn)

		Resign()
        Sleep(3000)
		Do
		   Sleep(50)
	    Until GetIsDead(-2) = True

		ReturnToOutpost()
		WaitMapLoading($Beetletun)
	 Else
		$bCanContinue = True
	 EndIf
EndFunc
the good news is that the function works at detecting Falken and resigning. the problem is that I don't think I know the proper way to implement it. I tried just injecting it into the MainFarm() function in the script. The problem is that when it resigns due to Falken, it then wants to go ahead and continue the rest of the function and starts moving around in Beetletun instead of exiting out to restart the MainFarm() loop. I'm clearly missing some if-then statement that would kill the MainFarm() function and start again, but I'm not sure what.

here's how I just slapped it into the MainFarm() code:

Code:
Func MainFarm()
     Local $lTimer, $lTime
	 Local $lDeadlock

	 Local $lDebug, $lDebugTime

     Sleep(1000)
	 Move(22500, -11700)
	 WaitMapLoading($NeboTerrace)

     $lTimer = TimerInit()
	 Out("Begin run #" & $Runs)

Falken()

	 MoveTo(-10998, 18328)
	 MoveTo(-8005, 17962)
	 UseSkillEx($DE, -2)
	 MoveTo(-3618, 17264)
	 MoveTo(-1077, 16959)

	 Out("Checking Spawn...")

	 TargetNearestAlly()
	 if  GetNumberOfAlliesInRangeOfAgent(-2,1250) > 4 Then
		$bCanContinue = True
	 Else
		$bCanContinue = False
	 EndIf

     If $bCanContinue = True Then
	    Out("Found spawn")
        Out("Waiting for text")
		Sleep(35000)

		Out("Pre buff")
		UseSkillEx($SOD, -2)

	  $lDeadlock = TimerInit()
		Do
		   Sleep(50)
	    Until GetNumberOfFoesInRangeOfAgent(-2, 1250) > 0 Or TimerDiff($lDeadlock) > 50000

		UseSkillEx($IAU, -2)
		UseSkillEx($EBSOH, -2)
		Fight()

		If $bCanContinue = True Then PickUpLoot()
        If $bCanContinue = True Then $EnemiesKilled = $EnemiesKilled + 7
	    Resign()
        Sleep(3000)
	    Do
		   Sleep(200)
        Until GetIsDead(-2) = True

	    ReturnToOutpost()
	    WaitMapLoading($Beetletun)

     Else
	    Out("No spawn, restarting")
	    $NoSpawn = $NoSpawn + 1
		GUICtrlSetData($NoSpawnLabel, $NoSpawn)

		Resign()
        Sleep(3000)
		Do
		   Sleep(50)
	    Until GetIsDead(-2) = True

		ReturnToOutpost()
		WaitMapLoading($Beetletun)

	 EndIf

	    $Runs = $Runs + 1
		GUICtrlSetData($RunsLabel, $Runs)
        Out("Run finished")
	    Sleep(200)

	    Sleep(200)
	 EndFunc
so if anyone can help me understand how I messed this up, I'll work on tweaking it and releasing an updated version.
05/01/2023 22:15 solos#5
as with my tired eyes, it looks like there is no global $bcancontinue and you use different $bcancontinue variables in the 2 different functions without willing to do so. try to add "global $bcancontinue" at the most top might solve the issue, just thinking .. without any testing of myself, just being on my phone.

or just pass the variable as return.
you can use return true or return false inside the falken function.
and check using "if falken() then. .. else .. "
the long term would be " if falken() =1 then ... else ..."