/* Take an object from a room */ void obj_from_room(struct obj_data *object) { struct obj_data *temp; struct char_data *t, *tempch; if (!object || IN_ROOM(object) == NOWHERE) { log("SYSERR: NULL object (%p) or obj not in a room (%d) passed to obj_from_room", object, IN_ROOM(object)); return; } /* if people are sitting in it, toss their butt to the ground */ if (OBJ_SAT_IN_BY(object) != NULL) { for (tempch = OBJ_SAT_IN_BY(object); tempch; tempch = t) { t = NEXT_SITTING(tempch); SITTING(tempch) = NULL; NEXT_SITTING(tempch) = NULL; } } REMOVE_FROM_LIST(object, world[IN_ROOM(object)].contents, next_content); if (ROOM_FLAGGED(IN_ROOM(object), ROOM_HOUSE)) SET_BIT_AR(ROOM_FLAGS(IN_ROOM(object)), ROOM_HOUSE_CRASH); IN_ROOM(object) = NOWHERE; object->next_content = NULL; }
/* should do sanity checks on vnums & remove invalid records */ void House_boot(void) { struct house_control_rec temp_house; int real_house, real_atrium; FILE *fl; memset((char *)house_control,0,sizeof(struct house_control_rec)*MAX_HOUSES); if (!(fl = fopen(HCONTROL_FILE, "rb"))) { log("House control file does not exist."); return; } while (!feof(fl) && num_of_houses < MAX_HOUSES) { fread(&temp_house, sizeof(struct house_control_rec), 1, fl); if (feof(fl)) break; if (get_name_by_id(temp_house.owner) == NULL) continue; /* owner no longer exists -- skip */ if ((real_house = real_room(temp_house.vnum)) < 0) continue; /* this vnum doesn't exist -- skip */ if ((find_house(temp_house.vnum)) >= 0) continue; /* this vnum is already a hosue -- skip */ if ((real_atrium = real_room(temp_house.atrium)) < 0) continue; /* house doesn't have an atrium -- skip */ if (temp_house.exit_num < 0 || temp_house.exit_num >= NUM_OF_DIRS) continue; /* invalid exit num -- skip */ if (TOROOM(real_house, temp_house.exit_num) != real_atrium) continue; /* exit num mismatch -- skip */ house_control[num_of_houses++] = temp_house; SET_BIT_AR(ROOM_FLAGS(real_house), ROOM_HOUSE); SET_BIT_AR(ROOM_FLAGS(real_house), ROOM_PRIVATE); SET_BIT_AR(ROOM_FLAGS(real_atrium), ROOM_ATRIUM); House_load(temp_house.vnum); } fclose(fl); House_save_control(); }
void hcontrol_destroy_house(struct char_data * ch, char *arg) { int i, j; int real_atrium, real_house; if (!*arg) { send_to_char(HCONTROL_FORMAT, ch); return; } if ((i = find_house(atoi(arg))) < 0) { send_to_char("Unknown house.\r\n", ch); return; } if ((real_atrium = real_room(house_control[i].atrium)) < 0) log("SYSERR: House had invalid atrium!"); else REMOVE_BIT_AR(ROOM_FLAGS(real_atrium), ROOM_ATRIUM); if ((real_house = real_room(house_control[i].vnum)) < 0) log("SYSERR: House had invalid vnum!"); else { REMOVE_BIT_AR(ROOM_FLAGS(real_house), ROOM_HOUSE); REMOVE_BIT_AR(ROOM_FLAGS(real_house), ROOM_PRIVATE); REMOVE_BIT_AR(ROOM_FLAGS(real_house), ROOM_HOUSE_CRASH); } House_delete_file(house_control[i].vnum); for (j = i; j < num_of_houses - 1; j++) house_control[j] = house_control[j + 1]; num_of_houses--; send_to_char("House deleted.\r\n", ch); House_save_control(); /* * Now, reset the ROOM_ATRIUM flag on all existing houses' atriums, * just in case the house we just deleted shared an atrium with another * house. --JE 9/19/94 */ for (i = 0; i < num_of_houses; i++) if ((real_atrium = real_room(house_control[i].atrium)) >= 0) SET_BIT_AR(ROOM_FLAGS(real_atrium), ROOM_ATRIUM); }
/* crash-save all the houses */ void House_save_all(void) { int i; int real_house; for (i = 0; i < num_of_houses; i++) if ((real_house = real_room(house_control[i].vnum)) != NOWHERE) if (IS_SET_AR(ROOM_FLAGS(real_house), ROOM_HOUSE_CRASH)) House_crashsave(house_control[i].vnum); }
/* put an object in a room */ void obj_to_room(struct obj_data * object, room_rnum room) { if (!object || room < 0 || room > top_of_world) log("SYSERR: Illegal value(s) passed to obj_to_room"); else { object->next_content = world[room].contents; world[room].contents = object; object->in_room = room; object->carried_by = NULL; if (ROOM_FLAGGED(room, ROOM_HOUSE)) SET_BIT(ROOM_FLAGS(room), ROOM_HOUSE_CRASH); } }
/* put an object in a room */ void obj_to_room(struct obj_data *object, room_rnum room) { if (!object || room == NOWHERE || room > top_of_world) log("SYSERR: Illegal value(s) passed to obj_to_room. (Room #%d/%d, obj %p)", room, top_of_world, object); else { object->next_content = world[room].contents; world[room].contents = object; IN_ROOM(object) = room; object->carried_by = NULL; if (ROOM_FLAGGED(room, ROOM_HOUSE)) SET_BIT_AR(ROOM_FLAGS(room), ROOM_HOUSE_CRASH); } }
/* Take an object from a room */ void obj_from_room(struct obj_data * object) { struct obj_data *temp; if (!object || object->in_room == NOWHERE) { log("SYSERR: NULL object or obj not in a room passed to obj_from_room"); return; } REMOVE_FROM_LIST(object, world[object->in_room].contents, next_content); if (ROOM_FLAGGED(object->in_room, ROOM_HOUSE)) SET_BIT(ROOM_FLAGS(object->in_room), ROOM_HOUSE_CRASH); object->in_room = NOWHERE; object->next_content = NULL; }
/* Save all objects in a house */ void House_crashsave(room_vnum vnum) { int rnum; char buf[MAX_STRING_LENGTH]; FILE *fp; if ((rnum = real_room(vnum)) == -1) return; if (!House_get_filename(vnum, buf)) return; if (!(fp = fopen(buf, "wb"))) { perror("SYSERR: Error saving house file"); return; } if (!House_save(world[rnum].contents, fp)) { fclose(fp); return; } fclose(fp); House_restore_weight(world[rnum].contents); REMOVE_BIT_AR(ROOM_FLAGS(rnum), ROOM_HOUSE_CRASH); }
void hcontrol_build_house(struct char_data * ch, char *arg) { char arg1[MAX_INPUT_LENGTH]; struct house_control_rec temp_house; int virt_house, real_house, real_atrium, virt_atrium, exit_num; long owner; if (num_of_houses >= MAX_HOUSES) { send_to_char("Max houses already defined.\r\n", ch); return; } /* first arg: house's vnum */ arg = one_argument(arg, arg1); if (!*arg1) { send_to_char(HCONTROL_FORMAT, ch); return; } virt_house = atoi(arg1); if ((real_house = real_room(virt_house)) < 0) { send_to_char("No such room exists.\r\n", ch); return; } if ((find_house(virt_house)) >= 0) { send_to_char("House already exists.\r\n", ch); return; } /* second arg: direction of house's exit */ arg = one_argument(arg, arg1); if (!*arg1) { send_to_char(HCONTROL_FORMAT, ch); return; } if ((exit_num = search_block(arg1, dirs, FALSE)) < 0) { sprintf(buf, "'%s' is not a valid direction.\r\n", arg1); send_to_char(buf, ch); return; } if (TOROOM(real_house, exit_num) == NOWHERE) { sprintf(buf, "There is no exit %s from room %d.\r\n", dirs[exit_num], virt_house); send_to_char(buf, ch); return; } real_atrium = TOROOM(real_house, exit_num); virt_atrium = world[real_atrium].number; if (TOROOM(real_atrium, rev_dir[exit_num]) != real_house) { send_to_char("A house's exit must be a two-way door.\r\n", ch); return; } /* third arg: player's name */ arg = one_argument(arg, arg1); if (!*arg1) { send_to_char(HCONTROL_FORMAT, ch); return; } if ((owner = get_id_by_name(arg1)) < 0) { sprintf(buf, "Unknown player '%s'.\r\n", arg1); send_to_char(buf, ch); return; } temp_house.mode = HOUSE_PRIVATE; temp_house.vnum = virt_house; temp_house.atrium = virt_atrium; temp_house.exit_num = exit_num; temp_house.built_on = time(0); temp_house.last_payment = 0; temp_house.owner = owner; temp_house.num_of_guests = 0; house_control[num_of_houses++] = temp_house; SET_BIT_AR(ROOM_FLAGS(real_house), ROOM_HOUSE); SET_BIT_AR(ROOM_FLAGS(real_house), ROOM_PRIVATE); SET_BIT_AR(ROOM_FLAGS(real_atrium), ROOM_ATRIUM); House_crashsave(virt_house); send_to_char("House built. Mazel tov!\r\n", ch); House_save_control(); }
void suffer_activity(int pulse) { struct char_data *ch, *next_ch; char *desc; char dam_msg1[120] = "msg1 for suffer room not defined, report this to an imm!\r\n"; char dam_msg2[120] = "msg2 for suffer room not defined, report this to an imm!\r\n"; char dam_msg3[120] = "msg3 for suffer room not defined, report this to an imm!\r\n"; char dam_msg4[120] = "msg4 for suffer room not defined, report this to an imm!\r\n"; char death_char[120] = "You drift into coma and die."; char death_room[120] = "$n has drifted into coma and dies."; char suffer_msg[120] = "$n is suffering."; int percent_hp; int min_dam = 10, max_dam = 20, dam_amount; int hot = FALSE, cold = FALSE , dry = FALSE; for (ch = character_list; ch; ch = next_ch) { next_ch = ch->next; if (GET_LEVEL(ch) >= LVL_IMMORT) /* Lets not hurt our immortals */ continue; if (IS_NPC(ch)) continue; // I'm adding in a check to make outlaws "suffer" if in a peace room // Added by Sanji if( (ROOM_FLAGGED(IN_ROOM(ch), ROOM_PEACEFUL) || IN_ARENA(ch) || IS_SET_AR(ROOM_FLAGS((ch)->in_room), ROOM_CLAN)) && (IS_SET_AR(PLR_FLAGS(ch), PLR_HUNTED) || IS_SET_AR(PLR_FLAGS(ch), PLR_THIEF))) { int to_room = 18001; // Samsera center // hurt the little cheater GET_HIT(ch) = MAX(1, GET_HIT(ch) - GET_MAX_HIT(ch)/8); GET_MANA(ch) = MAX(0, GET_MANA(ch) - GET_MAX_MANA(ch)/8); GET_MOVE(ch) = MAX(0, GET_MOVE(ch) - GET_MAX_MOVE(ch)/8); // where to send the victim? //do //{ // to_room = number( 0, top_of_world ); //} while (IS_SET_AR(world[to_room].room_flags, ROOM_PRIVATE) || // IS_SET_AR(world[to_room].room_flags, ROOM_DEATH) || // IS_SET_AR(world[to_room].room_flags, ROOM_PEACEFUL)); // Lets send out a message, more can be added later. // send_to_char("Naughty naughty. No hiding!\r\n", ch); // Time to move the victim char_from_room(ch); char_to_room(ch, real_room(to_room)); look_at_room(ch, 0); } hot = (ROOM_FLAGGED(IN_ROOM(ch), ROOM_HOT)); cold = (ROOM_FLAGGED(IN_ROOM(ch), ROOM_COLD)); dry = (ROOM_FLAGGED(IN_ROOM(ch), ROOM_DRY)); if (!hot && !cold && !dry) continue; /* Getting ready to pull the damage amount out of the extra desc in the room */ if ((desc = find_exdesc("min_dam", world[ch->in_room].ex_description)) != NULL) min_dam = atoi(desc); else min_dam = 0; if ((desc = find_exdesc("max_dam", world[ch->in_room].ex_description)) != NULL) max_dam = atoi(desc); else max_dam = 25; if (max_dam < min_dam) { send_to_char("SYSERR: Max damage lower then Min damage. Report to an Immortal.\r\n", ch); return; } dam_amount = number(min_dam, max_dam); if ((desc = find_exdesc("suffer1", world[ch->in_room].ex_description)) != NULL) sprintf(dam_msg1, "%s", desc); if ((desc = find_exdesc("suffer2", world[ch->in_room].ex_description)) != NULL) sprintf(dam_msg2, "%s", desc); if ((desc = find_exdesc("suffer3", world[ch->in_room].ex_description)) != NULL) sprintf(dam_msg3, "%s", desc); if ((desc = find_exdesc("suffer4", world[ch->in_room].ex_description)) != NULL) sprintf(dam_msg4, "%s", desc); if ((desc = find_exdesc("death_char", world[ch->in_room].ex_description)) != NULL) sprintf(death_char, "%s", desc); if ((desc = find_exdesc("death_room", world[ch->in_room].ex_description)) != NULL) sprintf(death_room, "%s", desc); if ((desc = find_exdesc("suffer_msg", world[ch->in_room].ex_description)) != NULL) sprintf(suffer_msg, "%s", desc); if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_COLD) && IS_AFFECTED(ch, AFF_NO_COLD)) continue; else if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_HOT) && IS_AFFECTED(ch, AFF_NO_HOT)) continue; else if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_HOT) && IS_AFFECTED(ch, AFF_NO_DRY)) continue; // DUH! added a check for soak if (((ROOM_FLAGGED(IN_ROOM(ch), ROOM_HOT) || ROOM_FLAGGED(IN_ROOM(ch), ROOM_DRY)) && (GET_COND(ch, THIRST) > 0))) GET_COND(ch, THIRST) = 0; if (dam_amount >= GET_HIT(ch)) dam_amount = GET_HIT(ch) + number(4, 7); else act(suffer_msg, FALSE, ch, 0, 0, TO_ROOM); GET_HIT(ch) -= dam_amount; percent_hp = (100 * GET_HIT(ch)) / GET_MAX_HIT(ch); // need a check here to see if the char is still in the room! if ((ROOM_FLAGGED(IN_ROOM(ch), ROOM_HOT)) || (ROOM_FLAGGED(IN_ROOM(ch), ROOM_COLD)) || (ROOM_FLAGGED(IN_ROOM(ch), ROOM_DRY))){ if (percent_hp > 75) send_to_char(dam_msg1, ch); else if (percent_hp > 50) send_to_char(dam_msg2, ch); else if (percent_hp > 30) send_to_char(dam_msg3, ch); else if (percent_hp >= 15) send_to_char(dam_msg4, ch); else if (percent_hp >= 1) { GET_HIT(ch) = number (-3, -5); send_to_char("You have passed out.\r\n", ch); act("$n has passed out and fallen to the ground.", FALSE, ch, 0, 0, TO_ROOM); update_pos(ch); } else { GET_HIT(ch) = number(-7, -10); act(death_char, FALSE, ch, 0, 0, TO_CHAR); act(death_room, FALSE, ch, 0, 0, TO_ROOM); update_pos(ch); GET_MANA(ch) = 1; die(ch, NULL, 0); } } } /* End of for loop */ }