Help! How to hook enum function has reference object parameter?

thienha1

Approved Modder
Approved Modder
This is my ex default function:
C#:
public override NPC.Status GetMoveStatus(ref object[] p)
{
    return NPC.Status.Running;
}
I want to return like this:
C#:
public override NPC.Status GetMoveStatus(ref object[] p)
{
    return NPC.Status.Walking;
}
Ex enum function:
C#:
public enum Status
        {
            Running, // 0
            Walking, // 1
            Stopped // 2
        }
So I hook this function as I think it will work:
C++:
bool walk;
int (*old_GetMoveStatus)(void *instance, void p);
int GetMoveStatus(void *instance, void p) {
    if (instance != NULL && walk) {
        return 1;
    }
    return old_GetMoveStatus(instance, p);
}
And a result, it get crash immediately after enable this function.
Can you guys have any idea or solution for this issue?
 
C++:
bool walk;
int (*old_GetMoveStatus)(void *instance, void *p);
int GetMoveStatus(void *instance, void *p) {
    if (instance != NULL && walk) {
        return 1;
    }
    return old_GetMoveStatus(instance, p);
}
Try with this code, btw you didn't provide enough info.
 
Back
Top Bottom