Well raikoug got me interested in doing this when he posted a thread in the request section,
.
It works a little different from the way he describe what he would like to do in the original post. I found that tying the auto-pot, auto-special, and auto-nexus together, all sharing the same activation point, was dangerous. The problem was that it took time from when the request to use the special ablilty or heal potion and the time when the effects manifested themselves (probably due to server communication). During this time auto-nexus would not activate because there was an alternative (use special or use potion). This caused it to be more risky to use over the normal auto-nexus. What I ended up doing was separating the features, giving all them their own unique activation point (the percentage of health on which to activate). This way auto-nexus will still activate even if there is an alternative available (works just like normal auto-nexus). It's safer this way and I think it works rather well.
This should work with any and all pots that have the Heal or Magic activate property. There is also a check for quiet status effect so it doesn't waste magic pots unnecessarily.
If you want to change the activation points, it should be fairly obvious where to do so in the code.
As a side note, I've experienced kick to character select screen a few times. I think I solved the problem though. Let me know if you are experiencing this and think this code is the culprit.
Stick this in com.company.assembleegameclient.objects:Player/update function, just before the returnvalue instruction at the end.
Add this to the Player.class.asasm file. These are functions used by the above code and can be inserted just above the "end ; class" line at the end of the file.
Code:
trait method QName(PackageNamespace(""), "use_potion")
method
refid "com.company.assembleegameclient.objects:Player/use_potion"
param QName(PackageNamespace(""), "String")
returns QName(PackageNamespace(""), "int")
body
maxstack 8
localcount 10
initscopedepth 8
maxscopedepth 8
code
; --- TEMP for checking for Quiet status effect ---
pushstring "Magic"
getlocal1
ifne SEARCH_4_POTION
getlocal0
getproperty QName(PackageNamespace(""), "_-86") ; holds current magic points
pushbyte 0
ifne SEARCH_4_POTION ; current magic points is 0, likely because of quite so don't do anything
findpropstrict QName(PackageNamespace(""), "trace")
pushstring "Quiet probably active"
callpropvoid QName(PackageNamespace(""), "trace"), 1
pushint -1
returnvalue
; -------------------------------------------------
SEARCH_4_POTION:
pushbyte 4
setlocal 2 ; index
getlocal0
getproperty QName(PackageNamespace(""), "map_")
getproperty QName(PackageNamespace(""), "player_")
getproperty QName(PackageNamespace(""), "inventory")
getproperty QName(PackageNamespace(""), "slots_")
coerce_a
setlocal 3 ; slot array
jump CHECK_INV
CHECK_INV_LOOP:
label
getlocal 3
getlocal 2
nextvalue
coerce QName(PackageNamespace("com.company.assembleegameclient.ui"), "_-E6")
dup
setlocal 4 ; holds slot item
getproperty QName(PackageNamespace(""), "objectType_")
dup
setlocal 5 ; holds item type
pushint -1
ifeq CHECK_INV ; goto next slot, no itme exist in current slot
getlex QName(PackageNamespace("com.company.assembleegameclient.objects"), "ObjectLibrary")
getproperty QName(PackageNamespace(""), "_-QF")
getlocal 5
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("_-09j"), StaticProtectedNs("_-09j"), StaticProtectedNs("_-0-I")])
dup
setlocal 6 ; holds item xml data
pushstring "Potion"
callproperty Multiname("hasOwnProperty", [PrivateNamespace("*", "com.company.assembleegameclient.objects:_-Od/iinit#0"), PackageNamespace(""), PrivateNamespace("*", "com.company.assembleegameclient.objects:_-Od/iinit#1"), PackageNamespace("com.company.assembleegameclient.objects"), PackageInternalNs("com.company.assembleegameclient.objects"), Namespace("http://adobe.com/AS3/2006/builtin"), ProtectedNamespace("_-V"), StaticProtectedNs("_-V")]), 1
pushfalse
ifeq CHECK_INV ; goto next slot if item isn't a potion
;----- start inner loop to check potion for heal/magic activation -----
pushbyte 0
setlocal 7 ; index for inner loop
getlocal 6
getproperty Multiname("Activate", [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("_-iX"), StaticProtectedNs("_-iX"), StaticProtectedNs("_-TE"), StaticProtectedNs("_-iP"), StaticProtectedNs("_-0-I")])
coerce_a
setlocal 8 ; holds activate array
jump CHECK_POT
CHECK_POT_LOOP:
label
getlocal 8
getlocal 7
nextvalue
coerce QName(PackageNamespace(""), "XML")
dup
setlocal 9 ; holds activate line
callproperty Multiname("toString", [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("_-iX"), StaticProtectedNs("_-iX"), StaticProtectedNs("_-TE"), StaticProtectedNs("_-iP"), StaticProtectedNs("_-0-I")]), 0
getlocal1
ifne CHECK_POT ; jump to next attribute if desired attribute not found
findpropstrict QName(PackageNamespace(""), "trace")
pushstring "Using "
getlocal1
add
pushstring " Pot"
add
callpropvoid QName(PackageNamespace(""), "trace"), 1
getlocal 4
callpropvoid QName(PackageNamespace(""), "attemptUse"), 0 ; use potion
kill 8
kill 7
kill 3
kill 2
getlocal 9
getproperty MultinameA("amount", [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("_-iX"), StaticProtectedNs("_-iX"), StaticProtectedNs("_-TE"), StaticProtectedNs("_-iP"), StaticProtectedNs("_-0-I")])
; ^^ sends back amount of health/magic gained
jump DONE
CHECK_POT:
hasnext2 8, 7
iftrue CHECK_POT_LOOP
kill 8
kill 7
;----------------------------------------------------------------------
CHECK_INV:
hasnext2 3, 2
iftrue CHECK_INV_LOOP
kill 3
kill 2
pushint -1 ; no suitable potion found
DONE:
returnvalue
end ; code
end ; body
end ; method
end ; trait
trait method QName(PackageNamespace(""), "use_special")
method
refid "com.company.assembleegameclient.objects:Player/use_special"
returns QName(PackageNamespace(""), "int")
body
maxstack 8
localcount 10
initscopedepth 8
maxscopedepth 8
code
;--- get player's special stats ---
getlocal0
getproperty QName(PackageNamespace(""), "_-zq")
pushbyte 1
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("_-09j"), StaticProtectedNs("_-09j"), StaticProtectedNs("_-0-I")])
dup
setlocal 1 ; holds special objectType
pushint -1
ifne CHECK_MAGIC ; end if no special equiped
pushint 1 ; means no special equipped
returnvalue
CHECK_MAGIC:
;--- check to see if player has enough magic to cast special ---
getlex QName(PackageNamespace("com.company.assembleegameclient.objects"), "ObjectLibrary")
getproperty QName(PackageNamespace(""), "_-QF")
getlocal 1
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("_-09j"), StaticProtectedNs("_-09j"), StaticProtectedNs("_-0-I")])
dup
setlocal 2 ; holds xml of special
findpropstrict QName(PackageNamespace(""), "int")
swap
getproperty Multiname("MpCost", [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("_-iX"), StaticProtectedNs("_-iX"), StaticProtectedNs("_-TE"), StaticProtectedNs("_-iP"), StaticProtectedNs("_-0-I")])
callproperty QName(PackageNamespace(""), "int"), 1
dup
setlocal 3 ; holds mp cost
getlocal0
getproperty QName(PackageNamespace(""), "_-86")
ifle COOLDOWN_CHECK ; jump if player has enough mana
pushint 2 ; means not enough mana
returnvalue
COOLDOWN_CHECK:
;--- check to see if cooldown is up ---
findpropstrict QName(PackageNamespace("flash.utils"), "getTimer")
callproperty QName(PackageNamespace("flash.utils"), "getTimer"), 0
dup
setlocal 4 ; holds current time
getlocal0
getproperty QName(PackageNamespace(""), "_-0m") ; _-0m holds time at which cooldown is up
ifge RESET_TIMER ; jump if cooldown is up
pushint 3 ; means cooldown not up
returnvalue
RESET_TIMER:
;--- reset timer ---
getlocal0
findpropstrict QName(PackageNamespace(""), "Number")
getlocal 2
getproperty Multiname("Cooldown", [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("_-iX"), StaticProtectedNs("_-iX"), StaticProtectedNs("_-TE"), StaticProtectedNs("_-iP"), StaticProtectedNs("_-0-I")])
callproperty QName(PackageNamespace(""), "Number"), 1
convert_i
pushint 1000
multiply ; cool down time
dup
pushbyte 0
ifne SET_COOLDOWN:
pop
pushint 500
SET_COOLDOWN:
getlocal 4
add
setproperty QName(PackageNamespace(""), "_-0m")
;--- use special ---
findpropstrict QName(PackageNamespace(""), "trace")
pushstring "Using Special"
callpropvoid QName(PackageNamespace(""), "trace"), 1
getlocal0
getproperty QName(PackageNamespace(""), "map_")
dup
dup
getproperty QName(PackageNamespace(""), "mouseX")
swap
getproperty QName(PackageNamespace(""), "mouseY")
callproperty QName(PackageNamespace(""), "pSTopW"), 2
coerce QName(PackageNamespace("flash.geom"), "Point")
setlocal 5
getlocal0
getproperty QName(PackageNamespace(""), "map_")
getproperty QName(PackageNamespace(""), "gs_")
getproperty QName(PackageNamespace(""), "gsc_")
getlocal 4
getlocal0
getproperty QName(PackageNamespace(""), "objectId_")
pushbyte 1
getlocal 1
getlocal 5
getproperty QName(PackageNamespace(""), "x")
getlocal 5
getproperty QName(PackageNamespace(""), "y")
callpropvoid QName(PackageNamespace(""), "useItem"), 6
pushbyte 0 ; means use special succeeded
returnvalue
end ; code
end ; body
end ; method
end ; trait