Character.GetAtScreenXY via plugin (SOLVED)

Started by Dualnames, Wed 06/03/2019 03:30:36

Previous topic - Next topic

Dualnames

I want to access this specific code inside a plugin code

Character.GetAtScreenXY(xx, yy)==cEgo

I've looked it up and I'm clueless on how to do that
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Dualnames

Code: AGS


int (*sfGetAtXY)(int,int);
sfGetAtXY = ((int(*)(int,int)) engine->GetScriptFunctionAddress("GetCharacterAt"));
int getID=sfGetAtXY(xx,yy);


Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Snarky

Nice to know! Thanks for posting your solution. (lol at this topic being in Beginners'.)

Crimson Wizard

#3
"GetCharacterAt" is a deprecated function that may be removed from future versions of the engine.
"Character::GetAtScreenXY" returns a pointer to character object which you may use to access its properties either
1) directly by casting it to AGSCharacter from plugin api and reading its variables (not recommended because it's honestly unsafe and will be deprecated in ags4 also)
2) by using property getter "Character::get_ID" and passing previously received character pointer there.

There's another thing, GetScriptFunctionAddress is in truth "GetSymbolAddress", meaning you can get not only functions. Thus you may do engine->GetScriptFunctionAddress("player"), because "player" is a builtin global variable, and get player character's pointer, and then compare directly to the one you received from "Character::GetAtScreenXY".
If you already know player's ID somehow you may get player's pointer also by engine->GetCharacter(n).

SMF spam blocked by CleanTalk