Hello everyone, long time no post:: been out of state, anyway.
I ran into a ..logical problem when I started writing my combat logic because it kept getting tied into the RunToPoint() code (ie. while I'm running, make sure i'm not getting attacked etc) so I eventually rewrote my Gps.RunToPoint into Combat.RunToPoint()..symantics..anyway --> MOST of my classes are interdependent so this code won't compile (ie. class combat uses class GPS uses class etc): Just looking for some comments --> again, because I'm not posting all the code (combat.TargetMob, combat.KillTarget, etc) you won't know much..but, from what you see: any comments?
Vb.Net
Code:
Public Sub RunToPoint(ByVal wPoint As worldPoint, ByVal stopRange As Single, ByVal asGhost As Boolean, ByVal killAll As Boolean, ByVal stopAtEnd As Boolean)
GPS.SetView45()
If wPoint.DistanceFromLocalPlayer <= stopRange Then
DoOutput("[already @ point!!!]")
Exit Sub
End If
'''''''''''''''''''''''''''
If asGhost = True Then
'we are dead, just run!
Do Until wPoint.DistanceFromLocalPlayer <= stopRange
GPS.TurnToPoint(wPoint, asGhost)
If GPS.IsRunningForward = False Then GPS.StartRunForward()
Application.DoEvents()
Loop
'@point
ElseIf killAll = True Then
'asGhost = false, killAll=True
'We can die..are we being attacked?
Dim closestMobBase As UInt32 = 0
Dim killTarg As New objMgrUnitObject
Do Until wPoint.DistanceFromLocalPlayer <= stopRange
'1. Are we being attacked?
'2. Should we attack something? (killAll)
If LocalPlayer.Health = 0 Then
MessageBox.Show("DIED While in Combat.RunToPoint()")
Application.Exit()
End If
If NumberOfAttackers > 0 Then
DoOutput("[ambush while running--]")
DefendSelf()
End If
_lastPointOnpath = LocalPlayer.PosAsWorldPoint
badLabelGoHunting:
closestMobBase = FindClosestMobBase(COMBAT._maxAttackRange)
If closestMobBase > 0 Then
If GPS.IsRunningForward = True Then GPS.StopRunForward()
'DoOutput("[mob near path]")
'Mob Found in Range
'Are we too far from the path?
If _lastPointOnpath.DistanceFromLocalPlayer > SETTINGS.COMBAT.MaxDistanceFromPathToTarget Then
'we should return to the last point
DoOutput("[returning to path]")
Application.DoEvents()
RunToPoint(_lastPointOnpath, 5, False, False, False) ' recursive
Else
'we should kill again!
killTarg.BaseAddress = closestMobBase
' DoOutput("[targeting mob]")
If TargetMob(killTarg) = True Then
KillTarget()
GoTo badLabelGoHunting
End If
End If
Else
'No Mobs In Range
'just keep running to the point
End If
If GPS.IsRunningForward = False Then GPS.StartRunForward()
Application.DoEvents()
_lastPointOnpath = LocalPlayer.PosAsWorldPoint
If wPoint.TurnDistance >= 0.1 Then
GPS.TurnToPoint(wPoint, asGhost)
End If
Loop
'@point
Else 'asghost = false, killAll = false
'we can't attack anything, just run and selfDefense
Do Until wPoint.DistanceFromLocalPlayer <= stopRange
'Did we die?
If LocalPlayer.Health = 0 Then
MessageBox.Show("DIED While in Combat.RunToPoint() ghost=False,KillAll=False")
Application.Exit() ' exit sub, handle elsewhere
End If
If NumberOfAttackers > 0 Then
DoOutput("[ambush while running...]")
DefendSelf()
End If
GPS.TurnToPoint(wPoint, asGhost)
If GPS.IsRunningForward = False Then GPS.StartRunForward()
Application.DoEvents()
Loop
'@point
End If
If stopAtEnd = True Then
If GPS.IsRunningForward = True Then GPS.StopRunForward()
End If
End Sub
Hmm...
1) I know I don't check if I get stuck..
2) gps.IsRunningForward is just a bool I keep --> should/will read (player struct?) for isMoving -- works for now: runs/stops when supposed to
3) checking for Lp.Hp=0 looks at best...not good -> I haven't coded much with dieing/rezzing etc -that'll come later/last. I know after DefendSelf it should check for .hp=0 again....that'll come later
4) Application.DoEvents is sprinkled in there..will take out later.
5) _lastPointOnPath is used to keep us within a certain distance of the path line --> *could* go astray..99.9 won't happen
6) __________ <-- your msg
anyway..if anyone is interested/has ideas/tips msg I can post more code
any vb coders out there?