Example #1
0
void make_corpse(struct char_data * ch)
{
  struct obj_data *corpse, *o;
  struct obj_data *money;
  int i;

  corpse = create_obj();

  corpse->item_number = NOTHING;
  IN_ROOM(corpse) = NOWHERE;
  corpse->name = str_dup("corpse");

  sprintf(buf2, "The corpse of %s is lying here.", GET_NAME(ch));
  corpse->description = str_dup(buf2);

  sprintf(buf2, "the corpse of %s", GET_NAME(ch));
  corpse->short_description = str_dup(buf2);

  GET_OBJ_TYPE(corpse) = ITEM_CONTAINER;
  GET_OBJ_WEAR(corpse) = ITEM_WEAR_TAKE;
  GET_OBJ_EXTRA(corpse) = ITEM_NODONATE;
  GET_OBJ_VAL(corpse, 0) = 0;	/* You can't store stuff in a corpse */
  GET_OBJ_VAL(corpse, 3) = 1;	/* corpse identifier */
  GET_OBJ_WEIGHT(corpse) = GET_WEIGHT(ch) + IS_CARRYING_W(ch);
  GET_OBJ_RENT(corpse) = 100000;
  if (IS_NPC(ch))
    GET_OBJ_TIMER(corpse) = max_npc_corpse_time;
  else
    GET_OBJ_TIMER(corpse) = max_pc_corpse_time;

  /* transfer character's inventory to the corpse */
  corpse->contains = ch->carrying;
  for (o = corpse->contains; o != NULL; o = o->next_content)
    o->in_obj = corpse;
  object_list_new_owner(corpse, NULL);

  /* transfer character's equipment to the corpse */
  for (i = 0; i < NUM_WEARS; i++)
    if (GET_EQ(ch, i)) {
      remove_otrigger(GET_EQ(ch, i), ch);
      obj_to_obj(unequip_char(ch, i), corpse);
    }

  /* transfer gold */
  if (GET_GOLD(ch) > 0) {
    /* following 'if' clause added to fix gold duplication loophole */
    if (IS_NPC(ch) || (!IS_NPC(ch) && ch->desc)) {
      money = create_money(GET_GOLD(ch));
      obj_to_obj(money, corpse);
    }
    GET_GOLD(ch) = 0;
  }
  ch->carrying = NULL;
  IS_CARRYING_N(ch) = 0;
  IS_CARRYING_W(ch) = 0;

  obj_to_room(corpse, IN_ROOM(ch));
}
Example #2
0
shared_ptr<FrameState<Dtype> > Environment<Dtype>::GetFrame() {
  CHECK( !GameOver() );
  const ALEScreen & screen = ale_->getScreen();
  
  CHECK_EQ( screen.height(), SCREEN_HEIGHT );
  CHECK_EQ( screen.width(), SCREEN_WIDTH );
  GetFrameGrayScale( screen.getArray() );
  
  const double xRatio = (double)SCREEN_HEIGHT / CROP_HEIGHT;    
  const double yRatio = (double)SCREEN_WIDTH / CROP_WIDTH;
  
  static Dtype pixels[CROP_SIZE];
  for ( int i = 0; i < CROP_HEIGHT; ++i ) {
    for ( int j = 0; j < CROP_WIDTH; ++j ) {
      int xL = int(i * xRatio);
      int xR = int((i + 1) * xRatio);
      int yL = int(j * yRatio);
      int yR = int((j + 1) * yRatio);
      double result = 0.0;
#define GET_WEIGHT( i, x, ratio, l, r, weight ) \
  weight = 1.0; \
  if ( x == l ) weight = x + 1 - i * ratio; \
  else if ( x == r ) weight = (i + 1) * ratio - x; \
  CHECK_LE( 0.0, weight ); \
  CHECK_LE( weight, 1.0 );
      double xWeight, yWeight;
      for ( int x = xL; x <= xR; ++x ) {
        GET_WEIGHT( i, x, xRatio, xL, xR, xWeight );
        for ( int y = yL; y <= yR; ++y ) {
          GET_WEIGHT( j, y, yRatio, yL, yR, yWeight );
          Dtype grayScale = GrayScale( x, y );
          result += (xWeight / xRatio) * (yWeight / yRatio) * grayScale;
        }
      }
#undef GET_WEIGHT
      pixels[i * CROP_WIDTH + j] = result;
    }
  }
  FrameState<Dtype>* frame = new FrameState<Dtype>( pixels, CROP_SIZE );
  //frame->inspect( "Environment::Getframe" );
  return shared_ptr<FrameState<Dtype> >( frame );
}
Example #3
0
/*
 * Ideally, this function should be in db.c, but I'll put it here for
 * portability.
 */
void init_mobile(struct char_data *mob)
{
  clear_char(mob);

  GET_HIT(mob) = GET_MANA(mob) = 1;
  GET_MAX_MANA(mob) = GET_MAX_MOVE(mob) = 100;
  GET_NDD(mob) = GET_SDD(mob) = 1;
  GET_WEIGHT(mob) = 200;
  GET_HEIGHT(mob) = 198;
  GET_MOB_WEIGHT(mob) = 1;

  mob->real_abils.str = mob->real_abils.intel = mob->real_abils.wis = 11;
  mob->real_abils.dex = mob->real_abils.con = mob->real_abils.cha = 11;
  mob->aff_abils = mob->real_abils;

  SET_BIT(MOB_FLAGS(mob), MOB_ISNPC);
  mob->player_specials = &dummy_mob;
}
Example #4
0
void set_height_and_weight_by_race(struct char_data *ch)
{
  int race, sex, mod;

  race = GET_RACE(ch);
  sex = GET_SEX(ch);
  if (sex < SEX_NEUTRAL || sex >= NUM_SEX) {
    log("Invalid gender in set_height_and_weight_by_race: %d", sex);
    sex = SEX_NEUTRAL;
  }
  if (race <= RACE_UNDEFINED || race >= NUM_RACES) {
    log("Invalid gender in set_height_and_weight_by_race: %d", GET_SEX(ch));
    race = RACE_UNDEFINED + 1; /* first defined race */
  }

  mod = dice(2, hw_info[race].heightdie);
  GET_HEIGHT(ch) = hw_info[race].height[sex] + mod;
  mod *= hw_info[race].weightfac;
  mod /= 100;
  GET_WEIGHT(ch) = hw_info[race].weight[sex] + mod;
}
Example #5
0
/* Ideally, this function should be in db.c, but I'll put it here for portability. */
static void init_mobile(struct char_data *mob) {
    clear_char(mob);

    GET_HIT(mob) = GET_MANA(mob) = 1;
    GET_MAX_MANA(mob) = GET_MAX_MOVE(mob) = 100;
    GET_NDD(mob) = GET_SDD(mob) = 1;
    GET_WEIGHT(mob) = 200;
    GET_HEIGHT(mob) = 198;

    mob->real_abils.str = mob->real_abils.intel = mob->real_abils.wis = 11;
    mob->real_abils.dex = mob->real_abils.con = mob->real_abils.cha = 11;
    mob->aff_abils = mob->real_abils;

    GET_SAVE(mob, SAVING_PARA) = 0;
    GET_SAVE(mob, SAVING_ROD) = 0;
    GET_SAVE(mob, SAVING_PETRI) = 0;
    GET_SAVE(mob, SAVING_BREATH) = 0;
    GET_SAVE(mob, SAVING_SPELL) = 0;

    SET_BIT_AR(MOB_FLAGS(mob), MOB_ISNPC);
    mob->player_specials = &dummy_mob;
}
Example #6
0
void medit_disp_menu(struct descriptor_data *d)
{
    int base = calc_karma(NULL, MOB);

    CLS(CH);
    send_to_char(CH, "Mob number: %s%d%s\r\n", CCCYN(CH, C_CMP), d->edit_number,
                 CCNRM(CH, C_CMP));
    send_to_char(CH, "1) Keywords: %s%s%s\r\n", CCCYN(CH, C_CMP),
                 MOB->player.physical_text.keywords, CCNRM(CH, C_CMP));
    send_to_char(CH, "2) Name: %s%s%s\r\n", CCCYN(CH, C_CMP),
                 MOB->player.physical_text.name, CCNRM(CH, C_CMP));
    send_to_char(CH, "3) Room description:\r\n%s%s%s\r\n", CCCYN(CH, C_CMP),
                 MOB->player.physical_text.room_desc,CCNRM(CH, C_CMP));
    send_to_char(CH, "4) Look description:\r\n%s\r\n",
                 MOB->player.physical_text.look_desc);
    MOB_FLAGS(MOB).PrintBits(buf1, MAX_STRING_LENGTH, action_bits, MOB_MAX);
    send_to_char(CH, "5) Mob Flags: %s%s%s\r\n", CCCYN(CH, C_CMP), buf1,
                 CCNRM(CH, C_CMP));
    MOB->char_specials.saved.affected_by.PrintBits(buf1, MAX_STRING_LENGTH,
            affected_bits, AFF_MAX);
    send_to_char(CH, "6) Affected Flags: %s%s%s\r\n", CCCYN(CH, C_CMP), buf1,
                 CCNRM(CH, C_CMP));
    send_to_char(CH, "8) Avg. nuyen: %s%6d%s      Avg. credstick value: %s%6d%s\r\n", CCCYN(CH, C_CMP),
                 GET_NUYEN(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP),
                 GET_BANK(MOB), CCNRM(CH, C_CMP));
    send_to_char(CH, "9) Bonus karma points: %s%d%s    (Total karma points: %s%d%s)\r\n",
                 CCCYN(CH, C_CMP), GET_KARMA(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), base, CCNRM(CH, C_CMP));
    send_to_char(CH, "a) Attributes: B(%s%d%s), Q(%s%d%s), S(%s%d%s), C(%s%d%s), "
                 "I(%s%d%s), W(%s%d%s), M(%s%d%s), R(%s%d%s)\r\n",
                 CCCYN(CH, C_CMP), GET_REAL_BOD(MOB), CCNRM(CH, C_CMP),
                 CCCYN(CH, C_CMP), GET_REAL_QUI(MOB), CCNRM(CH, C_CMP),
                 CCCYN(CH, C_CMP), GET_REAL_STR(MOB), CCNRM(CH, C_CMP),
                 CCCYN(CH, C_CMP), GET_REAL_CHA(MOB), CCNRM(CH, C_CMP),
                 CCCYN(CH, C_CMP), GET_REAL_INT(MOB), CCNRM(CH, C_CMP),
                 CCCYN(CH, C_CMP), GET_REAL_WIL(MOB), CCNRM(CH, C_CMP),
                 CCCYN(CH, C_CMP), MOB->real_abils.mag / 100, CCNRM(CH, C_CMP),
                 CCCYN(CH, C_CMP), GET_REAL_REA(MOB), CCNRM(CH, C_CMP));
    send_to_char(CH, "b) Level: %s%d%s\r\n", CCCYN(CH, C_CMP), GET_LEVEL(MOB),
                 CCNRM(CH, C_CMP));
    send_to_char(CH, "c) Ballistic: %s%d%s, ", CCCYN(CH, C_CMP), GET_BALLISTIC(MOB),
                 CCNRM(CH, C_CMP));
    send_to_char(CH, "d) Impact: %s%d%s\r\n", CCCYN(CH, C_CMP), GET_IMPACT(MOB),
                 CCNRM(CH, C_CMP));
    send_to_char(CH, "e) Max physical points: %s%d%s, f) Max mental points: %s%d%s\r\n", CCCYN(CH, C_CMP),
                 (int)(GET_MAX_PHYSICAL(MOB) / 100), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP),
                 (int)(GET_MAX_MENTAL(MOB) / 100), CCNRM(CH, C_CMP));
    sprinttype(GET_POS(MOB), position_types, buf1);
    send_to_char(CH, "g) Position: %s%s%s, ", CCCYN(CH, C_CMP), buf1,
                 CCNRM(CH, C_CMP));
    sprinttype(GET_DEFAULT_POS(MOB), position_types, buf1);
    send_to_char(CH, "h) Default Position: %s%s%s\r\n", CCCYN(CH, C_CMP), buf1,
                 CCNRM(CH, C_CMP));
    sprinttype(GET_SEX(MOB), genders, buf1);
    //  strcpy(buf1, genders[GET_SEX(d->edit_mob)]);
    send_to_char(CH, "i) Gender: %s%s%s, ", CCCYN(CH, C_CMP), buf1,
                 CCNRM(CH, C_CMP));
    send_to_char(CH, "j) Weight: %s%d%s, ", CCCYN(CH, C_CMP), GET_WEIGHT(MOB),
                 CCNRM(CH, C_CMP));
    send_to_char(CH, "k) Height: %s%d%s\r\n", CCCYN(CH, C_CMP), GET_HEIGHT(MOB),
                 CCNRM(CH, C_CMP));
    sprinttype(GET_RACE(MOB), npc_classes, buf1);
    send_to_char(CH, "l) Mob class: %s%s%s\r\n", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP));
    // gotta subtract TYPE_HIT to make it work properly
    sprinttype(!(MOB->mob_specials.attack_type) ? 0 :
               (MOB->mob_specials.attack_type - TYPE_HIT), attack_types, buf1);
    send_to_char(CH, "m) Attack Type: %s%s%s\r\n", CCCYN(CH, C_CMP), buf1,
                 CCNRM(CH, C_CMP));
    send_to_char("n) Skill menu.\r\n", CH);
    send_to_char(CH, "o) Arrive text: ^c%s^n,  p) Leave text: ^c%s^n\r\n",
                 MOB->mob_specials.arrive, MOB->mob_specials.leave);
    send_to_char("q) Quit and save\r\n", CH);
    send_to_char("x) Exit and abort\r\n", CH);
    send_to_char("Enter your choice:\r\n", CH);
    d->edit_mode = MEDIT_MAIN_MENU;
}
Example #7
0
void medit_parse(struct descriptor_data *d, char *arg)
{

    int number;
    int mob_number;  // the RNUM

    switch(d->edit_mode)
    {
    case MEDIT_CONFIRM_EDIT:
        /* if player hits 'Y' then edit mob */
        switch (*arg) {
        case 'y':
        case 'Y':
            medit_disp_menu(d);
            break;
        case 'n':
        case 'N':
            STATE(d) = CON_PLAYING;
            /* free up the editing mob */
            if (d->edit_mob)
                Mem->DeleteCh(d->edit_mob);
            d->edit_mob = NULL;
            d->edit_number = 0;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("That's not a valid choice!\r\n", CH);
            send_to_char("Do you wish to edit it?\r\n", CH);
            break;
        }
        break;                      /* end of MEDIT_CONFIRM_EDIT */

    case MEDIT_CONFIRM_SAVESTRING:
        switch(*arg) {
        case 'y':
        case 'Y':
            // first write to the internal tables
            if (!from_ip_zone(d->edit_number)) {
                sprintf(buf,"%s wrote new mob #%ld",
                        GET_CHAR_NAME(d->character), d->edit_number);
                mudlog(buf, d->character, LOG_WIZLOG, TRUE);
            }
            mob_number = real_mobile(d->edit_number);
            if (mob_number > 0) {
                // first we go through the entire list of mobs to find out
                // which are pointing to this prototype; if it is, it gets
                // replaced
                struct char_data *i, *temp;
                int c;
                for (i = character_list; i; i = i->next) {
                    if (mob_number == i->nr) {
                        // alloc a temp mobile
                        temp = Mem->GetCh();
                        *temp = *i;
                        *i = *d->edit_mob;
                        /* copy game-time dependent vars over */
                        i->in_room = temp->in_room;
                        i->nr = mob_number;
                        i->affected = temp->affected;
                        i->carrying = temp->carrying;
                        i->cyberware = temp->cyberware;
                        i->bioware = temp->bioware;
                        // any eq worn
                        for (c = 0; c < NUM_WEARS; ++c)
                            i->equipment[c] = temp->equipment[c];
                        i->next_in_room = temp->next_in_room;
                        i->next = temp->next;
                        i->next_fighting = temp->next_fighting;
                        i->followers = temp->followers;
                        i->master = temp->master;
                        i->char_specials.fighting = temp->char_specials.fighting;
                        i->char_specials.hunting = temp->char_specials.hunting;
                        i->mob_specials.last_direction = temp->mob_specials.last_direction;
                        i->mob_specials.memory = temp->mob_specials.memory;
                        i->mob_specials.wait_state = temp->mob_specials.wait_state;
                        Mem->ClearCh(temp);
                    } // end if statement

                } // end for loop

                // now you can free the old prototype and put in the new one
                if (mob_proto[mob_number].player.physical_text.keywords)
                    delete [] mob_proto[mob_number].player.physical_text.keywords;
                if (mob_proto[mob_number].player.title)
                    delete [] mob_proto[mob_number].player.title;
                if (mob_proto[mob_number].player.physical_text.name)
                    delete [] mob_proto[mob_number].player.physical_text.name;
                if (mob_proto[mob_number].player.physical_text.room_desc)
                    delete [] mob_proto[mob_number].player.physical_text.room_desc;
                if (mob_proto[mob_number].player.physical_text.look_desc)
                    delete [] mob_proto[mob_number].player.physical_text.look_desc;
                if (mob_proto[mob_number].mob_specials.arrive)
                    delete [] mob_proto[mob_number].mob_specials.arrive;
                if (mob_proto[mob_number].mob_specials.leave)
                    delete [] mob_proto[mob_number].mob_specials.leave;


                mob_proto[mob_number] = *d->edit_mob;
                mob_proto[mob_number].nr = mob_number;

            } else {  // if not, we need to make a new spot in the list
                int             counter;
                int             found = FALSE;

                struct char_data *new_mob_proto;
                struct index_data *new_mob_index;
                struct char_data *temp_mob;

                // two because you are adding one and you need one over
                new_mob_index = new struct index_data[top_of_mobt + 2];
                new_mob_proto = new struct char_data[top_of_mobt + 2];
                // count through the tables
                for (counter = 0; counter < top_of_mobt + 1; counter++) {
                    /* if we haven't found it */
                    if (!found) {
                        /* check if current virtual is bigger than our virtual */
                        if (MOB_VNUM_RNUM(counter) > d->edit_number) {
                            /* eureka. insert now */
                            /*---------*/
                            new_mob_index[counter].vnum = d->edit_number;
                            new_mob_index[counter].number = 0;
                            new_mob_index[counter].func = NULL;
                            /*---------*/
                            new_mob_proto[counter] = *(d->edit_mob);
                            new_mob_proto[counter].in_room = NOWHERE;
                            /* it is now safe (and necessary!) to assign real number to
                             * the edit_mob, which has been -1 all this time */
                            d->edit_mob->nr = counter;
                            /* and assign to prototype as well */
                            new_mob_proto[counter].nr = counter;
                            found = TRUE;
                            /* insert the other proto at this point */
                            new_mob_index[counter + 1] = mob_index[counter];
                            new_mob_proto[counter + 1] = mob_proto[counter];
                            new_mob_proto[counter + 1].nr = counter + 1;
                        } else {
                            /* just copy from old to new, no num change */
                            new_mob_proto[counter] = mob_proto[counter];
                            new_mob_index[counter] = mob_index[counter];
                        }

                    } else { // if !found else
                        /* we HAVE already found it.. therefore copy to mobile + 1 */
                        new_mob_index[counter + 1] = mob_index[counter];
                        new_mob_proto[counter + 1] = mob_proto[counter];
                        new_mob_proto[counter + 1].nr = counter + 1;
                    }
                } // for loop through list


                /* if we STILL haven't found it, means the mobile was > than all
                * the other mobs.. so insert at end */
                if (!found) {
                    new_mob_index[top_of_mobt + 1].vnum = d->edit_number;
                    new_mob_index[top_of_mobt + 1].number = 0;
                    new_mob_index[top_of_mobt + 1].func = NULL;

                    clear_char(new_mob_proto + top_of_mobt + 1);
                    new_mob_proto[top_of_mobt + 1] = *(d->edit_mob);
                    new_mob_proto[top_of_mobt + 1].in_room = NOWHERE;
                    new_mob_proto[top_of_mobt + 1].nr = top_of_mobt + 1;
                    /* it is now safe (and necessary!) to assign real number to
                     * the edit_mob, which has been -1 all this time */
                    d->edit_mob->nr = top_of_mobt + 1;
                }
                top_of_mobt++;

                /* we also have to renumber all the mobiles currently    *
                *  existing in the world. This is because when I start   *
                * extracting mobiles, bad things will happen!           */
                for (temp_mob = character_list; temp_mob; temp_mob = temp_mob->next)
                    if (GET_MOB_RNUM (temp_mob) >= d->edit_mob->nr)
                        GET_MOB_RNUM (temp_mob)++;

                /* free and replace old tables */
                delete [] mob_proto;
                delete [] mob_index;
                mob_proto = new_mob_proto;
                mob_index = new_mob_index;

                /* RENUMBER ZONE TABLES HERE, only              *
                *   because I ADDED a mobile!                   *
                *   This code shamelessly ripped off from db.c */

                int zone, cmd_no;
                for (zone = 0; zone <= top_of_zone_table; zone++)
                    for (cmd_no = 0; cmd_no < zone_table[zone].num_cmds; cmd_no++) {
                        switch (ZCMD.command) {
                        case 'M':
                            ZCMD.arg1 = (ZCMD.arg1 >= d->edit_mob->nr ? ZCMD.arg1 + 1 : ZCMD.arg1);
                            break;
                        }

                    }

            } // finally done putting the mobile into memory

            send_to_char("Writing mobile to disk...", CH);
            write_mobs_to_disk(d->character->player_specials->saved.zonenum);

            // again, here we don't delete it cause we don't want to end up
            // deleting the strings from the prototypes
            if (d->edit_mob)
                Mem->ClearCh(d->edit_mob);
            d->edit_mob = NULL;
            STATE(d) = CON_PLAYING;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            send_to_char("Done.\r\n", d->character);
            break;
        case 'n':
        case 'N':
            send_to_char("Mobile not saved, aborting.\r\n", d->character);
            STATE(d) = CON_PLAYING;
            // complete nuke
            if (d->edit_mob)
                Mem->DeleteCh(d->edit_mob);
            d->edit_mob = NULL;
            d->edit_number = 0;
            d->edit_zone = 0;
            PLR_FLAGS(d->character).RemoveBit(PLR_EDITING);
            break;
        default:
            send_to_char("Invalid choice!\r\n", d->character);
            send_to_char("Do you wish to save this mobile internally?\r\n", d->character);
            break;
        }

        break;

    case MEDIT_MAIN_MENU:
        switch (*arg) {
        case 'q':
        case 'Q':
            d->edit_mode = MEDIT_CONFIRM_SAVESTRING;
            medit_parse(d, "y");
            break;
        case 'x':
        case 'X':
            d->edit_mode = MEDIT_CONFIRM_SAVESTRING;
            medit_parse(d, "n");
            break;
        case '1':
            send_to_char("Enter keywords:", CH);
            d->edit_mode = MEDIT_EDIT_NAMELIST;
            break;
        case '2':
            send_to_char("Enter name:", CH);
            d->edit_mode = MEDIT_SHORT_DESCR;
            break;
        case '3':
            send_to_char("Enter room description:", CH);
            d->edit_mode = MEDIT_REG_DESCR;
            d->str = new (char *);
            if (!d->str) {
                mudlog("Malloc failed!", NULL, LOG_SYSLOG, TRUE);
                shutdown();
            }

            *(d->str) = NULL;
            d->max_str = MAX_REG_DESC_LENGTH;
            d->mail_to = 0;
            break;
        case '4':
            // go to modify.cc
            send_to_char("Enter look description:\r\n", CH);
            d->edit_mode = MEDIT_LONG_DESCR;
            d->str = new (char *);
            if (!d->str) {
                mudlog("Malloc failed!", NULL, LOG_SYSLOG, TRUE);
                shutdown();
            }

            *(d->str) = NULL;
            d->max_str = MAX_MESSAGE_LENGTH;
            d->mail_to = 0;
            break;
        case '5':
            medit_disp_mobflags_menu(d);
            d->edit_mode = MEDIT_MOB_FLAGS;
            break;
        case '6':
            medit_disp_affected_menu(d);
            d->edit_mode = MEDIT_AFF_FLAGS;
            break;
        case '8':
            send_to_char("Enter average nuyen: ", CH);
            d->edit_mode = MEDIT_NUYEN;
            break;
        case '9':
            send_to_char("Enter bonus karma points: ", CH);
            d->edit_mode = MEDIT_EXPERIENCE;
            break;
        case 'a':
            medit_disp_att_menu(d);
            d->edit_mode = MEDIT_ATTRIBUTES;
            break;
        case 'b':
            send_to_char("Enter level: ", CH);
            d->edit_mode = MEDIT_LEVEL;
            break;
        case 'c':
            send_to_char("Enter ballistic armor points: ", CH);
            d->edit_mode = MEDIT_BALLISTIC;
            break;
        case 'd':
            send_to_char("Enter impact armor points: ", CH);
            d->edit_mode = MEDIT_IMPACT;
            break;
        case 'e':
            send_to_char("Enter max physical points: ", CH);
            d->edit_mode = MEDIT_PHYSICAL;
            break;
        case 'f':
            send_to_char("Enter max mental points: ", CH);
            d->edit_mode = MEDIT_MENTAL;
            break;
        case 'g':
            medit_disp_pos_menu(d);
            send_to_char("Enter position: ", CH);
            d->edit_mode = MEDIT_POSITION;
            break;
        case 'h':
            medit_disp_pos_menu(d);
            send_to_char("Enter default position: ", CH);
            d->edit_mode = MEDIT_DEFAULT_POSITION;
            break;
        case 'i':
            medit_disp_gender_menu(d);
            d->edit_mode = MEDIT_GENDER;
            break;
        case 'j':
            send_to_char("Enter weight (in kilograms): ", CH);
            d->edit_mode = MEDIT_WEIGHT;
            break;
        case 'k':
            send_to_char("Enter height (in centimeters): ", CH);
            d->edit_mode = MEDIT_HEIGHT;
            break;
        case 'l':
            medit_disp_class_menu(d);
            d->edit_mode = MEDIT_CLASS;
            break;
        case 'm':
            medit_disp_attack_menu(d);
            d->edit_mode = MEDIT_ATTACK_TYPE;
            break;
        case 'n':
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
            break;
        case 'o':
            send_to_char("Enter arrive text: ", CH);
            d->edit_mode = MEDIT_ARRIVE_MSG;
            break;
        case 'p':
            send_to_char("Enter leave text: ", CH);
            d->edit_mode = MEDIT_LEAVE_MSG;
            break;

        default:
            medit_disp_menu(d);
            break;
        }
        break;

    case MEDIT_EDIT_NAMELIST:
        if (MOB->player.physical_text.keywords)
            delete [] MOB->player.physical_text.keywords;
        MOB->player.physical_text.keywords = str_dup(arg);
        medit_disp_menu(d);
        break;

    case MEDIT_SHORT_DESCR:
        if (MOB->player.physical_text.name)
            delete [] MOB->player.physical_text.name;
        MOB->player.physical_text.name = str_dup(arg);
        medit_disp_menu(d);
        break;

    case MEDIT_ARRIVE_MSG:
        if (MOB->mob_specials.arrive)
            delete [] MOB->mob_specials.arrive;
        MOB->mob_specials.arrive = str_dup(arg);
        medit_disp_menu(d);
        break;

    case MEDIT_LEAVE_MSG:
        if (MOB->mob_specials.leave)
            delete [] MOB->mob_specials.leave;
        MOB->mob_specials.leave = str_dup(arg);
        medit_disp_menu(d);
        break;

    case MEDIT_REG_DESCR:
        // you should not come here
        break;

    case MEDIT_LONG_DESCR:
        // you should not come here
        break;

    case MEDIT_MOB_FLAGS:
        number = atoi(arg);
        if ((number < 0) || (number > MOB_MAX))
            medit_disp_mobflags_menu(d);
        else {
            if (number == 0) // 0 = quit
                medit_disp_menu(d);
            else {
                MOB_FLAGS(MOB).ToggleBit(number-1);
                medit_disp_mobflags_menu(d);
            }
        }
        break;

    case MEDIT_AFF_FLAGS:
        number = atoi(arg);
        if ((number < 0) || (number > AFF_MAX))
            medit_disp_affected_menu(d);
        else {
            if (number == 0) // 0 = quit
                medit_disp_menu(d);
            else {
                AFF_FLAGS(MOB).ToggleBit(number - 1);
                medit_disp_affected_menu(d);
            }
        }
        break;

    case MEDIT_NUYEN:
        number = atoi(arg);
        if ((number < 0) || (number > 999999)) {
            send_to_char("Value must range between 0 and 999999.\r\n", CH);
            send_to_char("Enter average nuyen: ", CH);
        } else {
            GET_NUYEN(MOB) = number;
            send_to_char("Enter average credstick value: ", CH);
            d->edit_mode = MEDIT_CREDSTICK;
        }
        break;

    case MEDIT_CREDSTICK:
        number = atoi(arg);
        if ((number < 0) || (number > 999999)) {
            send_to_char("Value must range between 0 and 999999.\r\n", CH);
            send_to_char("Enter average credstick value: ", CH);
        } else {
            GET_BANK(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_EXPERIENCE:
        number = atoi(arg);
        if ((number < 0) || (number > 7500)) {
            send_to_char("Value must range between 0 and 7500.\r\n", CH);
            send_to_char("Enter bonus karma points: ", CH);
        } else {
            int karma;
            if (number > (karma=calc_karma(NULL, MOB))) {
                send_to_char("Bonus karma may not be higher than actual karma.  Lowering.\r\n", CH);
                number = karma;
            }
            GET_KARMA(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_SKILLS:
        switch (*arg) {
        case '0':
            medit_disp_menu(d);
            break;
        case '1':
            medit_disp_skills(d);
            send_to_char("Enter a skill (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL1;
            break;
        case '2':
            medit_disp_skills(d);
            send_to_char("Enter a skill (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL2;
            break;
        case '3':
            medit_disp_skills(d);
            send_to_char("Enter a skill (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL3;
            break;
        case '4':
            medit_disp_skills(d);
            send_to_char("Enter a skill (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL4;
            break;
        case '5':
            medit_disp_skills(d);
            send_to_char("Enter a skill (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL5;
            break;

        default:
            medit_disp_skill_menu(d);
            break;
        }
        break; // end of MEDIT_SKILLS

    case MEDIT_SKILL1:
        number = atoi(arg);
        if ((number < 0) || (number > MAX_SKILLS)) {
            medit_disp_skills(d);
            send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS);
            send_to_char("Enter a skill (0 to quit): ", CH);
        } else if (number == 0) { // 0 = quit
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
        } else {
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0)
            MOB->mob_specials.mob_skills[0] = number; // to adjust it
            send_to_char("Enter skill level (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL1_VAL;
        }
        break;

    case MEDIT_SKILL2:
        number = atoi(arg);
        if ((number < 0) || (number > MAX_SKILLS)) {
            medit_disp_skills(d);
            send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS);
            send_to_char("Enter a skill (0 to quit): ", CH);
        } else if (number == 0) { // 0 = quit
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
        } else {
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0)
            MOB->mob_specials.mob_skills[0] = number; // to adjust it
            send_to_char("Enter skill level (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL2_VAL;
        }
        break;
    case MEDIT_SKILL3:
        number = atoi(arg);
        if ((number < 0) || (number > MAX_SKILLS)) {
            medit_disp_skills(d);
            send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS);
            send_to_char("Enter a skill (0 to quit): ", CH);
        } else if (number == 0) { // 0 = quit
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
        } else {
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0)
            MOB->mob_specials.mob_skills[0] = number; // to adjust it
            send_to_char("Enter skill level (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL3_VAL;
        }
        break;
    case MEDIT_SKILL4:
        number = atoi(arg);
        if ((number < 0) || (number > MAX_SKILLS)) {
            medit_disp_skills(d);
            send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS);
            send_to_char("Enter a skill (0 to quit): ", CH);
        } else if (number == 0) { // 0 = quit
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
        } else {
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0)
            MOB->mob_specials.mob_skills[0] = number; // to adjust it
            send_to_char("Enter skill level (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL4_VAL;
        }
        break;
    case MEDIT_SKILL5:
        number = atoi(arg);
        if ((number < 0) || (number > MAX_SKILLS)) {
            medit_disp_skills(d);
            send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS);
            send_to_char("Enter a skill (0 to quit): ", CH);
        } else if (number == 0) { // 0 = quit
            medit_disp_skill_menu(d);
            d->edit_mode = MEDIT_SKILLS;
        } else {
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0)
            MOB->mob_specials.mob_skills[0] = number; // to adjust it
            send_to_char("Enter skill level (0 to quit): ", CH);
            d->edit_mode = MEDIT_SKILL5_VAL;
        }
        break;

    case MEDIT_SKILL1_VAL:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Skill level must be between 1 and 50.\r\n", CH);
            send_to_char("Enter skill level: ", CH);
        } else if (number == 0) {
            MOB->mob_specials.mob_skills[0] = 0;
            MOB->mob_specials.mob_skills[1] = 0;
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        } else {
            MOB->mob_specials.mob_skills[1] = number;
            GET_SKILL(MOB, MOB->mob_specials.mob_skills[0]) = MOB->mob_specials.mob_skills[1];
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[0],
                      MOB->mob_specials.mob_skills[1]);
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        }
        break;

    case MEDIT_SKILL2_VAL:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Skill level must be between 1 and 50.\r\n", CH);
            send_to_char("Enter skill level: ", CH);
        } else if (number == 0) {
            MOB->mob_specials.mob_skills[2] = 0;
            MOB->mob_specials.mob_skills[3] = 0;
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        } else {
            MOB->mob_specials.mob_skills[3] = number;
            GET_SKILL(MOB, MOB->mob_specials.mob_skills[2]) = MOB->mob_specials.mob_skills[3];
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[2],
                      MOB->mob_specials.mob_skills[3]);
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        }
        break;

    case MEDIT_SKILL3_VAL:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Skill level must be between 1 and 50.\r\n", CH);
            send_to_char("Enter skill level: ", CH);
        } else if (number == 0) {
            MOB->mob_specials.mob_skills[4] = 0;
            MOB->mob_specials.mob_skills[5] = 0;
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        } else {
            MOB->mob_specials.mob_skills[5] = number;
            GET_SKILL(MOB, MOB->mob_specials.mob_skills[4]) = MOB->mob_specials.mob_skills[5];
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[4],
                      MOB->mob_specials.mob_skills[5]);
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        }
        break;

    case MEDIT_SKILL4_VAL:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Skill level must be between 1 and 50.\r\n", CH);
            send_to_char("Enter skill level: ", CH);
        } else if (number == 0) {
            MOB->mob_specials.mob_skills[6] = 0;
            MOB->mob_specials.mob_skills[7] = 0;
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        } else {
            MOB->mob_specials.mob_skills[7] = number;
            GET_SKILL(MOB, MOB->mob_specials.mob_skills[6]) = MOB->mob_specials.mob_skills[7];
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[6],
                      MOB->mob_specials.mob_skills[7]);
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        }
        break;

    case MEDIT_SKILL5_VAL:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Skill level must be between 1 and 50.\r\n", CH);
            send_to_char("Enter skill level: ", CH);
        } else if (number == 0) {
            MOB->mob_specials.mob_skills[8] = 0;
            MOB->mob_specials.mob_skills[9] = 0;
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        } else {
            MOB->mob_specials.mob_skills[9] = number;
            GET_SKILL(MOB, MOB->mob_specials.mob_skills[8]) = MOB->mob_specials.mob_skills[9];
            SET_SKILL(MOB, MOB->mob_specials.mob_skills[8],
                      MOB->mob_specials.mob_skills[9]);
            d->edit_mode = MEDIT_SKILLS;
            medit_disp_skill_menu(d);
        }
        break;


    case MEDIT_ATTRIBUTES:
        switch (*arg) {
        case '1':
            send_to_char("Enter body attribute: ", CH);
            d->edit_mode = MEDIT_BOD;
            break;
        case '2':
            send_to_char("Enter quickness attribute: ", CH);
            d->edit_mode = MEDIT_QUI;
            break;
        case '3':
            send_to_char("Enter strength attribute: ", CH);
            d->edit_mode = MEDIT_STR;
            break;
        case '4':
            send_to_char("Enter charisma attribute: ", CH);
            d->edit_mode = MEDIT_CHA;
            break;
        case '5':
            send_to_char("Enter intelligence attribute: ", CH);
            d->edit_mode = MEDIT_INT;
            break;
        case '6':
            send_to_char("Enter willpower attribute: ", CH);
            d->edit_mode = MEDIT_WIL;
            break;
        case '7':
            send_to_char("Enter magic attribute: ", CH);
            d->edit_mode = MEDIT_MAG;
            break;
        case 'q':
        case 'Q': // back to main menu
            medit_disp_menu(d);
            break;
        default:
            medit_disp_att_menu(d);
            break;
        }
        break;

    case MEDIT_BOD:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter body attribute: ", CH);
        } else {
            GET_REAL_BOD(MOB) = number;
            MOB->real_abils.bod_index = number * 100;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_QUI:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter quickness attribute: ", CH);
        } else {
            GET_REAL_QUI(MOB) = number;
            GET_REAL_REA(MOB) = (number + GET_REAL_INT(MOB)) >> 1;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_STR:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter strength attribute: ", CH);
        } else {
            GET_REAL_STR(MOB) = number;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_CHA:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter charisma attribute: ", CH);
        } else {
            GET_REAL_CHA(MOB) = number;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_INT:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter intelligence attribute: ", CH);
        } else {
            GET_REAL_INT(MOB) = number;
            GET_REAL_REA(MOB) = (number + GET_REAL_QUI(MOB)) >> 1;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_WIL:
        number = atoi(arg);
        if ((number < 1) || (number > 50)) {
            send_to_char("Value must range between 1 and 50.\r\n", CH);
            send_to_char("Enter willpower attribute: ", CH);
        } else {
            GET_REAL_WIL(MOB) = number;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_MAG:
        number = atoi(arg);
        if ((number < 0) || (number > 50)) {
            send_to_char("Value must range between 0 and 50.\r\n", CH);
            send_to_char("Enter magic attribute: ", CH);
        } else {
            MOB->real_abils.mag = number * 100;
            medit_disp_att_menu(d);
        }
        break;

    case MEDIT_LEVEL:
        number = atoi(arg);
        if (number < 0) {
            send_to_char("Invalid choice.\r\n", CH);
            send_to_char("Enter level: ", CH);
        } else {
            GET_LEVEL(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_BALLISTIC:
        number = atoi(arg);
        if (number < 0) {
            send_to_char("Value must be greater than 0.\r\n", CH);
            send_to_char("Enter ballistic armor points: ", CH);
        } else {
            GET_BALLISTIC(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_IMPACT:
        number = atoi(arg);
        if (number < 0) {
            send_to_char("Value must be greater than 0.\r\n", CH);
            send_to_char("Enter impact armor points: ", CH);
        } else {
            GET_IMPACT(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_PHYSICAL:
        number = atoi(arg);
        if ((number < 0) || (number > 10)) {
            send_to_char("Value must range between 0 and 10.\r\n", CH);
            send_to_char("Enter max physical points: ", CH);
        } else {
            GET_MAX_PHYSICAL(MOB) = number * 100;
            GET_PHYSICAL(MOB) = number * 100;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_MENTAL:
        number = atoi(arg);
        if ((number < 0) || (number > 10)) {
            send_to_char("Value must range between 0 and 10.\r\n", CH);
            send_to_char("Enter max mental points: ", CH);
        } else {
            GET_MAX_MENTAL(MOB) = number * 100;
            GET_MENTAL(MOB) = number * 100;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_WEIGHT:
        number = atoi(arg);
        if (number < 0) {
            send_to_char("Value must be greater than 0.\r\n", CH);
            send_to_char("Enter weight (in kilograms): ", CH);
        } else {
            GET_WEIGHT(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_HEIGHT:
        number = atoi(arg);
        if (number < 0) {
            send_to_char("Value must be greater than 0.\r\n", CH);
            send_to_char("Enter height (in centimeters): ", CH);
        } else {
            GET_HEIGHT(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_CLASS:
        number = atoi(arg);
        if ((number < 1) || (number > NUM_MOB_CLASSES))
            medit_disp_class_menu(d);
        else {
            GET_RACE(MOB) = (number - 1);
            medit_disp_menu(d);
        }
        break;

    case MEDIT_POSITION:
        number = atoi(arg);
        if ((number < POS_MORTALLYW) || (number > POS_STANDING)) {
            send_to_char("Invalid choice.\r\nEnter position: ", CH);
            medit_disp_pos_menu(d);
        } else {
            GET_POS(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_DEFAULT_POSITION:
        number = atoi(arg);
        if ((number < POS_MORTALLYW) || (number > POS_STANDING)) {
            send_to_char("Invalid choice.\r\nEnter default position: ", CH);
            medit_disp_pos_menu(d);
        } else {
            GET_DEFAULT_POS(MOB) = number;
            medit_disp_menu(d);
        }
        break;

    case MEDIT_GENDER:
        number = atoi(arg);
        if ((number < 0) || (number > 3)) {
            send_to_char("Invalid choice.\r\n", CH);
            medit_disp_gender_menu(d);
        } else if (number != 0) // 0 = quit
            GET_SEX(MOB) = (number - 1);
        medit_disp_menu(d);
        break;

    case MEDIT_ATTACK_TYPE:
        number = atoi(arg);
        if ((number < 0) || (number > NUM_ATTACK_TYPES)) {
            send_to_char("Invalid choice.\r\n", CH);
            medit_disp_attack_menu(d);
        } else if (number != 0) // 0 = quit
            MOB->mob_specials.attack_type = number-1 + TYPE_HIT;
        medit_disp_menu(d);
        break;

    }
}
Example #8
0
void make_corpse(struct char_data *ch)
{
  char buf2[MAX_NAME_LENGTH + 64];
  struct obj_data *corpse, *o;
  struct obj_data *money;
  int i;

  corpse = create_obj();

  corpse->item_number = NOTHING;
  IN_ROOM(corpse) = NOWHERE;
  corpse->name = strdup("corpse");

  snprintf(buf2, sizeof(buf2), "The corpse of %s is lying here.", GET_NAME(ch));
  corpse->description = strdup(buf2);

  snprintf(buf2, sizeof(buf2), "the corpse of %s", GET_NAME(ch));
  corpse->short_description = strdup(buf2);

  GET_OBJ_TYPE(corpse) = ITEM_CONTAINER;
  GET_OBJ_WEAR(corpse) = ITEM_WEAR_TAKE;
  GET_OBJ_EXTRA(corpse) = ITEM_NODONATE;
  GET_OBJ_VAL(corpse, 0) = 0;	/* You can't store stuff in a corpse */
  GET_OBJ_VAL(corpse, 3) = 1;	/* corpse identifier */
  GET_OBJ_WEIGHT(corpse) = GET_WEIGHT(ch) + IS_CARRYING_W(ch);
  GET_OBJ_RENT(corpse) = 100000;
  if (IS_NPC(ch))
    GET_OBJ_TIMER(corpse) = max_npc_corpse_time;
  else
    GET_OBJ_TIMER(corpse) = max_pc_corpse_time;

  /* transfer character's inventory to the corpse */
  corpse->contains = ch->carrying;
  for (o = corpse->contains; o != NULL; o = o->next_content)
    o->in_obj = corpse;
  object_list_new_owner(corpse, NULL);

  /* transfer character's equipment to the corpse */
  for (i = 0; i < NUM_WEARS; i++)
    if (GET_EQ(ch, i))
      obj_to_obj(unequip_char(ch, i), corpse);

  /* transfer gold */
  if (GET_GOLD(ch) > 0) {
    /*
     * following 'if' clause added to fix gold duplication loophole
     * The above line apparently refers to the old "partially log in,
     * kill the game character, then finish login sequence" duping
     * bug. The duplication has been fixed (knock on wood) but the
     * test below shall live on, for a while. -gg 3/3/2002
     */
    if (IS_NPC(ch) || ch->desc) {
      money = create_money(GET_GOLD(ch));
      obj_to_obj(money, corpse);
    }
    GET_GOLD(ch) = 0;
  }
  ch->carrying = NULL;
  IS_CARRYING_N(ch) = 0;
  IS_CARRYING_W(ch) = 0;

  obj_to_room(corpse, IN_ROOM(ch));
}
Example #9
0
void affect_modify(struct char_data * ch, byte loc, sbyte mod, long bitv,
		        bool add)
{
  if (add) {
    SET_BIT(AFF_FLAGS(ch), bitv);
  } else {
    REMOVE_BIT(AFF_FLAGS(ch), bitv);
    mod = -mod;
  }

  switch (loc) {
  case APPLY_NONE:
    break;

  case APPLY_STR:
    GET_STR(ch) += mod;
    break;
  case APPLY_DEX:
    GET_DEX(ch) += mod;
    break;
  case APPLY_INT:
    GET_INT(ch) += mod;
    break;
  case APPLY_WIS:
    GET_WIS(ch) += mod;
    break;
  case APPLY_CON:
    GET_CON(ch) += mod;
    break;
  case APPLY_CHA:
    GET_CHA(ch) += mod;
    break;

  case APPLY_CLASS:
    /* ??? GET_CLASS(ch) += mod; */
    break;

  case APPLY_LEVEL:
    /* ??? GET_LEVEL(ch) += mod; */
    break;

  case APPLY_AGE:
    ch->player.time.birth -= (mod * SECS_PER_MUD_YEAR);
    break;

  case APPLY_CHAR_WEIGHT:
    GET_WEIGHT(ch) += mod;
    break;

  case APPLY_CHAR_HEIGHT:
    GET_HEIGHT(ch) += mod;
    break;

  case APPLY_HIT:
    GET_MAX_HIT(ch) += mod;
    break;

  case APPLY_MOVE:
    GET_MAX_MOVE(ch) += mod;
    break;

  case APPLY_GOLD:
    break;

  case APPLY_EXP:
    break;

  case APPLY_AC:
    GET_AC(ch) += mod;
    break;

  case APPLY_HITROLL:
    GET_HITROLL(ch) += mod;
    break;

  case APPLY_DAMROLL:
    GET_DAMROLL(ch) += mod;
    break;

  case APPLY_SAVING_PARA:
    GET_SAVE(ch, SAVING_PARA) += mod;
    break;

  case APPLY_SAVING_ROD:
    GET_SAVE(ch, SAVING_ROD) += mod;
    break;

  case APPLY_SAVING_PETRI:
    GET_SAVE(ch, SAVING_PETRI) += mod;
    break;

  case APPLY_SAVING_BREATH:
    GET_SAVE(ch, SAVING_BREATH) += mod;
    break;

  case APPLY_SAVING_SPELL:
    GET_SAVE(ch, SAVING_SPELL) += mod;
    break;

  case APPLY_LIGHT:
    break;

  case APPLY_UNDEFINED:
  case APPLY_UNDEFINED_2:
    break;

  default:
    {
      log("SYSERR: Unknown apply adjust %p attempt (%s, affect_modify).",
        log, __FILE__);
    }
    break;

  } /* switch */
}
Example #10
0
void affect_modify(struct char_data *ch,byte loc, long mod, long bitv,bool add)
{
  int i;
  char buff[200];

  if (loc == APPLY_IMMUNE) {
    if (add) {
            if(bitv && !mod)
        SET_BIT(ch->immune, bitv);
      else
        SET_BIT(ch->immune, mod);
    } else {
      if(bitv && !mod)
        REMOVE_BIT(ch->immune, bitv);
      else
        REMOVE_BIT(ch->immune, mod);
    }
  } else if (loc == APPLY_SUSC) {
    if (add) {
      SET_BIT(ch->susc, mod);
    } else {
      REMOVE_BIT(ch->susc, mod);
    }
    
  } else if (loc == APPLY_M_IMMUNE) {
    if (add) {
      SET_BIT(ch->M_immune, mod);
    } else {
      REMOVE_BIT(ch->M_immune, mod);
    }
  } else if (loc == APPLY_SPELL) {
    if (add) {
      SET_BIT(ch->specials.affected_by, mod);
    } else {
      REMOVE_BIT(ch->specials.affected_by, mod);
    }
  } else if (loc == APPLY_WEAPON_SPELL) {
    return;
  } else if (loc == APPLY_BV2) {
    if (add) {
      SET_BIT(ch->specials.affected_by2, bitv);
    } else {
      REMOVE_BIT(ch->specials.affected_by2, bitv);
    }
    return;
  } else {
    if (add) {
      SET_BIT(ch->specials.affected_by, bitv);
    } else {
      REMOVE_BIT(ch->specials.affected_by, bitv);
      mod = -mod;
    }
  }

    
  switch(loc)
    {
    case APPLY_NONE:
    case APPLY_INTRINSIC:
      break;
      
    case APPLY_STR:
      ChangeStrength(ch, mod);
      break;
      
    case APPLY_DEX: 
#if 0
      temp = GET_DEX(ch);
            temp2=GET_DEX(ch);
      if(temp2 < ch->abilities.dex)
	GET_DEX(ch)=ch->abilities.dex;
      if(temp > 18) temp=18;
      if(GET_DEX(ch) > 18) GET_DEX(ch)=18;
      GET_AC(ch) -= dex_app[temp].defensive;
      GET_AC(ch) += dex_app[GET_DEX(ch)].defensive;
#endif
      GET_DEX(ch) += mod;
      break;
      

    case APPLY_INT:
      GET_INT(ch) += mod;
      break;
      
    case APPLY_WIS:
      GET_WIS(ch) += mod;
      break;
      
    case APPLY_CON:
      GET_CON(ch) += mod;
      break;
      
    case APPLY_SEX:
      GET_SEX(ch) = (!(ch->player.sex-1))+1;
      break;
      
    case APPLY_CHR:
      GET_CHR(ch) += mod;
      break;
      
    case APPLY_LEVEL:
      break;
      
    case APPLY_AGE:
      ch->player.time.birth -= SECS_PER_MUD_YEAR*mod;
      break;
      
    case APPLY_CHAR_WEIGHT:
      GET_WEIGHT(ch) += mod;
      break;
      
    case APPLY_CHAR_HEIGHT:
      GET_HEIGHT(ch) += mod;
      break;
      
    case APPLY_MANA:
      ch->points.max_mana += mod;
      break;
      
    case APPLY_HIT:
      /* ch->points.max_hit += mod; */
      ch->points.max_hit += mod;
      break;
      
    case APPLY_MOVE:
      ch->points.max_move += mod;
      break;
      
    case APPLY_GOLD:
      break;
      

    case APPLY_EXP:
      break;
      
    case APPLY_AC:
      GET_AC(ch) += mod;
      break;
      
    case APPLY_HITROLL:
      GET_HITROLL(ch) += mod;
      break;
      
    case APPLY_DAMROLL:
      GET_DAMROLL(ch) += mod;
      break;

 /* negatives make saving throws better */
      
    case APPLY_SAVING_PARA:
      ch->specials.apply_saving_throw[0] += mod;
      break;
      
    case APPLY_SAVING_ROD:
      ch->specials.apply_saving_throw[1] += mod;
      break;
      
    case APPLY_SAVING_PETRI:
      ch->specials.apply_saving_throw[2] += mod;
      break;
      
    case APPLY_SAVING_BREATH:
      ch->specials.apply_saving_throw[3] += mod;
      break;
      
    case APPLY_SAVING_SPELL:
      ch->specials.apply_saving_throw[4] += mod;
      break;
      
    case APPLY_SAVE_ALL:       {
	for (i=0;i<=4;i++)
	  ch->specials.apply_saving_throw[i] += mod;
      }
      break;
    case APPLY_IMMUNE:
      break;
    case APPLY_SUSC:
      break;
    case APPLY_M_IMMUNE:
      break;
    case APPLY_SPELL:
      break;
    case APPLY_HITNDAM:
      GET_HITROLL(ch) += mod;
      GET_DAMROLL(ch) += mod;
      break; 
    case APPLY_WEAPON_SPELL:
    case APPLY_EAT_SPELL:
      break;
    case APPLY_BACKSTAB:
      if (!ch->skills) return;
      ch->skills[SKILL_BACKSTAB].learned += mod;
      break;
    case APPLY_KICK:
      if (!ch->skills) return;
      ch->skills[SKILL_KICK].learned += mod;
      break;
    case APPLY_SNEAK:
      if (!ch->skills) return;
      ch->skills[SKILL_SNEAK].learned += mod;
      break;
    case APPLY_HIDE:
      if (!ch->skills) return;
      ch->skills[SKILL_HIDE].learned += mod;
      break;
    case APPLY_BASH:
      if (!ch->skills) return;
      ch->skills[SKILL_BASH].learned += mod;
      break;
    case APPLY_PICK:
      if (!ch->skills) return;
      ch->skills[SKILL_PICK_LOCK].learned += mod;
      break;
    case APPLY_STEAL:
      if (!ch->skills) return;
      ch->skills[SKILL_STEAL].learned += mod;
      break;
    case APPLY_TRACK:
      if (!ch->skills) return;
      ch->skills[SKILL_HUNT].learned += mod;
      break;

    case APPLY_SPELLFAIL:
      ch->specials.spellfail += mod;
      break;

    case APPLY_HASTE:
      if (mod > 0) {
	if (WizLock)
	  fprintf(stderr, "current mult = %f\n", ch->mult_att);
	ch->mult_att = ch->mult_att * 2.0;
	if (WizLock)
	  fprintf(stderr, "new mult = %f\n", ch->mult_att);
      } else if (mod < 0) {
	ch->mult_att = ch->mult_att / 2.0;
      }
      break;

    case APPLY_SLOW:
      if (mod > 0)
	ch->mult_att /= 2.0;
      else if (mod < 0) 
	ch->mult_att *= 2.0;
      break;

    case APPLY_ATTACKS:
      break;

    case APPLY_FIND_TRAPS:
      if (!ch->skills) return;
      ch->skills[SKILL_LOCATE_TRAP].learned += mod;
      break;

    case APPLY_RIDE:
      if (!ch->skills) return;
      ch->skills[SKILL_RIDE].learned += mod;
      break;

    case APPLY_RACE_SLAYER:
    case APPLY_ALIGN_SLAYER:
      break;

    case APPLY_MANA_REGEN:
      ch->points.mana_gain += mod;
      break;

    case APPLY_HIT_REGEN:
      ch->points.hit_gain += mod;
      break;

    case APPLY_MOVE_REGEN:
      ch->points.move_gain += mod;
      break;

    case APPLY_MOVE_BONUS:
      ch->specials.move_cost += mod;
      break;

    default:
      logE("Unknown apply adjust attempt (handler.c, affect_modify).");
      logE(ch->player.name);
      
      break;
      
    } /* switch */
}
Example #11
0
void aff_apply_modify(struct char_data *ch, byte loc, sbyte mod, char *msg)
{
  switch (loc) {
  case APPLY_NONE:
    break;

  case APPLY_STR:
    GET_STR(ch) += mod;
    break;
  case APPLY_DEX:
    GET_DEX(ch) += mod;
    break;
  case APPLY_INT:
    GET_INT(ch) += mod;
    break;
  case APPLY_WIS:
    GET_WIS(ch) += mod;
    break;
  case APPLY_CON:
    GET_CON(ch) += mod;
    break;
  case APPLY_CHA:
    GET_CHA(ch) += mod;
    break;

  case APPLY_AGE:
    ch->player.time.birth -= (mod * SECS_PER_MUD_YEAR);
    break;

  case APPLY_CHAR_WEIGHT:
    GET_WEIGHT(ch) += mod;
    break;

  case APPLY_CHAR_HEIGHT:
    GET_HEIGHT(ch) += mod;
    break;

  case APPLY_MANA:
    GET_MAX_MANA(ch) += mod;
    break;

  case APPLY_HIT:
    GET_MAX_HIT(ch) += mod;
    break;

  case APPLY_MOVE:
    GET_MAX_MOVE(ch) += mod;
    break;

  case APPLY_AC:
    GET_AC(ch) += mod;
    break;

  case APPLY_HITROLL:
    GET_HITROLL(ch) += mod;
    break;

  case APPLY_DAMROLL:
    GET_DAMROLL(ch) += mod;
    break;

  case APPLY_SAVING_PARA:
    GET_SAVE(ch, SAVING_PARA) += mod;
    break;

  case APPLY_SAVING_ROD:
    GET_SAVE(ch, SAVING_ROD) += mod;
    break;

  case APPLY_SAVING_PETRI:
    GET_SAVE(ch, SAVING_PETRI) += mod;
    break;

  case APPLY_SAVING_BREATH:
    GET_SAVE(ch, SAVING_BREATH) += mod;
    break;

  case APPLY_SAVING_SPELL:
    GET_SAVE(ch, SAVING_SPELL) += mod;
    break;

  default:
    log("SYSERR: Unknown apply adjust %d attempt (%s, affect_modify).", loc, __FILE__);
    break;

  } /* switch */
}
Example #12
0
void
save_player_to_file(struct creature *ch, const char *path)
{
    void expire_old_grievances(struct creature *);
    // Save vital statistics
    FILE *ouf;
    char *tmp_path;
    struct alias_data *cur_alias;
    int idx;
    int hit = GET_HIT(ch), mana = GET_MANA(ch), move = GET_MOVE(ch);

    tmp_path = tmp_sprintf("%s.tmp", path);
    ouf = fopen(tmp_path, "w");

    if (!ouf) {
        fprintf(stderr, "Unable to open XML player file for save.[%s] (%s)\n",
            path, strerror(errno));
        return;
    }
    struct aff_stash *aff_stash = stash_creature_affects(ch);

    expire_old_grievances(ch);

    fprintf(ouf, "<creature name=\"%s\" idnum=\"%ld\">\n",
        GET_NAME(ch), ch->char_specials.saved.idnum);

    fprintf(ouf,
        "<points hit=\"%d\" mana=\"%d\" move=\"%d\" maxhit=\"%d\" maxmana=\"%d\" maxmove=\"%d\"/>\n",
        ch->points.hit, ch->points.mana, ch->points.move, ch->points.max_hit,
        ch->points.max_mana, ch->points.max_move);

    fprintf(ouf, "<money gold=\"%" PRId64 "\" cash=\"%" PRId64 "\" xp=\"%d\"/>\n",
        ch->points.gold, ch->points.cash, ch->points.exp);

    fprintf(ouf,
        "<stats level=\"%d\" sex=\"%s\" race=\"%s\" height=\"%d\" weight=\"%f\" align=\"%d\"/>\n",
        GET_LEVEL(ch), genders[(int)GET_SEX(ch)],
        race_name_by_idnum(GET_RACE(ch)), GET_HEIGHT(ch), GET_WEIGHT(ch),
        GET_ALIGNMENT(ch));

    fprintf(ouf, "<class name=\"%s\"", class_names[GET_CLASS(ch)]);
    if (GET_REMORT_CLASS(ch) != CLASS_UNDEFINED)
        fprintf(ouf, " remort=\"%s\"", class_names[GET_REMORT_CLASS(ch)]);
    if (GET_REMORT_GEN(ch) > 0)
        fprintf(ouf, " gen=\"%d\"", GET_REMORT_GEN(ch));

    if (IS_CYBORG(ch)) {
        if (GET_OLD_CLASS(ch) != -1)
            fprintf(ouf, " subclass=\"%s\"",
                borg_subchar_class_names[GET_OLD_CLASS(ch)]);
        if (GET_TOT_DAM(ch))
            fprintf(ouf, " total_dam=\"%d\"", GET_TOT_DAM(ch));
        if (GET_BROKE(ch))
            fprintf(ouf, " broken=\"%d\"", GET_BROKE(ch));
    }
    if (GET_CLASS(ch) == CLASS_MAGE &&
        GET_SKILL(ch, SPELL_MANA_SHIELD) > 0) {
        fprintf(ouf, " manash_low=\"%ld\" manash_pct=\"%ld\"",
            ch->player_specials->saved.mana_shield_low,
            ch->player_specials->saved.mana_shield_pct);
    }
    fprintf(ouf, "/>\n");

    fprintf(ouf,
        "<time birth=\"%ld\" death=\"%ld\" played=\"%ld\" last=\"%ld\"/>\n",
        ch->player.time.birth, ch->player.time.death, ch->player.time.played,
        ch->player.time.logon);

    fprintf(ouf,
        "<carnage pkills=\"%d\" akills=\"%d\" mkills=\"%d\" deaths=\"%d\" reputation=\"%d\"",
        GET_PKILLS(ch), GET_ARENAKILLS(ch), GET_MOBKILLS(ch),
        GET_PC_DEATHS(ch), ch->player_specials->saved.reputation);
    fprintf(ouf, "/>\n");

    fprintf(ouf,
        "<attr str=\"%d\" int=\"%d\" wis=\"%d\" dex=\"%d\" con=\"%d\" cha=\"%d\"/>\n",
            ch->real_abils.str, ch->real_abils.intel, ch->real_abils.wis,
            ch->real_abils.dex, ch->real_abils.con, ch->real_abils.cha);

    fprintf(ouf, "<condition hunger=\"%d\" thirst=\"%d\" drunk=\"%d\"/>\n",
        GET_COND(ch, FULL), GET_COND(ch, THIRST), GET_COND(ch, DRUNK));

    fprintf(ouf, "<player wimpy=\"%d\" lp=\"%d\" clan=\"%d\"/>\n",
        GET_WIMP_LEV(ch), GET_LIFE_POINTS(ch), GET_CLAN(ch));

    if (ch->desc)
        ch->player_specials->desc_mode = ch->desc->input_mode;
    if (ch->player_specials->rentcode == RENT_CREATING ||
        ch->player_specials->rentcode == RENT_REMORTING) {
        fprintf(ouf, "<rent code=\"%d\" perdiem=\"%d\" "
            "currency=\"%d\" state=\"%s\"/>\n",
            ch->player_specials->rentcode, ch->player_specials->rent_per_day,
            ch->player_specials->rent_currency,
            desc_modes[(int)ch->player_specials->desc_mode]);
    } else {
        fprintf(ouf, "<rent code=\"%d\" perdiem=\"%d\" currency=\"%d\"/>\n",
            ch->player_specials->rentcode, ch->player_specials->rent_per_day,
            ch->player_specials->rent_currency);
    }
    fprintf(ouf, "<home town=\"%d\" homeroom=\"%d\" loadroom=\"%d\"/>\n",
        GET_HOME(ch), GET_HOMEROOM(ch), GET_LOADROOM(ch));

    fprintf(ouf, "<quest");
    if (GET_QUEST(ch))
        fprintf(ouf, " current=\"%d\"", GET_QUEST(ch));
    if (GET_LEVEL(ch) >= LVL_IMMORT)
        fprintf(ouf, " allowance=\"%d\"", GET_QUEST_ALLOWANCE(ch));
    if (GET_IMMORT_QP(ch) != 0)
        fprintf(ouf, " points=\"%d\"", GET_IMMORT_QP(ch));
    fprintf(ouf, "/>\n");

    fprintf(ouf, "<bits flag1=\"%" PRIx32 "\" flag2=\"%" PRIx32 "\"/>\n",
        ch->char_specials.saved.act, ch->player_specials->saved.plr2_bits);
    if (PLR_FLAGGED(ch, PLR_FROZEN)) {
        fprintf(ouf, "<frozen thaw_time=\"%d\" freezer_id=\"%d\"/>\n",
            ch->player_specials->thaw_time, ch->player_specials->freezer_id);
    }

    fprintf(ouf, "<prefs flag1=\"%" PRIx32 "\" flag2=\"%" PRIx32 "\" tongue=\"%s\"/>\n",
        ch->player_specials->saved.pref, ch->player_specials->saved.pref2,
        tongue_name(GET_TONGUE(ch)));

    fprintf(ouf, "<affects flag1=\"%" PRIx32 "\" flag2=\"%" PRIx32 "\" flag3=\"%" PRIx32 "\"/>\n",
        ch->char_specials.saved.affected_by,
        ch->char_specials.saved.affected2_by,
        ch->char_specials.saved.affected3_by);

    for (idx = 0; idx < MAX_WEAPON_SPEC; idx++) {
        if (GET_WEAP_SPEC(ch, idx).level > 0)
            fprintf(ouf, "<weaponspec vnum=\"%d\" level=\"%d\"/>\n",
                GET_WEAP_SPEC(ch, idx).vnum,
                GET_WEAP_SPEC(ch, idx).level);
    }

    if (GET_TITLE(ch) && *GET_TITLE(ch)) {
        fprintf(ouf, "<title>%s</title>\n", xmlEncodeTmp(GET_TITLE(ch)));
    }

    if (GET_LEVEL(ch) >= 50) {
        fprintf(ouf, "<immort badge=\"%s\" qlog=\"%d\" invis=\"%d\"/>\n",
            xmlEncodeSpecialTmp(BADGE(ch)), GET_QLOG_LEVEL(ch),
            GET_INVIS_LVL(ch));
        if (POOFIN(ch) && *POOFIN(ch))
            fprintf(ouf, "<poofin>%s</poofin>\n", xmlEncodeTmp(POOFIN(ch)));
        if (POOFOUT(ch) && *POOFOUT(ch))
            fprintf(ouf, "<poofout>%s</poofout>\n", xmlEncodeTmp(POOFOUT(ch)));
    }
    if (ch->player.description && *ch->player.description) {
        fprintf(ouf, "<description>%s</description>\n",
            xmlEncodeTmp(tmp_gsub(tmp_gsub(ch->player.description, "\r\n",
                        "\n"), "\r", "")));
    }
    for (cur_alias = ch->player_specials->aliases; cur_alias;
        cur_alias = cur_alias->next)
        fprintf(ouf, "<alias type=\"%d\" alias=\"%s\" replace=\"%s\"/>\n",
            cur_alias->type, xmlEncodeSpecialTmp(cur_alias->alias),
            xmlEncodeSpecialTmp(cur_alias->replacement));

    for (struct affected_type *cur_aff = aff_stash->saved_affs;
         cur_aff;
         cur_aff = cur_aff->next)
        fprintf(ouf,
            "<affect type=\"%d\" duration=\"%d\" modifier=\"%d\" location=\"%d\" level=\"%d\" instant=\"%s\" affbits=\"%lx\" index=\"%d\" owner=\"%ld\"/>\n",
            cur_aff->type, cur_aff->duration, cur_aff->modifier,
            cur_aff->location, cur_aff->level,
            (cur_aff->is_instant) ? "yes" : "no", cur_aff->bitvector,
            cur_aff->aff_index, cur_aff->owner);

    if (!IS_IMMORT(ch)) {
        for (idx = 0; idx < MAX_SKILLS; idx++)
            if (ch->player_specials->saved.skills[idx] > 0)
                fprintf(ouf, "<skill name=\"%s\" level=\"%d\"/>\n",
                    spell_to_str(idx), GET_SKILL(ch, idx));
        write_tongue_xml(ch, ouf);
        for (GList * it = GET_RECENT_KILLS(ch); it; it = it->next) {
            struct kill_record *kill = it->data;
            fprintf(ouf, "<recentkill vnum=\"%d\" times=\"%d\"/>\n",
                kill->vnum, kill->times);
        }
        for (GList * it = GET_GRIEVANCES(ch); it; it = it->next) {
            struct grievance *grievance = it->data;
            fprintf(ouf,
                "<grievance time=\"%lu\" player=\"%d\" reputation=\"%d\" kind=\"%s\"/>\n",
                (long unsigned)grievance->time, grievance->player_id,
                grievance->rep, grievance_kind_descs[grievance->grievance]);
        }
    }

    
    if (IS_PC(ch) && ch->player_specials->tags) {
        GHashTableIter iter;
        char *key;

        g_hash_table_iter_init(&iter, ch->player_specials->tags);

        while (g_hash_table_iter_next(&iter, (gpointer *)&key, NULL)) {
            fprintf(ouf, "<tag tag=\"%s\"/>\n", key);
        }
    }

    fprintf(ouf, "</creature>\n");
    fclose(ouf);

    // on success, move temp file on top of the old file
    rename(tmp_path, path);

    restore_creature_affects(ch, aff_stash);
    free(aff_stash);

    GET_HIT(ch) = MIN(GET_MAX_HIT(ch), hit);
    GET_MANA(ch) = MIN(GET_MAX_MANA(ch), mana);
    GET_MOVE(ch) = MIN(GET_MAX_MOVE(ch), move);
}
Example #13
0
void make_corpse(struct char_data *ch)
{
	struct obj_data *corpse, *o;
	struct obj_data *money;	
	char buf[MAX_STRING_LENGTH];
	int i;

	char *strdup(char *source);
	struct obj_data *create_money( int amount );

	CREATE(corpse, struct obj_data, 1);
	clear_object(corpse);

	
	corpse->item_number = NOWHERE;
	corpse->in_room = NOWHERE;
	corpse->name = strdup("corpse");

	sprintf(buf, "Corpse of %s is lying here.", 
	  (IS_NPC(ch) ? ch->player.short_descr : GET_NAME(ch)));
	corpse->description = strdup(buf);

	sprintf(buf, "Corpse of %s",
	  (IS_NPC(ch) ? ch->player.short_descr : GET_NAME(ch)));
	corpse->short_description = strdup(buf);

	corpse->contains = ch->carrying;
	if ( (GET_GOLD(ch)>0) &&
        ( IS_NPC(ch) || (ch->desc) ) )
	{
		money = create_money(GET_GOLD(ch));
		GET_GOLD(ch)=0;
		obj_to_obj(money,corpse);
	}

	corpse->obj_flags.type_flag = ITEM_CONTAINER;
	corpse->obj_flags.wear_flags = ITEM_TAKE;
	corpse->obj_flags.value[0] = 0; /* You can't store stuff in a corpse */
	corpse->obj_flags.value[3] = 1; /* corpse identifyer */
	corpse->obj_flags.weight = GET_WEIGHT(ch)+IS_CARRYING_W(ch);
	corpse->obj_flags.cost_per_day = 100000;
	if (IS_NPC(ch))
		corpse->obj_flags.timer = MAX_NPC_CORPSE_TIME;
	else
		corpse->obj_flags.timer = MAX_PC_CORPSE_TIME;

	for (i=0; i<MAX_WEAR; i++)
		if (ch->equipment[i])
			obj_to_obj(unequip_char(ch, i), corpse);

	ch->carrying = 0;
	IS_CARRYING_N(ch) = 0;
	IS_CARRYING_W(ch) = 0;

	corpse->next = object_list;
	object_list = corpse;

	for(o = corpse->contains; o; o->in_obj = corpse, o = o->next_content);
	object_list_new_owner(corpse, 0);

	obj_to_room(corpse, ch->in_room);
}
Example #14
0
void affect_modify(struct char_data *ch, byte loc, byte mod, long bitv, bool add)
{
    int maxabil;

    if (add) {
	SET_BIT(ch->specials.affected_by, bitv);
    } else {
	REMOVE_BIT(ch->specials.affected_by, bitv);
	mod = -mod;
    }


    maxabil = (IS_NPC(ch) ? 25:18);

    switch(loc)
    {
	case APPLY_NONE:
	    break;

	case APPLY_STR:
	    GET_STR(ch) += mod;
	    break;

	case APPLY_DEX:
	    GET_DEX(ch) += mod;
	    break;

	case APPLY_INT:
	    GET_INT(ch) += mod;
	    break;

	case APPLY_WIS:
	    GET_WIS(ch) += mod;
	    break;

	case APPLY_CON:
	    GET_CON(ch) += mod;
	    break;

	case APPLY_SEX:
	    /* ??? GET_SEX(ch) += mod; */
	    break;

	case APPLY_CLASS:
	    /* ??? GET_CLASS(ch) += mod; */
	    break;

	case APPLY_LEVEL:
	    /* ??? GET_LEVEL(ch) += mod; */
	    break;

	case APPLY_AGE:
	    ch->player.time.birth -= ((long)SECS_PER_MUD_YEAR*(long)mod); 
	    break;

	case APPLY_CHAR_WEIGHT:
	    GET_WEIGHT(ch) += mod;
	    break;

	case APPLY_CHAR_HEIGHT:
	    GET_HEIGHT(ch) += mod;
	    break;

	case APPLY_MANA:
            ch->points.max_mana += mod;
	    break;

	case APPLY_HIT:
	    ch->points.max_hit += mod;
	    break;

	case APPLY_MOVE:
	    /* Will change nothing on players ch->points.max_move += mod; */
	    break;

	case APPLY_GOLD:
	    break;

	case APPLY_EXP:
	    break;

	case APPLY_AC:
	    GET_AC(ch) += mod;
	    break;

	case APPLY_HITROLL:
	    GET_HITROLL(ch) += mod;
	    break;

	case APPLY_DAMROLL:
	    GET_DAMROLL(ch) += mod;
	    break;

	case APPLY_SAVING_PARA:
	    ch->specials.apply_saving_throw[0] += mod;
	    break;

	case APPLY_SAVING_ROD:
	    ch->specials.apply_saving_throw[1] += mod;
	    break;

	case APPLY_SAVING_PETRI:
	    ch->specials.apply_saving_throw[2] += mod;
	    break;

	case APPLY_SAVING_BREATH:
	    ch->specials.apply_saving_throw[3] += mod;
	    break;

	case APPLY_SAVING_SPELL:
	    ch->specials.apply_saving_throw[4] += mod;
	    break;

	default:
	    log("Unknown apply adjust attempt (handler.c, affect_modify).");
	    break;

    } /* switch */
}