> I'm working a 2-hand limit code, but am stuck now. I know this is > possible, because the great Daniel Koepke has coded this for me before, > but since that the MUD has been deleted, and I tried to code it again from > memory, and that didn't work too well, so I tried doing it a different, > but that didn't work too well either, would anyone care to give me a few > pointers on going about this? Ok, I'm sure Daniel et al have done this in a different way, but this way works fine, even if it's not as elegant as I'd like. First I defined a couple of new macros in utils.h: #define IS_OFFHAND(i) ((i == WEAR_DWIELD) || (i == WEAR_HOLD) || \ (i == WEAR_LIGHT) || (i == WEAR_SHIELD)) #define HAS_OFFHAND(ch) (GET_EQ(ch, WEAR_HOLD) || GET_EQ(ch, WEAR_LIGHT) || \ GET_EQ(ch, WEAR_DWIELD) || GET_EQ(ch, WEAR_SHIELD) || \ GET_EQ(ch, WEAR_TWIELD)) Where WEAR_DWIELD is a weapon that's dual wielded, and TWIELD is wielded two-handed. Then, in perform_wear: if (GET_EQ(ch, where) || (IS_OFFHAND(where) && HAS_OFFHAND(ch)) || ((where == WEAR_TWIELD) && (GET_OBJ_WEIGHT(obj) > str_app[STRENGTH_APPLY_INDEX(ch)].wield_w) && (GET_OBJ_WEIGHT(obj) < 1.5*str_app[STRENGTH_APPLY_INDEX(ch)].wield_w) && (GET_EQ(ch, WEAR_WIELD) || HAS_OFFHAND(ch))) || (where == WEAR_WIELD && GET_EQ(ch, WEAR_TWIELD))) { send_to_char(already_wearing[where], ch); return; } Erk, messy. Anyway, it checks to see whether there's already eq in that pos, or whether you already have something in your offhand and you're trying to equip to a position that's defined as offhand, or the position is "wield two-handed" (for which the weapon weight has to be between the max weight you can wield and 1.5* that), and you already have something either in your offhand or wielded or both. Of course, you have to add the relevant bits to structs.h, and extra messages for wear position and so forth. Now in do_wield: if (!CAN_WEAR(obj, ITEM_WEAR_WIELD)) send_to_char("You can't wield that.\r\n", ch); else if (GET_OBJ_WEIGHT(obj) > 1.5*str_app[STRENGTH_APPLY_INDEX(ch)].wield_w) send_to_char("It's too heavy for you to use, even with both hands.\r\n", ch); else if (GET_OBJ_WEIGHT(obj) > str_app[STRENGTH_APPLY_INDEX(ch)].wield_w) perform_wear(ch, obj, WEAR_TWIELD); else if (GET_EQ(ch, WEAR_WIELD) && GET_SKILL(ch, SKILL_DWIELD)){ if (GET_OBJ_WEIGHT(obj) > str_app[STRENGTH_APPLY_INDEX(ch)].wield_w/3) send_to_char("It's too heavy for you to use in your off hand.\r\n", ch); else perform_wear(ch, obj, WEAR_DWIELD); } else perform_wear(ch, obj, WEAR_WIELD); } This isn't all of the code, just the most difficult bits. It works fine on my mud, but you'll probably want to tidy it up a lot. Note that I have a skill for dual wield, but let everyone wield heavy weapons two-handed. At the expense of not being able to hold a light, a held item, dual wielding or wearing a shield. Chris. _____________________________________________________ "A double-edged sword lets you cut down your enemies with the backswing as well." -- Gerrard of the Weatherlight ----------------------------------------------------- Check out Dominia Mud, on snafu.net.au 3333 Or my homepage: http://yoyo.cc.monash.edu.au/~cjp +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST