void hunt_victim( CHAR_DATA *ch ) { CHAR_DATA *tmp; int dir,chance; bool found; if ( !ch || !ch->hunting ) { return; } /* * Make sure the victim still exists. */ for ( found = FALSE, tmp = char_list; tmp && !found; tmp = tmp->next ) { if ( ch->hunting == tmp ) { found = TRUE; } } if ( !can_move( ch) || !found || !can_see( ch, ch->hunting ) ) { stop_hunting( ch ); return; } if ( ch->in_room == ch->hunting->in_room ) { if ( ch->fighting ) return; found_prey( ch, ch->hunting ); return; } if ( !IS_NPC ( ch ) ) { WAIT_STATE( ch, skill_table[gsn_track].beats ); } dir = find_path( ch->in_room->vnum, ch->hunting->in_room->vnum, ch, -40000, TRUE ); if ( dir < 0 || dir >= MAX_DIR ) { stop_hunting( ch ); return; } /* * Give a random direction if the mob misses the die roll. * * 20% for PC * 2% for NPC */ chance = IS_NPC ( ch ) ? 2 : 20; if ( number_percent( ) < chance + 1 ) { do { dir = number_door( ); } while ( !( ch->in_room->exit[dir] ) || !( ch->in_room->exit[dir]->u1.to_room ) ); } if ( IS_SET(ch->in_room->exit[dir]->exit_info, EX_SECRET) && !IS_SET(ch->in_room->exit[dir]->exit_info, EX_HIDDEN) && IS_AFFECTED(ch, AFF_DETECT_HIDDEN) ) { // do_secret(ch, (char *)dir_name[dir]); return; } if ( IS_SET( ch->in_room->exit[dir]->exit_info, EX_CLOSED ) ) { do_open( ch, (char *) dir_name[dir] ); return; } if( IS_SET(sector_table[ch->in_room->exit[dir]->u1.to_room->sector_type].flag, SECT_UNDERWATER) || IS_SET(ch->in_room->exit[dir]->exit_info, EX_NO_MOB) || EXT_IS_SET(ch->in_room->exit[dir]->u1.to_room->room_flags, ROOM_NO_MOB) || ( EXT_IS_SET(ch->act, ACT_STAY_AREA) && ch->in_room->exit[dir]->u1.to_room->area != ch->in_room->area ) || ( EXT_IS_SET(ch->act, ACT_STAY_SECTOR) && ch->in_room->exit[dir]->u1.to_room->sector_type != ch->in_room->sector_type ) || ( EXT_IS_SET(ch->act, ACT_OUTDOORS) && EXT_IS_SET(ch->in_room->exit[dir]->u1.to_room->room_flags,ROOM_INDOORS)) || ( EXT_IS_SET(ch->act, ACT_INDOORS) && EXT_IS_SET(ch->in_room->exit[dir]->u1.to_room->room_flags,ROOM_INDOORS))) return; move_char( ch, dir, FALSE, NULL ); if ( !ch->hunting ) { if ( !ch->in_room ) { char buf [ MAX_STRING_LENGTH ]; sprintf( buf, "Hunt_victim: no ch->in_room! Mob #%d, name: %s. Placing mob in limbo (char_to_room).", ch->pIndexData->vnum, ch->name ); bug( buf, 0 ); char_to_room( ch, get_room_index( ROOM_VNUM_LIMBO ) ); return; } return; } if ( ch->in_room == ch->hunting->in_room ) found_prey( ch, ch->hunting ); return; }
void hunt_victim( CHAR_DATA * ch ) { bool found; CHAR_DATA *tmp; EXIT_DATA *pexit; short ret; if( !ch || !ch->hunting || ch->position < 5 ) return; /* * make sure the char still exists */ for( found = FALSE, tmp = first_char; tmp && !found; tmp = tmp->next ) if( ch->hunting->who == tmp ) found = TRUE; if( !found ) { do_say( ch, "Damn! My prey is gone!!" ); stop_hunting( ch ); return; } if( ch->in_room == ch->hunting->who->in_room ) { if( ch->fighting ) return; found_prey( ch, ch->hunting->who ); return; } ret = find_first_step( ch->in_room, ch->hunting->who->in_room, 500 + ch->level * 25 ); if( ret < 0 ) { do_say( ch, "Damn! Lost my prey!" ); stop_hunting( ch ); return; } else { if( ( pexit = get_exit( ch->in_room, ret ) ) == NULL ) { bug( "%s", "Hunt_victim: lost exit?" ); return; } move_char( ch, pexit, FALSE ); /* * Crash bug fix by Shaddai */ if( char_died( ch ) ) return; if( !ch->hunting ) { if( !ch->in_room ) { bug( "Hunt_victim: no ch->in_room! Mob #%d, name: %s. Placing mob in limbo.", ch->pIndexData->vnum, ch->name ); char_to_room( ch, get_room_index( ROOM_VNUM_LIMBO ) ); return; } do_say( ch, "Damn! Lost my prey!" ); return; } if( ch->in_room == ch->hunting->who->in_room ) found_prey( ch, ch->hunting->who ); else { CHAR_DATA *vch; /* * perform a ranged attack if possible */ /* * Changed who to name as scan_for_victim expects the name and * * Not the char struct. --Shaddai */ if( ( vch = scan_for_victim( ch, pexit, ch->hunting->name ) ) != NULL ) { if( !mob_fire( ch, ch->hunting->who->name ) ) { /* * ranged spell attacks go here */ } } } return; } }
void hunt_victim( CHAR_DATA *ch ) { CHAR_DATA *tmp; int dir; bool found; if ( !ch || ch->deleted || !ch->hunting ) return; /* * Make sure the victim still exists. */ found = FALSE; for ( tmp = char_list; tmp; tmp = tmp->next ) if ( ch->hunting->who == tmp ) { found = TRUE; break; } if ( !found ) { do_say( ch, "Damn! My prey is gone!!" ); stop_hunting( ch ); return; } if ( ch->in_room == ch->hunting->who->in_room ) { if ( ch->fighting ) return; found_prey( ch, ch->hunting->who ); return; } /* * Give a random direction if the mob misses the die roll. */ if ( number_percent( ) > 75 ) /* @ 25% */ { do { dir = number_door( ); } while ( !( ch->in_room->exit[dir] ) || !( ch->in_room->exit[dir]->to_room ) ); } else { dir = find_path( ch->in_room, ch->hunting->who->in_room, 500 + ch->level * 25 ); if ( dir < 0 ) { act( "$n says 'Damn! Lost $M!'", ch, NULL, ch->hunting->who, TO_ROOM ); stop_hunting( ch ); return; } } { EXIT_DATA *pexit; pexit = ch->in_room->exit[dir]; if ( IS_SET( pexit->to_room->room_flags, ROOM_NO_MOB ) || ( xIS_SET( ch->act, ACT_STAY_AREA ) && pexit->to_room->area != ch->in_room->area ) ) { stop_hunting( ch ); return; } if ( IS_SET( pexit->exit_info, EX_CLOSED ) ) { do_open( ch, dir_name[dir] ); return; } } move_char( ch, dir ); if ( ch->deleted ) { return; } if ( !ch->hunting ) { if ( !ch->in_room ) { char buf [ MAX_STRING_LENGTH ]; sprintf( buf, "Hunt_victim: no ch->in_room! Mob #%d, name: %s. Placing mob in limbo.", ch->pIndexData->vnum, ch->name ); bug( buf, 0 ); char_to_room( ch, get_room_index( ROOM_VNUM_LIMBO ) ); return; } do_say( ch, "Damn! Lost my prey!" ); return; } if ( ch->in_room == ch->hunting->who->in_room ) found_prey( ch, ch->hunting->who ); return; }