From: "Edward Felch" <dustlos@HOTMAIL.COM>
> Sorry to bother everyone with another question, I've added in the ranged
> weapon code and altered it to my mud but I'd like it to have a weapon to
> have a range that can be set in oedit (like 3 rooms, 4 rooms over, etc).
> Right now its only set to be a single room over and the do_scan function
> isn't giveing me much help with finding a target some distance over...
> Could someone please help me with searching some X rooms in a straight
> line (not through doors) and check to see if a victim (arg1) is there?
The following are minimal changes to your code. It assumes that you
define a variable called distance in your function, and that you have
one called max_distance that is the maximum number of rooms one can
travel in a straight line.
> // Code
> /* some case switching which sets a variable called far_room (the
direction
> being fired) is here */
> .
> .
> .
> if (far_room == -1 ) {
> send_to_char("Invalid direction given. Valid values are N, E, S, W, U,
> D.\r\n",ch);
> return;
> }
Add:
vict = NULL;
distance=0;
> if (CAN_GO(ch, far_room)) {
Change to:
while (!vict && CAN_GO(ch, far_room) && ++distance <= max_distance) {
> target_room = world[ch->in_room].dir_option[far_room]->to_room;
> }
Remove above brace
> if (target_room == -1) {
> send_to_char("You can't find anything worth firing at in that
> direction.\r\n",ch);
> return;
> }
> source_room = ch->in_room;
> ch->in_room = target_room;
> vict = get_char_room_vis(ch, arg1);
> ch->in_room = source_room;
Add:
}
> if (!vict) {
> sprintf(buf, "There doesn't seem to be a %s that way.\r\n",arg2);
> send_to_char(buf, ch);
> return;
> }
--
+---------------------------------------------------------------+
| FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
| Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
+---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/04/01 PST