Author Topic: Lost the plot  (Read 2466 times)

Offline saquivor

  • BFF
  • ***
  • Posts: 111
    • View Profile
Lost the plot
« on: September 21, 2006, 05:19:13 am »
Can anyone help me I have got in a tangle over the drop command! I would

like items to eventDestruct() when dropped, but using add_action drop interfered with other objects I hold?

I tried to use SetPreventDrop and created an action to destroy it. But I can't suss out how to get vendors to pass me an item with SetPreventDrop on! Ideally I am wanting the object to Destruct when dropped. Please help as I have lost the plot over this issue and my brain has become mush!



Thanks,



Saq

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1022
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Lost the plot
« Reply #1 on: September 21, 2006, 05:34:12 am »
/lib/events/drop.c


Replace your LIB_DROP with this, and then do a recursive
reload of the items you want to test.





code:
/*    /lib/drop.c
 *    From the Dead Souls Object Library
 *    Makes an object something which can be dropped
 *    Created by Descartes of Borg 960113
 *    Version: @(#) drop.c 1.2@(#)
 *    Last modified: 96/12/22
 */

#include <lib.h>
#include <function.h>
#include <rooms.h>

private mixed PreventDrop = 0;
private mixed DestructOnDrop = 0;

// abstract methods
string GetDefiniteShort();
mixed eventMove(mixed dest);
// end abstract methods

mixed GetPreventDrop() {
    return PreventDrop;
}

mixed SetPreventDrop(mixed val) {
    if(!intp(val) && !stringp(val) && !functionp(val) && !objectp(val) ) {
   error("Bad argument 1 to SetPreventDrop().\n");
    }
    return (PreventDrop = val);
}

int GetDestructOnDrop() {
    return DestructOnDrop;
}

int SetDestructOnDrop(int val) {
    return (DestructOnDrop = val);
}

mixed CanDrop(object who) {
    if( !PreventDrop ) {
   return 1;
    }
    if( intp(PreventDrop) ) {
   return 0;
    }
    if( stringp(PreventDrop) ) {
   return PreventDrop;
    }
    if( objectp(PreventDrop) ) {
   if( PreventDrop == who ) {
       return capitalize(GetDefiniteShort()) +
       " simply will not leave your grasp.";
   }
   else {
       return 1;
   }
    }
    else {
   if( functionp(PreventDrop) & FP_OWNER_DESTED ) {
       return "There is a problem with a functional.";
   }
   return evaluate(PreventDrop, who);
    }
}

mixed eventDrop(object who) {
    mixed tmp;

    if( who != environment() ) {
   return 0;
    }

    if(DestructOnDrop) tmp = eventMove(ROOM_FURNACE);
    else tmp = eventMove(environment(who));

    if( !tmp ) {
   who->eventPrint("Something prevents you from dropping "
     + GetDefiniteShort() + ".");
   return 1;
    }
    if( tmp != 1 ) {
   return tmp;
    }
    send_messages("drop", "$agent_name $agent_verb $target_name.",
      who, this_object(), environment(who));
    if(DestructOnDrop) tell_room(environment(who),capitalize(this_object()->GetShort())+" vanishes in a flash of light!");
    return 1;
}

mixed direct_drop_obj(object target) {
    if( environment() != this_player() ) {
   return "#You don't have that to drop.";
    }
    return CanDrop(this_player());
}


Offline saquivor

  • BFF
  • ***
  • Posts: 111
    • View Profile
Lost the plot
« Reply #2 on: September 21, 2006, 05:49:51 am »
Thanks for your help.



Saq