1% take.pl
    2% May 18, 1996
    3% John Eikenberry
    4%
    5% Dec 13, 2035
    6% Douglas Miles
    7%
    8/* * module *
    9% This file defines the basic take command
   10%
   11*/
   12:-swi_module(moduleTake, [do_act_for_take/2]).   13
   14:- include(prologmud(mud_header)).   15
   16% :- register_module_type (mtCommand).
   17
   18vtActionTemplate(actTake(tCarryAble)).
   19
   20% Command Hook
   21baseKB:agent_call_command(Agent,actTake(Obj)) :- 
   22  \+ call_u(action_verb_useable(actTake,_,_,_,_)),
   23  must(agent_call_take(Agent,Obj)).
   24
   25% Successfully
   26agent_call_take(Agent,Obj) :- 
   27	once((farthest_reachable_object(Agent,Obj))),
   28	must((nop(props(Obj,mudWeight<2)),
   29	ignore(do_act_affect(Agent,actTake,Obj)))),
   30	do_act_for_take(Agent,Obj),
   31	call_update_charge(Agent,actTake).
   32
   33% Unsuccessfully
   34agent_call_take(Agent,_Obj) :- 
   35	call_update_charge(Agent,actTake),
   36	add_cmdfailure(Agent,actTake).
   37
   38
   39% Is the obect going to stick around after take-ing, either as is
   40% or in the agent's possession.
   41do_act_for_take(Agent,Obj) :-
   42	do_change_for_take(Agent,Obj),!,
   43        xlisting(Obj).
   44
   45do_change_for_take(_,Obj):-
   46        props(Obj,mudPermanence(actTake,Disappears)), 
   47		member(Disappears,[0,vTakenDeletes]),
   48        detatch_object(Obj),
   49        ain(mudStowing(Agent,Obj)),    
   50        must_post_for_take(Agent,Obj),
   51        detatch_object(Obj),
   52        destroy_instance(Obj).
   53do_change_for_take(Agent,Source) :-
   54	props(Source,mudPermanence(actTake,vTakenCopyFn(What))),
   55        create_new_object([What],Obj),
   56        detatch_object(Obj),
   57        ain(mudStowing(Agent,Obj)),        
   58        must_post_for_take(Agent,Obj).
   59do_change_for_take(Agent,Obj) :-        
   60        props(Obj,mudPermanence(actTake,vTakenStays)),!,
   61        mudAtLoc(Obj,Was),
   62        detatch_object(Obj),
   63        ain(mudStowing(Agent,Obj)),
   64        must_post_for_take(Agent,Obj),
   65        detatch_object(Obj),
   66        ain(mudAtLoc(Obj,Was)).
   67% default is same as vTakenMoves
   68do_change_for_take(Agent,Obj) :-
   69	ignore((props(Obj,mudPermanence(actTake,Held)),member(Held,[1,vTakenMoves]))),
   70        detatch_object(Obj),
   71	ain(mudStowing(Agent,Obj)),
   72        must_post_for_take(Agent,Obj).
   73
   74must_post_for_take(Agent,Obj):-
   75       fmt([Agent,take,Obj]),
   76       sanity(mudPossess(Agent,Obj)).
   77
   78% Record keeping
   79update_charge(Agent,actTake) :- 
   80        padd(Agent,mudEnergy(+ -2)).
   81
   82:- include(prologmud(mud_footer)).