struct obj_data *get_obj_vis_accessible(struct char_data *ch, char *name) { struct obj_data *i; int j, number; char tmpname[MAX_INPUT_LENGTH]; char *tmp; strcpy(tmpname,name); tmp = tmpname; if(!(number = get_number(&tmp))) return(0); /* scan items carried */ for (i = ch->carrying, j=1; i && j<=number; i = i->next_content) if (isname(tmp, i->name) && CAN_SEE_OBJ(ch, i)) if (j == number) return(i); else j++; for (i = real_roomp(ch->in_room)->contents; i && j<=number; i = i->next_content) if (isname(tmp, i->name) && CAN_SEE_OBJ(ch, i)) if (j==number) return(i); else j++; return 0; }
CHAR_DATA * mp_whohasobj (CHAR_DATA * mob, int obj_virt) { CHAR_DATA *tch; OBJ_DATA *tobj; ROOM_DATA *room; room = vtor (mob->in_room); if (!room) return NULL; /* If the character is hiding the object in another object, this routine will not find it */ for (tch = room->people; tch; tch = tch->next_in_room) { if (tch->right_hand && tch->right_hand->nVirtual == obj_virt && CAN_SEE_OBJ (mob, tch->right_hand)) return tch; if (tch->left_hand && tch->left_hand->nVirtual == obj_virt && CAN_SEE_OBJ (mob, tch->left_hand)) return tch; for (tobj = tch->equip; tobj; tobj = tobj->next_content) if (tobj->nVirtual == obj_virt && CAN_SEE_OBJ (mob, tobj)) return tobj->equiped_by; } return NULL; }
int dump(struct char_data *ch, int cmd, char *arg) { struct obj_data *k; char buf[100]; struct char_data *tmp_char; int value=0; void do_drop(struct char_data *ch, char *argument, int cmd); char *fname(char *namelist); for(k = world[ch->in_room].contents; k ; k = world[ch->in_room].contents) { sprintf(buf, "The %s vanish in a puff of smoke.\n\r" ,fname(k->name)); for(tmp_char = world[ch->in_room].people; tmp_char; tmp_char = tmp_char->next_in_room) if (CAN_SEE_OBJ(tmp_char, k)) send_to_char(buf,tmp_char); extract_obj(k); } if(cmd!=60) return(FALSE); do_drop(ch, arg, cmd); value = 0; for(k = world[ch->in_room].contents; k ; k = world[ch->in_room].contents) { sprintf(buf, "The %s vanish in a puff of smoke.\n\r",fname(k->name)); for(tmp_char = world[ch->in_room].people; tmp_char; tmp_char = tmp_char->next_in_room) if (CAN_SEE_OBJ(tmp_char, k)) send_to_char(buf,tmp_char); value += MAX(1, MIN(50, k->obj_flags.cost/10)); extract_obj(k); } if (value) { act("You are awarded for outstanding performance.", FALSE, ch, 0, 0, TO_CHAR); act("$n has been awarded for being a good citizen.", TRUE, ch, 0,0, TO_ROOM); if (GET_LEVEL(ch) < 3) gain_exp(ch, value); else GET_GOLD(ch) += value; } }
/* search the entire world for an object, and return a pointer */ struct obj_data *get_obj_vis(struct char_data *ch, char *name, int *number) { struct obj_data *i; int num; if (!number) { number = # num = get_number(&name); } if (*number == 0) return (NULL); /* scan items carried */ if ((i = get_obj_in_list_vis(ch, name, number, ch->carrying)) != NULL) return (i); /* scan room */ if ((i = get_obj_in_list_vis(ch, name, number, world[IN_ROOM(ch)].contents)) != NULL) return (i); /* ok.. no luck yet. scan the entire obj list */ for (i = object_list; i && *number; i = i->next) if (isname(name, i->name)) if (CAN_SEE_OBJ(ch, i)) if (--(*number) == 0) return (i); return (NULL); }
struct obj_data *get_obj_vis_world(struct char_data *ch, char *name, int *count) { struct obj_data *i; int j, number; char tmpname[MAX_INPUT_LENGTH]; char *tmp; strcpy(tmpname,name); tmp = tmpname; if(!(number = get_number(&tmp))) return(0); j = count ? *count : 1; /* ok.. no luck yet. scan the entire obj list */ for (i = object_list; i && (j <= number); i = i->next) if (isname(tmp, i->name)) if (CAN_SEE_OBJ(ch, i)) { if (j == number) return(i); j++; } if (count) *count = j; return(0); }
/*search the entire world for an object, and return a pointer */ struct obj_data *get_obj_vis(struct char_data *ch, char *name) { struct obj_data *i; int j, number; char tmpname[MAX_INPUT_LENGTH]; char *tmp; /* scan items carried */ if ( ( i = get_obj_in_list_vis(ch, name, ch->carrying) ) != NULL ) return(i); /* scan room */ if ( ( i = get_obj_in_list_vis(ch, name, world[ch->in_room].contents) ) != NULL ) return(i); strcpy(tmpname,name); tmp = tmpname; if ( ( number = get_number(&tmp) ) == 0 ) return(0); /* ok.. no luck yet. scan the entire obj list */ for (i = object_list, j = 1; i && (j <= number); i = i->next) if (isname(tmp, i->name)) if (CAN_SEE_OBJ(ch, i)) { if (j == number) return(i); j++; } return(0); }
/* search the entire world for an object, and return a pointer */ struct obj_data *get_obj_vis(struct char_data * ch, char *name) { struct obj_data *i; int j = 0, number; char tmpname[MAX_INPUT_LENGTH]; char *tmp = tmpname; /* scan items carried */ if ((i = get_obj_in_list_vis(ch, name, ch->carrying))) return i; /* scan room */ if ((i = get_obj_in_list_vis(ch, name, world[ch->in_room].contents))) return i; strcpy(tmp, name); if (!(number = get_number(&tmp))) { number = 1; tmp = name; } /* ok.. no luck yet. scan the entire obj list */ for (i = object_list; i && (j <= number); i = i->next) if (isname(tmp, i->name)) if (CAN_SEE_OBJ(ch, i)) if (++j == number) return i; return NULL; }
struct obj_data *get_object_in_equip_vis(struct char_data * ch, char *arg, struct obj_data * equipment[], int *j) { int number, tot = 0; char tmpname[MAX_INPUT_LENGTH]; char *tmp = tmpname; strcpy(tmp, arg); if (!(number = get_number(&tmp))) { number = 1; tmp = arg; } for ((*j) = 0; (*j) < NUM_WEARS; (*j)++) if (equipment[(*j)]) if (CAN_SEE_OBJ(ch, equipment[(*j)]) && !hidden_eq(ch, equipment[(*j)])) if (isname(tmp, equipment[(*j)]->name)) { tot ++; if (tot == number) { return (equipment[(*j)]); } } return NULL; }
void shopping_list( char *arg, struct char_data *ch, struct char_data *keeper, int shop_nr) { char buf[MAX_STRING_LENGTH], buf2[100],buf3[100]; struct obj_data *temp1; extern char *drinks[]; int found_obj; int i; float mult = 0; if(!(is_ok(keeper,ch,shop_nr))) return; if(keeper->generic != 0) for(i = 0; i <= MAX_TRADE; i++) { if(keeper->generic == FAMINE) if(shop_index[shop_nr].type[i] == ITEM_FOOD) { mult = shop_multiplier; /* we're in a famine, we sell food, so we */ break; /* our prices to hell ;-) -DM */ } if(keeper->generic == DWARVES_STRIKE) if((shop_index[shop_nr].type[i] == ITEM_ARMOR) || (shop_index[shop_nr].type[i] == ITEM_WEAPON)) { mult = shop_multiplier; break; } } strcpy(buf,"You can buy:\n\r"); found_obj = FALSE; if(keeper->carrying) for(temp1=keeper->carrying; temp1; temp1 = temp1->next_content) if((CAN_SEE_OBJ(ch,temp1)) && (temp1->obj_flags.cost>0)) { found_obj = TRUE; if(temp1->obj_flags.type_flag != ITEM_DRINKCON) sprintf(buf2,"%s for %d gold coins.\n\r" ,(temp1->short_description),(int)(temp1->obj_flags.cost*shop_index[shop_nr].profit_buy - ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost))); else { if (temp1->obj_flags.value[1]) sprintf(buf3,"%s of %s",(temp1->short_description) ,drinks[temp1->obj_flags.value[2]]); else sprintf(buf3,"%s",(temp1->short_description)); sprintf(buf2,"%s for %d gold coins.\n\r",buf3, (int)(temp1->obj_flags.cost*shop_index[shop_nr].profit_buy - ((chr_apply[GET_CHR(ch)].reaction*temp1->obj_flags.cost)/100) + (mult * temp1->obj_flags.cost))); } strcat(buf,CAP(buf2)); }; if(!found_obj) strcat(buf,"Nothing!\n\r"); send_to_char(buf,ch); return; }
struct obj_data *get_object_in_equip_vis(struct char_data *ch, char *arg, struct obj_data *equipment[], int *j) { for ((*j) = 0; (*j) < MAX_WEAR ; (*j)++) if (equipment[(*j)]) if (CAN_SEE_OBJ(ch,equipment[(*j)])) if (isname(arg, equipment[(*j)]->name)) return(equipment[(*j)]); return (0); }
void shopping_list(char *arg, struct char_data *ch, struct char_data * keeper, int shop_nr) { char buf[MAX_STRING_LENGTH], name[MAX_INPUT_LENGTH]; struct obj_data *obj, *last_obj = 0; int cnt = 0, index = 0; bool found = FALSE; if (!(is_ok(keeper, ch, shop_nr))) return; if (SHOP_SORT(shop_nr) < IS_CARRYING_N(keeper)) sort_keeper_objs(keeper, shop_nr); one_argument(arg, name); strcpy(buf, " ## Available Item Cost\n\r"); strcat(buf, "-------------------------------------------------------------------------\n\r"); if (keeper->carrying) for (obj = keeper->carrying; obj; obj = obj->next_content) if (CAN_SEE_OBJ(ch, obj) && (obj->obj_flags.cost > 0)) { if (!last_obj) { last_obj = obj; cnt = 1; } else if (same_obj(last_obj, obj)) cnt++; else { index++; if (!(*name) || isname(name, last_obj->name)) { strcat(buf, list_object(ch, last_obj, cnt, index, shop_nr)); found = TRUE; } cnt = 1; last_obj = obj; } } index++; if (!last_obj) stc("Currently, there is nothing for sale.\r\n", ch); else if (*name && !found) stc("Presently, none of those are for sale.\r\n", ch); else { if (!(*name) || isname(name, last_obj->name)) strcat(buf, list_object(ch, last_obj, cnt, index, shop_nr)); page_string(ch->desc, buf, 1); } }
void list_obj_to_char(struct obj_data *list,struct char_data *ch, int mode, bool show) { struct obj_data *i; bool found; found = FALSE; for ( i = list ; i ; i = i->next_content ) { if (CAN_SEE_OBJ(ch,i)) { show_obj_to_char(i, ch, mode); found = TRUE; } } if ((! found) && (show)) send_to_char("Nothing\n\r", ch); }
void shopping_list( char *arg, struct char_data *ch, struct char_data *keeper, int shop_nr) { char buf[MAX_STRING_LENGTH], buf2[100],buf3[100]; struct obj_data *temp1; extern char *drinks[]; int found_obj; if(!(is_ok(keeper,ch,shop_nr))) return; strcpy(buf,"You can buy:\n\r"); found_obj = FALSE; if(keeper->carrying) for(temp1=keeper->carrying; temp1; temp1 = temp1->next_content) if((CAN_SEE_OBJ(ch,temp1)) && (temp1->obj_flags.cost>0)) { found_obj = TRUE; if(temp1->obj_flags.type_flag != ITEM_DRINKCON) sprintf(buf2,"%s for %d gold coins.\n\r" ,(temp1->short_description) ,(int)(temp1->obj_flags.cost* shop_index[shop_nr].profit_buy)); else { if (temp1->obj_flags.value[1]) sprintf(buf3,"%s of %s",(temp1->short_description) ,drinks[temp1->obj_flags.value[2]]); else sprintf(buf3,"%s",(temp1->short_description)); sprintf(buf2,"%s for %d gold coins.\n\r",buf3, (int)(temp1->obj_flags.cost*shop_index[shop_nr].profit_buy)); } strcat(buf,CAP(buf2)); }; if(!found_obj) strcat(buf,"Nothing!\n\r"); send_to_char(buf,ch); return; }
int get_obj_pos_in_equip_vis(struct char_data *ch, char *arg, int *number, struct obj_data *equipment[]) { int j, num; if (!number) { number = # num = get_number(&arg); } if (*number == 0) return (-1); for (j = 0; j < NUM_WEARS; j++) if (equipment[j] && CAN_SEE_OBJ(ch, equipment[j]) && isname(arg, equipment[j]->name)) if (--(*number) == 0) return (j); return (-1); }
struct obj_data * get_hash_obj_vis(struct char_data * ch, char *name, struct obj_data * list) { struct obj_data *loop, *last_obj = 0; int index; if ((is_number(name + 1))) index = atoi(name + 1); else return (0); for (loop = list; loop; loop = loop->next_content) if (CAN_SEE_OBJ(ch, loop) && (loop->obj_flags.cost > 0)) if (!same_obj(last_obj, loop)) { if (--index == 0) return (loop); last_obj = loop; } return (0); }
struct obj_data *get_obj_in_list_vis(struct char_data *ch, char *name, int *number, struct obj_data *list) { struct obj_data *i; int num; if (!number) { number = # num = get_number(&name); } if (*number == 0) return (NULL); for (i = list; i && *number; i = i->next_content) if (isname(name, i->name)) if (CAN_SEE_OBJ(ch, i)) if (--(*number) == 0) return (i); return (NULL); }
struct obj_data *get_obj_in_list_vis(struct char_data *ch, char *name, struct obj_data *list) { struct obj_data *i; int j, number; char tmpname[MAX_INPUT_LENGTH]; char *tmp; strcpy(tmpname,name); tmp = tmpname; if(!(number = get_number(&tmp))) return(0); for (i = list, j = 1; i && (j <= number); i = i->next_content) if (isname(tmp, i->name)) if (CAN_SEE_OBJ(ch, i)) { if (j == number) return(i); j++; } return(0); }
int DamageItem(struct char_data *ch, struct obj_data *o) { int temp,i; if (!o) return 0; if (ROOM_FLAGGED(ch->in_room, ROOM_ARENA | ROOM_PEACEFUL)) return 0; temp = number(1, 2); if(GET_OBJ_COND(o) == 101){ return FALSE; } else{ for (i = 0; i < NUM_WEARS; i++) { if (GET_EQ(ch, i)) GET_AC(ch) += apply_ac(ch, i); } GET_OBJ_COND(o) -= temp; for (i = 0; i < NUM_WEARS; i++) { if (GET_EQ(ch, i)) GET_AC(ch) -= apply_ac(ch, i); } } save_char(ch, NOWHERE); sprintf(buf, "&G%s&g was &Gdamaged&g in the combat!&n\r\n", (CAN_SEE_OBJ(ch, o) ? CAP(o->short_description) : "Something")); send_to_char(buf, ch); if (GET_OBJ_COND(o) < 0) { GET_OBJ_COND(o) = 0; return TRUE; } return FALSE; }
struct obj_data *get_obj_in_list_vis(struct char_data * ch, char *name, struct obj_data * list) { struct obj_data *i; int j = 0, number; char tmpname[MAX_INPUT_LENGTH]; char *tmp = tmpname; strcpy(tmp, name); if (!(number = get_number(&tmp))) { number = 1; tmp = name; } for (i = list; i && (j <= number); i = i->next_content) if (isname(tmp, i->name)) if (CAN_SEE_OBJ(ch, i)) if (++j == number) return i; return NULL; }
int chalice(struct char_data *ch, int cmd, char *arg) { /* 222 is the normal chalice, 223 is chalice-on-altar */ struct obj_data *chalice; char buf1[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH]; static int chl = -1, achl = -1; if (chl < 1) { chl = real_object(222); achl = real_object(223); } switch(cmd) { case 10: /* get */ if (!(chalice = get_obj_in_list_num(chl, world[ch->in_room].contents)) && CAN_SEE_OBJ(ch, chalice)) if (!(chalice = get_obj_in_list_num(achl, world[ch->in_room].contents)) && CAN_SEE_OBJ(ch, chalice)) return(0); /* we found a chalice.. now try to get us */ do_get(ch, arg, cmd); /* if got the altar one, switch her */ if (chalice == get_obj_in_list_num(achl, ch->carrying)) { extract_obj(chalice); chalice = read_object(chl, VIRTUAL); obj_to_char(chalice, ch); } return(1); break; case 67: /* put */ if (!(chalice = get_obj_in_list_num(chl, ch->carrying))) return(0); argument_interpreter(arg, buf1, buf2); if (!str_cmp(buf1, "chalice") && !str_cmp(buf2, "altar")) { extract_obj(chalice); chalice = read_object(achl, VIRTUAL); obj_to_room(chalice, ch->in_room); send_to_char("Ok.\n\r", ch); } return(1); break; case 176: /* pray */ if (!(chalice = get_obj_in_list_num(achl, world[ch->in_room].contents))) return(0); do_action(ch, arg, cmd); /* pray */ send_to_char(CHAL_ACT, ch); extract_obj(chalice); act("$n is torn out of existence!", TRUE, ch, 0, 0, TO_ROOM); char_from_room(ch); char_to_room(ch, real_room(2500)); /* before the fiery gates */ do_look(ch, "", 15); return(1); break; default: return(0); break; } }
void show_char_to_char(struct char_data *i, struct char_data *ch, int mode) { char buffer[MAX_STRING_LENGTH]; int j, found, percent; struct obj_data *tmp_obj; if (mode == 0) { if (IS_AFFECTED(i, AFF_HIDE) || !CAN_SEE(ch,i)) { if (IS_AFFECTED(ch, AFF_SENSE_LIFE)) send_to_char("You sense a hidden life form in the room.\n\r", ch); return; } if (!(i->player.long_descr)||(GET_POS(i) != i->specials.default_pos)) { /* A player char or a mobile without long descr, or not in default pos. */ if (!IS_NPC(i)) { strcpy(buffer,GET_NAME(i)); strcat(buffer," "); strcat(buffer,GET_TITLE(i)); } else { strcpy(buffer, i->player.short_descr); CAP(buffer); } if ( IS_AFFECTED(i,AFF_INVISIBLE)) strcat(buffer," (invisible)"); switch(GET_POS(i)) { case POSITION_STUNNED : strcat(buffer," is lying here, stunned."); break; case POSITION_INCAP : strcat(buffer," is lying here, incapacitated."); break; case POSITION_MORTALLYW: strcat(buffer," is lying here, mortally wounded."); break; case POSITION_DEAD : strcat(buffer," is lying here, dead."); break; case POSITION_STANDING : strcat(buffer," is standing here."); break; case POSITION_SITTING : strcat(buffer," is sitting here."); break; case POSITION_RESTING : strcat(buffer," is resting here."); break; case POSITION_SLEEPING : strcat(buffer," is sleeping here."); break; case POSITION_FIGHTING : if (i->specials.fighting) { strcat(buffer," is here, fighting "); if (i->specials.fighting == ch) strcat(buffer," YOU!"); else { if (i->in_room == i->specials.fighting->in_room) if (IS_NPC(i->specials.fighting)) strcat(buffer, i->specials.fighting->player.short_descr); else strcat(buffer, GET_NAME(i->specials.fighting)); else strcat(buffer, "someone who has already left."); } } else /* NIL fighting pointer */ strcat(buffer," is here struggling with thin air."); break; default : strcat(buffer," is floating here."); break; } if (IS_AFFECTED(ch, AFF_DETECT_EVIL)) { if (IS_EVIL(i)) strcat(buffer, " (Red Aura)"); } strcat(buffer,"\n\r"); send_to_char(buffer, ch); } else /* npc with long */ { if (IS_AFFECTED(i,AFF_INVISIBLE)) strcpy(buffer,"*"); else *buffer = '\0'; if (IS_AFFECTED(ch, AFF_DETECT_EVIL)) { if (IS_EVIL(i)) strcat(buffer, " (Red Aura)"); } strcat(buffer, i->player.long_descr); send_to_char(buffer, ch); } if (IS_AFFECTED(i,AFF_SANCTUARY)) act("$n glows with a bright light!", FALSE, i, 0, ch, TO_VICT); } else if (mode == 1) { if (i->player.description) send_to_char(i->player.description, ch); else { act("You see nothing special about $m.", FALSE, i, 0, ch, TO_VICT); } /* Show a character to another */ if (GET_MAX_HIT(i) > 0) percent = (100*GET_HIT(i))/GET_MAX_HIT(i); else percent = -1; /* How could MAX_HIT be < 1?? */ if (IS_NPC(i)) strcpy(buffer, i->player.short_descr); else strcpy(buffer, GET_NAME(i)); if (percent >= 100) strcat(buffer, " is in an excellent condition.\n\r"); else if (percent >= 90) strcat(buffer, " has a few scratches.\n\r"); else if (percent >= 75) strcat(buffer, " has some small wounds and bruises.\n\r"); else if (percent >= 50) strcat(buffer, " has quite a few wounds.\n\r"); else if (percent >= 30) strcat(buffer, " has some big nasty wounds and scratches.\n\r"); else if (percent >= 15) strcat(buffer, " looks pretty hurt.\n\r"); else if (percent >= 0) strcat(buffer, " is in an awful condition.\n\r"); else strcat(buffer, " is bleeding awfully from big wounds.\n\r"); send_to_char(buffer, ch); found = FALSE; for (j=0; j< MAX_WEAR; j++) { if (i->equipment[j]) { if (CAN_SEE_OBJ(ch,i->equipment[j])) { found = TRUE; } } } if (found) { act("\n\r$n is using:", FALSE, i, 0, ch, TO_VICT); for (j=0; j< MAX_WEAR; j++) { if (i->equipment[j]) { if (CAN_SEE_OBJ(ch,i->equipment[j])) { send_to_char(where[j],ch); show_obj_to_char(i->equipment[j],ch,1); } } } } if ((GET_CLASS(ch) == CLASS_THIEF) && (ch != i)) { found = FALSE; send_to_char("\n\rYou attempt to peek at the inventory:\n\r", ch); for(tmp_obj = i->carrying; tmp_obj; tmp_obj = tmp_obj->next_content) { if (CAN_SEE_OBJ(ch, tmp_obj) && (number(0,20) < GET_LEVEL(ch))) { show_obj_to_char(tmp_obj, ch, 1); found = TRUE; } } if (!found) send_to_char("You can't see anything.\n\r", ch); } } else if (mode == 2) { /* Lists inventory */ act("$n is carrying:", FALSE, i, 0, ch, TO_VICT); list_obj_to_char(i->carrying,ch,1,TRUE); } }
void do_look(struct char_data *ch, char *argument, int cmd) { char buffer[MAX_STRING_LENGTH]; char arg1[MAX_STRING_LENGTH]; char arg2[MAX_STRING_LENGTH]; int keyword_no; int j, bits, temp; bool found; struct obj_data *tmp_object, *found_object; struct char_data *tmp_char; char *tmp_desc; static char *keywords[]= { "north", "east", "south", "west", "up", "down", "in", "at", "", /* Look at '' case */ "\n" }; if (!ch->desc) return; if (GET_POS(ch) < POSITION_SLEEPING) send_to_char("You can't see anything but stars!\n\r", ch); else if (GET_POS(ch) == POSITION_SLEEPING) send_to_char("You can't see anything, you're sleeping!\n\r", ch); else if ( IS_AFFECTED(ch, AFF_BLIND) ) send_to_char("You can't see a damn thing, you're blinded!\n\r", ch); else if ( IS_DARK(ch->in_room) ) send_to_char("It is pitch black...\n\r", ch); else { argument_split_2(argument,arg1,arg2); keyword_no = search_block(arg1, keywords, FALSE); /* Partiel Match */ if ((keyword_no == -1) && *arg1) { keyword_no = 7; strcpy(arg2, arg1); /* Let arg2 become the target object (arg1) */ } found = FALSE; tmp_object = 0; tmp_char = 0; tmp_desc = 0; switch(keyword_no) { /* look <dir> */ case 0 : case 1 : case 2 : case 3 : case 4 : case 5 : { if (EXIT(ch, keyword_no)) { if (EXIT(ch, keyword_no)->general_description) { send_to_char(EXIT(ch, keyword_no)-> general_description, ch); } else { send_to_char("You see nothing special.\n\r", ch); } if (IS_SET(EXIT(ch, keyword_no)->exit_info, EX_CLOSED) && (EXIT(ch, keyword_no)->keyword)) { sprintf(buffer, "The %s is closed.\n\r", fname(EXIT(ch, keyword_no)->keyword)); send_to_char(buffer, ch); } else { if (IS_SET(EXIT(ch, keyword_no)->exit_info, EX_ISDOOR) && EXIT(ch, keyword_no)->keyword) { sprintf(buffer, "The %s is open.\n\r", fname(EXIT(ch, keyword_no)->keyword)); send_to_char(buffer, ch); } } } else { send_to_char("Nothing special there...\n\r", ch); } } break; /* look 'in' */ case 6: { if (*arg2) { /* Item carried */ bits = generic_find(arg2, FIND_OBJ_INV | FIND_OBJ_ROOM | FIND_OBJ_EQUIP, ch, &tmp_char, &tmp_object); if (bits) { /* Found something */ if (GET_ITEM_TYPE(tmp_object)== ITEM_DRINKCON) { if (tmp_object->obj_flags.value[1] <= 0) { act("It is empty.", FALSE, ch, 0, 0, TO_CHAR); } else { temp=((tmp_object->obj_flags.value[1]*3)/tmp_object->obj_flags.value[0]); sprintf(buffer,"It's %sfull of a %s liquid.\n\r", fullness[temp],color_liquid[tmp_object->obj_flags.value[2]]); send_to_char(buffer, ch); } } else if (GET_ITEM_TYPE(tmp_object) == ITEM_CONTAINER) { if (!IS_SET(tmp_object->obj_flags.value[1],CONT_CLOSED)) { send_to_char(fname(tmp_object->name), ch); switch (bits) { case FIND_OBJ_INV : send_to_char(" (carried) : \n\r", ch); break; case FIND_OBJ_ROOM : send_to_char(" (here) : \n\r", ch); break; case FIND_OBJ_EQUIP : send_to_char(" (used) : \n\r", ch); break; } list_obj_to_char(tmp_object->contains, ch, 2, TRUE); } else send_to_char("It is closed.\n\r", ch); } else { send_to_char("That is not a container.\n\r", ch); } } else { /* wrong argument */ send_to_char("You do not see that item here.\n\r", ch); } } else { /* no argument */ send_to_char("Look in what?!\n\r", ch); } } break; /* look 'at' */ case 7 : { if (*arg2) { bits = generic_find(arg2, FIND_OBJ_INV | FIND_OBJ_ROOM | FIND_OBJ_EQUIP | FIND_CHAR_ROOM, ch, &tmp_char, &found_object); if (tmp_char) { show_char_to_char(tmp_char, ch, 1); if (ch != tmp_char) { act("$n looks at you.", TRUE, ch, 0, tmp_char, TO_VICT); act("$n looks at $N.", TRUE, ch, 0, tmp_char, TO_NOTVICT); } return; } /* Search for Extra Descriptions in room and items */ /* Extra description in room?? */ if (!found) { tmp_desc = find_ex_description(arg2, world[ch->in_room].ex_description); if (tmp_desc) { page_string(ch->desc, tmp_desc, 0); return; /* RETURN SINCE IT WAS A ROOM DESCRIPTION */ /* Old system was: found = TRUE; */ } } /* Search for extra descriptions in items */ /* Equipment Used */ if (!found) { for (j = 0; j< MAX_WEAR && !found; j++) { if (ch->equipment[j]) { if (CAN_SEE_OBJ(ch,ch->equipment[j])) { tmp_desc = find_ex_description(arg2, ch->equipment[j]->ex_description); if (tmp_desc) { page_string(ch->desc, tmp_desc, 1); found = TRUE; } } } } } /* In inventory */ if (!found) { for(tmp_object = ch->carrying; tmp_object && !found; tmp_object = tmp_object->next_content) { if CAN_SEE_OBJ(ch, tmp_object) { tmp_desc = find_ex_description(arg2, tmp_object->ex_description); if (tmp_desc) { page_string(ch->desc, tmp_desc, 1); found = TRUE; } } } } /* Object In room */ if (!found) { for(tmp_object = world[ch->in_room].contents; tmp_object && !found; tmp_object = tmp_object->next_content) { if CAN_SEE_OBJ(ch, tmp_object) { tmp_desc = find_ex_description(arg2, tmp_object->ex_description); if (tmp_desc) { page_string(ch->desc, tmp_desc, 1); found = TRUE; } } } } /* wrong argument */ if (bits) { /* If an object was found */ if (!found) show_obj_to_char(found_object, ch, 5); /* Show no-description */ else show_obj_to_char(found_object, ch, 6); /* Find hum, glow etc */ } else if (!found) { send_to_char("You do not see that here.\n\r", ch); } } else { /* no argument */ send_to_char("Look at what?\n\r", ch); } }
void mobile_activity(void) { register struct char_data *ch, *next_ch, *vict; struct char_data *min_vict = NULL; struct obj_data *obj, *next_obj, *best_obj, *cont; int door, found, max, where; int casual, max_abil=0, curr_abil, gold; memory_rec *names; room_rnum target_room; extern int no_specials; ACMD(do_get); for (ch = character_list; ch; ch = next_ch) { next_ch = ch->next; if (!IS_MOB(ch)) continue; //lance ripristina il master! if (IS_NPC(ch) && MOB_FLAGGED(ch, MOB_SAVE)) chkmaster(ch); // Examine call for special procedure if (MOB_FLAGGED(ch, MOB_SPEC) && !no_specials) { if (mob_index[GET_MOB_RNUM(ch)].func == NULL) { sprintf(buf, "SYSERR: %s (#%d): Attempting to call non-existing mob func", GET_NAME(ch), GET_MOB_VNUM(ch)); log(buf); REMOVE_BIT(MOB_FLAGS(ch), MOB_SPEC); } else { //(mob_index[GET_MOB_RNUM(ch)].func) (ch, ch, 0, ""); if ((mob_index[GET_MOB_RNUM(ch)].func) (ch, ch, 0, "")) continue; /* go to next char*/ } } // If the mob has no specproc, do the default actions if (FIGHTING(ch) || !AWAKE(ch)) continue; // Nuovo Scavenger (picking up objects) by Rusty if (MOB_FLAGGED(ch, MOB_SCAVENGER)) if (world[ch->in_room].contents && (number(0, 10) > 5)) { max = -1000; best_obj = NULL; for (obj = world[ch->in_room].contents; obj; obj = obj->next_content) if (CAN_GET_OBJ(ch, obj) && objlevel(obj) > max) { best_obj = obj; max = objlevel(obj); } if (best_obj != NULL) { obj_from_room(best_obj); obj_to_char(best_obj, ch); act("$n prende $p.", FALSE, ch, best_obj, 0, TO_ROOM); // Orione, tolta la procedura che fa indossare l'eq raccolto ai mob scavenger // Scavenger Plus:Mob wear the best object /* where=find_eq_pos(ch, best_obj, 0); if (CAN_WEAR(best_obj, ITEM_WEAR_WIELD)) where=WEAR_WIELD; if ( (where>0) && GET_EQ(ch,where)) { // se ce l'ha gia! if ((objlevel((ch)->equipment[where]))< objlevel(best_obj)) { obj_to_char((obj=unequip_char(ch, where)), ch); act("$n smette di usare $p.", FALSE, ch, obj, 0, TO_ROOM); } else { where = NUM_WEARS; // cioe' oggetto non indossabile } if (GET_LEVEL(ch)>=objlevel(best_obj)) { if (where>=0 && where <NUM_WEARS) { obj_from_char(best_obj); equip_char(ch,best_obj,where); wear_message(ch,best_obj,where); } } } */ } } //End ifif // Mob BodyGuard !? if (MOB_FLAGGED(ch, MOB_BGUARD) && (ch->master)) { if ( (FIGHTING(ch->master) && (npc_rescue(ch, ch->master) == FALSE)) || (ch->master && WHOKILLED(ch->master)) ) { act("$N Si schiera Prontamente al tuo fianco!", FALSE,ch->master, 0, ch, TO_CHAR); act("$n Si schiera prontamente al fianco di $N", FALSE, ch, 0, ch->master, TO_ROOM); if (WHOKILLED(ch->master)) hit(ch, WHOKILLED(ch->master), TYPE_UNDEFINED);/*in ogni caso assiste*/ else hit(ch, FIGHTING(ch->master), TYPE_UNDEFINED);/*in ogni caso assiste*/ } if (FIGHTING(ch)) { npc_rescue(ch, ch->master); if (WHOKILLED(ch->master)) hit(ch, WHOKILLED(ch->master), TYPE_UNDEFINED); /*in ogni caso assiste*/ continue; } } //MOB_THIEF if ( MOB_FLAGGED(ch, MOB_CRIMINAL) && (GET_POS(ch) == POS_RESTING) && IS_AFFECTED(ch, AFF_HIDE) && GET_HIT(ch) >= 2*GET_MAX_HIT(ch)/3) { appear(ch); GET_POS(ch)=POS_STANDING; } if ( MOB_FLAGGED(ch, MOB_CRIMINAL) && ( GET_POS(ch) == POS_STANDING) && ( (casual = number(0, 11)) < 6 ) ) { // 50% Rubare // cerca le vittime 1) Devono aver almeno 1 coin // 2) Deve aver una buona prob di farcela for (found=FALSE, min_vict = NULL, vict = world[ch->in_room].people; vict; vict = vict->next_in_room) { if (CAN_SEE(ch, vict) && (vict != ch)) { if ((min_vict == NULL) || (max_abil < 100)) { //se ha il 100% tanto vale fermarsi //Calcolo dell abilita:presa esattamente da D n'D curr_abil = MIN(90, (10*(GET_LEVEL(ch)) - 5*GET_LEVEL(vict))); curr_abil -= dex_app[GET_DEX(vict)].reaction; if (GET_POS(vict) < POS_STANDING) curr_abil += 200; // Se la vittima e' addormentata-stunned - incap o morta ovviamente // deruberai questa sicuramente if ( (curr_abil >= 40) && (GET_GOLD(vict) != 0) && (curr_abil > max_abil) ) { min_vict = vict; max_abil = curr_abil; found=TRUE; } } } } // Se ha trovato la vittima if (found == TRUE) { if ((casual = number(1, 100)) > max_abil) { if (!IS_NPC(min_vict)) act(" $n cerca di prendere dei soldi dal tuo Borsello", FALSE, ch, 0, min_vict, TO_CHAR); else { act("Oops...", FALSE, ch, 0, min_vict, TO_ROOM); act("$n cerca di rubare soldi a $N..Ma viene Scoperto! ", FALSE, ch, 0, min_vict, TO_ROOM); } //Beccato ... fa 2 tentativi di fuga if (((door = number(1, 7)) < NUM_OF_DIRS) && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) ) perform_move(ch,door,1,CAN_SHOW_ROOM); if ((door -= 1) < NUM_OF_DIRS && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) ) perform_move(ch,door,1,CAN_SHOW_ROOM); if ((door += 2) < NUM_OF_DIRS && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) ) perform_move(ch,door,1,CAN_SHOW_ROOM); if (IS_NPC(min_vict)) { act("$n Urla: $N e' uno sporco LADRO!!!!", FALSE, min_vict, 0, ch, TO_ROOM); hit(min_vict, ch, TYPE_UNDEFINED); } } // Il Bastardo ce la fa! else { if (GET_POS(min_vict) < 5) { GET_GOLD(ch) += GET_GOLD(min_vict); GET_GOLD(min_vict) = 0; //la ripulisce completamente } else { gold = number((GET_GOLD(min_vict) / 10), (GET_GOLD(min_vict) / 2)); //gold = MIN(5000, gold); if (gold > 0) { GET_GOLD(ch) += gold; GET_GOLD(min_vict) -= gold; if (GET_GOLD(min_vict) < 0) GET_GOLD(min_vict) = 0; } } // Dopo il furto si allontana if (((door = number(1, 6)) < NUM_OF_DIRS) && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) ) perform_move(ch,door,1,CAN_SHOW_ROOM); if ((door -=1) < NUM_OF_DIRS && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) ) perform_move(ch,door,1,CAN_SHOW_ROOM); if ((door +=2) < NUM_OF_DIRS && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) ) perform_move(ch,door,1,CAN_SHOW_ROOM); } } else { // Nessuna vittima appetibile:se ne va! if (((door = number(0, 6)) < NUM_OF_DIRS) && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) ) perform_move(ch, door, 1, CAN_SHOW_ROOM); } } // Mob Sciacalli indossano EQ if (MOB_FLAGGED(ch, MOB_NECRO) && !FIGHTING(ch) && AWAKE(ch)) if (world[ch->in_room].contents) { max = -1000; best_obj=NULL; for (cont = world[ch->in_room].contents;cont;cont = cont->next_content) if (GET_OBJ_TYPE(cont) == ITEM_CONTAINER) { for (obj = cont->contains; obj; obj = next_obj) { next_obj = obj->next_content; if (obj != NULL) { if (CAN_SEE_OBJ(ch, obj) && ( (max = objlevel(obj)) <= GET_LEVEL(ch)) ) { perform_get_from_container(ch, obj, cont, FIND_OBJ_INV); if (obj != NULL) { where = find_eq_pos(ch, obj, 0); if (CAN_WEAR(obj, ITEM_WEAR_HOLD)) where = WEAR_HOLD; if (GET_OBJ_TYPE(obj)==ITEM_LIGHT) where = WEAR_LIGHT; if (CAN_WEAR(obj, ITEM_WEAR_WIELD)) where = WEAR_WIELD; if (where < 0) { sprintf(buf,"SYSERR:pos < 0 ,in cont %s obj %d %s In room %d", cont->name, GET_OBJ_RNUM(obj), obj->name, IN_ROOM(ch)); log(buf); where = NUM_WEARS; } if (GET_EQ(ch, where) && where < NUM_WEARS) { if ((objlevel((ch)->equipment[where])) < objlevel(obj)) { obj_to_char((best_obj = unequip_char(ch, where)), ch); act("$n smette di usare $p.",FALSE, ch, best_obj, 0, TO_ROOM); } else where = NUM_WEARS; } if (where >= 0 && where < NUM_WEARS) { wear_message(ch, obj, where); obj_from_char(obj); equip_char(ch, obj, where); } } } } } } //End forif } //End ifif // Mob Movement if (HUNTING(ch)) hunt_victim(ch); else { if (MOB_FLAGGED(ch , MOB_SEARCHER)) {} else { if (ch->in_room != NOWHERE) { if (!IS_IN_WILD(ch)) { if ( !MOB_FLAGGED(ch, MOB_SENTINEL) && (GET_POS(ch) == POS_STANDING) && ( (door = number(0, 8)) < NUM_OF_DIRS) && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) && ( !MOB_FLAGGED(ch, MOB_STAY_ZONE) || (world[EXIT(ch, door)->to_room].zone == world[ch->in_room].zone))) { perform_move(ch, door, 1, CAN_SHOW_ROOM); } } else { // E' in wilderness if (MOB_FLAGGED(ch, MOB_WILDHUNT)) door = wild_mobhunter(ch); else door = number(0, 8); if (door >= 0 && door < NUM_OF_DIRS) target_room = wild_target_room(ch, door); else target_room = -1; if ( !MOB_FLAGGED(ch, MOB_SENTINEL) && (GET_POS(ch) == POS_STANDING) && (target_room != -1) && ( !MOB_FLAGGED(ch, MOB_STAY_ZONE) || (world[target_room].wild_rnum == world[ch->in_room].wild_rnum))) { perform_move(ch, door, 1, CAN_SHOW_ROOM); } } } } } // Aggressive Mobs if (MOB_FLAGGED(ch, MOB_AGGRESSIVE | MOB_AGGR_TO_ALIGN)) { found = FALSE; for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room) { if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE)) continue; if (number(0, 3) < 2) continue; // Simple simulate Random a Joke from Phantom ;P if (GET_ABIL (vict, ABIL_TRATTATIVA) >= EXPERT_LIV) continue; // I pg con trattativa ad esperto fanno pace con gli aggressivi (by Spini) if (controllo_volo(ch, vict)) continue; if (affected_by_spell (vict, SPELLSKILL, DISEASE_PESTE)) continue; if (MOB_FLAGGED(ch, MOB_AGGR_NO_PROP) && (MASTER_ID(ch)==GET_IDNUM(vict))) continue; if (MOB_FLAGGED(ch, MOB_AGGR_NO_CLAN) && (CLAN_ID(ch)==GET_CLAN(vict))) continue; if (MOB_FLAGGED(ch, MOB_AGGR_NO_AL_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == ALLIANCE)) continue; if (MOB_FLAGGED(ch, MOB_AGGR_NO_EN_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == WAR)) continue; if (MOB_FLAGGED(ch, MOB_AGGR_NO_PC_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == PEACE)) continue; if (MOB_FLAGGED(ch, MOB_AGGR_VAS_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == VASSALLO)) continue; if ( !MOB_FLAGGED(ch, MOB_AGGR_TO_ALIGN) || (MOB_FLAGGED(ch, MOB_AGGR_EVIL) && IS_EVIL(vict)) || (MOB_FLAGGED(ch, MOB_AGGR_NEUTRAL) && IS_NEUTRAL(vict)) || (MOB_FLAGGED(ch, MOB_AGGR_GOOD) && IS_GOOD(vict)) ) { if (GET_MOB_SPEC(ch)== thief) npc_backstab(ch,vict); else hit(ch, vict, TYPE_UNDEFINED); found = TRUE; } } } // Mob Memory if (MOB_FLAGGED(ch, MOB_MEMORY) && MEMORY(ch)) { found = FALSE; for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room) { if (!CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE)) continue; for (names = MEMORY(ch); names && !found; names = names->next) if (names->id == GET_IDNUM(vict)) { found = TRUE; act("$n esclama, 'Hey!! Tu sei il tipo che mi ha attaccato!!!'", FALSE, ch, 0, 0, TO_ROOM); hit(ch, vict, TYPE_UNDEFINED); } //End forif } } // Helper Mobs Paladino del bene if ( MOB_FLAGGED(ch, MOB_HELPER) && !MOB_FLAGGED(ch, MOB_CRIMINALHELPER) ) { found = FALSE; for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room) if ( ch != vict && IS_NPC(vict) && FIGHTING(vict) && !IS_NPC(FIGHTING(vict)) && ch != FIGHTING(vict) ) { if ( MOB_FLAGGED(vict, MOB_CRIMINAL) || ( (ch->master) && (FIGHTING(vict) == ch->master) ) ) { hit(ch, vict, TYPE_UNDEFINED); found = TRUE; } else { act("$n arriva in aiuto di $N!", FALSE, ch, 0, vict, TO_ROOM); hit(ch, FIGHTING(vict), TYPE_UNDEFINED); found = TRUE; } } //End forif } // Helper Mobs Servo del male if ( MOB_FLAGGED(ch, MOB_CRIMINALHELPER) && !MOB_FLAGGED(ch, MOB_HELPER) ) { found = FALSE; for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room) if ( ch != vict && IS_NPC(vict) && FIGHTING(vict) && !IS_NPC(FIGHTING(vict)) && ch != FIGHTING(vict) ) { if ( MOB_FLAGGED(vict, MOB_CRIMINAL) || ( (ch->master) && (vict == ch->master) ) ) { act("$n arriva in aiuto di $N!", FALSE, ch, 0, vict, TO_ROOM); hit(ch, FIGHTING(vict), TYPE_UNDEFINED); found = TRUE; } } //End forif } // Add new mobile actions here } // end for() }
void do_write (struct char_data *ch, char *argument, int cmd) { struct obj_data *paper = 0, *pen = 0; char papername[MAX_INPUT_LENGTH], penname[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH]; argument_interpreter (argument, papername, penname); if (!ch->desc) return; if (!*papername) { /* nothing was delivered */ send_to_char ("Write? with what? ON what? what are you trying to do??\n\r", ch); return; } if (*penname) { /* there were two arguments */ if (!(paper = get_obj_in_list_vis (ch, papername, ch->carrying))) { sprintf (buf, "You have no %s.\n\r", papername); send_to_char (buf, ch); return; } if (!(pen = get_obj_in_list_vis (ch, penname, ch->carrying))) { sprintf (buf, "You have no %s.\n\r", papername); send_to_char (buf, ch); return; } } else { /* there was one arg.let's see what we can find */ if (!(paper = get_obj_in_list_vis (ch, papername, ch->carrying))) { sprintf (buf, "There is no %s in your inventory.\n\r", papername); send_to_char (buf, ch); return; } if (paper->obj_flags.type_flag == ITEM_PEN) { /* oops, a pen.. */ pen = paper; paper = 0; } else if (paper->obj_flags.type_flag != ITEM_NOTE) { send_to_char ("That thing has nothing to do with writing.\n\r", ch); return; } /* one object was found. Now for the other one. */ if (!ch->equipment[HOLD]) { sprintf (buf, "You can't write with a %s alone.\n\r", papername); send_to_char (buf, ch); return; } if (!CAN_SEE_OBJ (ch, ch->equipment[HOLD])) { send_to_char ("The stuff in your hand is invisible! Yeech!!\n\r", ch); return; } if (pen) paper = ch->equipment[HOLD]; else pen = ch->equipment[HOLD]; } /* ok.. now let's see what kind of stuff we've found */ if (pen->obj_flags.type_flag != ITEM_PEN) { act ("$p is no good for writing with.", FALSE, ch, pen, 0, TO_CHAR); } else if (paper->obj_flags.type_flag != ITEM_NOTE) { act ("You can't write on $p.", FALSE, ch, paper, 0, TO_CHAR); } else if (paper->action_description) send_to_char ("There's something written on it already.\n\r", ch); else { /* we can write - hooray! */ send_to_char ("Ok.. go ahead and write.. end the note with a @.\n\r", ch); act ("$n begins to jot down a note.", TRUE, ch, 0, 0, TO_ROOM); ch->desc->str = &paper->action_description; ch->desc->max_str = MAX_NOTE_LENGTH; } }