Scriptable* GetActorFromObject(Scriptable* Sender, Object* oC, int ga_flags) { Scriptable *aC = NULL; if (!oC) { return NULL; } Targets *tgts = GetAllObjects(Sender->GetCurrentArea(), Sender, oC, ga_flags); if (tgts) { //now this could return other than actor objects aC = tgts->GetTarget(0,-1); delete tgts; /*if (!aC && (ga_flags&GA_GLOBAL) ) { tgts = GetAllObjectsNearby(Sender, oC, ga_flags); if (tgts) { //now this could return other than actor objects aC = tgts->GetTarget(0,-1); delete tgts; } }*/ return aC; } if (oC->objectName[0]) { // if you ActionOverride a global actor, they might not have a map :( // TODO: don't allow this to happen? if (Sender->GetCurrentArea()) { aC = GetActorObject(Sender->GetCurrentArea()->GetTileMap(), oC->objectName ); if (aC) { return aC; } } Game *game = core->GetGame(); //global actors are always found by scripting name! aC = game->FindPC(oC->objectName); if (aC) { return aC; } aC = game->FindNPC(oC->objectName); if (aC) { return aC; } /*if (ga_flags&GA_GLOBAL) { size_t mc = game->GetLoadedMapCount(); while(mc--) { Map *map = game->GetMap(mc); if (map==Sender->GetCurrentArea()) continue; aC = GetActorObject(map->GetTileMap(), oC->objectName); if (aC) { return aC; } } }*/ } return NULL; }
Scriptable* GetActorFromObject(Scriptable* Sender, Object* oC, int ga_flags) { Scriptable *aC = NULL; Game *game = core->GetGame(); Targets *tgts = GetAllObjects(Sender->GetCurrentArea(), Sender, oC, ga_flags); if (tgts) { //now this could return other than actor objects aC = tgts->GetTarget(0,-1); delete tgts; if (aC || !oC || oC->objectFields[0]!=-1) { return aC; } //global actors are always found by object ID! return game->GetGlobalActorByGlobalID(oC->objectFields[1]); } if (!oC) { return NULL; } if (oC->objectName[0]) { // if you ActionOverride a global actor, they might not have a map :( // TODO: don't allow this to happen? if (Sender->GetCurrentArea()) { aC = GetActorObject(Sender->GetCurrentArea()->GetTileMap(), oC->objectName ); if (aC) { return aC; } } //global actors are always found by scripting name! aC = game->FindPC(oC->objectName); if (aC) { return aC; } aC = game->FindNPC(oC->objectName); if (aC) { return aC; } } return NULL; }