/* Wersja wykonywana przy chodzeniu */ void auto_hunt( CHAR_DATA *ch ) { char buf[ MAX_STRING_LENGTH ]; CHAR_DATA *victim; int direction; bool fArea; if ( IS_NPC( ch ) ) /* moby maja wlasna metode polowania */ return; victim = ch->hunting; if ( !victim ) return; if ( !can_see( ch, victim ) ) { /* Vigud 26.7.2010 */ /* act( ZM_ZAWSZE, "Nie mo`zesz st`ad znale`x`c drogi do $!. Przestajesz polowa`c na $#.", ch, NULL, victim, TO_CHAR ); */ sprintf( buf, "Nie mo`zesz st`ad znale`x`c drogi do %s. Przestajesz polowa`c na %s.\n\r", victim->dopelniacz, victim->biernik ); STC( buf, ch ); wywal_zwod( &victim->zwod_hunting, ch ); ch->hunting = NULL; return; } if ( ch->in_room == victim->in_room ) { act( ZM_ZAWSZE, "{Y$N jest tutaj!{x", ch, NULL, victim, TO_CHAR ); wywal_zwod( &victim->zwod_hunting, ch ); ch->hunting = NULL; return; } if ( IS_SET( ch->in_room->room_flags, ROOM_NO_HUNT ) ) { send_to_char( "Nie mo`zesz tu znale`x`c niczyich `slad`ow.\n\r", ch ); wywal_zwod( &victim->zwod_hunting, ch ); ch->hunting = NULL; return; } /* only imps can hunt to different areas */ fArea = ( skill_get_trust( ch ) < 106 ); /* * Deduct some movement. */ if ( ch->move > 2 ) ch->move -= 3; else { ASTC( "Jeste`s zbyt wyczerpan$y, aby szuka`c `slad`ow!", ch ); return; } act( ZM_WZROK | ZM_WID_CHAR, "$n szuka `slad`ow na ziemi.", ch, NULL, NULL, TO_ROOM ); WAIT_STATE( ch, 3 ); direction = find_path( ch->in_room, victim->in_room, 40000, fArea, TRUE ); if ( direction == -1 ) { /* Vigud 26.7.2010 */ /* act( ZM_ZAWSZE, "Nie mo`zesz st`ad znale`x`c drogi do $!. Przestajesz polowa`c na $#.", ch, NULL, victim, TO_CHAR ); */ sprintf( buf, "Nie mo`zesz st`ad znale`x`c drogi do %s. Przestajesz polowa`c na %s.\n\r", victim->dopelniacz, victim->biernik ); STC( buf, ch ); wywal_zwod( &victim->zwod_hunting, ch ); ch->hunting = NULL; return; } if ( direction < 0 || direction > 9 ) { send_to_char( "Co`s tu jest nie tak.\n\r", ch ); wywal_zwod( &victim->zwod_hunting, ch ); ch->hunting = NULL; return; } /* * Give a random direction if the player misses the die roll. */ if ( ( IS_NPC( ch ) && number_percent( ) < 25 ) /* NPC @ 25% */ || ( !IS_NPC( ch ) && number_percent( ) > /* PC @ norm */ ch->pcdata->learned[ gsn_hunt ] ) ) { do { direction = number_door( ); } while ( !ch->in_room->exit[ direction ] || !ch->in_room->exit[ direction ]->to_room ); } /* * Display the results of the search. */ sprintf( buf, "{YDroga do $! prowadzi na %s.{x", kierunki[ direction ].biernik ); act( ZM_ZAWSZE, buf, ch, NULL, victim, TO_CHAR ); return; }
void writfl(long wrtnum) { int bytes; long todo, count; uint8_t *p, *q, thisch; short tabfnd, spacnt, chrpos; int inindent; /* Inside indenting whitespace */ /* * Initialise */ count = 0; /* No lines written yet */ todo = wrtnum; /* Max # to write */ q = fbuf; /* 1st char goes here */ unused = Q_BUFSIZ; /* Room for this many in file fbuf */ fscode = 0; /* * Main loop on lines */ for (; todo > 0; todo--) { if (!rdlin(curr, false)) { fprintf(stderr, "End of file reached:- %ld lines written\r\n", count); break; } count++; p = curr->bdata; /* Next char from here */ bytes = curr->bchars; /* Bytes in this line */ /* * Strip trailing spaces (usually)... */ if (!(fmode & 020 || binary)) while (bytes > 0) { if (curr->bdata[bytes - 1] != SPACE) break; bytes--; } spacnt = 0; /* Not pending any spaces */ tabfnd = 0; /* Not seen a real tab yet */ chrpos = 0; /* At line start */ /* In putative w/s at line start, if we care */ inindent = fmode & 040000; /* * Inner loop for this line */ for (; bytes > 0; bytes--) { thisch = *p++; /* Get editor char */ /* * Compress spaces to tabs if requested */ if (!binary && (fmode & 010 || fmode & inindent) && !tabfnd) { /* If on 8-char bdry & have spaces */ if (!(chrpos % tabsiz) && spacnt) { if (spacnt == 1) STC(SPACE); else STC('\t'); spacnt = 0; } /* if(!(chrpos%tabsiz)&&spacnt) */ chrpos++; /* Track pos'n in line */ if (thisch == '\t') tabfnd = 1; if (thisch == SPACE) /* Always increase space count, even if zero previously... */ { spacnt++; continue; /* for(;bytes>0;bytes--) */ } /* if(thisch==SPACE) */ else if (inindent) inindent = 0; for (; spacnt > 0; spacnt--) STC(SPACE); /* Flush any spaces */ } /* if (!binary && ... */ STC(thisch); /* O/p the char */ } /* for(; bytes > 0; bytes--) */ /* * Finish off line */ if (!binary) { if (spacnt) { if (!(chrpos % tabsiz)) { if (spacnt == 1) STC(SPACE); else STC('\t'); } /* if(!(chrpos%tabsiz)) */ else for (; spacnt > 0; spacnt--) STC(SPACE); } /* if(spacnt) */ if (fmode & 2) STC('\r'); /* If DOS o/p wanted */ STC('\n'); } /* if(!binary) */ } /* for(;todo>0;todo--) */ /* * All requested lines read from Workfile. Write out any partial file * buffer and close the file. Then we are finished... */ if (unused != Q_BUFSIZ) /* If any chars in buffer */ if (do_write() < 0) errlbl: fscode = errno; if (fscode) fprintf(stderr, "%s. fd %d (write)\r\n", strerror(fscode), funit); SYSCALL(bytes, close(funit)); if (bytes == -1) fprintf(stderr, "%s. fd %d (close)\r\n", strerror(errno), funit); return; }
void do_hunt( CHAR_DATA *ch, char *argument ) { char buf[ MAX_STRING_LENGTH ]; char arg[ MAX_STRING_LENGTH ]; CHAR_DATA *victim; int direction; bool fArea; bool uzycie; one_argument( argument, arg ); if ( ch->hunting ) { wywal_zwod( &ch->hunting->zwod_hunting, ch ); ch->hunting = NULL; } if ( arg[ 0 ] == '\0' ) { send_to_char( "Na kogo chcesz zapolowa`c?\n\r", ch ); return; } if ( ch->in_room->area == area_czysciec ) { send_to_char( "No co`s ty, w niecielesnym `swiecie?\n\r", ch ); return; } if ( IS_SET( ch->in_room->room_flags, ROOM_NO_HUNT ) ) { send_to_char( "Nie mo`zesz tu znale`x`c niczyich `slad`ow.\n\r", ch ); return; } /* only imps can hunt to different areas */ fArea = ( get_trust( ch ) < L_SEN ); if ( fArea ) victim = get_char_area( ch, arg ); else victim = get_char_world( ch, arg ); if ( !victim ) { send_to_char( "Nikogo takiego nie ma w pobli`zu.\n\r", ch ); return; } if ( ch == victim ) { send_to_char( "Znajdujesz siebie!\n\r", ch ); return; } if ( ch->in_room == victim->in_room ) { act( ZM_ZAWSZE, "$N jest tutaj!", ch, NULL, victim, TO_CHAR ); return; } if ( IS_NPC( victim ) && IS_SET( victim->act, ACT_NO_HUNT ) ) { act( ZM_ZAWSZE, "Nie mo`zesz znale`x`c drogi do $!.", ch, NULL, victim, TO_CHAR ); return; } /* * Deduct some movement. */ if ( ch->move > 2 ) ch->move -= 3; else { ASTC( "Jeste`s zbyt wyczerpan$y, aby szuka`c `slad`ow!", ch ); return; } act( ZM_WZROK | ZM_WID_CHAR, "$n szuka `slad`ow na ziemi.", ch, NULL, NULL, TO_ROOM ); WAIT_STATE( ch, skill_table[ gsn_hunt ].beats ); direction = find_path( ch->in_room, victim->in_room, 40000, fArea, TRUE ); if ( direction == -1 ) { /* Vigud 26.7.2010: jesli nie moglem widziec celu, $! bylo zamieniane na "kogos", a to wygladalo dosc glupio, skoro wiem, na kogo poluje */ /* act( ZM_ZAWSZE, "Nie mo`zesz st`ad znale`x`c drogi do $!.", ch, NULL, victim, TO_CHAR ); */ sprintf( buf, "Nie mo`zesz st`ad znale`x`c drogi do %s.\n\r", victim->dopelniacz ); STC( buf, ch ); return; } if ( direction < 0 || direction > 9 ) { send_to_char( "Wiesz, co`s tu jest nie tak.\n\r", ch ); return; } /* * Give a random direction if the player misses the die roll. */ uzycie = TRUE; if ( ( IS_NPC( ch ) && number_percent( ) < 25 ) /* NPC @ 25% */ || ( !IS_NPC( ch ) && number_percent( ) > /* PC @ norm */ ch->pcdata->learned[ gsn_hunt ] ) ) { do { direction = number_door( ); } while ( ch->in_room->exit[ direction ] == NULL || ch->in_room->exit[ direction ]->to_room == NULL ); uzycie = FALSE; } /* * Display the results of the search. */ sprintf( buf, "Droga do $! prowadzi na %s.", kierunki[ direction ].biernik ); act( ZM_ZAWSZE, buf, ch, NULL, victim, TO_CHAR ); /* bez wywal_zwod, jest to robione wczesniej */ ch->hunting = victim; dod_zwod( &victim->zwod_hunting, ch ); if ( uzycie ) uzyj( ch, gsn_hunt, "poszukiwaniu dr`og" ); return; }