Quote:
Originally Posted by ForgottenRelic
Okay so here goes once again a horrible attempt at creating something...
So lets say I wanna make an EXTREMELY NOOBISH script.....
(Farming a green boss w/heroes) <---- childish, right? its 2020.
I have kinda copied and pasted some functions that I know work from other scripts.
I have already figured out how to travel to said outpost, add heroes that I want with specific build needed and load my build for my character.
The bloody problem i'm having is this...
option 1 : just run to said place of boss and let heroes farm it ( no attacking required)
or option 2: target nearest foe and start attacking.
I have tried different ways all day yesterday and kept on getting errors. will attach my noobish script to it, any helpful pointers is much appreciated.
|
"Option 1"
First, To solve your first issue, load up a program to get your coordinates. Toolbox works fine for this. Move from your spawn point to the nearest exit and again get your coordinates (ensure you select the best path that prevents you from getting stuck. You may need to add more coordinates to move around obstacles).
Once you have your coordinates, then write out your movements. You can just simply write something like the below:
Code:
MoveTo(2331, 7832)
MoveTo(5478, 9872)
MoveTo(4312, 4391)
When I first write a script I might make some minor notes like:
Code:
MoveTo(2331, 7832) ;Stairs
MoveTo(5478, 9872) ;Near Merch
MoveTo(4312, 4391) ;Exit Portal
Once you do this then of course test and make sure its working smoothly and you don't get stuck anywhere. Also, try starting from a different town to make sure you don't get stuck when you zone to your target town and have a different spawn point.
Next get your portal way point and make sure to write this as:
Remember, your MoveTo() function will send the command for your character to move to a certain location and then when it arrives it will go to the next movement or command so if you try to Zone with MoveTo() then you will often have a disconnect so always use Move() as this will simply begin to walk through the portal and immediately go to your next command which should be:
This will have your char wait until the map is loaded before proceeding to the next command.
Test a few times to ensure its working smoothly.
Next, map out your next path and get the coordinates to your boss. If there are no enemy between you and the boss and therefore no fighting then you can continue to use MoveTo() otherwise try something like MoveAggro() or MoveAggroing() or MoveKill() pull an example of a good moving and fighting function from a different script. Check scripts like Feather farmers, Kilroy, UW, or Froggy. Also, make sure to go through and look at the functions in GWA2 and become familiar with them as well.
"Option 2"
For your final fight, you can TargetNearestEnemy() and Attack() but you also want to try to work in some sort of cast engine for yourself. You should look at other scripts to see how they use the skills but you can also simply write a basic order for casting like:
Code:
UseSkill(1,-2)
UseSkill(2)
UseSkill(3)
UseSkill(4)
UseSkill(5,-2)
UseSkill(6)
UseSkill(7)
UseSkill(8)
From GWA2:
Code:
;~ Description: Use a skill.
Func UseSkill($aSkillSlot, $aTarget, $aCallTarget = False)
Local $lTargetID
If IsDllStruct($aTarget) = 0 Then
$lTargetID = ConvertID($aTarget)
Else
$lTargetID = DllStructGetData($aTarget, 'ID')
EndIf
DllStructSetData($mUseSkill, 2, $aSkillSlot)
DllStructSetData($mUseSkill, 3, $lTargetID)
DllStructSetData($mUseSkill, 4, $aCallTarget)
Enqueue($mUseSkillPtr, 16)
EndFunc ;==>UseSkill
Here is an example of skill casting sequence from the Dervish Feather script and also the modified function:
Code:
Func KillOldVersion()
If GetMapLoading() == 2 Then Disconnected()
If GetIsDead(-2) Then Return
If GetEffectTimeRemaining(1516) <= 0 Then UseSkillEx(8,-2)
If GetEffectTimeRemaining(1540) <= 0 Then UseSkillEx(7,-2)
If GetEffectTimeRemaining(1510) <= 0 Then UseSkillEx(1,-2)
TargetNearestEnemy()
WaitForSettle(800, 210)
If IsRecharged(2) Then UseSkillEx(2,-2)
If GetEnergy(-2) >= 10 Then
UseSkillEx(3,-2)
UseSkillEx(4,-1)
EndIf
While GetNumberOfFoesInRangeOfAgent(-2,900) > 0
If GetMapLoading() == 2 Then Disconnected()
If GetIsDead(-2) Then Return
TargetNearestEnemy()
If GetEffectTimeRemaining(1516) <= 0 Then UseSkillEx(8,-2)
If GetEffectTimeRemaining(1540) <= 0 Then UseSkillEx(7,-2)
If GetEffectTimeRemaining(1510) <= 0 And GetNumberOfFoesInRangeOfAgent(-2,300) > 1 Then UseSkillEx(1,-2)
If GetEffectTimeRemaining(1759) <= 0 Then UseSkillEx(2,-2)
Sleep(100)
Attack(-1)
WEnd
RndSleep(200)
PickUpLoot()
EndFunc
Another Example:
Code:
If IsRecharged(2) Then UseSkillEx(2,-2)
If GetEnergy(-2) >= 10 Then
UseSkillEx(3,-2)
UseSkillEx(4,-1)
EndIf
Attack(-1)
And here is the function for UseSkillEx()
Code:
Func UseSkillEx($lSkill, $lTgt = -2, $aTimeout = 3000)
If GetIsDead(-2) Then Return
If Not IsRecharged($lSkill) Then Return
Local $Skill = GetSkillByID(GetSkillBarSkillID($lSkill, 0))
Local $Energy = StringReplace(StringReplace(StringReplace(StringMid(DllStructGetData($Skill, 'Unknown4'), 6, 1), 'C', '25'), 'B', '15'), 'A', '10')
If GetEnergy(-2) < $Energy Then Return
Local $lAftercast = DllStructGetData($Skill, 'Aftercast')
Local $lDeadlock = TimerInit()
UseSkill($lSkill, $lTgt)
Do
Sleep(50)
If GetIsDead(-2) = 1 Then Return
Until (Not IsRecharged($lSkill)) Or (TimerDiff($lDeadlock) > $aTimeout)
Sleep($lAftercast * 1000)
EndFunc ;==>UseSkillEx
Func CountFreeSlots($NumOfBags = 4)
Local $FreeSlots, $Slots
For $Bag = 1 to $NumOfBags
$Slots += DllStructGetData(GetBag($Bag), 'Slots')
$Slots -= DllStructGetData(GetBag($Bag), 'ItemsCount')
Next
Return $Slots
EndFunc
I like this function because it uses the skill and adds in the needed time before moving to the next skill so you do not need to add in sleep time or anything before your next skill or command.
Some skills are attack skills that target others and some are self targeting so that is why you see some written like:
Code:
UseSkillEx(1)
UseSkillEx(2)
UseSkillEx(3)
and some skills written like:
Code:
UseSkillEx(1, -2)
UseSkillEx(2, -2)
UseSkillEx(3, -2)
You just have to take note of this and the parameters of the skill function.
Code:
Func UseSkillEx($lSkill, $lTgt = -2, $aTimeout = 3000)
So in summary, there are many ways to write a basic boss farm script but I tried to make it as simple as I could here. Make these adjustments and try again. Post your results and lets see if you can get it.
Function Summary Example:
Code:
MoveTo(2331, 7832) ;Stairs
MoveTo(5478, 9872) ;Near Merch
MoveTo(4312, 4391) ;Exit portal near tree
Move(4532, 3421) ;Zoning
WaitMapLoading() ;Waiting to load into Domain of Anguish
MoveAggroing(3455, 6532) ;1st group of enemy
MoveAggroing(3421, 4321) ;2nd group of enemy
MoveAggroing(3421, 2351) ;3rd group of enemy
MoveAggroing(3421, 4321) ;4th group of enemy near rock
MoveAggroing(3421, 2351) ;5th group of enemy with monks
KillBoss()
PickUpLoot()
UpdateStats()
BackToTown()