/* Ranged Room Combat BAH 07-FEB-2001 1:46AM Okay range only applies to weapons (right now) so we are using GET_OBJ_VAL(weap, 0) since it's not currently being use elsewhere. Also we added 2 new variables to the pfile which will require a pwipe unless you have ASCII pfiles. (As long as Jeremy and George decided to leave that 0 spot open for use on weapons you won't have to wipe them, if they change their minds then we are scrwed 8) I do have a work-around but I'm not to worried about it at this point. This is made for stock CircleMUD bpl 17 but can be easily adapted for ASCII pfiles (all you have to do is save the 2 new variables in the pfile) Disclaimer: The normal, if it's broke it ain't my fault 8) Okay if you find a bug or a way to make this code nicer please send it to me at: hartvigsen@gci.net please, if you can't send it to me then send it to the list 8) Me first though... Okay to add ranged weapons it's quite simple, change the 0 value to anything above 4 just about. Range 1 - 3 in my opinion is melee combat 4 - 10 is more like sword/staff combat, and 11 -30 is ranged. Got it? I don't 8) I just know how it works, not how to explain it.. Ah the life of a coder.. GET_RANGEMOD(ch) returns the character's modified range (default: 1) In my MUD tall people/races have a +1 to range (making this return 2). GET_DEFRANGE(ch) returns the character's Default Range (where they go when they enter a new room) GET_RANGE(ch) returns the character's actual Range (where they are currently standing.) */ Add to act.movement.c At the top: ACMD(do_range); Wherever: /* Added By BAH [Ranged Room Combat (function)] */ ACMD(do_range) { one_argument(argument, arg); /* No argument? Display current settings */ if(!*arg) { sprintf(buf, "Your current range is %d.\r\nDefault range of %d.\r\n", GET_RANGE(ch),GET_DEFRANGE(ch)); send_to_char(buf, ch); return; } /* Are they giving us a number setting? */ if (isdigit(*arg)) { GET_RANGE(ch) = atoi(arg); sprintf(buf, "Your current range is %d.\r\nDefault range of %d.\r\n", GET_RANGE(ch),GET_DEFRANGE(ch)); send_to_char(buf, ch); } else { /* or a letter setting?*/ switch(*arg) { /* Set their Default */ case 'd': case 'D': two_arguments(argument,arg,buf); if(!*buf) { send_to_char("Range Default *must* have a second variable. range d < # | N | M | F >\r\n",ch); return; } if(isdigit(*buf)) { /* absolute */ GET_DEFRANGE(ch)=atoi(buf); } else { switch(*buf) { /* Near Range */ case 'n': case 'N': GET_DEFRANGE(ch) = number(1,3); break; /* Middle Range */ case 'm': case 'M': GET_DEFRANGE(ch) = number(4,10); break; /* Far Range */ case 'f': case 'F': GET_DEFRANGE(ch) = number(11,30); break; default: send_to_char("That's not a default range setting!\r\n",ch); return; } } break; /* Near Range */ case 'n': case 'N': GET_RANGE(ch) = number(1,3); break; /* Middle Range */ case 'm': case 'M': GET_RANGE(ch) = number(4,10); break; /* Far Range */ case 'f': case 'F': GET_RANGE(ch) = number(11,30); break; default: send_to_char("That's not a range setting!\r\n",ch); return; } sprintf(buf, "Your current range is %d.\r\nDefault range of %d.\r\n", GET_RANGE(ch),GET_DEFRANGE(ch)); send_to_char(buf, ch); GET_WAIT_STATE(ch) = PULSE_VIOLENCE * 2; } } In act.informative.c [list_one_char (around line 250)] find: else *buf = '\0'; add this after: /* Added By BAH [Ranged Room Combat (2)] */ sprintf(buf2, "[%2d] ", GET_RANGE(i)); strcat(buf, buf2); find: if (IS_NPC(i)) { sprintf(buf2,"[%2d] %s",GET_RANGE(i),CAP(i->player.short_descr)); strcpy(buf, buf2); } else change the next line to: /* Changed By BAH [Ranged Room Combat (1)] */ sprintf(buf, "[%2d] %s %s",GET_RANGE(i), i->player.name, GET_TITLE(i)); In act.offensive.c [do_hit (around line 105)] Find: } else if (AFF_FLAGGED(ch, AFF_CHARM) && (ch->master == vict)) act("$N is just such a good friend, you simply can't hit $M.", FALSE, ch, 0, vict, TO_CHAR); Add after it: /* Added by BAH [Ranged Room Combat (6)] */ else if (GET_EQ(ch,WEAR_WIELD) && \ (abs(GET_RANGE(vict) - GET_RANGE(ch)) > (GET_OBJ_VAL(GET_EQ(ch, WEAR_WIELD),0) + GET_RANGEMOD(ch)))) act("$N is out of your weapon's range.", FALSE, ch, 0, vict, TO_CHAR); else if ((!GET_EQ(ch, WEAR_WIELD)) && abs(GET_RANGE(vict) - GET_RANGE(ch)) > GET_RANGEMOD(ch)){ act("$N is out of your range.", FALSE, ch, 0, vict, TO_CHAR); } in db.c [init_char (around line 2543)] Add in there somewhere: /* Added By BAH [Ranged Room Combat (2)] */ GET_RANGE(ch) = GET_DEFRANGE(ch) = number(1,30); GET_RANGEMOD(ch) = 1; in fight.c [hit (around line 816)] After the first if statement close bracker add: /* Added by BAH [Ranged Room Combat (9)] */ if ((wielded) && abs(GET_RANGE(victim) - GET_RANGE(ch)) > GET_OBJ_VAL(wielded,0)) { act("$n is outside your weapon's range.", TRUE, victim, 0, ch, TO_CHAR); act("You stand outside $n's weapon range of attack.", TRUE, ch, 0, victim, TO_CHAR); return; } else if (abs(GET_RANGE(victim) - GET_RANGE(ch)) > GET_RANGEMOD(ch)) { act("$n is outside your range.", TRUE, victim, 0, ch, TO_CHAR); act("You stand outside $n's range of attack.", TRUE, ch, 0, victim, TO_CHAR); return; } in interpreter.c (in command parser) at the top add: ACMD(do_range) add: { "range" , POS_FIGHTING, do_range , 0, 0 }, in structs.h[(char_special_data_saved (around line 755)] add: /* Added by BAH [Ranged Room Combat (3)] */ int rangedef; int rangemod; int range; Finally in utils.h add: /* Added By BAH [Ranged Room Combat (3)] */ #define GET_DEFRANGE(ch) ((ch)->char_specials.saved.rangedef) #define GET_RANGE(ch) ((ch)->char_specials.saved.range) #define GET_RANGEMOD(ch) ((ch)->char_specials.saved.rangemod)