/* * Lets the mobile load an object * * Syntax: mob oload [vnum] [level] {R} */ void do_mpoload(CHAR_DATA * ch, char *argument) { char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char arg3[MAX_INPUT_LENGTH]; OBJ_INDEX_DATA *pObjIndex; OBJ_DATA *obj; int level; bool fToroom = FALSE, fWear = FALSE; argument = one_argument(argument, arg1); argument = one_argument(argument, arg2); one_argument(argument, arg3); if (arg1[0] == '\0' || !is_number(arg1)) { bug("Mpoload - Bad syntax from vnum %d.", IS_NPC(ch) ? ch->pIndexData->vnum : 0); return; } if (arg2[0] == '\0') { level = get_trust(ch); } else { /* * New feature from Alander. */ if (!is_number(arg2)) { bug("Mpoload - Bad syntax from vnum %d.", IS_NPC(ch) ? ch->pIndexData->vnum : 0); return; } level = atoi(arg2); if (level < 0 || level > get_trust(ch)) { bug("Mpoload - Bad level from vnum %d.", IS_NPC(ch) ? ch->pIndexData->vnum : 0); return; } } /* * Added 3rd argument * omitted - load to mobile's inventory * 'R' - load to room * 'W' - load to mobile and force wear */ if (arg3[0] == 'R' || arg3[0] == 'r') fToroom = TRUE; else if (arg3[0] == 'W' || arg3[0] == 'w') fWear = TRUE; if ((pObjIndex = get_obj_index(atoi(arg1))) == NULL) { bug("Mpoload - Bad vnum arg from vnum %d.", IS_NPC(ch) ? ch->pIndexData->vnum : 0); return; } obj = create_object(pObjIndex, level); if ((fWear || !fToroom) && CAN_WEAR(obj, ITEM_TAKE)) { obj_to_char(obj, ch); if (fWear) wear_obj(ch, obj, TRUE); } else { obj_to_room(obj, ch->in_room); } return; }
//to calkowita obsluga ladowania artefactow //sprawdzanie czy mozna + ladowanie + ew. zakladanie void load_artefact( ROOM_INDEX_DATA *room, OBJ_DATA *obj, CHAR_DATA *ch ) { char buf[ MAX_INPUT_LENGTH ]; ARTEFACT_DATA *atmp = NULL; ARTEFACT_LOADER *ltmp = NULL; OBJ_DATA *loaded_obj; int type; int vnum = 0; if ( room != NULL ) { vnum = room->vnum;type = 0; } else if ( obj != NULL ) { vnum = obj->pIndexData->vnum;type = 1; } else if ( ch != NULL ) { vnum = ch->pIndexData->vnum;type = 2; } else return ; //gdzie for ( atmp = artefact_system;atmp;atmp = atmp->next ) { for ( ltmp = atmp->loader;ltmp;ltmp = ltmp->next ) { //jesli nie zgadza sie typ (np: obj=obj) i vnumy to wychodzimy if (!( ltmp->type == type && ltmp->vnum == vnum )) { continue; } //jesli room to sprawdzanie czy juz tam nie ma if (( type == 0 ) && ( count_obj_list( get_obj_index( atmp->avnum ), room->contents ) > 0 ) ) { sprintf( buf, "NIE LADUJE do room a (juz jest): %d do %d", atmp->avnum, room->vnum ); wiznet( buf, NULL, NULL, WIZ_ARTEFACTLOAD, 0, 39 ); continue; } //aktualizacja ilosci atmp->count = artefact_new_count( atmp ); //tera prawd. jesli mniejsze to nastepny loader if ( number_range( 1, ltmp->probup ) > ltmp->probdown ) { continue; } //juz max artefaktu, nastepny loader if ( atmp->count >= atmp->max_count ) continue; //ladujemy bo wsie warunki spelnione loaded_obj = create_object ( get_obj_index( atmp->avnum ), FALSE ); create_artefact( loaded_obj->pIndexData->vnum ); //dokad ladujemy if ( type == 0 ) //do rooma { sprintf( buf, "Artefakt [%d] za³adowany do rooma [%d].", loaded_obj->pIndexData->vnum, room->vnum ); obj_to_room( loaded_obj, room ); wiznet( buf, NULL, NULL, WIZ_ARTEFACTLOAD, 0, 39 ); } else if ( type == 1 ) //do srodka objectu { sprintf( buf, "Artefakt [%d] za³adowany do wnêtrza obiektu [%d],", loaded_obj->pIndexData->vnum, obj->pIndexData->vnum ); obj_to_obj( loaded_obj, obj ); wiznet( buf, NULL, NULL, WIZ_ARTEFACTLOAD, 0, 39 ); //okresla room if ( obj->in_room ) sprintf( buf, " w roomie [%d]", obj->in_room->vnum ); if ( obj->carried_by ) sprintf( buf, " na mobie [%d] w roomie [%d]", obj->carried_by->pIndexData->vnum, obj->carried_by->in_room->vnum ); wiznet( buf, NULL, NULL, WIZ_ARTEFACTLOAD, 0, 39 ); } else if ( type == 2 ) //mobowi { sprintf( buf, "Artefakt [%d] za³adowany mobowi [%d] roomie [%d].", loaded_obj->pIndexData->vnum, ch->pIndexData->vnum, ch->in_room->vnum ); obj_to_char( loaded_obj, ch ); wiznet( buf, NULL, NULL, WIZ_ARTEFACTLOAD, 0, 39 ); //+zakladanie jesli moze (nie sprzedawca) if ( ch->pIndexData->pShop == NULL && loaded_obj->wear_loc == WEAR_NONE && can_see_obj( ch, loaded_obj ) ) { if ( loaded_obj->item_type == ITEM_WEAPON ) { if ( !get_eq_char( ch, WEAR_WIELD ) ) wield_weapon( ch, loaded_obj, TRUE ); } else wear_obj( ch, loaded_obj, FALSE ); } } //end dokad // } //end typ=typ, vnum=vnum } //end po loaderach } //end po artefaktach }
bool spec_wanderer( CHAR_DATA *ch ) { OBJ_DATA *trash; OBJ_DATA *trash_next; OBJ_DATA *obj2; ROOM_INDEX_DATA *was_in_room; EXIT_DATA *pexit = NULL; CHAR_DATA *vch; int door; int chance=50; bool found = FALSE; /* Valid direction */ bool thrown = FALSE;/* Whether to be thrown or not */ bool noexit = TRUE; /* Assume there is no valid exits */ was_in_room = ch->in_room; if ( !IS_AWAKE(ch) ) return FALSE; if((pexit = ch->in_room->first_exit) !=NULL) noexit=FALSE; if(chance>number_percent()){ /**** * Look for objects on the ground and pick it up ****/ for ( trash = ch->in_room->first_content; trash; trash = trash_next ) { trash_next = trash->next_content; if ( !IS_SET( trash->wear_flags, ITEM_TAKE ) || IS_OBJ_STAT( trash, ITEM_BURIED ) ) continue; if ( trash->item_type == ITEM_WEAPON || trash->item_type == ITEM_ARMOR || trash->item_type == ITEM_LIGHT ) { separate_obj( trash ); /* So there is no 'sword <6>' gets only one object off ground */ act( AT_ACTION, "$n leans over and gets $p.", ch, trash, NULL, TO_ROOM ); obj_from_room( trash ); trash = obj_to_char( trash, ch ); /***** * If object is too high a level throw it away. *****/ if ( ch->level < trash->level ) { act( AT_ACTION, "$n tries to use $p, but is too inexperienced.",ch, trash, NULL, TO_ROOM ); thrown = TRUE; } /***** * Wear the object if it is not to be thrown. The FALSE is passed * so that the mob wont remove a piece of armor already there * if it is not worn it is assumed that they can't use it or * they already are wearing something. *****/ if(!thrown) wear_obj( ch, trash, FALSE, -1 ); /***** * Look for an object in the inventory that is not being worn * then throw it away... *****/ found=FALSE; if(!thrown) for ( obj2 = ch->first_carrying; obj2; obj2 = obj2->next_content ){ if (obj2->wear_loc == WEAR_NONE){ do_say(ch,"Hmm, I can't use this."); trash=obj2; thrown=TRUE; } } /***** * Ugly bit of code.. * Checks if the object is to be thrown & there is a valid exit, * randomly pick a direction to throw it, and check to make sure no other * spec_wanderer mobs are in that room. *****/ if(thrown && !noexit) while(!found && !noexit){ door=number_door(); if((pexit = get_exit(ch->in_room,door) ) != NULL && pexit->to_room && !IS_SET(pexit->exit_info, EX_CLOSED) && !xIS_SET(pexit->to_room->room_flags, ROOM_NODROP)){ if( (vch = pexit->to_room->first_person) !=NULL) for( vch = pexit->to_room->first_person; vch; vch = vch->next_in_room){ if (!str_cmp(lookup_spec(vch->spec_fun), "spec_wanderer")){ noexit = TRUE; /*act( AT_CYAN,"$n spec_wanderer inroom $T", ch, NULL,dir_name[pexit->vdir], TO_ROOM);*/ return FALSE; } } found = TRUE; } } if (!noexit && thrown){ /*if (trash->value*/ set_cur_obj( trash ); if( damage_obj( trash ) != rOBJ_SCRAPPED){ separate_obj(trash); act( AT_ACTION, "$n growls and throws $p $T.", ch, trash, dir_name[pexit->vdir], TO_ROOM ); obj_from_char( trash ); obj_to_room( trash, pexit->to_room ); char_from_room(ch); char_to_room(ch, pexit->to_room); act( AT_CYAN,"$p thrown by $n lands in the room.",ch, trash, ch, TO_ROOM); char_from_room(ch); char_to_room(ch, was_in_room); } else{ do_say(ch,"This thing is junk!"); act( AT_ACTION, "$n growls and breaks $p.",ch, trash, NULL, TO_ROOM); } return TRUE; } return TRUE; } } /* get next obj */ return FALSE; /* No objects :< */ } return FALSE; }
/* * Hit one guy with a projectile. * Handles use of missile weapons (wield = missile weapon) * or thrown items/weapons */ ch_ret projectile_hit( char_data * ch, char_data * victim, obj_data * wield, obj_data * projectile, short dist ) { int vic_ac, thac0, plusris, diceroll, prof_bonus, prof_gsn = -1, proj_bonus, dt, pchance; double dam = 0; ch_ret retcode; if( !projectile ) return rNONE; if( projectile->item_type == ITEM_PROJECTILE || projectile->item_type == ITEM_WEAPON ) { dt = TYPE_HIT + projectile->value[3]; if( wield ) proj_bonus = number_range( wield->value[1], wield->value[2] ); else proj_bonus = 0; } else { dt = TYPE_UNDEFINED; proj_bonus = 0; } /* * Can't beat a dead char! */ if( victim->position == POS_DEAD || victim->char_died( ) ) { projectile->extract( ); return rVICT_DIED; } if( wield ) prof_bonus = weapon_prof_bonus_check( ch, wield, prof_gsn ); else prof_bonus = 0; if( dt == TYPE_UNDEFINED ) { dt = TYPE_HIT; if( wield && wield->item_type == ITEM_MISSILE_WEAPON ) dt += wield->value[3]; } thac0 = calc_thac0( ch, victim, dist ); vic_ac = umax( -19, ( victim->GET_AC( ) / 10 ) ); /* * if you can't see what's coming... */ if( !victim->can_see_obj( projectile, false ) ) vic_ac += 1; if( !ch->can_see( victim, false ) ) vic_ac -= 4; /* * Weapon proficiency bonus */ vic_ac += prof_bonus; /* * The moment of excitement! */ while( ( diceroll = number_bits( 5 ) ) >= 20 ) ; if( diceroll == 0 || ( diceroll != 19 && diceroll < thac0 - vic_ac ) ) { /* * Miss. */ if( prof_gsn != -1 ) ch->learn_from_failure( prof_gsn ); /* * Do something with the projectile */ if( number_percent( ) < 50 ) projectile->extract( ); else { if( projectile->carried_by ) projectile->from_char( ); projectile->to_room( victim->in_room, victim ); } damage( ch, victim, 0, dt ); return rNONE; } /* * Hit. * Calc damage. */ pchance = number_range( 1, 10 ); switch ( pchance ) { case 1: case 2: case 3: /* Hit in the arm */ dam = number_range( projectile->value[1], projectile->value[2] ) + proj_bonus; break; case 4: case 5: case 6: /* Hit in the leg */ dam = number_range( ( 2 * projectile->value[1] ), ( 2 * projectile->value[2] ) ) + proj_bonus; break; default: case 7: case 8: case 9: case 10: /* Hit in the chest */ dam = number_range( ( 3 * projectile->value[1] ), ( 3 * projectile->value[2] ) ) + proj_bonus; break; } /* * Bonuses. */ dam += ch->GET_DAMROLL( ); if( prof_bonus ) dam += prof_bonus / 4; /* * Calculate Damage Modifiers from Victim's Fighting Style */ if( victim->position == POS_BERSERK ) dam = 1.2 * dam; else if( victim->position == POS_AGGRESSIVE ) dam = 1.1 * dam; else if( victim->position == POS_DEFENSIVE ) dam = .85 * dam; else if( victim->position == POS_EVASIVE ) dam = .8 * dam; if( !ch->isnpc( ) && ch->pcdata->learned[gsn_enhanced_damage] > 0 && number_percent( ) < ch->pcdata->learned[gsn_enhanced_damage] ) dam += ( int )( dam * ch->LEARNED( gsn_enhanced_damage ) / 120 ); else ch->learn_from_failure( gsn_enhanced_damage ); if( !victim->IS_AWAKE( ) ) dam *= 2; if( dam <= 0 ) dam = 1; plusris = 0; if( projectile->extra_flags.test( ITEM_MAGIC ) ) dam = ris_damage( victim, dam, RIS_MAGIC ); else dam = ris_damage( victim, dam, RIS_NONMAGIC ); /* * Handle PLUS1 - PLUS6 ris bits vs. weapon hitroll -Thoric */ if( wield ) plusris = wield->hitroll( ); /* * check for RIS_PLUSx - Thoric */ if( dam ) { int x, res, imm, sus, mod; if( plusris ) plusris = RIS_PLUS1 << UMIN( plusris, 7 ); /* * initialize values to handle a zero plusris */ imm = res = -1; sus = 1; /* * find high ris *//* * FIXME: Absorb handling needs to be included */ for( x = RIS_PLUS1; x <= RIS_PLUS6; ++x ) { if( victim->has_immune( x ) ) imm = x; if( victim->has_resist( x ) ) res = x; if( victim->has_suscep( x ) ) sus = x; } mod = 10; if( imm >= plusris ) mod -= 10; if( res >= plusris ) mod -= 2; if( sus <= plusris ) mod += 2; /* * check if immune */ if( mod <= 0 ) dam = -1; if( mod != 10 ) dam = ( dam * mod ) / 10; } /* * immune to damage */ if( dam == -1 ) { if( dt >= 0 && dt < num_skills ) { skill_type *skill = skill_table[dt]; bool found = false; if( skill->imm_char && skill->imm_char[0] != '\0' ) { act( AT_HIT, skill->imm_char, ch, nullptr, victim, TO_CHAR ); found = true; } if( skill->imm_vict && skill->imm_vict[0] != '\0' ) { act( AT_HITME, skill->imm_vict, ch, nullptr, victim, TO_VICT ); found = true; } if( skill->imm_room && skill->imm_room[0] != '\0' ) { act( AT_ACTION, skill->imm_room, ch, nullptr, victim, TO_NOTVICT ); found = true; } if( found ) { if( number_percent( ) < 50 ) projectile->extract( ); else { if( projectile->carried_by ) projectile->from_char( ); projectile->to_room( victim->in_room, victim ); } return rNONE; } } dam = 0; } if( ( retcode = damage( ch, victim, dam, dt ) ) != rNONE ) { if( projectile->value[5] == PROJ_STONE ) projectile->extract( ); else { if( victim->char_died( ) ) { projectile->extract( ); return rVICT_DIED; } projectile->from_char( ); projectile->to_char( victim ); projectile->extra_flags.set( ITEM_LODGED ); switch ( pchance ) { case 1: case 2: case 3: /* Hit in the arm */ projectile->wear_flags.set( ITEM_LODGE_ARM ); wear_obj( victim, projectile, true, get_wflag( "lodge_arm" ) ); break; case 4: case 5: case 6: /* Hit in the leg */ projectile->wear_flags.set( ITEM_LODGE_LEG ); wear_obj( victim, projectile, true, get_wflag( "lodge_leg" ) ); break; default: case 7: case 8: case 9: case 10: /* Hit in the chest */ projectile->wear_flags.set( ITEM_LODGE_RIB ); wear_obj( victim, projectile, true, get_wflag( "lodge_rib" ) ); break; } } return retcode; } if( ch->char_died( ) ) { projectile->extract( ); return rCHAR_DIED; } if( victim->char_died( ) ) { projectile->extract( ); return rVICT_DIED; } retcode = rNONE; if( dam == 0 ) { if( number_percent( ) < 50 ) projectile->extract( ); else { if( projectile->carried_by ) projectile->from_char( ); projectile->to_room( victim->in_room, victim ); } return retcode; } /* * weapon spells -Thoric */ if( wield && !victim->has_immune( RIS_MAGIC ) && !victim->in_room->flags.test( ROOM_NO_MAGIC ) ) { list < affect_data * >::iterator paf; for( paf = wield->pIndexData->affects.begin( ); paf != wield->pIndexData->affects.end( ); ++paf ) { affect_data *af = *paf; if( af->location == APPLY_WEAPONSPELL && IS_VALID_SN( af->modifier ) && skill_table[af->modifier]->spell_fun ) retcode = ( *skill_table[af->modifier]->spell_fun ) ( af->modifier, 7, ch, victim ); } if( retcode != rNONE || ch->char_died( ) || victim->char_died( ) ) { projectile->extract( ); return retcode; } for( paf = wield->affects.begin( ); paf != wield->affects.end( ); ++paf ) { affect_data *af = *paf; if( af->location == APPLY_WEAPONSPELL && IS_VALID_SN( af->modifier ) && skill_table[af->modifier]->spell_fun ) retcode = ( *skill_table[af->modifier]->spell_fun ) ( af->modifier, 7, ch, victim ); } if( retcode != rNONE || ch->char_died( ) || victim->char_died( ) ) { projectile->extract( ); return retcode; } } projectile->extract( ); return retcode; }