Stack packet

Here you can post threads specific to the current release of the core (099)

Moderator: POL Developer

Post Reply
qrak
Grandmaster Poster
Posts: 198
Joined: Sun Feb 05, 2006 4:35 pm
Location: Poland

Stack packet

Post by qrak »

Is there any way to handle item stack packet? I mean like stacking items with diffrent name returns 0 ?
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Stack packet

Post by CWO »

The drop item packet (0x08) handles stacking. Here's most of what you need right here...

Code: Select all

use uo;
use os;
use cfgfile;

var config := ReadConfigFile("::tiles");

program drag()
   return 1;
endprogram

exported function dropping(who, byref packet)
   var dropserial := packet.GetInt32(10);
   if ( dropserial != 0xFFFFFFFF )                     // If the character is not dropping it into the outside world
      var dropitem := SystemFindObjectBySerial(dropserial);
      var dragitem := SystemFindObjectBySerial(packet.GetInt32(1));
      if (dragitem.graphic == dropitem.graphic && !dragitem.isA(POLCLASS_CONTAINER))         // If the graphics are the same and its not a container, its trying to stack them
         var elem := FindConfigElem(config, dropitem.graphic);
         if (!elem.stackable)                  // If its not stackable...
            if (dropitem.container)
               packet.SetInt32(10, dropitem.container.serial);   // If the stack is in a container then send it to the container instead
            else
               packet.SetInt32(10, 0xFFFFFFFF);      // If the stack isn't in a container then send it to the outside world
            endif
         endif
      endif
   endif
   return 0;
endfunction
add what you want to compare to the IF statement on the line

Code: Select all

 if (!elem.stackable)                  // If its not stackable...
Don't mess with the returns. If it's item.desc that you want to compare, you change it to

Code: Select all

if ((!elem.stackable) || (dragitem.desc != dropitem.desc))                  // If its not stackable...
qrak
Grandmaster Poster
Posts: 198
Joined: Sun Feb 05, 2006 4:35 pm
Location: Poland

Re: Stack packet

Post by qrak »

Thank you! :bacondance:
Post Reply