Original post here
I've reworked aanpsx's item scripts to streamline the whole thing. One tiny script + id tables for the items/resources/artifacts I've obtained so far.
Note: You'll need a custom 'RPG VX type'.
If you don't have it follow these instructions ⟶
Code: Select all
alloc(ConvertRoutine,1024)
alloc(ConvertBackRoutine,1024)
alloc(TypeName,256)
alloc(ByteSize,4)
alloc(UsesFloat,1)
alloc(CallMethod,1)
TypeName:
db 'RPG VX type',0
ByteSize:
dd 4
UsesFloat:
db 0 //Change to 1 if this custom type should be treated as a float
CallMethod:
db 1 //Remove or change to 0 for legacy call mechanism
//The convert routine should hold a routine that converts the data to an integer (in eax)
//function declared as: cdecl int ConvertRoutine(unsigned char *input, PTR_UINT address);
//Note: Keep in mind that this routine can be called by multiple threads at the same time.
ConvertRoutine:
//jmp dllname.functionname
[64-bit]
//or manual:
//parameters: (64-bit)
//rcx=address of input
//rdx=address
mov eax,[rcx] //eax now contains the bytes 'input' pointed to
shr eax, 1
ret
[/64-bit]
[32-bit]
//jmp dllname.functionname
//or manual:
//parameters: (32-bit)
push ebp
mov ebp,esp
//[ebp+8]=address of input
//[ebp+c]=address
//example:
mov eax,[ebp+8] //place the address that contains the bytes into eax
mov eax,[eax] //place the bytes into eax so it's handled as a normal 4 byte value
shr eax, 1
pop ebp
ret
[/32-bit]
//The convert back routine should hold a routine that converts the given integer back to a row of bytes (e.g when the user wats to write a new value)
//function declared as: cdecl void ConvertBackRoutine(int i, PTR_UINT address, unsigned char *output);
ConvertBackRoutine:
//jmp dllname.functionname
//or manual:
[64-bit]
//parameters: (64-bit)
//ecx=input
//rdx=address
//r8=address of output
//example:
shl ecx, 1
inc ecx
mov [r8],ecx //place the integer at the 4 bytes pointed to by r8
ret
[/64-bit]
[32-bit]
//parameters: (32-bit)
push ebp
mov ebp,esp
//[ebp+8]=input
//[ebp+c]=address
//[ebp+10]=address of output
//example:
push eax
push ebx
mov eax,[ebp+8] //load the value into eax
mov ebx,[ebp+10] //load the output address into ebx
shl eax, 1
inc eax
mov [ebx],eax //write the value into the address
pop ebx
pop eax
pop ebp
ret
[/32-bit]
As I mentioned before, we're injecting into probably display code. That's also one of the reasons the item list was changing after going on any artifact listing screen. This means 4 things:
- If you want to update the item pointers, set
Update when loading inventory?
toUpdate items
then open one of the item screens in-game like [Organize Army > Use Items] or [Organize Army > Squad Operations > Use Items] or to update arena tokens, head to [Arena]. - If you want to update the artifact pointers, set
Update when loading inventory?
toUpdate artifacts
then open one of the artifact screens in-game like [Organize Army > Squad Operations > Artifacts] or [Marketplace > Sell Items]. - After updating one of the lists once, set
Update when loading inventory?
toDon't update
to avoid overriding the lists just in case. - You only need to update again if you gain new items or artifacts. Follow steps 1. or 2. again for that.
Select By Id
and then activate Load By Id
and it will point to the correct item.