superuser
2011-08-25 14:15:19
I think this is necessary, as R_GetInteractingNPC only returns first interacting NPC. This is highly inconvenient, as for example if the player has summoned familiar and fights a monter, it only returns the familiar. The following returns all NPCs interacting.
function R_GetInteractingNPCs(Null: Boolean): TNPCArray;
var
MyPlayer, InteractingPlayer: TPlayer;
NPCs: TNPCArray;
I, H, PlayerIndex: Integer;
begin
MyPlayer := R_GetMe;
NPCs := R_GetAllNPCs(Null);
H := High(NPCs);
for I := 0 to H do
begin
PlayerIndex := NPCs[I].Interacting - 32768;
if(PlayerIndex < 0)then
Continue;
InteractingPlayer := R_GetPlayer(PlayerIndex);
if(InteractingPlayer.Name = MyPlayer.Name)then
begin
SetLength(result, Length(result) + 1);
result[High(result)] := NPCs[I];
end;
end;
end;