Generate an act flag on mobile, on reset area

Posted by Zeno on Tue 27 Jul 2004 11:18 PM — 4 posts, 16,070 views.

USA #0
Okay, what I want to do, is every area reset, the code will go through all the mobs with certain ifchecks, and a random chance. If all is true, it will set an act flag on the mobs. I've nearly done this, except for that if the mob is already in the area, it won't set it. Here's the code, in reset.c, reset_area:


      if ( pMobIndex->count >= pReset->arg2 )
      {
        mob = NULL;
        break;
      }

      mob = create_mobile(pMobIndex);

        chance = number_range( 0, 25 );
        if ( chance == 24 && !xIS_SET(mob->act, ACT_PACIFIST ) && !xIS_SET(mob->act, ACT_SHARD_NEVER ) &&
                   !xIS_SET(mob->act, ACT_PROTOTYPE ) )
        {
          sprintf ( buf, "Loading shard on %s.", mob->name );
          to_channel( buf, CHANNEL_SHARDMONITOR, "ShardMonitor", LEVEL_SUB_IMPLEM );
          xSET_BIT(mob->act, ACT_HAS_SHARD);
          mob->hitroll *= 2;
          mob->damroll *= 2;
        }

      {
        ROOM_INDEX_DATA *pRoomPrev = get_room_index(pReset->arg3 - 1);

        if ( pRoomPrev && IS_SET(pRoomPrev->room_flags, ROOM_PET_SHOP) )
          xSET_BIT(mob->act, ACT_PET);
      }
      if ( room_is_dark(pRoomIndex) )
          xSET_BIT(mob->affected_by, AFF_INFRARED);


Now the flag will be set if the mob isn't in the area, and there's a reset for it, but not if the mob is not in the area. How do I change this, so it will check/set all mobs?
Canada #1
Yeah, I know why its not working. You have that check in the section of code that creates mobs. If the mob doesn't need to be created, then this check will be completely missed. You probably want something above the check for if it should create it or not. Like in here:
      if ( pMobIndex->count >= pReset->arg2 )
      {
        /* here would work, I think, you just have to use each instance of the mob from here */
        mob = NULL;
        break;
      }

USA #2
Doesn't work. The mob is null.


#0  0x08104e84 in reset_area (pArea=0x8350b60) at reset.c:1358
1358                xSET_BIT(mob->act, ACT_HAS_SHARD);
(gdb) bt
#0  0x08104e84 in reset_area (pArea=0x8350b60) at reset.c:1358
#1  0x08102e2b in edit_reset (ch=0x8372438, argument=0xbffff2ba "", pArea=0x8350b60, aRoom=0x0) at reset.c:429
#2  0x08104823 in do_reset (ch=0x8372438, argument=0xbffff2b6 "area") at reset.c:1072
#3  0x080d38ac in interpret (ch=0x8372438, argument=0xbffff2b6 "area") at interp.c:557
#4  0x080a9183 in game_loop () at comm.c:671
#5  0x080a8ab1 in main (argc=2, argv=0xbffff6d0) at comm.c:304
#6  0x42015967 in __libc_start_main () from /lib/i686/libc.so.6

(gdb) print mob
$1 = (struct char_data *) 0x0



      if ( pMobIndex->count >= pReset->arg2 )
      {
//        chance = number_range( 0, 25 );
//        if ( chance == 24 && !xIS_SET(mob->act, ACT_PACIFIST ) && !xIS_SET(mob->act, ACT_SHARD_NEVER ) &&
//                   !xIS_SET(mob->act, ACT_PROTOTYPE ) )
//          {
            sprintf ( buf, "Loading shard on %s.", mob->name );
            to_channel( buf, CHANNEL_SHARDMONITOR, "ShardMonitor", LEVEL_SUB_IMPLEM );
            xSET_BIT(mob->act, ACT_HAS_SHARD);
            mob->hitroll *= 2;
            mob->damroll *= 2;
//          }
        mob = NULL;
        break;
      }
Amended on Wed 28 Jul 2004 07:05 AM by Zeno
USA #3
I thought it might be a few mobs that were null, so I made an ifcheck if ( mob ) but it didn't find any mobs at all that time. reset_area is the only function that this would work on I think, but I can't seem to get it to work.