Home API Manuals About Forum
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

IsNPC

Returns True if the specified object is a mobile (NPC or player character), False otherwise.

ObjID — ID of the object to check.

Despite the name, this method checks the mobile flag, so it returns True for any mobile — both NPCs and player characters. To distinguish between NPCs and players, you can use GetNotoriety, differences in name or GetTitle, presence of a container in the Buy/Sell layer, and other shard-specific heuristics. There is no single universal method that guarantees 100% distinction between an NPC and a player on every shard.

Returns False if the object does not exist or the character is disconnected.

Возвращает True, если указанный объект является мобайлом (NPC или персонаж игрока), иначе False.

ObjID — ID объекта для проверки.

Несмотря на название, метод проверяет флаг мобайла, поэтому возвращает True для любого мобайла — как NPC, так и персонажей игроков. Для различения NPC и игроков можно использовать GetNotoriety, возможные отличия в имени или GetTitle, наличие контейнера в Buy/Sell layer и прочие варианты, применимые к конкретному шарду. Однозначного варианта, гарантирующего 100% отличие NPC от игрока на любом шарде — нет.

Возвращает False, если объект не существует или персонаж не подключён.

Pascal

function IsNPC(ObjID: Cardinal): Boolean;

Python

def IsNPC(ObjID: int) -> bool: ...

Pascal Example

begin
  if IsNPC(LastTarget) then
    AddToSystemJournal('Target is a mobile (NPC or player)')
  else
    AddToSystemJournal('Target is an item');
end.

Python Example

if IsNPC(LastTarget()):
    AddToSystemJournal('Target is a mobile (NPC or player)')
else:
    AddToSystemJournal('Target is an item')

See Also

GetNotoriety, IsFemale