PenUltima Online

It is currently Thu Aug 21, 2008 11:26 pm

All times are UTC - 4 hours




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: item.isA(POLCLASS_*)
PostPosted: Tue Aug 29, 2006 8:12 am 
Offline

Joined: Sat Jul 22, 2006 12:25 pm
Posts: 29
Location: Italy
A command like
GetItemPolclass(item) ?

_________________
--------------------------
ZuluHotelItalia Admin


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 29, 2006 10:33 am 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 6:30 am
Posts: 384
Location: San Diego, California
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

_________________
-Austin


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 29, 2006 6:26 pm 
Offline

Joined: Sat Jul 22, 2006 12:25 pm
Posts: 29
Location: Italy
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.

_________________
--------------------------
ZuluHotelItalia Admin


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 4 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl