Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 Couple bugs
Yesterday, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Yahoo!, DotBot

Members: 0
Guests: 14
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » Bug: ranged_attack( ) TO_ROOM...
Forum Rules | Mark all | Recent Posts

Bug: ranged_attack( ) TO_ROOM messages won't display
< Newer Topic :: Older Topic > ACT( ) call from wrong room

Pages:<< prev 1 next >>
Post is unread #1 Feb 27, 2012, 8:41 pm   Last edited Feb 27, 2012, 9:57 pm by GatewaySysop
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts367
JoinedMar 7, 2005

Another interesting one that took some deciphering to figure out because of how the while loop is working.

In this block, skills.c, in ranged_attack( ):

   while( dist <= range )
   {
      char_from_room( ch );
      char_to_room( ch, pexit->to_room );

      if( IS_SET( pexit->exit_info, EX_CLOSED ) )
      {
         /*
          * whadoyahknow, the door's closed 
          */
         if( projectile )
            snprintf( buf, MAX_STRING_LENGTH, "You see your %s pierce a door in the distance to the %s.",
                      myobj( projectile ), dir_name[dir] );
         else
            snprintf( buf, MAX_STRING_LENGTH, "You see your %s hit a door in the distance to the %s.", stxt, dir_name[dir] );
         act( color, buf, ch, NULL, NULL, TO_CHAR );
         if( projectile )
         {
            snprintf( buf, MAX_STRING_LENGTH, "$p flies in from %s and implants itself solidly in the %sern door.", dtxt,
                      dir_name[dir] );
            act( color, buf, ch, projectile, NULL, TO_ROOM );
         }
         else
         {
            snprintf( buf, MAX_STRING_LENGTH, "%s flies in from %s and implants itself solidly in the %sern door.",
                      aoran( stxt ), dtxt, dir_name[dir] );
            buf[0] = UPPER( buf[0] );
            act( color, buf, ch, NULL, NULL, TO_ROOM );
         }
         break;
      }



You need to be cognizant of the fact that (ch) is currently on the other side of the EX_CLOSED exit when the calls to ACT( ) are made. Consequently, the caller (ch) will see the TO_CHAR echo, but the TO_ROOM will be announced to the occupants in the room with the EX_CLOSED exit, because they are on the opposite side of the exit.

In other words, you reach this code when (ch) has gone one more room in the direction the projectile is trying to go (notice the char_to_room( ) call comes first, THEN the examination of the exit that was just passed through). When ACT( ) calls are made, the person who fired the projectile (ch) will see the TO_CHAR message, but there's nobody with him on the other side of the closed exit to see the TO_ROOM message. It is supposed to be echoed to the previous room, where potential occupants are supposed to see the projectile has terminated its flight at said closed exit (by hitting the door/gate/whatever it is).

One way to fix this, since the loop does a break anyway afterward and puts (ch) back where they fired from, is to add a new ROOM_INDEX_DATA variable (e.g. 'temproom') at the top of the function and then do like so:

    while ( dist <= range )
    {
	char_from_room(ch);
	char_to_room(ch, pexit->to_room);

	if ( IS_SET(pexit->exit_info, EX_CLOSED) )
	{
	    /* whadoyahknow, the door's closed */

            /* We need to go back one step before echoing these messages  */
            temproom = ch->was_in_room;   /* Room with the closed exit */
            char_from_room( ch );         /* Out of here, overwrites ch->was_in_room */
            char_to_room( ch, temproom ); /* Put them one room back */



Incidentally, you need to also handle the projectile in these cases, else it stays in inventory and you can fire it at the closed exit an infinite number of times. I suggest the following modification before the break statement in the same block:

            if ( projectile )
                extract_obj(projectile);

	    break; 


Hope that's helpful! :alien:
       
Post is unread #2 Mar 7, 2012, 5:02 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,858
JoinedJul 26, 2005

Thanks, Id already fixed the extracting it long ago it looks like but guess i never paid that one any attention. I instead just moved the char_from_room and char_to_room down below that whole block where it checked if the exit was closed should work fine that way also.
       
Post is unread #3 Mar 7, 2012, 9:44 pm   Last edited Mar 7, 2012, 9:53 pm by GatewaySysop
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts367
JoinedMar 7, 2005

Remcon said:

Thanks, Id already fixed the extracting it long ago it looks like but guess i never paid that one any attention. I instead just moved the char_from_room and char_to_room down below that whole block where it checked if the exit was closed should work fine that way also.


Not a bad idea! :cyclops:

I actually took this opportunity to re-write most of this loop and put things in an order that was more intuitive and made more sense to somebody looking at it for the first time. For example, move this closed door check after the "is there even an exit in the first place" check at the bottom, rather than having it at the top, and the increment for distance at the top rather than the bottom of the loop, so that distance is counted properly in the first place. Previously, distance was incremented after the check for dist == range, which essentially gave you a freebie of one room. :crazy:
       
Post is unread #4 Aug 20, 2012, 2:57 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

I'd be interested in seeing your rewritten function, if it's nothing too invasive, maybe we can just replace the function and make it all more intuitive rather than just band-aiding the little issues here and there.
       
Pages:<< prev 1 next >>