Hey all. I've been hacking around with my MUD, and in anticipation of my smoking code, I thought it'd be nice to be able to pass smoke-containers (and everything else) around. I'll explain what it does... it's basically "give", but it goes from what you're holding (WEAR_HOLD) to what your victim is holding... it checks if they're holding something, and the various weights and gives the appropriate errors. Basically, what I want to do with my smoking code is that to smoke from something, it needs to be held in your hands (unlike drink code, where it can be in your inventory). Eventually, smoke-container items will be type SMOKECON as a container for smokeables, but this isn't implemented yet. Certain items can be on the floor like a smoke-fountain (think of a hooka in the room, type SMOKEFOUNT or something (maybe HOOKA as a type?), again it's coming soon. So this pass command allows someone to smoke from a pipe, then pass the pipe along to someone else, as long as their hands aren't full. I've tested it in my MUD, and it seems to work fine... passing various things back and forth seem to work OK. This is my first attempt at coding, and it's basically just cut-and-paste from code like do_give, remove, stuff like that. The files affected are: act.item.c & interpreter.c Hope everyone likes this... if the various gurus can show me a nicer/cleaner way of doing it, I'd be most appreciative. If you want to credit me, go ahead (circlemud@lore.com), I'm not going to worry about it, as it's basically just cut and paste. Adam aka DrWho interpreter.c: Search for: ACMD(do_page); and add this after it (to keep alphabetical order): ACMD(do_pass); Then search for: { "pardon" , POS_DEAD , do_wizutil , LVL_GOD, SCMD_PARDON }, and add this after: { "pass" , POS_RESTING , do_pass , 0, 0 }, and that's it for interpreter.c act.item.c: Search for: void perform_remove(struct char_data *ch, int pos); and add this after: void perform_pass(struct char_data *ch, struct char_data *vict); A few lines down from there you should find: ACMD(do_give); and add this after: ACMD(do_pass); I put the subroutines under the do_give routine, I think after this you can put it pretty much anywhere: void perform_pass(struct char_data *ch, struct char_data *vict) { struct obj_data *obj; if (!(obj = GET_EQ(ch, WEAR_HOLD))) log("SYSERR: perform_remove: bad pos %d passed.", WEAR_HOLD); else if (OBJ_FLAGGED(obj, ITEM_NODROP)) act("You can't remove $p, it must be CURSED!", FALSE, ch, obj, 0, TO_CHAR); else if (GET_EQ(vict, WEAR_HOLD)) { act("$N seems to be have $S hands full.", FALSE, ch, 0, vict, TO_CHAR); act("$n tries to pass you $p, but your hands are full.", TRUE, ch, obj, vict, TO_VICT); act("$n tries to pass $p to $N, but $S hands are full.", TRUE, ch, obj, vict, TO_NOTVICT); } else if (GET_OBJ_WEIGHT(obj) + IS_CARRYING_W(vict) > CAN_CARRY_W(vict)) act("$E can't carry that much weight.", FALSE, ch, 0, vict, TO_CHAR); else { obj_to_char(unequip_char(ch, WEAR_HOLD), ch); obj_from_char(obj); equip_char(vict, obj, WEAR_HOLD); act("You pass $N $p.", FALSE, ch, obj, vict, TO_CHAR); act("$n passes you $p.", FALSE, ch, obj, vict, TO_VICT); act("$n passes $N $p.", TRUE, ch, obj, vict, TO_NOTVICT); } } ACMD(do_pass) { char arg[MAX_STRING_LENGTH]; struct char_data *vict; argument = one_argument(argument, arg); if (!*arg) send_to_char(ch, "Pass what to who?\r\n"); else { char buf1[MAX_INPUT_LENGTH]; one_argument(argument, buf1); if (!(vict = give_find_vict(ch, buf1))) return; else { if (get_obj_pos_in_equip_vis(ch, arg, NULL, ch->equipment) != WEAR_HOLD) send_to_char(ch, "You don't seem to be holding %s %s.\r\n", AN(arg), arg); else perform_pass(ch, vict); } } } --- So, that's it. Please, be gentle. -- +---------------------------------------------------------------+ | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html | | Newbie List: http://groups.yahoo.com/group/circle-newbies/ | +---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 06/26/03 PDT