A command like
GetItemPolclass(item) ?
item.isA(POLCLASS_*)
Moderator: POL Developer
This is in the 097 distro's uo_extend.inc and will do what you're asking for.
Code: Select all
// For: GetIsAType()
CONST ISA_GET_MAIN := 0x0; // Default
CONST ISA_GET_ALL := 0x1;
Code: Select all
/*
* GetIsAType(object, flags)
*
* Purpose
* Retrieves the 'IsA' type for an object or all of the
* classes it belongs to.
*
* Parameters:
* object: Anything belonging to the UObject class heirarchy.
* flags: Flags...
*
* Return value:
* Returns an error on failure.
* Returns an integer if ISA_GET_MAIN is passed for flags.
* Returns an array of integers if ISA_GET_ALL is used.
*
*/
function GetIsAType(object, flags:=ISA_GET_MAIN)
var type_list := array;
var i := 16; // Max number of IsA Id #s
for ( i; i > 0; i-=1 )
if ( !object.IsA(i) )
continue;
elseif ( flags & ISA_GET_ALL )
type_list.Append(i);
else
return i;
endif
SleepMS(2);
endfor
if ( type_list.Size() > 0 )
return type_list;
else
return error{"errortext":="Unable to determine IsA type of '"+TypeOf(object)+"'"};
endif
endfunction
It is not a very fast code to do a loop to scan all possibile POLCLASS_*
const POLCLASS_UOBJECT := 1;
const POLCLASS_ITEM := 2;
const POLCLASS_MOBILE := 3;
const POLCLASS_NPC := 4;
const POLCLASS_LOCKABLE := 5;
const POLCLASS_CONTAINER := 6;
const POLCLASS_CORPSE := 7;
const POLCLASS_DOOR := 8;
const POLCLASS_SPELLBOOK := 9;
const POLCLASS_MAP := 10;
const POLCLASS_MULTI := 11;
const POLCLASS_BOAT := 12;
const POLCLASS_HOUSE := 13;
const POLCLASS_EQUIPMENT := 14;
const POLCLASS_ARMOR := 15;
const POLCLASS_WEAPON := 16;
I was able to write a function like the one upper
Anymore thnks for reply.
const POLCLASS_UOBJECT := 1;
const POLCLASS_ITEM := 2;
const POLCLASS_MOBILE := 3;
const POLCLASS_NPC := 4;
const POLCLASS_LOCKABLE := 5;
const POLCLASS_CONTAINER := 6;
const POLCLASS_CORPSE := 7;
const POLCLASS_DOOR := 8;
const POLCLASS_SPELLBOOK := 9;
const POLCLASS_MAP := 10;
const POLCLASS_MULTI := 11;
const POLCLASS_BOAT := 12;
const POLCLASS_HOUSE := 13;
const POLCLASS_EQUIPMENT := 14;
const POLCLASS_ARMOR := 15;
const POLCLASS_WEAPON := 16;
I was able to write a function like the one upper
Anymore thnks for reply.