! Chest script
! By AbyssDragon                                         
!    abyssdragon@juno.com                                
!    http://www.geocities.com/TimesSquare/2795           
! Copyright (c)1998 AbyssWare                            
!                                                        
!  YOU CAN USE/MODIFY/ABUSE THIS SCRIPT IN ANY WAY YOU   
!       PLEASE, AS LONG AS YOU GIVE ME CREDIT.
!
!   BE SURE TO HAVE A NPC.TYPE AS CHEST IN THE DCCTOKEN.DAT FILE
!
! Allows for NPCs to be chests, that hold items the player can get.
! Also, lets you easily add traps to chests, by altering their v1 values
! when being placed through DCWorld. It will only activate traps the first
! time the chest it opened.
! Traps (the number represents the v1 value):
! 1)Spike       2)Poison        3)Dart          4)Destruction
! 5)Blade       6)Rock          7)Weight
! You can easily add more.
!------------------------------------------------------------------------!
:@TALK ! Talk to the character !
!------------------------------------------------------------------------!
  if npc.count = 0 then
    L0 = msgbox( ERROR, 1, "Ok", "ERROR: NPC Script called with no NPC selected!" );
    STOP;
  endif;
  timeck(5);
  inc(npc.block);
  if npc.v0 = 1 then
   if group.size > 1 then
    L0 = select(group);
   endif;
   goto TAKE;
  endif;
:TRAP
  if group.size > 1 then
   L0 = select(group);
   S1 = swriteln("Do you want ",player.name," to search for traps?");
   L0 = msgbox(EXCLAMATION,2,"Yes","No",S1);
   if L0 = 1 goto TRAP;
  endif;
  if npc.v1 = 1 then
   if random(player.dex) > npc.dex then
    S1 = swriteln("Spike trap found and disarmed!");
   else
    L1 = random(npc.level);
    S1 = swriteln("Spike trap does ",L1," damage to ",player.name,"!");
    dec(player.hp,L1);
   endif;
  elsif npc.v1 = 2 then
   if random(player.dex) > npc.dex then
    S1 = swriteln("Poison trap found and disarmed!");
   else
    L1 = random(npc.level);
    S1 = swriteln("Poison trap does ",L1," damage to ",player.name,"!");
    dec(player.hp,L1);
    inc(player.poisoned, 3);
   endif;
  elsif npc.v1 = 3 then
   if random(player.dex) > npc.dex then
    S1 = swriteln("Dart trap found and disarmed!");
   else
    L1 = random(npc.level - player.dex);
    S1 = swriteln("Dart trap does ",L1," damage to ",player.name,"!");
    dec(player.hp,L1);
   endif;
  elsif npc.v1 = 4 then
   if random(player.dex) > npc.dex then
    S1 = swriteln("Destruction trap found and disarmed!");
   else
    S1 = swriteln("Destruction trap causes the chest to dissolve!");
    npc.block = 1024;
    npc.x = 0;
    npc.y = 0;
    npc.count = 0;
    L0 = msgbox(EXCLAMATION,1,"Okay",S1);
    goto XSTOP;
   endif;
  elsif npc.v1 = 5 then
   if random(player.dex) > npc.dex then
    S1 = swriteln("Blade trap found and disarmed!");
   else
    S1 = swriteln("Blade trap kills ", player.name,".");
    player.hp = 0;
    L0 = msgbox(EXCLAMATION,1,"Okay",S1);
    if group.size = 0 goto XSTOP;
   endif;
  elsif npc.v1 = 6 then
   if random(player.dex) > npc.dex then
    S1 = swriteln("Rock trap found and disarmed!");
   else
    S1 = swriteln("Rock trap strikes ",player.name,"!");
    player.hp = 1;
   endif;
  elsif npc.v1 = 7 then
   if random(player.dex) > npc.dex then
    S1 = swriteln("Weight trap found and disarmed!");
   else
    S1 = swriteln("Weight trap injures ",player.name,"!");
    dec(player.str);
    dec(player.dex);
   endif;
  else
   S1 = swriteln("No traps were put on the chest.");
  endif;
  L0 = msgbox(EXCLAMATION,1,"Okay",S1);
  if player.hp < 1 then
   player.hp = 1;
  endif;
  if group.size > 1 then
   L0 = select(group);
  endif;
:TAKE
  L0 = select("Take Something","Leave");
  if L0 = 1 goto XSTOP;
  L3 = select( NPC );
  if L3 < 0 then
   L0 = msgbox(EXCLAMATION,1,"Okay","EMPTY!");
   goto XSTOP;
  endif;
  if L3 < 0 goto XSTOP;
  if npc.bp.type = FOOD and npc.bp.class = NONE then
   L10 = 255 - group.food; ! Max food we can carry !
   if L10 < npc.bp.count then
    L11 = npc.bp.count - L10;
    S1 = swriteln( "{You have to carry ", L11, " in your backpack}" );
    L0 = msgbox( EXCLAMATION, 1, "Okay", S1);
    inc( group.food, L10 );
    move( npc.bp, player, L11 ); ! Put L11 foods in the backpack !
   else
    inc( group.food, npc.bp.count );
    npc.bp.count = 0;
   endif;
  else
   L12 = npc.bp.count;
   move( NPC.BP, PLAYER );
   if failure then
    S1 = swriteln("You couldn't hold it!");
    L0 = msgbox(EXCLAMATION,1,"Okay",S1);
   endif;
  endif;
 goto TAKE;
:XSTOP
 timeck(5);
 if npc.count then
  dec(npc.block);
  npc.v0 = 1;
 endif;
 group.current = 0;
 paint( large );
 STOP;

    Source: geocities.com/timessquare/2795

               ( geocities.com/timessquare)