Date sent: Wed, 16 Jul 1997 18:43:52 -0200 To: "Liner/Nosferatu" From: Rick Rogers (by way of Rick Rogers ) Subject: RCL: utility.h Even more utilities we use in specs, V_ROOM etc are in this one. Rick ------------ /* ************************************************************************ * file: utility.h, Utility module. Part of DIKUMUD * * Usage: Utility procedures * * Copyright (C) 1990, 1991 - see 'license.doc' for complete information. * ************************************************************************* */ #ifndef __UTILITY_H #define __UTILITY_H typedef struct char_data CHAR; typedef struct obj_data OBJ; typedef struct room_data Room; /* Common external variables */ extern struct room_data *world; extern struct mob_proto *mob_proto_table; extern struct obj_proto *obj_proto_table; extern int rev_dir[]; extern char *affected_bits[]; extern char *action_bits[]; extern char *extra_bits[]; extern char *wear_bits[]; extern char *apply_types[]; extern char *item_types[]; extern char *sector_types[]; extern char *sector_types_i[]; extern char *room_bits[]; int MIN(int a, int b); int MAX(int a, int b); int number(int from, int to) ; int dice(int number, int size) ; char *str_dup(char *source); int str_cat(char *s, int len, int maxlen, const char *append); int str_cmp(char *arg1, char *arg2); int strn_cmp(char *arg1, char *arg2, int n); char *string_to_lower(char *string); char *PERS(CHAR *ch, CHAR*vict); void log(char *str); void wizinfo(char *str, int level); void wizlog(char *str, int level, int which); void sprintbit(long vektor, char *names[], char *result); void sprinttype(int type, char *names[], char *result); int IS_CARRYING_W(struct char_data *ch); int IS_CARRYING_N(struct char_data *ch); int COUNT_CONTENTS(struct obj_data *obj); int COUNT_RENTABLE_CONTENTS(struct obj_data *obj); struct time_info_data real_time_passed(time_t t2, time_t t1); struct time_info_data mud_time_passed(time_t t2, time_t t1); struct time_info_data age(struct char_data *ch); struct obj_data *EQ( struct char_data *ch, int loc ); char is_carrying_obj (struct char_data *ch, int virtual); char is_wearing_obj (struct char_data *ch, int virtual, int loc); void drain_mana_hit_mv(struct char_data *ch,struct char_data *vict,int m, int h,int mv,bool add_m,bool add_hp,bool add_mv); struct char_data *get_ch (int virtual, int scope, int location) ; struct char_data *get_ch_world (int virtual) ; struct char_data *get_ch_zone (int virtual, int zone) ; struct char_data *get_ch_room (int virtual, int realroom) ; int V_OBJ(struct obj_data *o) ; int V_MOB(struct char_data *m) ; int V_ROOM(struct char_data *m) ; struct obj_data *get_obj_room (int virtual, int loc) ; int count_mortals (struct char_data *ch, byte scope, bool see_invis) ; int count_mortals_room (struct char_data *ch, bool see_invis) ; int count_mortals_room_fighting (struct char_data *ch, bool see_invis) ; int count_mortals_zone (struct char_data *ch, bool see_invis) ; int count_mortals_world (struct char_data *ch, bool see_invis) ; int count_mortals_real_room (int room) ; struct obj_data *get_random_obj_in_list (struct obj_data *list) ; struct obj_data *get_random_obj_room (struct char_data *ch) ; struct obj_data *get_random_obj_inv (struct char_data *ch) ; int get_random_obj_eq (struct char_data *ch) ; struct char_data *get_random_victim( struct char_data *ch ) ; struct char_data *get_random_victim_fighting( struct char_data *ch ) ; void move_eq_from_to (struct char_data *fch, struct char_data *tch) ; void move_inv_from_to (struct char_data *fch, struct char_data *tch) ; void set_item_value (struct obj_data *o, int val, int new) ; void move_objs_to_room (int frm, int to) ; void move_chars_to_room (int frm, int to) ; int count_mobiles (struct char_data *ch, int virtual, int scope) ; int ISCARRYING_W(struct char_data *ch); int GETOBJ_WEIGHT(struct obj_data *obj); /* The following function will return an affected_type specified by the parameters type, modifier and location. All but type can be left to zero, which specifies the exact type of the spec_affect. The syntax for setting a spec_affect on a player would be : #define SPEC_RED_PLAGUE 1 struct affected_type *af; af = create_spec_affect (SPEC_RED_PLAGUE, -6, APPLY_STR); affect_to_char (ch, af); All the SPEC_XXX will be collected in one file, and care must be taken not to define new ones with already existing values. */ struct affected_type *create_spec_affect (sh_int type, sh_int mod,byte locat) ; /* remove_spec_affect will remove a specified spec_affect from a character by first finding the right affect and then removing it. If the charater is not affected by the specified spec_aff, then nothing will be done. To use this function, you are not required to check if the character is or isn't affected by the spec_aff you are trying to remove. The syntax for using this function would be : remove_spec_affect (ch, SPEC_RED_PLAGUE); */ void remove_spec_affect (struct char_data *ch, sh_int type) ; /* is_affected_spec will try to find a specified spec_aff on a character and will return TRUE if it finds one. */ bool is_affected_spec (struct char_data *ch, sh_int type) ; char *how_good(int percent); void check_equipment(struct char_data *ch); void produce_core(); void empty_container(struct obj_data *j) ; void empty_all_containers(struct char_data *ch); #endif