I was looking at cubeone's code and realized that code for targeting enemy with highest hp is already in there. What cubeone did was first considered the distance of the enemies, then if they happen to be the same (rarely) it would target the one with the highest max hp. So what I did was just switch those checks around. With the code posted below, it will first check all enemies within shooting distance for the one with the highest health. If there are 2 or more enemies have the same max health, it will choose the closest one.
Code:
trait method QName(PackageNamespace(""), "_-0B8")
method
refid "com.company.assembleegameclient.objects:Player/_-0B8"
param QName(PackageNamespace(""), "Number")
returns QName(PackageNamespace(""), "void")
body
maxstack 16
localcount 16
initscopedepth 16
maxscopedepth 18
code
;pushfalse
;pushtrue
;setlocal2
;setlocal3
;aimingAngle = arg1 + Parameters.data_.cameraAngle;
getlocal0
pushscope
getlocal1
getlex QName(PackageNamespace("com.company.assembleegameclient.parameters"), "Parameters")
getproperty QName(PackageNamespace(""), "data_")
getproperty Multiname("cameraAngle", [PrivateNamespace("*", "com.company.assembleegameclient.objects:Player#0"), PackageNamespace(""), PrivateNamespace("*", "com.company.assembleegameclient.objects:Player#1"), PackageNamespace("com.company.assembleegameclient.objects"), PackageInternalNs("com.company.assembleegameclient.objects"), Namespace("http://adobe.com/AS3/2006/builtin"), ProtectedNamespace("_-00H"), StaticProtectedNs("_-00H"), StaticProtectedNs("_-M4"), StaticProtectedNs("_-036"), StaticProtectedNs("_-QF"), StaticProtectedNs("Object")])
add
setlocal 7
;if (Left_Clicking) don't alter aimingAngle
getlex QName(PackageNamespace(""), "map_")
getproperty QName(PackageNamespace(""), "gs_")
getproperty QName(PackageNamespace(""), "mui_")
getproperty QName(PackageNamespace(""), " use") ;<-Doesn't resolve to the right address, hex edit to fix
iftrue L138
;Get game object
pushnull
coerce QName(PackageNamespace("com.company.assembleegameclient.objects"), "GameObject") ;coerce null that was pushed onto stack into a GameObject obj ???
setlocal 4 ;save object to local register 4
;initialize current target distance to -1
pushbyte 255
setlocal 8
;initialize considered target distance to 0
pushbyte 0
setlocal 9
;set local register 11 to any type (used for speed and lifetime of player's projectile)
pushnull
coerce_a
setlocal 11
;current target max health
pushbyte 0
setlocal 12
;considered target max health
pushbyte 0
setlocal 13
;used for hasnext2 instruction
pushbyte 0
setlocal 5
;get the list of every object in game? jump to start going through list
getlex QName(PackageNamespace(""), "map_")
getproperty QName(PackageNamespace(""), "goDict_")
coerce_a
setlocal 6
jump L131
L40:
label
getlocal 6
getlocal 5
nextvalue
coerce QName(PackageNamespace("com.company.assembleegameclient.objects"), "GameObject")
dup
setlocal 4
;getlocal 4
;getlex QName(PackageNamespace("com.company.assembleegameclient.objects"), "Player")
;istypelate
;iftrue L131
;make sure object is a character and not something like a wall
;getlocal 4
getlex QName(PackageNamespace("com.company.assembleegameclient.objects"), "Character")
istypelate
iffalse L131
;make sure object is an enemy
getlocal 4
getproperty QName(PackageNamespace(""), "props_")
getproperty QName(PackageNamespace(""), "isEnemy_")
iffalse L131
getlocal 4
callproperty QName(PackageNamespace(""), " case"), 0
iftrue L131
getlocal 4
callproperty QName(PackageNamespace(""), "_-Fo"), 0
iftrue L131
getlocal 4
callproperty QName(PackageNamespace(""), "_-IB"), 0
iftrue L131
;make sure player isn't paused
getlocal 4
callproperty QName(PackageNamespace(""), "isPaused"), 0
iftrue L131
;calculate distance enemy is from player
getlex QName(PackageNamespace(""), "Math")
getlocal 4
getproperty QName(PackageNamespace(""), "y_")
getlex QName(PackageNamespace(""), "y_")
subtract
dup
multiply
getlocal 4
getproperty QName(PackageNamespace(""), "x_")
getlex QName(PackageNamespace(""), "x_")
subtract
dup
multiply
add
callproperty QName(PackageNamespace(""), "sqrt"), 1
dup
setlocal 9 ;store considered target distance
;load up equiped weapon info ???
getlex QName(PackageNamespace("com.company.assembleegameclient.objects"), "ObjectLibrary")
getproperty QName(PackageNamespace(""), "_-PC")
getlex QName(PackageNamespace(""), "_-dd")
pushbyte 0
getproperty MultinameL([PrivateNamespace("*", "com.company.assembleegameclient.objects:Projectile#0"), PrivateNamespace("*", "com.company.assembleegameclient.objects:Projectile#1"), PackageNamespace(""), PackageNamespace("com.company.assembleegameclient.objects"), PackageInternalNs("com.company.assembleegameclient.objects"), Namespace("http://adobe.com/AS3/2006/builtin"), ProtectedNamespace("_-uM"), StaticProtectedNs("_-uM"), StaticProtectedNs("_-QF")])
convert_i
getproperty MultinameL([PrivateNamespace("*", "com.company.assembleegameclient.objects:Projectile#0"), PrivateNamespace("*", "com.company.assembleegameclient.objects:Projectile#1"), PackageNamespace(""), PackageNamespace("com.company.assembleegameclient.objects"), PackageInternalNs("com.company.assembleegameclient.objects"), Namespace("http://adobe.com/AS3/2006/builtin"), ProtectedNamespace("_-uM"), StaticProtectedNs("_-uM"), StaticProtectedNs("_-QF")])
getproperty QName(PackageNamespace(""), "_-85")
pushbyte 0
getproperty MultinameL([PrivateNamespace("*", "com.company.assembleegameclient.objects:Projectile#0"), PrivateNamespace("*", "com.company.assembleegameclient.objects:Projectile#1"), PackageNamespace(""), PackageNamespace("com.company.assembleegameclient.objects"), PackageInternalNs("com.company.assembleegameclient.objects"), Namespace("http://adobe.com/AS3/2006/builtin"), ProtectedNamespace("_-uM"), StaticProtectedNs("_-uM"), StaticProtectedNs("_-QF")])
dup
setlocal 11 ;store weapon data in registry
;calculate if considered target is in range using weapon projectile speed and lifetime
getproperty QName(PackageNamespace(""), "speed_")
pushshort 10000
divide
getlocal 11
getproperty QName(PackageNamespace(""), "lifetime_")
multiply
ifgt L131 ;jump to next considered object (current considered object out of range)
;get considered target max health
getlocal 4
getproperty QName(PackageNamespace(""), "_-PV")
dup
setlocal 13 ;store max health
;if considered target max health is the same as current target max health, check distance
getlocal 12
ifeq L109
;if considered target max health is less than current target max health, move on to next object.
getlocal 13
getlocal 12
iflt L131
jump L1099 ;considered target max health is greather than current target's, set new target
L109:
;if there is no current target, set new target
;getlocal 8
;pushbyte 255
;ifeq L1099
;if considered target distance is less than current target distance, set new target
getlocal 9 ;considered target
getlocal 8 ;current target
iflt L1099
jump L131 ;current target is closer than considered target, check next object
L1099:
;considered target max health is more than current, set at new target.
getlocal 13
setlocal 12
getlocal 9
setlocal 8
;calculate shooting angle
getlex QName(PackageNamespace(""), "Math")
getlocal 4
getproperty QName(PackageNamespace(""), "y_")
getlex QName(PackageNamespace(""), "y_")
subtract
getlocal 4
getproperty QName(PackageNamespace(""), "x_")
getlex QName(PackageNamespace(""), "x_")
subtract
callproperty QName(PackageNamespace(""), "atan2"), 2
setlocal 7 ;store new angle
jump L131 ;look at next object
L131:
hasnext2 6, 5
iftrue L40
kill 6
kill 5
getlocal 12
pushbyte 0
ifeq L141
L138:
getlocal0
getlocal 7
callpropvoid QName(PrivateNamespace("*", "com.company.assembleegameclient.objects:Player#0"), "shoot"), 1
L141:
returnvoid
end ; code
end ; body
end ; method
end ; trait
BTW if you haven't seen my post on page 2 with the aimbot howto, you'll need to if you want to use this code.