Welcome to the Builder Academy

Question Creating a Floaty

More
11 Jun 2012 01:01 - 11 Jun 2012 01:08 #13 by Rumble
Creating a Floaty was created by Rumble
By Tink, 2010

Introduction
I wrote this guide to help people add a rather simple floating item. This code is written, tested, and works on stock tbaMUD 3.61. It may or may not work if your game is heavily modified or from an older version of CWG.

Note
To use a floating item, the player must <b>release (keyword)</b>. It will only work on an item that is set to be a FLOATING wear item.

The Code
Code:
// In act.item.c> in wear_bitvectors, add it to the end of the list. *** // Note: Don't forget to add a comma after the last one! (And don't put one after your new addition...) *** int wear_bitvectors[] = { ITEM_WEAR_TAKE, ITEM_WEAR_FINGER, ITEM_WEAR_FINGER, ITEM_WEAR_NECK, ITEM_WEAR_NECK, ITEM_WEAR_BODY, ITEM_WEAR_HEAD, ITEM_WEAR_LEGS, ITEM_WEAR_FEET, ITEM_WEAR_HANDS, ITEM_WEAR_ARMS, ITEM_WEAR_SHIELD, ITEM_WEAR_ABOUT, ITEM_WEAR_WAIST, ITEM_WEAR_WRIST, ITEM_WEAR_WRIST, - ITEM_WEAR_WIELD, ITEM_WEAR_TAKE, ITEM_WEAR_ANKLE, ITEM_WEAR_ANKLE + ITEM_WEAR_WIELD, ITEM_WEAR_TAKE, ITEM_WEAR_ANKLE, ITEM_WEAR_ANKLE, + ITEM_WEAR_FLOATING }; // In const char *already_wearing, add it to the bottom. Don't forget to pay attention to the commas! *** "You're already wearing something around both of your wrists.\r\n", "You're already wielding a weapon.\r\n", - "You're already holding something.\r\n" + "You're already holding something.\r\n", + "You're already using something as a floaty.\r\n" }; // In *keywords, add it to the bottom. There must be a comma at the end of the last line! *** "hands", "arms", "shield", "about", "waist", "wrist", "!RESERVED!", "!RESERVED!", "!RESERVED!", "ankle", "!RESERVED!", + "floating", }; // After do_wear, add a similar command. *** ACMD(do_release) { char arg[MAX_INPUT_LENGTH]; struct obj_data *obj; one_argument(argument, arg); if (!*arg) send_to_char(ch, "Release what?\r\n"); else if (!(obj = get_obj_in_list_vis(ch, arg, NULL, ch->carrying))) send_to_char(ch, "You don't seem to have %s %s.\r\n", AN(arg), arg); else { if (!CAN_WEAR(obj, ITEM_WEAR_FLOATING)) send_to_char(ch, "You can't release that as a floaty.\r\n"); else perform_wear(ch, obj, WEAR_FLOATING); } } // In <i>constants.c</i> in *wear_where, add it to the bottom of the list. *** // Note: Mind the comma! *** "&lt;worn on waist&gt; ", "&lt;worn around wrist&gt; ", "&lt;worn around wrist&gt; ", "&lt;wielded&gt; ", "&lt;held&gt; ", "&lt;worn around ankle&gt; ", - "&lt;worn around ankle&gt; " + "&lt;worn around ankle&gt; ", + "&lt;floating nearby&gt; " // In *equipment_types, add it to the bottom of the list. *** "Worn around left wrist", "Wielded", "Held", "Worn on ankles", "Worn on ankles", + "Floating nearby", // In *wear_bits, add it to the bottom of the list. *** "WAIST", "WRIST", "WIELD", "HOLD", "ANKLE", + "FLOATING", "\n" }; // In <i>objsave.c</i>, add it to the bottom of the list in the big list of checks. *** case WEAR_HOLD: if (CAN_WEAR(obj, ITEM_WEAR_HOLD)) break; if (IS_WARRIOR(ch) && CAN_WEAR(obj, ITEM_WEAR_WIELD) && GET_OBJ_TYPE(obj) == ITEM_WEAPON) break; location = LOC_INVENTORY; break; case WEAR_ANKLE_R: case WEAR_ANKLE_L: if (!CAN_WEAR(obj, ITEM_WEAR_ANKLE)) location = LOC_INVENTORY; break; + case WEAR_FLOATING: + if (!CAN_WEAR(obj, ITEM_WEAR_FLOATING)) + location = LOC_INVENTORY; + break; default: location = LOC_INVENTORY; } // In <i>act.wizard.c</i> in zarmor, add it to the list at the bottom. *** // There should not be a comma at the end of this list. *** {ITEM_WEAR_WAIST, 10, "Belt"}, {ITEM_WEAR_WRIST, 10, "Wristwear"}, {ITEM_WEAR_HOLD, 10, "Held item"}, - {ITEM_WEAR_ANKLE, 10, "Anklewear"} + {ITEM_WEAR_ANKLE, 10, "Anklewear"}, + {ITEM_WEAR_FLOATING, 10, "Floating"} // In <i>structs.h</i> in the #defines for all the wear spots, add it to the bottom. *** // Be sure to increment the total afterward! *** #define WEAR_WRIST_L 15 /**< Equipment Location Left Wrist */ #define WEAR_WIELD 16 /**< Equipment Location Weapon */ #define WEAR_HOLD 17 /**< Equipment Location held in offhand */ #define WEAR_ANKLE_R 18 /**< Equipment Location for right ankle */ #define WEAR_ANKLE_L 19 /**< Equipment Location for left ankle */ + #define WEAR_FLOATING 20 /**< Equipment Location for floaty */ - #define NUM_WEARS 20 + #define NUM_WEARS 21 // In the item wear defines, add it to the bottom. *** // Again, note the increment in NUM_ITEM_WEARS. *** #define ITEM_WEAR_WRIST 12 #define ITEM_WEAR_WIELD 13 #define ITEM_WEAR_HOLD 14 #define ITEM_WEAR_ANKLE 15 + #define ITEM_WEAR_FLOATING 16 - #define NUM_ITEM_WEARS 16 + #define NUM_ITEM_WEARS 17 // Finish up the code by adding in the necessities for do_release...*** // In <i>act.h</i>, right at the top, add after do_wield. *** ACMD(do_wield); ACMD(do_release); // Finally, in <i>interpreter.c</i>, add it in the alphabetical listing. *** { "recite" , "reci" , POS_RESTING , do_use , 0, SCMD_RECITE }, { "receive" , "rece" , POS_STANDING, do_not_here , 1, 0 }, + { "release" , "rel" , POS_RESTING , do_release , 0, 0 }, { "remove" , "rem" , POS_RESTING , do_remove , 0, 0 }, { "remort" , "remo" , POS_STANDING, do_remort , 1, 0 },
Conclusion
Not hard at all. Please feel free to comment with suggestions for additions, or point out if I've missed anything. :)

Rumble
The Builder Academy
tbamud.com 9091
rumble@tbamud.com
Last edit: 11 Jun 2012 01:08 by Rumble.

Please Log in or Create an account to join the conversation.

Time to create page: 0.188 seconds