void do_wake (CHAR_DATA * ch, char *argument) { char arg[MAX_INPUT_LENGTH]; CHAR_DATA *victim; one_argument (argument, arg); if (arg[0] == '\0') { do_function (ch, &do_stand, ""); return; } if (!IS_AWAKE (ch)) { send_to_char ("You are asleep yourself!\n\r", ch); return; } if ((victim = get_char_room (ch, arg)) == NULL) { send_to_char ("They aren't here.\n\r", ch); return; } if (IS_AWAKE (victim)) { act ("$N is already awake.", ch, NULL, victim, TO_CHAR); return; } act_new ("$n wakes you.", ch, NULL, victim, TO_VICT, POS_SLEEPING); do_function (ch, &do_stand, ""); return; }
bool spec_nasty( CHAR_DATA *ch ) { CHAR_DATA *victim, *v_next; long gold; if (!IS_AWAKE(ch)) { return FALSE; } if (ch->position != POS_FIGHTING) { for ( victim = ch->in_room->people; victim != NULL; victim = v_next) { v_next = victim->next_in_room; if (!IS_NPC(victim) && (victim->level > ch->level) && (victim->level < ch->level + 10)) { do_function(ch, &do_backstab, victim->name); if (ch->position != POS_FIGHTING) { do_function(ch, &do_murder, victim->name); } /* should steal some coins right away? :) */ return TRUE; } } return FALSE; /* No one to attack */ } /* okay, we must be fighting.... steal some coins and flee */ if ( (victim = ch->fighting) == NULL) return FALSE; /* let's be paranoid.... */ switch ( number_bits(2) ) { case 0: act( "$n rips apart your coin purse, spilling your gold!", ch, NULL, victim, TO_VICT); act( "You slash apart $N's coin purse and gather his gold.", ch, NULL, victim, TO_CHAR); act( "$N's coin purse is ripped apart!", ch, NULL, victim, TO_NOTVICT); gold = victim->gold / 10; /* steal 10% of his gold */ victim->gold -= gold; ch->gold += gold; return TRUE; case 1: do_function(ch, &do_flee, ""); return TRUE; default: return FALSE; } }
static void *concurrent(void *arguments) { do_function(arguments); pthread_exit(NULL); return NULL; }
void do_handler(const char *topic, const char *data){ if (strcmp(topic, "do")==0) { do_function(data); } else { error(9); } }
bool spec_executioner( CHAR_DATA *ch ) { char buf[MSL]={'\0'}; CHAR_DATA *victim; CHAR_DATA *v_next; char *crime; if ( !IS_AWAKE(ch) || ch->fighting != NULL ) return FALSE; crime = ""; for ( victim = ch->in_room->people; victim != NULL; victim = v_next ) { v_next = victim->next_in_room; if ( !IS_NPC(victim) && IS_SET(victim->act, PLR_KILLER) && can_see(ch,victim)) { crime = "KILLER"; break; } if ( !IS_NPC(victim) && IS_SET(victim->act, PLR_THIEF) && can_see(ch,victim)) { crime = "THIEF"; break; } } if ( victim == NULL ) return FALSE; sprintf( buf, "%s is a %s! PROTECT THE INNOCENT! MORE BLOOOOD!!!", victim->name, crime ); REMOVE_BIT(ch->comm,COMM_NOSHOUT); do_function(ch, &do_yell, buf ); multi_hit( ch, victim, TYPE_UNDEFINED ); return TRUE; }
void do_recall (CHAR_DATA * ch, char *argument) { char buf[MAX_STRING_LENGTH]; ROOM_INDEX_DATA *location; if (IS_NPC (ch)) { send_to_char ("Only players can recall.\n\r", ch); return; } act ("$n prays for transportation!", ch, 0, 0, TO_ROOM); if ((location = get_room_index (100)) == NULL) { send_to_char ("You are completely lost.\n\r", ch); return; } if (ch->in_room == location) return; if (IS_SET (ch->in_room->room_flags, ROOM_NO_RECALL)) { send_to_char ("Mota has forsaken you.\n\r", ch); return; } if(ch->infight) { int lose, skill; skill = get_skill (ch, gsn_recall); if (number_percent () < 80 * skill / 100) { WAIT_STATE (ch, 4); sprintf (buf, "You failed!.\n\r"); send_to_char (buf, ch); return; } lose = (ch->desc != NULL) ? 25 : 50; gain_exp (ch, 0 - lose); sprintf (buf, "You recall from combat! You lose %d exps.\n\r", lose); send_to_char (buf, ch); stop_fighting (ch, TRUE); } ch->move /= 2; act ("$n disappears.", ch, NULL, NULL, TO_ROOM); char_from_room (ch); char_to_room (ch, location); act ("$n appears in the room.", ch, NULL, NULL, TO_ROOM); do_function (ch, &do_look, "auto"); return; }
/* ciut przerobione */ void found_prey( CHAR_DATA *ch, CHAR_DATA *victim ) { OBJ_DATA *weapon; char * target; if ( !victim ) { bug( "Found_prey: null victim", 0 ); return; } if ( !victim->in_room ) { bug( "Found_prey: null victim->in_room", 0 ); return; } if ( !can_see( ch, victim ) ) return; if ( is_safe( ch, victim ) ) return; stop_hunting( ch ); if( (weapon = get_eq_char(ch, WEAR_WIELD)) != NULL ) { if( (target = get_target_by_name(ch,victim)) == NULL) target = victim->name; if(weapon->value[0] == WEAPON_DAGGER && get_skill(ch, gsn_backstab) > 0) { do_function(ch, &do_backstab, target ); } else if ( get_skill(ch, gsn_charge) > 0 && IS_WEAPON_STAT( weapon, WEAPON_TWO_HANDS ) && weapon->value[0] != WEAPON_WHIP && weapon->value[0] != WEAPON_SHORTSWORD && weapon->value[0] != WEAPON_DAGGER ) { do_function(ch, &do_charge, target ); } else multi_hit( ch, victim, TYPE_UNDEFINED ); return; } multi_hit( ch, victim, TYPE_UNDEFINED ); return; }
void do_denounce(CHAR_DATA *ch, char * argument ) { char arg[MSL], arg2[MSL]; CHAR_DATA *victim; if(IS_NPC(ch ) ) return; if(!str_cmp(argument, "organization" ) ) { denounce_org(ch, FALSE); return; } argument = one_argument(argument, arg ); argument = one_argument(argument, arg2 ); if(!str_cmp(arg, "follower" ) ) { if(ch->pcdata->rank <= RANK_PRIEST ) { do_function(ch, &do_denounce, NULL ); return; } if(!IS_IMMORTAL(ch) ) { if( ( victim = get_char_room(ch, NULL, arg2 ) ) == NULL ) { send_to_char("They aren't here.\n\r",ch); return; } } else { if( ( victim = get_char_world(ch, arg2 ) ) == NULL ) { send_to_char("They aren't here.\n\r", ch); return; } } if(IS_NPC(victim) ) { send_to_char("Not on NPC's.\n\r",ch); return; } if(!IS_SAME_ORGANIZATION(ch, victim) && ch->pcdata->rank != RANK_GOD ) { send_to_char("They aren't in your organization!\n\r",ch); return; } if(ch->pcdata->rank <= victim->pcdata->rank ) { send_to_char("You cannot denounce their organization.\n\r",ch); return; } send_to_char("You denounce thier organization!\n\r",ch); denounce_org(victim, TRUE); return; } if(ch->pcdata->rank <= RANK_PRIEST ) send_to_char("To denounce a followers organization, use the syntax: 'denounce follower <name>'\n\r",ch); send_to_char("To denounce your faith, please type use the syntax: 'denounce organization'\n\r", ch); return; }
void spell_farsight( int sn, int level, CHAR_DATA *ch, void *vo,int target) { if (IS_AFFECTED(ch,AFF_BLIND)) { send_to_char("Maybe it would help if you could see?\n\r",ch); return; } do_function(ch, &do_scan, target_name); }
bool spec_guard( CHAR_DATA *ch ) { char buf[MSL]={'\0'}; CHAR_DATA *victim; CHAR_DATA *v_next; CHAR_DATA *ech; char *crime; int max_evil; if ( !IS_AWAKE(ch) || ch->fighting != NULL ) return FALSE; max_evil = 300; ech = NULL; crime = ""; for ( victim = ch->in_room->people; victim != NULL; victim = v_next ) { v_next = victim->next_in_room; if ( !IS_NPC(victim) && IS_SET(victim->act, PLR_KILLER) && can_see(ch,victim)) { crime = "KILLER"; break; } if ( !IS_NPC(victim) && IS_SET(victim->act, PLR_THIEF) && can_see(ch,victim)) { crime = "THIEF"; break; } if ( victim->fighting != NULL && victim->fighting != ch && victim->alignment < max_evil ) { max_evil = victim->alignment; ech = victim; } } if ( victim != NULL ) { sprintf( buf, "%s is a %s! PROTECT THE INNOCENT!! BANZAI!!", victim->name, crime ); REMOVE_BIT(ch->comm,COMM_NOSHOUT); do_function(ch, &do_yell, buf ); multi_hit( ch, victim, TYPE_UNDEFINED ); return TRUE; } if ( ech != NULL ) { act( "$n screams 'PROTECT THE INNOCENT!! BANZAI!!", ch, NULL, NULL, TO_ROOM ); multi_hit( ch, ech, TYPE_UNDEFINED ); return TRUE; } return FALSE; }
void force_cast(CHAR_DATA *ch, CHAR_DATA *victim, sh_int sn) { static char buf[MAX_INPUT_LENGTH]; char * target; if(ch == victim) { sprintf(buf,"'%s' self",skill_table[sn].name); do_function(ch,&do_cast, buf ); return; } if( (target = get_target_by_name(ch,victim)) == NULL) { sprintf(buf,"'%s' %s",skill_table[sn].name, victim ? victim->name : ""); do_function(ch,&do_cast, buf ); } else { sprintf(buf,"'%s' %s",skill_table[sn].name, target); do_function(ch,&do_cast, buf ); } return; }
/* * Start fights. */ void set_fighting( CHAR_DATA *ch, CHAR_DATA *victim ) { if ( ch->fighting != NULL ) { log_string(LOG_BUG, "Set_fighting: already fighting"); return; } if ( IS_AFFECTED(ch, AFF_SLEEP) ) affect_strip( ch, gsn_sleep ); do_function(ch, &do_visible,""); ch->fighting = victim; ch->position = P_FIGHT; return; }
bool spec_executioner( CHAR_DATA *ch ) { char buf[ MAX_STRING_LENGTH ]; CHAR_DATA *victim; CHAR_DATA *v_next; char *crime; if ( !IS_AWAKE( ch ) || ch->fighting != NULL ) return FALSE; crime = ""; for ( victim = ch->in_room->people; victim != NULL; victim = v_next ) { v_next = victim->next_in_room; if ( !IS_NPC( victim ) && EXT_IS_SET( victim->act, PLR_KILLER ) && can_see( ch, victim ) ) { crime = "KILLER"; break; } if ( !IS_NPC( victim ) && EXT_IS_SET( victim->act, PLR_THIEF ) && can_see( ch, victim ) ) { crime = "THIEF"; break; } } if ( victim == NULL ) return FALSE; sprintf( buf, "%s is a %s! BRONIÆ NIEWINNYCH! KRRRRWII!!!", victim->name, crime ); REMOVE_BIT( ch->comm, COMM_NOSHOUT ); do_function( ch, &do_yell, buf ); multi_hit( ch, victim, TYPE_UNDEFINED ); return TRUE; }
void delete_todelete( ) // delete chs from the todelete list { TODELETE_DATA *todelete; // declare the todelete variable for ( todelete = todelete_list; todelete; todelete = todelete->next ) // parse the todelete list { if ( time_diff( todelete->timestamp, current_time, ' ' ) < 0 ) // if the time is up { CHAR_DATA *dch; // declare the ch variable for ( dch = char_list; dch; dch = dch->next ) // parse the currently playing ch list { if ( !strcmp( dch->name, todelete->name ) ) // if found the ch { break; // exit the find ch loop } } if ( !dch ) // if no ch found { if ( !( dch = load_char_remote( todelete->name ) ) ) // if can't load the ch from file { char buf[MSL]; // declare a char array sprintf( buf, "delete_todelete: can't find player: %s", todelete->name ); // prepare an error message bug( buf, 0 ); // send the error message to the bug channel remove_todelete( todelete->name ); // fix the todelete list return; // exit the function } } do_function( dch, &do_delete, "" ); // delete the ch } } return; // exit the function }
bool spec_nasty( CHAR_DATA *ch ) { CHAR_DATA * victim, *v_next; long copper; if ( !IS_AWAKE( ch ) ) { return FALSE; } if ( ch->position != POS_FIGHTING ) { for ( victim = ch->in_room->people; victim != NULL; victim = v_next ) { v_next = victim->next_in_room; if ( !IS_NPC( victim ) && ( victim->level > ch->level ) && ( victim->level < ch->level + 10 ) ) { do_function( ch, &do_backstab, victim->name ); if ( ch->position != POS_FIGHTING ) { do_function( ch, &do_kill, victim->name ); } /* should steal some coins right away? :) */ return TRUE; } } return FALSE; /* No one to attack */ } /* okay, we must be fighting... steal some coins and flee */ if ( ( victim = ch->fighting ) == NULL ) { return FALSE; /* let's be paranoid... */ } copper = money_count_copper( victim ); if ( copper == 0 ) { return FALSE; } switch ( number_bits( 2 ) ) { case 0: act( "$n wpada na ciebie i zabiera twoj± sakiewkê!", ch, NULL, victim, TO_VICT ); if ( ch->sex == 0 ) { act( "Wpadasz na $N i zabierasz temu sakiewkê.", ch, NULL, victim, TO_CHAR ); act( "$n wpada na $Z i zabiera temu sakiewke!", ch, NULL, victim, TO_NOTVICT ); } else if ( ch->sex == 1 ) { act( "Wpadasz na $N i zabierasz mu sakiewkê.", ch, NULL, victim, TO_CHAR ); act( "$n wpada na $Z i zabiera mu sakiewke!", ch, NULL, victim, TO_NOTVICT ); } else { act( "Wpadasz na $N i zabierasz jej sakiewkê.", ch, NULL, victim, TO_CHAR ); act( "$n wpada na $Z i zabiera jej sakiewke!", ch, NULL, victim, TO_NOTVICT ); } money_transfer_spec_nasty ( ch, victim ); return TRUE; case 1: do_function( ch, &do_flee, "" ); return TRUE; default: return FALSE; } }
bool spec_mayor( CHAR_DATA *ch ) { static const char open_path[] = "W3a3003b33000c111d0d111Oe333333Oe22c222112212111a1S."; static const char close_path[] = "W3a3003b33000c111d0d111CE333333CE22c222112212111a1S."; static const char *path; static int pos; static bool move; if ( !move ) { if ( time_info.hour == 6 ) { path = open_path; move = TRUE; pos = 0; } if ( time_info.hour == 20 ) { path = close_path; move = TRUE; pos = 0; } } if ( ch->fighting != NULL ) return spec_cast_mage( ch ); if ( !move || ch->position < POS_SLEEPING ) return FALSE; switch ( path[pos] ) { case '0': case '1': case '2': case '3': move_char( ch, path[pos] - '0', FALSE ); break; case 'W': ch->position = POS_STANDING; act( "$n awakens and groans loudly.", ch, NULL, NULL, TO_ROOM ); break; case 'S': ch->position = POS_SLEEPING; act( "$n lies down and falls asleep.", ch, NULL, NULL, TO_ROOM ); break; case 'a': act( "$n says 'Hello Honey!'", ch, NULL, NULL, TO_ROOM ); break; case 'b': act( "$n says 'What a view! I must do something about that dump!'", ch, NULL, NULL, TO_ROOM ); break; case 'c': act( "$n says 'Vandals! Youngsters have no respect for anything!'", ch, NULL, NULL, TO_ROOM ); break; case 'd': act( "$n says 'Good day, citizens!'", ch, NULL, NULL, TO_ROOM ); break; case 'e': act( "$n says 'I hereby declare the city of Midgaard open!'", ch, NULL, NULL, TO_ROOM ); break; case 'E': act( "$n says 'I hereby declare the city of Midgaard closed!'", ch, NULL, NULL, TO_ROOM ); break; case 'O': /* do_function(ch, &do_unlock, "gate" ); */ do_function(ch, &do_open, "gate" ); break; case 'C': do_function(ch, &do_close, "gate" ); /* do_function(ch, &do_lock, "gate" ); */ break; case '.' : move = FALSE; break; } pos++; return FALSE; }
/* this procedure handles the input parsing for the skill generator */ bool parse_gen_groups(CHAR_DATA *ch,char *argument) { char arg[MAX_INPUT_LENGTH]={'\0'}; int gn,sn; if (argument[0] == '\0') return FALSE; argument = one_argument(argument,arg); if (!str_prefix(arg,"help")) { if (argument[0] == '\0') { do_function(ch, &do_help, "group help"); return TRUE; } do_function(ch, &do_help, argument); return TRUE; } if (!str_prefix(arg,"add")) { if (argument[0] == '\0') { send_to_char("You must provide a skill name.\n\r",ch); return TRUE; } gn = group_lookup(argument); if (gn != -1) { if (ch->gen_data->group_chosen[gn] || ch->pcdata->group_known[gn]) { send_to_char("You already know that group!\n\r",ch); return TRUE; } if (group_table[gn].rating[ch->iclass] < 1) { send_to_char("That group is not available.\n\r",ch); return TRUE; } /* Close security hole */ if (ch->gen_data->points_chosen + group_table[gn].rating[ch->iclass] > 300) { send_to_char( "You cannot take more than 300 creation points.\n\r", ch); return TRUE; } send_to_char( Format("%s group added\n\r",group_table[gn].name), ch); ch->gen_data->group_chosen[gn] = TRUE; ch->gen_data->points_chosen += group_table[gn].rating[ch->iclass]; gn_add(ch,gn); ch->pcdata->points += group_table[gn].rating[ch->iclass]; return TRUE; } sn = skill_lookup(argument); if (sn != -1) { if (ch->gen_data->skill_chosen[sn] || ch->pcdata->learned[sn] > 0) { send_to_char("You already know that skill!\n\r",ch); return TRUE; } if (skill_table[sn].rating[ch->iclass] < 1 || skill_table[sn].spell_fun != spell_null) { send_to_char("That skill is not available.\n\r",ch); return TRUE; } /* Close security hole */ if (ch->gen_data->points_chosen + skill_table[sn].rating[ch->iclass] > 300) { send_to_char("You cannot take more than 300 creation points.\n\r", ch); return TRUE; } send_to_char( Format("%s skill added\n\r",skill_table[sn].name), ch); ch->gen_data->skill_chosen[sn] = TRUE; ch->gen_data->points_chosen += skill_table[sn].rating[ch->iclass]; ch->pcdata->learned[sn] = 1; ch->pcdata->points += skill_table[sn].rating[ch->iclass]; return TRUE; } send_to_char("No skills or groups by that name...\n\r",ch); return TRUE; } if (!strcmp(arg,"drop")) { if (argument[0] == '\0') { send_to_char("You must provide a skill to drop.\n\r",ch); return TRUE; } gn = group_lookup(argument); if (gn != -1 && ch->gen_data->group_chosen[gn]) { int i = 0; send_to_char("Group dropped.\n\r",ch); ch->gen_data->group_chosen[gn] = FALSE; ch->gen_data->points_chosen -= group_table[gn].rating[ch->iclass]; gn_remove(ch,gn); for (i = 0; i < MAX_GROUP; i++) { if (ch->gen_data->group_chosen[gn]) gn_add(ch,gn); } ch->pcdata->points -= group_table[gn].rating[ch->iclass]; return TRUE; } sn = skill_lookup(argument); if (sn != -1 && ch->gen_data->skill_chosen[sn]) { send_to_char("Skill dropped.\n\r",ch); ch->gen_data->skill_chosen[sn] = FALSE; ch->gen_data->points_chosen -= skill_table[sn].rating[ch->iclass]; ch->pcdata->learned[sn] = 0; ch->pcdata->points -= skill_table[sn].rating[ch->iclass]; return TRUE; } send_to_char("You haven't bought any such skill or group.\n\r",ch); return TRUE; } if (!str_prefix(arg,"premise")) { do_function(ch, &do_help, "premise"); return TRUE; } if (!str_prefix(arg,"list")) { list_group_costs(ch); return TRUE; } if (!str_prefix(arg,"learned")) { list_group_chosen(ch); return TRUE; } if (!str_prefix(arg,"info")) { do_function(ch, &do_groups, argument); return TRUE; } return FALSE; }
/* used to get new skills */ void do_gain(CHAR_DATA *ch, char *argument) { char arg[MIL]={'\0'}; CHAR_DATA *trainer; int gn = 0, sn = 0; if (IS_NPC(ch)) { return; } /* find a trainer */ for ( trainer = ch->in_room->people; trainer != NULL; trainer = trainer->next_in_room) { if (IS_NPC(trainer) && IS_SET(trainer->act,ACT_GAIN)) { break; } } if (trainer == NULL || !can_see(ch,trainer)) { send_to_char("You can't do that here.\n\r",ch); return; } one_argument(argument,arg); if (arg[0] == '\0') { do_function(trainer, &do_say, "Pardon me?"); return; } if (!str_prefix(arg,"list")) { int col = 0; send_to_char( Format("%-18s %-5s %-18s %-5s %-18s %-5s\n\r", "group","cost","group","cost","group","cost"), ch); for (gn = 0; gn < MAX_GROUP; gn++) { if (group_table[gn].name == NULL) break; if (!ch->pcdata->group_known[gn] && group_table[gn].rating[ch->iclass] > 0) { send_to_char( Format("%-18s %-5d ", group_table[gn].name,group_table[gn].rating[ch->iclass]), ch); if (++col % 3 == 0) send_to_char("\n\r",ch); } } if (col % 3 != 0) send_to_char("\n\r",ch); send_to_char("\n\r",ch); col = 0; send_to_char( Format("%-18s %-5s %-18s %-5s %-18s %-5s\n\r", "skill","cost","skill","cost","skill","cost"), ch); for (sn = 0; sn < MAX_SKILL; sn++) { if (skill_table[sn].name == NULL) break; if (!ch->pcdata->learned[sn] && skill_table[sn].rating[ch->iclass] > 0 && skill_table[sn].spell_fun == spell_null) { send_to_char( Format("%-18s %-5d ", skill_table[sn].name,skill_table[sn].rating[ch->iclass]), ch); if (++col % 3 == 0) send_to_char("\n\r",ch); } } if (col % 3 != 0) send_to_char("\n\r",ch); return; } if (!str_prefix(arg,"convert")) { if (ch->practice < 10) { act("$N tells you 'You are not yet ready.'", ch,NULL,trainer,TO_CHAR); return; } act("$N helps you apply your practice to training", ch,NULL,trainer,TO_CHAR); ch->practice -= 10; ch->train +=1 ; return; } if (!str_prefix(arg,"points")) { if (ch->train < 2) { act("$N tells you 'You are not yet ready.'", ch,NULL,trainer,TO_CHAR); return; } if (ch->pcdata->points <= 40) { act("$N tells you 'There would be no point in that.'", ch,NULL,trainer,TO_CHAR); return; } act("$N trains you, and you feel more at ease with your skills.", ch,NULL,trainer,TO_CHAR); ch->train -= 2; ch->pcdata->points -= 1; ch->exp = exp_per_level(ch,ch->pcdata->points) * ch->level; return; } /* else add a group/skill */ gn = group_lookup(argument); if (gn > 0) { if (ch->pcdata->group_known[gn]) { act("$N tells you 'You already know that group!'", ch,NULL,trainer,TO_CHAR); return; } if (group_table[gn].rating[ch->iclass] <= 0) { act("$N tells you 'That group is beyond your powers.'", ch,NULL,trainer,TO_CHAR); return; } if (ch->train < group_table[gn].rating[ch->iclass]) { act("$N tells you 'You are not yet ready for that group.'", ch,NULL,trainer,TO_CHAR); return; } /* add the group */ gn_add(ch,gn); act("$N trains you in the art of $t", ch,group_table[gn].name,trainer,TO_CHAR); ch->train -= group_table[gn].rating[ch->iclass]; return; } sn = skill_lookup(argument); if (sn > -1) { if (skill_table[sn].spell_fun != spell_null) { act("$N tells you 'You must learn the full group.'", ch,NULL,trainer,TO_CHAR); return; } if (ch->pcdata->learned[sn]) { act("$N tells you 'You already know that skill!'", ch,NULL,trainer,TO_CHAR); return; } if (skill_table[sn].rating[ch->iclass] <= 0) { act("$N tells you 'That skill is beyond your powers.'", ch,NULL,trainer,TO_CHAR); return; } if (ch->train < skill_table[sn].rating[ch->iclass]) { act("$N tells you 'You are not yet ready for that skill.'", ch,NULL,trainer,TO_CHAR); return; } /* add the skill */ ch->pcdata->learned[sn] = 1; act("$N trains you in the art of $t", ch,skill_table[sn].name,trainer,TO_CHAR); ch->train -= skill_table[sn].rating[ch->iclass]; return; } act("$N tells you 'I do not understand...'",ch,NULL,trainer,TO_CHAR); }
void move_char (CHAR_DATA * ch, int door, bool follow) { CHAR_DATA *fch; CHAR_DATA *fch_next; ROOM_INDEX_DATA *in_room; ROOM_INDEX_DATA *to_room; EXIT_DATA *pexit; if(ch->infight) { if(!TURN(ch)) { printf_to_char(ch,"It's not your turn.\n"); return; } refresh(ch->in_room); if(ch->MoveLeft == 0) { printf_to_char(ch,"You have no moves left.\n"); return; } switch(door) { case DIR_EAST: if(find_char_xy(ch,ch->mposx+1,ch->mposy) == NULL) { if(hdif(ch,DIR_EAST) > ch->jump || hdif(ch,DIR_EAST) < -(ch->jump) || ch->mposx > 24) { printf_to_char(ch,"You can't jump that high.\n"); return; } ch->mposx++; ch->in_room->map.index[ch->mposy][ch->mposx].occupied = FALSE; ch->in_room->map.index[ch->mposy][ch->mposx+1].occupied = TRUE; announce_move(ch,"east"); } else printf_to_char(ch,"Somebody's in the way.\n"); break; case DIR_WEST: if(find_char_xy(ch,ch->mposx-1,ch->mposy) == NULL) { if(hdif(ch,DIR_WEST) > (ch->jump) || hdif(ch,DIR_WEST) < -(ch->jump) || ch->mposx < 1) { printf_to_char(ch,"You can't jump that high.\n"); return; } ch->in_room->map.index[ch->mposy][ch->mposx].occupied = FALSE; ch->in_room->map.index[ch->mposy][ch->mposx-1].occupied = TRUE; ch->mposx--; announce_move(ch,"west"); } else printf_to_char(ch,"Somebody's in the way.\n"); break; case DIR_NORTH: if(hdif(ch,DIR_NORTH) > (ch->jump) || hdif(ch,DIR_NORTH) < -(ch->jump) || ch->mposy < 1) { printf_to_char(ch,"You can't jump that high.\n"); return; } if(find_char_xy(ch,ch->mposx,ch->mposy-1) == NULL) { ch->in_room->map.index[ch->mposy][ch->mposx].occupied = FALSE; ch->in_room->map.index[ch->mposy-1][ch->mposx].occupied = TRUE; ch->mposy--; announce_move(ch,"north"); } else printf_to_char(ch,"Somebody's in the way.\n"); break; case DIR_SOUTH: if(hdif(ch,DIR_SOUTH) > (ch->jump) || hdif(ch,DIR_SOUTH) < -(ch->jump) || ch->mposy > 14) { printf_to_char(ch,"You can't jump that high.\n"); return; } if(find_char_xy(ch,ch->mposx,ch->mposy+1) == NULL) { ch->in_room->map.index[ch->mposy][ch->mposx].occupied = FALSE; ch->in_room->map.index[ch->mposy+1][ch->mposx].occupied = TRUE; ch->mposy++; announce_move(ch,"south"); } else printf_to_char(ch,"Somebody's in the way.\n"); break; } return; } if (door < 0 || door > 5) { bug ("Do_move: bad door %d.", door); return; } /* * Exit trigger, if activated, bail out. Only PCs are triggered. */ in_room = ch->in_room; if ((pexit = in_room->exit[door]) == NULL || (to_room = pexit->u1.to_room) == NULL || !can_see_room (ch, pexit->u1.to_room)) { send_to_char ("Alas, you cannot go that way.\n\r", ch); return; } if (IS_SET (pexit->exit_info, EX_CLOSED) || IS_SET (pexit->exit_info, EX_NOPASS)) { act ("The $d is closed.", ch, NULL, pexit->keyword, TO_CHAR); return; } if (!is_room_owner (ch, to_room) && room_is_private (to_room)) { send_to_char ("That room is private right now.\n\r", ch); return; } if ( ch->invis_level < LEVEL_HERO) act ("$n leaves $T.", ch, NULL, dir_name[door], TO_ROOM); char_from_room (ch); char_to_room (ch, to_room); if ( ch->invis_level < LEVEL_HERO) act ("$n has arrived.", ch, NULL, NULL, TO_ROOM); do_function (ch, &do_look, "auto"); if (in_room == to_room) /* no circular follows */ return; for (fch = in_room->people; fch != NULL; fch = fch_next) { fch_next = fch->next_in_room; if (fch->master == ch && fch->position == POS_STANDING && can_see_room (fch, to_room)) { if (IS_SET (ch->in_room->room_flags, ROOM_LAW) && (IS_NPC (fch) && IS_SET (fch->act, ACT_AGGRESSIVE))) { act ("You can't bring $N into the city.", ch, NULL, fch, TO_CHAR); act ("You aren't allowed in the city.", fch, NULL, NULL, TO_CHAR); continue; } act ("You follow $N.", fch, NULL, ch, TO_CHAR); move_char (fch, door, TRUE); } } /* * If someone is following the char, these triggers get activated * for the followers before the char, but it's safer this way... */ // if(number_range(1,10) > 2) // gen_random_battle(ch); return; }
int main(int argc, char **argv) { FILE *infile = stdin; char tmp[4096]; #ifdef __mc68000__ if(system("perl machdep/cpuopti")==-1) { perror("perl machdep/cpuopti"); return 10; } else return 0; #endif /* For debugging... */ if (argc == 2) infile = fopen (argv[1], "r"); for(;;) { char *s; if ((fgets(tmp, 4095, infile)) == NULL) break; s = strchr (tmp, '\n'); if (s != NULL) *s = 0; if (strncmp(tmp, ".globl op_", 10) == 0) { struct line *first_line = NULL, *prev = NULL; struct line **nextp = &first_line; struct func f; int nr_rets = 0; int can_opt = 1; do { struct line *current; if (strcmp (tmp, "#APP") != 0 && strcmp (tmp, "#NO_APP") != 0) { current = *nextp = (struct line *)malloc(sizeof (struct line)); nextp = ¤t->next; current->prev = prev; prev = current; current->next = NULL; current->delet = 0; current->data = strdup (tmp); if (match (current, "movl %esp,%ebp") || match (current, "enter")) { fprintf (stderr, "GCC failed to eliminate fp: %s\n", first_line->data); can_opt = 0; } if (match (current, "ret")) nr_rets++; } if ((fgets(tmp, 4095, infile)) == NULL) oops(); s = strchr (tmp, '\n'); if (s != NULL) *s = 0; } while (strncmp (tmp,".Lfe", 4) != 0); f.first_line = first_line; f.last_line = prev; if (nr_rets == 1 && can_opt) do_function(&f); /*else fprintf(stderr, "Too many RET instructions: %s\n", first_line->data);*/ output_function(&f); } printf("%s\n", tmp); } return 0; }
void do_stand (CHAR_DATA * ch, char *argument) { OBJ_DATA *obj = NULL; if (argument[0] != '\0') { if(ch->infight) { send_to_char ("Maybe you should finish fighting first?\n\r", ch); return; } obj = get_obj_list (ch, argument, ch->in_room->contents); if (obj == NULL) { send_to_char ("You don't see that here.\n\r", ch); return; } if (obj->item_type != ITEM_FURNITURE || (!IS_SET (obj->value[2], STAND_AT) && !IS_SET (obj->value[2], STAND_ON) && !IS_SET (obj->value[2], STAND_IN))) { send_to_char ("You can't seem to find a place to stand.\n\r", ch); return; } if (ch->on != obj && count_users (obj) >= obj->value[0]) { act_new ("There's no room to stand on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD); return; } ch->on = obj; } switch (ch->position) { case POS_SLEEPING: if (obj == NULL) { send_to_char ("You wake and stand up.\n\r", ch); act ("$n wakes and stands up.", ch, NULL, NULL, TO_ROOM); ch->on = NULL; } else if (IS_SET (obj->value[2], STAND_AT)) { act_new ("You wake and stand at $p.", ch, obj, NULL, TO_CHAR, POS_DEAD); act ("$n wakes and stands at $p.", ch, obj, NULL, TO_ROOM); } else if (IS_SET (obj->value[2], STAND_ON)) { act_new ("You wake and stand on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD); act ("$n wakes and stands on $p.", ch, obj, NULL, TO_ROOM); } else { act_new ("You wake and stand in $p.", ch, obj, NULL, TO_CHAR, POS_DEAD); act ("$n wakes and stands in $p.", ch, obj, NULL, TO_ROOM); } ch->position = POS_STANDING; do_function (ch, &do_look, "auto"); break; case POS_RESTING: case POS_SITTING: if (obj == NULL) { send_to_char ("You stand up.\n\r", ch); act ("$n stands up.", ch, NULL, NULL, TO_ROOM); ch->on = NULL; } else if (IS_SET (obj->value[2], STAND_AT)) { act ("You stand at $p.", ch, obj, NULL, TO_CHAR); act ("$n stands at $p.", ch, obj, NULL, TO_ROOM); } else if (IS_SET (obj->value[2], STAND_ON)) { act ("You stand on $p.", ch, obj, NULL, TO_CHAR); act ("$n stands on $p.", ch, obj, NULL, TO_ROOM); } else { act ("You stand in $p.", ch, obj, NULL, TO_CHAR); act ("$n stands on $p.", ch, obj, NULL, TO_ROOM); } ch->position = POS_STANDING; break; case POS_STANDING: send_to_char ("You are already standing.\n\r", ch); break; case POS_FIGHTING: send_to_char ("You are already fighting!\n\r", ch); break; } return; }
/* RT Enter portals */ void do_enter (CHAR_DATA * ch, char *argument) { ROOM_INDEX_DATA *location; if (ch->fighting != NULL) return; /* nifty portal stuff */ if (argument[0] != '\0') { ROOM_INDEX_DATA *old_room; OBJ_DATA *portal; CHAR_DATA *fch, *fch_next; old_room = ch->in_room; portal = get_obj_list (ch, argument, ch->in_room->contents); if (portal == NULL) { send_to_char ("You don't see that here.\n\r", ch); return; } if (portal->item_type != ITEM_PORTAL || (IS_SET (portal->value[1], EX_CLOSED) && !IS_TRUSTED (ch, ANGEL))) { send_to_char ("You can't seem to find a way in.\n\r", ch); return; } if (!IS_TRUSTED (ch, ANGEL) && !IS_SET (portal->value[2], GATE_NOCURSE) && (IS_AFFECTED (ch, AFF_CURSE) || IS_SET (old_room->room_flags, ROOM_NO_RECALL))) { send_to_char ("Something prevents you from leaving...\n\r", ch); return; } if (IS_SET (portal->value[2], GATE_RANDOM) || portal->value[3] == -1) { location = get_random_room (ch); portal->value[3] = location->vnum; /* for record keeping :) */ } else if (IS_SET (portal->value[2], GATE_BUGGY) && (number_percent () < 5)) location = get_random_room (ch); else location = get_room_index (portal->value[3]); if (location == NULL || location == old_room || !can_see_room (ch, location) || (room_is_private (location) && !IS_TRUSTED (ch, IMPLEMENTOR))) { act ("$p doesn't seem to go anywhere.", ch, portal, NULL, TO_CHAR); return; } if (IS_NPC (ch) && IS_SET (ch->act, ACT_AGGRESSIVE) && IS_SET (location->room_flags, ROOM_LAW)) { send_to_char ("Something prevents you from leaving...\n\r", ch); return; } act ("$n steps into $p.", ch, portal, NULL, TO_ROOM); if (IS_SET (portal->value[2], GATE_NORMAL_EXIT)) act ("You enter $p.", ch, portal, NULL, TO_CHAR); else act ("You walk through $p and find yourself somewhere else...", ch, portal, NULL, TO_CHAR); char_from_room (ch); char_to_room (ch, location); if (IS_SET (portal->value[2], GATE_GOWITH)) { /* take the gate along */ obj_from_room (portal); obj_to_room (portal, location); } if (IS_SET (portal->value[2], GATE_NORMAL_EXIT)) act ("$n has arrived.", ch, portal, NULL, TO_ROOM); else act ("$n has arrived through $p.", ch, portal, NULL, TO_ROOM); do_function (ch, &do_look, "auto"); /* charges */ if (portal->value[0] > 0) { portal->value[0]--; if (portal->value[0] == 0) portal->value[0] = -1; } /* protect against circular follows */ if (old_room == location) return; for (fch = old_room->people; fch != NULL; fch = fch_next) { fch_next = fch->next_in_room; if (portal == NULL || portal->value[0] == -1) /* no following through dead portals */ continue; if (fch->master == ch && IS_AFFECTED (fch, AFF_CHARM) && fch->position < POS_STANDING) do_function (fch, &do_stand, ""); if (fch->master == ch && fch->position == POS_STANDING) { if (IS_SET (ch->in_room->room_flags, ROOM_LAW) && (IS_NPC (fch) && IS_SET (fch->act, ACT_AGGRESSIVE))) { act ("You can't bring $N into the city.", ch, NULL, fch, TO_CHAR); act ("You aren't allowed in the city.", fch, NULL, NULL, TO_CHAR); continue; } act ("You follow $N.", fch, NULL, ch, TO_CHAR); do_function (fch, &do_enter, argument); } } if (portal != NULL && portal->value[0] == -1) { act ("$p fades out of existence.", ch, portal, NULL, TO_CHAR); if (ch->in_room == old_room) act ("$p fades out of existence.", ch, portal, NULL, TO_ROOM); else if (old_room->people != NULL) { act ("$p fades out of existence.", old_room->people, portal, NULL, TO_CHAR); act ("$p fades out of existence.", old_room->people, portal, NULL, TO_ROOM); } extract_obj (portal); } /* * If someone is following the char, these triggers get activated * for the followers before the char, but it's safer this way... */ if (IS_NPC (ch) && HAS_TRIGGER (ch, TRIG_ENTRY)) mp_percent_trigger (ch, NULL, NULL, NULL, TRIG_ENTRY); if (!IS_NPC (ch)) mp_greet_trigger (ch); return; } send_to_char ("Nope, can't do it.\n\r", ch); return; }
/* * Update all chars, including mobs. */ void char_update (void) { CHAR_DATA *ch = NULL; CHAR_DATA *ch_next; CHAR_DATA *ch_quit; ch_quit = NULL; /* update save counter */ save_number++; if (save_number > 29) save_number = 0; for (ch = char_list; ch != NULL; ch = ch_next) { AFFECT_DATA *paf; AFFECT_DATA *paf_next; ch_next = ch->next; if(!ch->infight) { ch->hit = ch->max_hit; ch->mana = ch->max_mana; ch->move = ch->max_move; update_pos (ch); } if (ch->timer > 30) ch_quit = ch; if (ch->position == POS_STUNNED) update_pos (ch); if (!IS_NPC (ch) && ch->level < LEVEL_IMMORTAL) { if (IS_IMMORTAL (ch)) ch->timer = 0; if (++ch->timer >= 12) { if (ch->was_in_room == NULL && ch->in_room != NULL) { ch->was_in_room = ch->in_room; act ("$n disappears into the void.", ch, NULL, NULL, TO_ROOM); send_to_char ("You disappear into the void.\n\r", ch); if (ch->level > 1) save_char_obj (ch); char_from_room (ch); char_to_room (ch, get_room_index (2)); } } gain_condition (ch, COND_DRUNK, -1); gain_condition (ch, COND_FULL, ch->size > SIZE_MEDIUM ? -4 : -2); gain_condition (ch, COND_THIRST, -1); gain_condition (ch, COND_HUNGER, ch->size > SIZE_MEDIUM ? -2 : -1); } for (paf = ch->affected; paf != NULL; paf = paf_next) { paf_next = paf->next; if (paf->duration > 0) { paf->duration--; if (number_range (0, 4) == 0 && paf->level > 0) paf->level--; /* spell strength fades with time */ } else if (paf->duration < 0); else { if (paf_next == NULL || paf_next->type != paf->type || paf_next->duration > 0) { if (paf->type > 0 && skill_table[paf->type].msg_off) { send_to_char (skill_table[paf->type].msg_off, ch); send_to_char ("\n\r", ch); } } affect_remove (ch, paf); } } /* * Careful with the damages here, * MUST NOT refer to ch after damage taken, * as it may be lethal damage (on NPC). */ if (ch->position == POS_INCAP && number_range (0, 1) == 0) { damage (ch, ch, 1, TYPE_UNDEFINED, ELE_NON, FALSE); } else if (ch->position == POS_MORTAL) { damage (ch, ch, 1, TYPE_UNDEFINED, ELE_NON, FALSE); } } /* * Autosave and autoquit. * Check that these chars still exist. */ for (ch = char_list; ch != NULL; ch = ch_next) { /* * Edwin's fix for possible pet-induced problem * JR -- 10/15/00 */ if (!IS_VALID(ch)) { bug("update_char: Trying to work with an invalidated character.\n",0); break; } ch_next = ch->next; if (ch->desc != NULL && ch->desc->descriptor % 30 == save_number) { save_char_obj (ch); } if (ch == ch_quit) { do_function (ch, &do_quit, ""); } } return; }
/* * Update all chars, including mobs. */ void char_update( void ) { CHAR_DATA *ch; CHAR_DATA *ch_next; CHAR_DATA *ch_quit; ch_quit = NULL; /* update save counter */ save_number++; if (save_number > 29) save_number = 0; for ( ch = char_list; ch != NULL; ch = ch_next ) { AFFECT_DATA *paf; AFFECT_DATA *paf_next; ch_next = ch->next; if ( ch->timer > 30 ) ch_quit = ch; if ( ch->position >= POS_STUNNED ) { /* check to see if we need to go home */ if (IS_NPC(ch) && ch->zone != NULL && ch->zone != ch->in_room->area && ch->desc == NULL && ch->fighting == NULL && !IS_AFFECTED(ch,AFF_CHARM) && number_percent() < 5) { act("$n wanders on home.",ch,NULL,NULL,TO_ROOM); extract_char(ch,TRUE); continue; } if ( ch->hit < ch->max_hit ) ch->hit += hit_gain(ch); else ch->hit = ch->max_hit; if ( ch->mana < ch->max_mana ) ch->mana += mana_gain(ch); else ch->mana = ch->max_mana; if ( ch->move < ch->max_move ) ch->move += move_gain(ch); else ch->move = ch->max_move; } if ( ch->position == POS_STUNNED ) update_pos( ch ); if ( !IS_NPC(ch) && ch->level < LEVEL_IMMORTAL ) { OBJ_DATA *obj; if ( ( obj = get_eq_char( ch, WEAR_LIGHT ) ) != NULL && obj->item_type == ITEM_LIGHT && obj->value[2] > 0 ) { if ( --obj->value[2] == 0 && ch->in_room != NULL ) { --ch->in_room->light; act( "$p goes out.", ch, obj, NULL, TO_ROOM ); act( "$p flickers and goes out.", ch, obj, NULL, TO_CHAR ); extract_obj( obj ); } else if ( obj->value[2] <= 5 && ch->in_room != NULL) act("$p flickers.",ch,obj,NULL,TO_CHAR); } if (IS_IMMORTAL(ch)) ch->timer = 0; if ( ++ch->timer >= 12 ) { if ( ch->was_in_room == NULL && ch->in_room != NULL ) { ch->was_in_room = ch->in_room; if ( ch->fighting != NULL ) stop_fighting( ch, TRUE ); act( "$n disappears into the void.", ch, NULL, NULL, TO_ROOM ); send_to_char( "You disappear into the void.\n\r", ch ); if (ch->level > 1) save_char_obj( ch ); char_from_room( ch ); char_to_room( ch, get_room_index( ROOM_VNUM_LIMBO ) ); } } gain_condition( ch, COND_DRUNK, -1 ); gain_condition( ch, COND_FULL, ch->size > SIZE_MEDIUM ? -4 : -2 ); gain_condition( ch, COND_THIRST, -1 ); gain_condition( ch, COND_HUNGER, ch->size > SIZE_MEDIUM ? -2 : -1); } for ( paf = ch->affected; paf != NULL; paf = paf_next ) { paf_next = paf->next; if ( paf->duration > 0 ) { paf->duration--; if (number_range(0,4) == 0 && paf->level > 0) paf->level--; /* spell strength fades with time */ } else if ( paf->duration < 0 ) ; else { if ( paf_next == NULL || paf_next->type != paf->type || paf_next->duration > 0 ) { if ( paf->type > 0 && skill_table[paf->type].msg_off ) { send_to_char( skill_table[paf->type].msg_off, ch ); send_to_char( "\n\r", ch ); } } affect_remove( ch, paf ); } } /* * Careful with the damages here, * MUST NOT refer to ch after damage taken, * as it may be lethal damage (on NPC). */ if (is_affected(ch, gsn_plague) && ch != NULL) { AFFECT_DATA *af, plague; CHAR_DATA *vch; int dam; if (ch->in_room == NULL) continue; act("$n writhes in agony as plague sores erupt from $s skin.", ch,NULL,NULL,TO_ROOM); send_to_char("You writhe in agony from the plague.\n\r",ch); for ( af = ch->affected; af != NULL; af = af->next ) { if (af->type == gsn_plague) break; } if (af == NULL) { REMOVE_BIT(ch->affected_by,AFF_PLAGUE); continue; } if (af->level == 1) continue; plague.where = TO_AFFECTS; plague.type = gsn_plague; plague.level = af->level - 1; plague.duration = number_range(1,2 * plague.level); plague.location = APPLY_STR; plague.modifier = -5; plague.bitvector = AFF_PLAGUE; for ( vch = ch->in_room->people; vch != NULL; vch = vch->next_in_room) { if (!saves_spell(plague.level - 2,vch,DAM_DISEASE) && !IS_IMMORTAL(vch) && !IS_AFFECTED(vch,AFF_PLAGUE) && number_bits(4) == 0) { send_to_char("You feel hot and feverish.\n\r",vch); act("$n shivers and looks very ill.",vch,NULL,NULL,TO_ROOM); affect_join(vch,&plague); } } dam = UMIN(ch->level,af->level/5+1); ch->mana -= dam; ch->move -= dam; damage( ch, ch, dam, gsn_plague,DAM_DISEASE,FALSE); } else if ( IS_AFFECTED(ch, AFF_POISON) && ch != NULL && !IS_AFFECTED(ch,AFF_SLOW)) { AFFECT_DATA *poison; poison = affect_find(ch->affected,gsn_poison); if (poison != NULL) { act( "$n shivers and suffers.", ch, NULL, NULL, TO_ROOM ); send_to_char( "You shiver and suffer.\n\r", ch ); damage(ch,ch,poison->level/10 + 1,gsn_poison, DAM_POISON,FALSE); } } else if ( ch->position == POS_INCAP && number_range(0,1) == 0) { damage( ch, ch, 1, TYPE_UNDEFINED, DAM_NONE,FALSE); } else if ( ch->position == POS_MORTAL ) { damage( ch, ch, 1, TYPE_UNDEFINED, DAM_NONE,FALSE); } } /* * Autosave and autoquit. * Check that these chars still exist. */ for ( ch = char_list; ch != NULL; ch = ch_next ) { ch_next = ch->next; if (ch->desc != NULL && ch->desc->descriptor % 30 == save_number) { save_char_obj(ch); } if (ch == ch_quit) { do_function(ch, &do_quit, "" ); } } return; }
/* * Inflict damage from a hit. */ int damage(CHAR_DATA *ch,CHAR_DATA *victim,int dam,int dt,int dam_type, bool show, int agg, int combo) { /*OBJ_DATA *corpse;*/ bool immune; if ( victim->position == P_DEAD ) return P_DEAD; /* @@@@@ FIX TORPOR if ( victim->position == P_TORPOR ) return P_TORPOR; */ /* damage reduction */ if ( dam > 15) dam = (dam - 5)/2 + 5; if(IS_SET(ch->form, FORM_HORRID)) dam++; /* @@@@@ FIX BITE DAMAGE FOR SERPENTIS 3 if(is_affected(ch, skill_lookup("skin of the adder")) && dam_type == DAM_BITE) dam++; */ /* In case of -ve agg ratings */ if (agg < 0) agg = 0; /* soakage */ dam = do_soak(victim, dam, agg); if ( victim != ch ) { if ( victim->position > P_STUN ) { if ( victim->fighting == NULL ) { set_fighting( victim, ch ); if ( IS_NPC( victim ) && HAS_TRIGGER( victim, TRIG_KILL ) ) mp_percent_trigger( victim, ch, NULL, NULL, TRIG_KILL ); } if (victim->timer <= 4) victim->position = P_FIGHT; } if ( victim->position > P_STUN ) { if ( ch->fighting == NULL ) set_fighting( ch, victim ); } /* * More charm stuff. */ if ( victim->master == ch ) stop_follower( victim ); } /* * Inviso attacks ... not. */ if ( IS_AFFECTED(ch, AFF_INVISIBLE) ) { affect_strip( ch, gsn_invis ); REMOVE_BIT( ch->affected_by, AFF_INVISIBLE ); act( "$n fades into existence.", ch, NULL, NULL, TO_ROOM, 0 ); } /* * Damage modifiers. */ if ( dam > 1 && !IS_NPC(victim) && victim->condition[COND_DRUNK] > 10 ) dam = 9 * dam / 10; if ( dam > 1 && !IS_NPC(victim) && victim->condition[COND_HIGH] > 10 ) dam = 9 * dam / 10; if ( dam > 1 && ((IS_AFFECTED(victim, AFF_PROTECT_EVIL) && !IS_NATURAL(ch) )) ) dam -= dam / 4; immune = FALSE; /* * Check for parry, and dodge. if ( dt >= TYPE_HIT && ch != victim) { if ( check_parry( ch, victim ) ) return -1; if ( check_dodge( ch, victim ) ) return -1; } */ switch(check_immune(victim,dam_type)) { case(IS_IMMUNE): immune = TRUE; dam = 0; break; case(IS_RESISTANT): dam -= dam/3; break; case(IS_VULNERABLE): dam += dam/2; break; } if (show) dam_message( ch, victim, dam, dt, immune, combo ); if(dam > (victim->health + victim->agghealth -7)) { victim->position = P_MORT; stop_fighting(ch, TRUE); } else if(dam == (victim->health + victim->agghealth -7)) { victim->position = P_INCAP; stop_fighting(ch, TRUE); } if (dam == 0) return -1; else if(IS_SET(ch->off_flags, BANDAGED)) REMOVE_BIT(ch->off_flags, BANDAGED); /* * Hurt the victim. * Inform the victim of his new state. */ if( (victim->race == race_lookup("vampire")) && (dt == DAM_FIRE) ) { victim->agghealth -= dam; update_pos( victim, UMAX(1, agg) ); if(agg <= 0) agg = 1; } else if( (victim->race == race_lookup("werewolf")) && (dt == DAM_SILVER) ) { victim->agghealth -= dam; update_pos( victim, UMAX(1, agg) ); if(agg <= 0) agg = 1; } else if( (victim->race == race_lookup("faerie")) && (dt == DAM_IRON) ) { victim->health -= dam; victim->GHB += dam/3; update_pos( victim, agg ); } else if(agg) { victim->agghealth -= dam; update_pos( victim, agg ); } else { victim->health -= dam; update_pos( victim, 0 ); } switch( victim->position ) { case P_MORT: act( "$n is mortally wounded, and will die soon, if not aided.", victim, NULL, NULL, TO_ROOM, 0 ); send_to_char("You are mortally wounded, and may die soon, if not aided.\n\r", victim ); break; case P_INCAP: act( "$n is incapacitated and will slowly die, if not aided.", victim, NULL, NULL, TO_ROOM, 0 ); send_to_char("You are incapacitated and will slowly die, if not aided.\n\r", victim ); break; case P_TORPOR: act( "$n is mortally wounded, and will slowly die if not aided.", victim, NULL, NULL, TO_ROOM, 0 ); send_to_char("You enter torpor.\n\r", victim ); break; case P_STUN: act( "$n is stunned, but will probably recover.", victim, NULL, NULL, TO_ROOM, 0 ); send_to_char("You are stunned, but will probably recover.\n\r", victim ); break; case P_DEAD: act( "$n is DEAD!!", victim, 0, 0, TO_ROOM, 0 ); send_to_char( "You have been KILLED!!\n\r\n\r", victim ); break; default: if ( dam > MAX_HEALTH / 4 ) send_to_char( "That really did HURT!\n\r", victim ); if ( (victim->health + victim->agghealth - 7) < MAX_HEALTH / 4 ) send_to_char( "You sure are BLEEDING!\n\r", victim ); break; } if(dam_type == DAM_FIRE) fire_effect((void *) victim, agg+dam/2, dam, TARGET_CHAR); if(dam_type == DAM_COLD) cold_effect((void *) victim, agg+dam/2, dam, TARGET_CHAR); if(dam_type == DAM_LIGHTNING) shock_effect((void *) victim, agg+dam/2, dam, TARGET_CHAR); if(dam_type == DAM_ACID) acid_effect((void *) victim, agg+dam/2, dam, TARGET_CHAR); if(dam_type == DAM_POISON) poison_effect((void *) victim, agg+dam/2, dam, TARGET_CHAR); /* * Sleep spells and extremely wounded folks. */ if ( !IS_AWAKE(victim) ) stop_fighting( victim, FALSE ); /* * Payoff for killing things. */ if ( (victim->position == P_INCAP && IS_NPC(victim)) || victim->position == P_DEAD || victim->position == P_TORPOR ) { if ( !IS_NPC(victim) ) { log_string( LOG_GAME, Format("%s killed by %s at %d", victim->name, (IS_NPC(ch) ? ch->short_descr : ch->name), ch->in_room->vnum) ); } snprintf( log_buf, 2*MIL, "\tY[WIZNET]\tn %s got toasted by %s at %s [room %d]", (IS_NPC(victim) ? victim->short_descr : victim->name), (IS_NPC(ch) ? ch->short_descr : ch->name), ch->in_room->name, ch->in_room->vnum); if (IS_NPC(victim)) wiznet(log_buf,NULL,NULL,WIZ_MOBDEATHS,0,0); else wiznet(log_buf,NULL,NULL,WIZ_DEATHS,0,0); /* * Death trigger */ if ( IS_NPC( victim ) && HAS_TRIGGER( victim, TRIG_DEATH) ) { victim->position = P_STAND; mp_percent_trigger( victim, ch, NULL, NULL, TRIG_DEATH ); } if((!str_cmp(ch->description, "") || strlen(ch->description) < 10) && ch->played > 10*60*60) { send_to_char("No experience without a description.\n\r", ch); } else { if(ch->ooc_xp_count < 2) { send_to_char("You learn from your encounter.\n\r", ch); ch->oocxp += 1; ch->ooc_xp_count++; } else if(IS_SET(victim->act2, ACT2_HUNTER) && ch->ooc_xp_count < 50) { send_to_char("You learn from your encounter.\n\r", ch); ch->exp += 1; ch->ooc_xp_count++; } } if(ch->quest) { if(ch->quest->quest_type == Q_HITMAN && ch->quest->victim == victim) (*quest_table[ch->quest->quest_type].q_fun) (ch, 2); if(victim->quest != NULL && victim->quest->quest_type == Q_HITMAN && victim->quest->victim == victim && victim->quest->questor != ch) (*quest_table[victim->quest->quest_type].q_fun) (victim->quest->questor, 3); if(victim->quest != NULL && (victim->quest->quest_type == Q_BODYGUARD || victim->quest->quest_type == Q_RESCUE) && victim->quest->victim == victim) (*quest_table[victim->quest->quest_type].q_fun) (victim->quest->questor, 3); } if(victim->position != P_TORPOR || agg) update_pos( victim, agg ); return victim->position; } if ( victim == ch ) return ch->position; /* Link dead salvation. */ if ( !IS_NPC(victim) && victim->desc == NULL ) { do_function(victim, &do_flee,""); } tail_chain( ); return victim->position; }
/* procedure for all mobile attacks */ void mob_hit (CHAR_DATA *ch, CHAR_DATA *victim, int dt) { int number; CHAR_DATA *vch, *vch_next; one_hit(ch,victim,dt); if (ch->fighting != victim) return; /* Area attack -- BALLS nasty! */ if (IS_SET(ch->off_flags,OFF_AREA_ATTACK)) { for (vch = ch->in_room->people; vch != NULL; vch = vch_next) { vch_next = vch->next; if ((vch != victim && vch->fighting == ch)) one_hit(ch,vch,dt); } } if (ch->fighting != victim || dt == gsn_backstab) return; /* oh boy! Fun stuff! */ if (ch->wait > 0) return; /* now for the skills */ number = number_range(0,8); switch(number) { case (0) : if (IS_SET(ch->off_flags,OFF_BASH)) do_function(ch, &do_bash,""); break; case (1) : break; case (2) : if (IS_SET(ch->off_flags,OFF_DISARM) || (get_weapon_sn(ch) != gsn_brawl )) do_function(ch, &do_disarm,""); break; case (3) : if (IS_SET(ch->off_flags,OFF_KICK)) do_function(ch, &do_kick,""); break; case (4) : if (IS_SET(ch->off_flags,OFF_KICK_DIRT)) do_function(ch, &do_dirt,""); break; case (5) : if (IS_SET(ch->off_flags,OFF_TAIL)) { /* do_tail(ch,"") */ ; } break; case (6) : if (IS_SET(ch->off_flags,OFF_TRIP)) do_function(ch, &do_trip,""); break; case (7) : if (IS_SET(ch->off_flags,OFF_CRUSH)) { /* do_crush(ch,"") */ ; } break; case (8) : if (IS_SET(ch->off_flags,OFF_BACKSTAB)) { do_function(ch, &do_backstab,""); } } }
/* for auto assisting */ void check_assist(CHAR_DATA *ch,CHAR_DATA *victim) { CHAR_DATA *rch, *rch_next; for (rch = ch->in_room->people; rch != NULL; rch = rch_next) { rch_next = rch->next_in_room; if (IS_AWAKE(rch) && rch->fighting == NULL && SAME_PLANE(ch,victim)) { if (!IS_NPC(ch) || IS_AFFECTED(ch,AFF_CHARM)) { if ( IS_AFFECTED(rch,AFF_CHARM) && is_same_group(ch,rch) ) multi_hit (rch,victim,TYPE_UNDEFINED); continue; } /* quick check for ASSIST_PLAYER */ if (!IS_NPC(ch) && IS_NPC(rch) && IS_SET(rch->off_flags,ASSIST_PLAYERS)) { do_function(rch, &do_emote,"screams and attacks!"); multi_hit(rch,victim,TYPE_UNDEFINED); continue; } /* now check the NPC cases */ if (IS_NPC(ch) && !IS_AFFECTED(ch,AFF_CHARM)) { if ( (IS_NPC(rch) && IS_SET(rch->off_flags,ASSIST_ALL)) || (IS_NPC(rch) && rch->group && rch->group == ch->group) || (IS_NPC(rch) && rch->race == ch->race && (rch->race != victim->race)) || (rch->pIndexData == ch->pIndexData && IS_SET(rch->off_flags,ASSIST_VNUM))) { CHAR_DATA *vch; CHAR_DATA *target; int number; if (number_bits(1) == 0) continue; target = NULL; number = 0; for (vch = ch->in_room->people; vch; vch = vch->next) { if (can_see(rch,vch) && is_same_group(vch,victim) && number_range(0,number) == 0) { target = vch; number++; } } if (target != NULL) { do_function(rch, &do_emote,"leaps into the fray!"); multi_hit(rch,target,TYPE_UNDEFINED); } } } } } }