PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
item.isA(POLCLASS_*)

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    PenUltima Online Forum Index -> Feature Suggestions
Display posts from previous:   

Author Message
GEEK



Joined: 22 Jul 2006
Posts: 29
Location: Italy

PostPosted: Tue Aug 29, 2006 8:12 am    Post subject: item.isA(POLCLASS_*) Reply with quote

A command like
GetItemPolclass(item) ?

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 354
Location: San Diego, California

PostPosted: Tue Aug 29, 2006 10:33 am    Post subject: Reply with quote

This is in the 097 distro's uo_extend.inc and will do what you're asking for.

Code:

// For: GetIsAType()
CONST ISA_GET_MAIN   := 0x0; // Default
CONST ISA_GET_ALL   := 0x1;


Code:

/*
 * 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

Author Message
GEEK



Joined: 22 Jul 2006
Posts: 29
Location: Italy

PostPosted: Tue Aug 29, 2006 6:26 pm    Post subject: Reply with quote

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 Smile
Anymore thnks for reply.

Post new topic   This topic is locked: you cannot edit posts or make replies.    PenUltima Online Forum Index -> Feature Suggestions All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty