Dual Wield [by Fire]
Snippet Posted Sunday, June 11th @ 02:27:29 PM, by Brandon Brown in the Skills dept.
Shane P. Lee writes, "...this snippet should install a workable dual-wield system to your MUD, but since all MUDs are not created equal, there is no telling WHAT might happen once you install this..." (click 'read more' for the snippet)
From: Fire 
Subject: Dual Wield


I tried adding several of the dual wields out there to my circleMUD with no luck, so I decided to make my own. It took some time, mostly because I had no idea what I was doing when I started:P
This snippet should install a workable dual-wield system to your MUD, but since all MUDs are not created equal, there is no telling WHAT might happen once you install this.

Please keep in mind: I installed dual wield in bpl17 using MSVC6 and am currently running on a Windows98 platform. Everything should be the same for you, but no promises.

Assumptions: 1. You are editing a stock, or close to stock MUD. If anything has been changed, please keep that in mind while you add this.
2. You have the ability to add skills/spells to your code without a tutorial in front of you.

STANDARD DISCLAIMER: (gotta love 'em:P)
#########################################################################

1. I am not responsible for this code. It is provided free of charge to the public, if you have problems with it or improve upon it, please contact me so that I can change it in the future. I will not come and install it for you, so please don't insult your intelligence by asking me to.

2. Others are not responsible for this code. I have (and hope to always) tried to give credit where credit is due, and several people (knowingly and unknowingly) contributed to this code. I am NOT taking credit for their work, but I may have changed it and forgotten, so if its buggy, its my fault, not theirs.

3. This is not a cure-all. Installing this snippet will not cause your dog to suddenly stop peeing the carpets, your cat to stop hacking up furballs, nor your MUD to suddenly become famous and full of friendly faces. It is basically a "See How This Is Done(tm)" snippet.

4. This code will probably ruin your life. There is an Artificial Intelligence hidden deep inside the code that will spring to life when you boot up the game. It will chase you down, drag you into the game and play with your naked corpse. Your little sister will suddenly start hating you, you will begin chain smoking and spending your free time in the corner muttering to yourself.

 IOW install at your own risk.

#########################################################################
END OF DISCLAIMER (still love 'em:P)

Begin snippet:
#########################################################################
I always edit the .h files when adding anything, so I can compile as I go along. This helps me find spelling errors quickly.

Open:

    spells.h

search for:

/* New skills may be added here up to MAX_SKILLS (200) */

below this add:

#define SKILL_DUAL		    xxx /* where xxx = the next number in your skills */

save and close spells.h

Open:

    structs.h

search for:

#define WEAR_HOLD      17

Add:

#define WEAR_DWIELD     X   /* where X = the next number in the list */

NOTE: Add 1 number to the #define NUM_WEARS. It should be one number higher than the last WEAR_x define.

save and close structs.h

#########################################################################
Now that the .h files have been edited, I like to go in alphabetical order from there. (silly no?)


Open:

    act.item.c

search for:

if (CAN_WEAR(obj, ITEM_WEAR_SHIELD)       where = WEAR_SHIELD;

and replace it with:

if (CAN_WEAR(obj, ITEM_WEAR_SHIELD) && (!GET_EQ(ch, WEAR_DWIELD)))      where = WEAR_SHIELD;

NOTE: This will stop anyone who is dual wielding from wearing a shield. If anyone knows a cleaner (or saner) way to do this, please let me know.

now search for:

  if (!*arg)
    send_to_char("Wield what?\r\n", ch);

directly below this add:

  else if (GET_EQ(ch, WEAR_DWIELD))
     send_to_char ("You are getting confused. Remove the secondary weapon first.\n\r", ch); /* this should never happen, but just in case:)  -spl */

now search for:

  if (!*arg)
    send_to_char("Hold what?\r\n", ch);

directly below this add:

  else if (GET_EQ(ch, WEAR_DWIELD))
     send_to_char ("You cannot dual wield AND hold something.\n\r", ch);

now search for:

    if (!get_object_in_equip_vis(ch, arg, ch->equipment, &i)) {
      sprintf(buf, "You don't seem to be using %s %s.\r\n", AN(arg), arg);
      send_to_char(buf, ch);
    } else
      perform_remove(ch, i);

directly below this add:

	if (!GET_EQ(ch, WEAR_WIELD) && (GET_EQ(ch, WEAR_DWIELD)))
	{
         send_to_char("Since you are not wielding a weapon, you can't dual wield too!\r\n", ch);
	  perform_remove(ch, WEAR_DWIELD);
	}

NOTE: This should come before any }s that come AFTER the last perform_remove(ch, i);


Now for the function:

copy the following to the end of your act.item.c file:

/* My dual wield function  -spl */
ACMD(do_dwield)
{
  struct obj_data *obj;

  one_argument(argument, arg);

  if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_DUAL))
    send_to_char("You have no idea how to do that.\r\n", ch);
  else if (!*arg)
    send_to_char("Dual wield what?\r\n", ch);
  else if (!GET_EQ(ch, WEAR_WIELD))
     send_to_char ("You must choose a primary weapon.\n\r", ch);
  else if (FIGHTING(ch))
    send_to_char("You are too busy fighting to attempt that!\r\n", ch);
  else if (GET_EQ(ch, WEAR_SHIELD))
     send_to_char ("You cannot dual wield while using a shield.\n\r", ch);
  else if (GET_EQ(ch, WEAR_HOLD))
     send_to_char ("You can't dual wield while holding an item.\n\r", ch);
  else if (!(obj = get_obj_in_list_vis(ch, arg, ch->carrying))) {
    sprintf(buf, "You don't seem to have %s %s.\r\n", AN(arg), arg);
    send_to_char(buf, ch);
  } else {
    if (!CAN_WEAR(obj, ITEM_WEAR_WIELD))
      send_to_char("You can't wield that.\r\n", ch);
    else if (GET_OBJ_WEIGHT(obj) > str_app[STRENGTH_APPLY_INDEX(ch)].wield_w)
      send_to_char("It's too heavy for you to use.\r\n", ch);
    else
      perform_wear(ch, obj, WEAR_DWIELD);
  }
}

################# E N D  C O P Y ################### <- don't add this!!!


save and close act.item.c

Open: 

    class.c

search for:

spell_level(SKILL_BASH, CLASS_WARRIOR, 12);

and below this add:

spell_level(SKILL_DUAL, CLASS_WARRIOR, 20);

save and close class.c

Open:

    constants.c

search for:

/*
 * WEAR_x - for eq list
 * Not use in sprinttype() so no \n.
 */
const char *where[] = {

after the entry for  add:

  "       ",

NOTE: This should be the last entry before }; in case you have added something.

Now in the functions below this one:

/* WEAR_x - for stat */
const char *equipment_types[] = {

after the entry for "Held", add:

  "Dual wielded",

NOTE: Again, if you have added something, this should come directly before "\n",

Now search for:

/* ITEM_WEAR_ (wear bitvector) */
const char *wear_bits[] = {

before   "\n"  add:

  "DWIELD",

NOTE: In stock circle, the last one is usually "HOLD", this new one should come after HOLD and before \n.

save and close constants.c

Open:

    fight.c

copy this DIRECTLY BELOW the void hit() funcion:

/*
 * The following function is a clone of 'void hit()'
 * it was done this way due to difficulties re-writting
 * hit to calculate dual wields -spl
*/

void hit2(struct char_data * ch, struct char_data * victim, int type)
{
  struct obj_data *wielded = GET_EQ(ch, WEAR_DWIELD);
  int w_type, victim_ac, calc_thaco, dam, diceroll;

  if(!ch || !victim)
    return;
  if (ch->in_room != victim->in_room) {
    if (FIGHTING(ch) && FIGHTING(ch) == victim)
      stop_fighting(ch);
    return;
  }
    w_type = GET_OBJ_VAL(wielded, 3) + TYPE_HIT;
  if (!IS_NPC(ch))
    calc_thaco = thaco((int) GET_CLASS(ch), (int) GET_LEVEL(ch));
  else
    calc_thaco = 20;
  calc_thaco -= str_app[STRENGTH_APPLY_INDEX(ch)].tohit;
  calc_thaco -= GET_HITROLL(ch);
  calc_thaco -= (int) ((GET_INT(ch) - 13) / 1.5);
  calc_thaco -= (int) ((GET_WIS(ch) - 13) / 1.5);
  victim_ac = compute_armor_class(victim) / 10;
  diceroll = number(1, 20);
  if ((((diceroll < 20) && AWAKE(victim)) &&
       ((diceroll == 1) || ((calc_thaco - diceroll) > victim_ac)))) {
      damage(ch, victim, 0, w_type);
  } else {
    dam = str_app[STRENGTH_APPLY_INDEX(ch)].todam;
    dam += GET_DAMROLL(ch);
      dam += dice(GET_OBJ_VAL(wielded, 1), GET_OBJ_VAL(wielded, 2));
    }
    if (GET_POS(victim) < POS_FIGHTING)
      dam *= 1 + (POS_FIGHTING - GET_POS(victim)) / 3;
    /* at least 1 hp damage min per hit */
    dam = MAX(1, dam);
      damage(ch, victim, dam, w_type);
   }

################# E N D  C O P Y ################### <- don't add this!!!

At the end of 'void perform_violence(void)' add:

/*
 * My dual wield call modeled after the "Dual Wield Patch" by Chris
 * Powell, which was a patch of Todd Kegley's snippet. Kinda
 * confusing, but let's give credit where credit is due:-)
 * -spl
*/
    if (GET_EQ(ch, WEAR_DWIELD)) {
 hit2(ch, FIGHTING(ch), TYPE_UNDEFINED);
    return;
     }

NOTE: This should come before the last 2  }s in the function.

save and close fight.c

Open:

    spell_parser.c

search for:

skillo(SKILL_BASH, "bash");

below this add:

skillo(SKILL_DUAL, "dual wield");

save and close spell_parser.c

###########################################################################
That should do it for dual wield. If you have any problems, please try adding it again, before emailing me. Also, if you are using and older version of circle, things will look different, I'll leave it to you to figure out what goes where.


PEOPLE TO THANK:
  ALL of the snippets and patch providers out there. Most of what I have added to my game has come from various snippet sites and without these contributions I would never have been able to accomplish this.
  If you have added a unique or maybe just different code to your game, I urge you to post it so that others may benifit from it. My few contributions so far have been minor I know, but someday maybe I can help someone out like I have been helped:-)


Fire
12:10 PM 2/26/00

<< FTP Uploads 2000//0/6/ | Reply | Threaded >>

 


Related Links
  CircleMUD
Shane P. Lee
Related Articles
More by bbrown
 
 

Quick Links
 
The CircleMUD FAQ
The CircleMUD home page
Alex's Snippets
Wintermute Snippets
CircleMUD Bug Reporting or Help
CircleMUD List Archives
CircleMUD Resources
Death Gate's Scripts
(Author of C conversion)
Sammy's code site
Erwin S. Andreasen's page
(Author of mudFTP and other goodies)
Death's Gate Scripting site
Help for CircleMUD in Windows
The OasisOLC Maintenance Effort
George's Random Stuff
Imaginary Realities
MUD Dictionary