Making custom commands in ROTMG
Well I figured out how to do this. I'm posting this more as a reference for me and those who care. Code is for v123.5.1.
The function that checks for client side commands is com.company.assembleegameclient.ui:_-4D/_-2T . If the command isn't seen there it is sent to the server at which point if it isn't recognized the player will be greeted with an unrecognized command message in the text box. If you look at the function there is only one command check present, that is the "/help" command. To add your own command all you need to do is add a check for the command you want and implement the desired functionality.
In this example, I allow for adjustments to the viewing distance in the fullscreen hack with a console command. It makes various checks for "/vd", the command I want to use to adjust viewing distance, after which it will set a variable that I made in com.company.assembleegameclient.map:_-0Dv (the class responsible for the viewing distance). Finally it will state the setting to the user via the text box.
The code I used in com.company.assembleegameclient.ui:_-4D/_-2T is provided below. It is placed at the start of the code section of the function.
Taking a look at the directions I provided for implementing the fullscreen hack. There is a part in there that says:
Instead of hard coding the value into the client, I made a variable that will hold the desired value. Here I replaced pushbyte 1 with getlex QName(PackageNamespace(""), "vd_") (vd_ is my variable name). Then at the bottom of the file along with all the trait const references I made a new line and placed this trait slot QName(PackageNamespace(""), "vd_") slotid 6 type QName(PackageNamespace(""), "int") value Integer(16) end there. Basically this sets up a static variable of type int with the value of 16 (the default value I wanted).
That it. To change the viewing distance in game just type /vd 12 or whatever the desired viewing distance number wanted.
The function that checks for client side commands is com.company.assembleegameclient.ui:_-4D/_-2T . If the command isn't seen there it is sent to the server at which point if it isn't recognized the player will be greeted with an unrecognized command message in the text box. If you look at the function there is only one command check present, that is the "/help" command. To add your own command all you need to do is add a check for the command you want and implement the desired functionality.
In this example, I allow for adjustments to the viewing distance in the fullscreen hack with a console command. It makes various checks for "/vd", the command I want to use to adjust viewing distance, after which it will set a variable that I made in com.company.assembleegameclient.map:_-0Dv (the class responsible for the viewing distance). Finally it will state the setting to the user via the text box.
The code I used in com.company.assembleegameclient.ui:_-4D/_-2T is provided below. It is placed at the start of the code section of the function.
Code:
; -------- Making your own commands --------
; If one of our commands are found make
; sure to return true else the command will
; be sent to the server and the player will
; be greeted with unrecognized command.
; ------------------------------------------
getlocal1
pushstring "/vd"
ifeq STATE_VD
getlocal1
pushbyte 0
pushbyte 4
callproperty QName(Namespace("http://adobe.com/AS3/2006/builtin"), "slice"), 2 ; stack now holds the first three characters in string
pushstring "/vd "
ifne NOT_VD
findpropstrict QName(PackageNamespace(""), "int")
getlocal1
dup
pushbyte 4
swap
getproperty QName(PackageNamespace(""), "length")
callproperty QName(Namespace("http://adobe.com/AS3/2006/builtin"), "slice"), 2
callproperty QName(PackageNamespace(""), "int"), 1
dup
setlocal 4 ; holds wanted setting
pushint 1
iflt STATE_VD ; lower bounds check
getlocal 4
pushint 255
ifgt STATE_VD ; upper bounds check
getlex QName(PackageNamespace("com.company.assembleegameclient.map"), "_-0Dv")
getlocal 4
setproperty QName(PackageNamespace(""), "vd_") ; sets wanted setting
STATE_VD:
getlocal0
getlex QName(PackageNamespace("com.company.assembleegameclient.parameters"), "Parameters")
getproperty QName(PackageNamespace(""), "_-Nv")
pushstring "Viewing Distance: "
getlex QName(PackageNamespace("com.company.assembleegameclient.map"), "_-0Dv")
getproperty QName(PackageNamespace(""), "vd_")
add
callpropvoid QName(PackageNamespace(""), "addText"), 2
pushtrue
returnvalue
NOT_VD:
Expanding your Horizon (Part 2)-
com.company.assembleegameclient.map:_-0Dv._-K
From the end (returnvoid) scan up for the instuction "pushbyte 1". Replace with a larger number. This is one of those variables that need to be optimized depending on desired resolution one wants to play at. (16 seems to be good for 1920x1080)
com.company.assembleegameclient.map:_-0Dv._-K
From the end (returnvoid) scan up for the instuction "pushbyte 1". Replace with a larger number. This is one of those variables that need to be optimized depending on desired resolution one wants to play at. (16 seems to be good for 1920x1080)
That it. To change the viewing distance in game just type /vd 12 or whatever the desired viewing distance number wanted.
