int questlog_done(int cn,int qnr) { struct quest *quest; int cnt,val; if (qnr<0 || qnr>=MAXQUEST) { elog("trying to set done for quest %d",qnr); btrace("questlog"); return 0; } if (!(quest=set_data(cn,DRD_QUESTLOG_PPD,sizeof(struct quest)*MAXQUEST))) return 0; cnt=quest[qnr].done++; quest[qnr].flags=QF_DONE; val=questlog_scale(cnt,questlog[qnr].exp); // scale down by level for those rushing ahead if (ch[cn].level>44) val=min(level_value(ch[cn].level)/6,val); else if (ch[cn].level>19) val=min(level_value(ch[cn].level)/4,val); else if (ch[cn].level>4) val=min(level_value(ch[cn].level)/2,val); else val=min(level_value(ch[cn].level),val); give_exp(cn,val); if (questlog[qnr].exp>0) dlog(cn,0,"Received %d exp for doing quest %s for the %d. time (nominal value %d exp)",val,questlog[qnr].name,(cnt+1),questlog[qnr].exp); sendquestlog(cn,ch[cn].player); return quest[qnr].done; }
void disco() { bool old_flip; mob_t * m; int i; pwait("THIS LOOKS LIKE A DANCE FLOOR!"); stile(player->y, player->x, TL_VOID); m = player; old_flip = m->flip; m->flip = true; m->type = MOB_DANCER; draw_board(); opause(); for (i = 0; i < 9; i++) { stile(m->y - 5 + i % 2, m->x - 4 + i, TL_DISCOLIGHT1 + i); draw_board(); lpause(); } NOW_DANCE(0); NOW_DANCE(1); NOW_DANCE(0); NOW_DANCE(1); DANCE_FLIP(); NOW_DANCE(0); NOW_DANCE(1); NOW_DANCE(0); NOW_DANCE(1); NOW_DANCE(0); NOW_DANCE(10); NOW_DANCE(11); NOW_DANCE(12); DANCE_FLIP(); NOW_DANCE(11); NOW_DANCE(10); NOW_DANCE(11); NOW_DANCE(12); DANCE_FLIP(); NOW_DANCE(11); DANCE_FLIP(); NOW_DANCE(20); NOW_DANCE(21); NOW_DANCE(20); NOW_DANCE(22); DANCE_FLIP(); NOW_DANCE(20); NOW_DANCE(21); NOW_DANCE(20); NOW_DANCE(22); // DANCE_FLIP(); m->x -= 1; NOW_DANCE(30); DANCE_FLIP(); m->x += 1; NOW_DANCE(30); DANCE_FLIP(); m->x += 1; NOW_DANCE(30); DANCE_FLIP(); m->x -= 1; NOW_DANCE(30); DANCE_FLIP(); m->x -= 1; NOW_DANCE(30); DANCE_FLIP(); m->x += 1; NOW_DANCE(30); DANCE_FLIP(); m->x += 1; NOW_DANCE(30); DANCE_FLIP(); m->x -= 1; NOW_DANCE(30); DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); m->x += 1; DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); m->x += 1; DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); //DANCE_FLIP(); m->x -= 1; m->y -= 1; NOW_DANCE(40); m->x -= 1; NOW_DANCE(40); m->x -= 1; m->y += 1; NOW_DANCE(40); DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); m->x += 1; m->y -= 1; NOW_DANCE(40); m->x += 1; NOW_DANCE(40); m->x += 1; m->y += 1; NOW_DANCE(40); NOW_DANCE(50); m->x -= 1; NOW_DANCE(51); NOW_DANCE(50); m->x -= 1; NOW_DANCE(51); NOW_DANCE(50); m->x -= 1; NOW_DANCE(51); NOW_DANCE(50); m->x -= 1; NOW_DANCE(51); NOW_DANCE(50); // NOW_DANCE(51); DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); m->x += 1; DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); m->x += 1; DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); NOW_DANCE(60); DANCE_FLIP(); NOW_DANCE(60); m->y += 1; NOW_DANCE(60); DANCE_FLIP(); m->y -= 1; NOW_DANCE(70); lpause(); NOW_DANCE(71); lpause(); NOW_DANCE(70); lpause(); NOW_DANCE(71); opause(); for (i = 0; i < 9; i++) { stile(m->y - 5, m->x - 4 + i, TL_VOID); stile(m->y - 4, m->x - 4 + i, TL_VOID); } m->type = MOB_PLAYER; m->flags = 0; m->flip = old_flip; draw_board(); lpause(); char line[DEFLEN]; snprintf(line, DEFLEN, "YOU GET %d EXPERIENCE", DISCO_EXP); pwait(line); draw_board(); give_exp(DISCO_EXP); draw_stats(); return; }
void fountain() { char line[DEFLEN]; char liquid[DEFLEN]; char * insert; int temp; int blood; int rlen; blood = (gtile(player->y, player->x) == TL_P_BLOOD_FOUNTAIN); snprintf(liquid, DEFLEN, "%s", blood ? "BLOOD" : "WATER"); stile(player->y, player->x, TL_FOUNT_BASE); stile(player->y - 1, player->x, TL_VOID); stile(player->y - 2, player->x, TL_VOID); stile(player->y - 2, player->x - 1, TL_VOID); stile(player->y - 2, player->x + 1, TL_VOID); snprintf(line, DEFLEN, "YOU DRINK FROM THE %sFOUNTAIN\n\n", (blood ? "BLOOD " : "")); rlen = strlen(line); insert = &line[rlen]; rlen = DEFLEN - rlen; draw_board(); switch (rand() % 10) { case 0: snprintf(insert, rlen, "THE %s TASTES FOUL!!", liquid); pwait(line); player->flags = GFX_HURT; draw_board(); lpause(); player->flags = 0; player->hp -= 1 + rand() % 10; draw_bars(); if (player->hp <= 0) { draw_board(); game_over("YOU DIED FROM A\n" "POISONED FOUNTAIN", false); } break; case 1: snprintf(insert, rlen, "THE %s TASTES BITTER!\n\nYOU FEEL SLOWER!", liquid); pwait(line); change_pl_sp(-1); draw_stats(); break; case 2: case 3: temp = 100 + (rand() % 5) * 100; temp += MAX(0, game->current_floor - 7) * 100; snprintf(insert, rlen, "THIS IS A FOUNTAIN OF WISDOM!\n\n" "YOU GET %d EXP", temp); pwait(line); draw_board(); give_exp(temp); break; case 4: case 5: snprintf(insert, rlen, "THE %s IS INVIGORATING!\n\nYOU FEEL STRONGER!", liquid); pwait(line); change_pl_st(+1); draw_stats(); break; default: snprintf(insert, rlen, "THE %s IS REFRESHING!", liquid); pwait(line); refill_hp(FOUNTAIN_HEAL); break; } return; }
void altar() { char line[DEFLEN]; int temp; char * p; stile(player->y, player->x, TL_GR_HL); /* Praying increases piety (hidden from the player); when the player has enough it will cause a beneficial effect. If the player chooses to loot the altar they will lose all piety. */ if (psel("YOU APPROACH THE ALTAR\n" "\n" "<- LOOT IT#PRAY ->") == 0) { stile(player->y - 2, player->x - 3, TL_VOID); stile(player->y - 2, player->x + 3, TL_VOID); stile(player->y - 3, player->x, TL_VOID); stile(player->y - 2, player->x - 1, TL_VOID); stile(player->y - 2, player->x, TL_VOID); stile(player->y - 2, player->x + 1, TL_VOID); draw_board(); give_gold("YOU LOOT THE ALTAR\n\n", 1 + rand() % ALTAR_LOOT_GOLD); game->piety -= ALTAR_LOOT_PENALTY + (rand() % ALTAR_LOOT_PENALTY); if (game->piety < -3000 && rand() % 3 == 0) { draw_board(); pwait("A MIGHTY VOICE BOOMS OUT:\n" "\"THOU HATH DEFILED MY ALTAR\n" " TOO MANY TIMES, MORTAL!\""); draw_board(); if (rand() % 2 == 0) { pwait("YOU ARE STRUCK BY LIGHTNING!"); draw_board(); lightning(player->y - view_y, player->x - view_x); player->hp -= 25 + rand() % 46; if (player->hp <= 0) game_over("YOU DIED FOR YOUR SINS", false); draw_bars(); } else { pwait("YOU FEEL WEAK!"); player->strength = MAX(1, player->strength - 1 - rand() % 3); player->speed = MAX(1, player->speed - 1 - rand() % 3); } } else if (game->piety < -2000 && rand() % 3 == 0) { tremor(5); draw_board(); pwait("YOU HEAR A RUMBLE IN THE DISTANCE"); } else if (game->piety < -1000 && rand() % 3 == 0) { draw_board(); pwait("YOU GET AN UNEASY FEELING"); } } else { stile(player->y - 3, player->x - 1, TL_YDOT); stile(player->y - 3, player->x, TL_YDOT); stile(player->y - 3, player->x + 1, TL_YDOT); // Update board with lit candles draw_board(); strcpy(line, "YOU PRAY AT THE ALTAR"); if (game->piety < 0) game->piety += 500; game->piety += ALTAR_PRAYER_PIETY + (rand() % ALTAR_PRAYER_PIETY); if (game->piety < 0) { strcat(line, "\n\nYOU ARE LEFT WITH A DISAPPROVING\n" "SENSATION OF EMPTINESS"); pwait(line); } else if (rand() % MAX(1, game->piety) > ALTAR_HEAL_PIETY) { game->piety -= ALTAR_HEAL_PIETY; strcat(line, "\n\n YOU ARE EMBRACED BY\n" " A WARM FEELING! "); pwait(line); draw_board(); refill_hp(ALTAR_EMBRACE_HEAL); } else if (rand() % MAX(1, game->piety) > ALTAR_WISDOM_PIETY) { game->piety -= ALTAR_WISDOM_PIETY; temp = (1 + rand() % game->current_floor) * 100; temp += MAX(0, game->current_floor - 7) * 200; // Find end of string for (p = line; *p != '\0'; p++) { } sprintf(p, "\n\nYOU HAVE BEEN ENLIGHTENED!\n\n" "YOU GET %d EXP", temp); pwait(line); draw_board(); give_exp(temp); } else { pwait(line); } } return; }
void stone_tablet() { char line[DEFLEN]; int seq[15]; int inp_seq[15]; int i; int states = 7; int exp; pwait("YOU FIND A MYSTERIOUS STONE TABLET"); stile(player->y, player->x, TL_VOID); stile(player->y - 1, player->x, TL_VOID); states = game->tablet_diff; draw_tablet(-1); pwait("REPEAT THE SEQUENCE\n" "USING THE DIRECTIONAL KEYS"); draw_tablet(-1); for (i = 0; i < states; i++) { opause(); seq[i] = rand() % 4; draw_tablet(seq[i]); opause(); draw_tablet(-1); } for (i = 0; i < states; i++) { int gk; gk = getch(); if (gk == KEY_UP) inp_seq[i] = 0; else if (gk == KEY_RIGHT) inp_seq[i] = 1; else if (gk == KEY_DOWN) inp_seq[i] = 2; else if (gk == KEY_LEFT) inp_seq[i] = 3; else { snprintf(lowmsg, DEFLEN, "INVALID INPUT"); draw_lowmsg(); continue; } if (inp_seq[i] != seq[i]) { lpause(); board_attr(A_REVERSE | A_BOLD, PAIR_RED); wrefresh(board); pwait("SHIT"); draw_board(); return; } else { draw_tablet(seq[i]); opause(); draw_tablet(-1); flush_input(); } } draw_board(); switch (states) { case 7: exp = 1000; break; case 8: exp = 2000; break; case 9: exp = 3000; break; default: exp = 1000; break; } snprintf(line, DEFLEN, "YOU HAVE DECODED THE MYSTIC RUNES\n" "\nYOU GET %d EXP", exp); pwait(line); draw_board(); give_exp(exp); draw_stats(); // Make it harder next time game->tablet_diff += 1; draw_stats(); return; }
void kill_enemy(mob_t * target) { char line[DEFLEN]; bool boss = false; if (target->type == MOB_ARCHDEMON) boss = true; game->monsters_killed++; /* // This shouldn't be needed anymore with monster packing if (target->type == MOB_BRICKWALL) { // Remove the hidden placeholders so creatures can move through the cleared area stile(target->y, target->x - 3, TL_VOID); stile(target->y, target->x + 3, TL_VOID); } */ if (boss) { snprintf(line, DEFLEN, "YOU HAVE SLAIN %s%s!!!", article[target->article], mob_name[target->type]); /* Don't remove boss */ } else { snprintf(line, DEFLEN, "YOU HAVE SLAIN %s%s\n" "\n" "YOU GET %d EXP", article[target->article], mob_name[target->type], target->exp); target->type = MOB_NONE; } draw_board(); enemy_bar = -1; draw_bars(); pwait(line); draw_board(); if (boss) { pwait("YOU HAVE WON!!!"); game_over(NULL, true); //shutdown(); // exit(0); } give_exp(target->exp); return; }
void smugglecom_driver(int cn,int ret,int lastact) { struct smugglecom_data *dat; struct staffer_ppd *ppd; int co,in,didsay=0,talkdir=0; struct msg *msg,*next; dat=set_data(cn,DRD_SMUGGLECOMDRIVER,sizeof(struct smugglecom_data)); if (!dat) return; // oops... // loop through our messages for (msg=ch[cn].msg; msg; msg=next) { next=msg->next; // did we see someone? if (msg->type==NT_CHAR) { co=msg->dat1; // dont talk to other NPCs if (!(ch[co].flags&CF_PLAYER)) { remove_message(cn,msg); continue; } // dont talk to players without connection if (ch[co].driver==CDR_LOSTCON) { remove_message(cn,msg); continue; } // only talk every ten seconds if (ticker<dat->last_talk+TICKS*4) { remove_message(cn,msg); continue; } if (ticker<dat->last_talk+TICKS*10 && dat->current_victim!=co) { remove_message(cn,msg); continue; } // dont talk to someone we cant see, and dont talk to ourself if (!char_see_char(cn,co) || cn==co) { remove_message(cn,msg); continue; } // dont talk to someone far away if (char_dist(cn,co)>10) { remove_message(cn,msg); continue; } // get current status with player ppd=set_data(co,DRD_STAFFER_PPD,sizeof(struct staffer_ppd)); if (ppd) { switch(ppd->smugglecom_state) { case 0: quiet_say(cn,"Greetings, %s!",ch[co].name); questlog_open(co,35); ppd->smugglecom_state++; didsay=1; break; case 1: quiet_say(cn,"I want you to find a book for me called 'the contraband book', which contains the names of four of the smuggler's most precious items."); ppd->smugglecom_state++; didsay=1; break; case 2: //quiet_say(cn,"Also, I will reward you for every piece of contraband you bring me. "); //ppd->smugglecom_state++; didsay=1; //break; // fall through intended for now case 3: quiet_say(cn,"Go now, and may Ishtar be with you."); ppd->smugglecom_state=4; didsay=1; break; case 4: break; case 5: if (questlog_isdone(co,36)) { ppd->smugglecom_state=7; break; } quiet_say(cn,"It lists four important items which I want you to retrieve: the Rainbow Pearls, the Crimson Ring, the Leopard Cape, and the Emerald Necklace. Find them, and bring them to me."); questlog_open(co,36); ppd->smugglecom_state++; didsay=1; break; case 6: if (ppd->smugglecom_bits==15) { ppd->smugglecom_state++; questlog_done(co,36); } break; case 7: quiet_say(cn,"Thank you, you are of great help in hurting the smuggler's operations."); if (questlog_isdone(co,37)) { ppd->smugglecom_state=10; break; } quiet_say(cn,"Now, as a final task, I want you to kill the smuggler's leader. Good luck!"); questlog_open(co,37); ppd->smugglecom_state++; didsay=1; break; case 8: break; case 9: quiet_say(cn,"Thank you for helping us, %s, you have been of great value.",ch[co].name); ppd->smugglecom_state++; didsay=1; questlog_done(co,37); break; case 10: break; } if (didsay) { dat->last_talk=ticker; talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y); dat->current_victim=co; notify_area(ch[cn].x,ch[cn].y,NT_NPC,NTID_DIDSAY,cn,0); } } } // talk back if (msg->type==NT_TEXT) { co=msg->dat3; if (ch[co].flags&CF_PLAYER) { ppd=set_data(co,DRD_STAFFER_PPD,sizeof(struct staffer_ppd)); switch((didsay=analyse_text_driver(cn,msg->dat1,(char*)msg->dat2,co))) { case 2: if (ppd && ppd->smugglecom_state<=4) { dat->last_talk=0; ppd->smugglecom_state=0; } if (ppd && ppd->smugglecom_state>=5 && ppd->smugglecom_state<=6) { dat->last_talk=0; ppd->smugglecom_state=5; } if (ppd && ppd->smugglecom_state>=7 && ppd->smugglecom_state<=8) { dat->last_talk=0; ppd->smugglecom_state=7; } break; case 3: if (ch[co].flags&CF_GOD) ppd->smugglecom_bits=ppd->smugglecom_state=0; break; } if (didsay) { talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y); dat->current_victim=co; } } } // got an item? if (msg->type==NT_GIVE) { co=msg->dat1; if ((in=ch[cn].citem)) { // we still have it int val; ppd=set_data(co,DRD_STAFFER_PPD,sizeof(struct staffer_ppd)); if (it[in].ID==IID_STAFF_SMUGGLEBOOK && ppd && ppd->smugglecom_state<=4 && (ch[co].flags&CF_PLAYER)) { quiet_say(cn,"Thank you for the book, %s.",ch[co].name); questlog_done(co,35); destroy_item_byID(co,IID_STAFF_SMUGGLEBOOK); ppd->smugglecom_state=5; } else if (it[in].ID==IID_STAFF_SMUGGLEPEARLS && ppd && !(ppd->smugglecom_bits&SMUGGLEBIT_PEARLS) && (ch[co].flags&CF_PLAYER)) { quiet_say(cn,"Thank you for bringing back the %s, %s.",it[in].name,ch[co].name); val=questlog_scale(questlog_count(co,36),1000); dlog(co,0,"Received %d exp for doing quest Contraband I for the %d. time (nominal value %d exp)",val,questlog_count(co,36)+1,1000); give_exp(co,min(val,level_value(ch[co].level)/4)); ppd->smugglecom_bits|=SMUGGLEBIT_PEARLS; } else if (it[in].ID==IID_STAFF_SMUGGLERING && ppd && !(ppd->smugglecom_bits&SMUGGLEBIT_RING) && (ch[co].flags&CF_PLAYER)) { quiet_say(cn,"Thank you for bringing back the %s, %s.",it[in].name,ch[co].name); val=questlog_scale(questlog_count(co,36),1000); dlog(co,0,"Received %d exp for doing quest Contraband II for the %d. time (nominal value %d exp)",val,questlog_count(co,36)+1,1000); give_exp(co,min(val,level_value(ch[co].level)/4)); ppd->smugglecom_bits|=SMUGGLEBIT_RING; } else if (it[in].ID==IID_STAFF_SMUGGLECAPE && ppd && !(ppd->smugglecom_bits&SMUGGLEBIT_CAPE) && (ch[co].flags&CF_PLAYER)) { quiet_say(cn,"Thank you for bringing back the %s, %s.",it[in].name,ch[co].name); val=questlog_scale(questlog_count(co,36),1000); dlog(co,0,"Received %d exp for doing quest Contraband III for the %d. time (nominal value %d exp)",val,questlog_count(co,36)+1,1000); give_exp(co,min(val,level_value(ch[co].level)/4)); ppd->smugglecom_bits|=SMUGGLEBIT_CAPE; } else if (it[in].ID==IID_STAFF_SMUGGLENECKLACE && ppd && !(ppd->smugglecom_bits&SMUGGLEBIT_NECKLACE) && (ch[co].flags&CF_PLAYER)) { quiet_say(cn,"Thank you for bringing back the %s, %s.",it[in].name,ch[co].name); val=questlog_scale(questlog_count(co,36),1000); dlog(co,0,"Received %d exp for doing quest Contraband IV for the %d. time (nominal value %d exp)",val,questlog_count(co,36)+1,1000); give_exp(co,min(val,level_value(ch[co].level)/4)); ppd->smugglecom_bits|=SMUGGLEBIT_NECKLACE; } else { quiet_say(cn,"Thou hast better use for this than I do. Well, if there is use for it at all."); if (give_char_item(co,ch[cn].citem)) ch[cn].citem=0; } // let it vanish, then if (ch[cn].citem) { destroy_item(ch[cn].citem); ch[cn].citem=0; } } } remove_message(cn,msg); } // do something. whenever possible, call do_idle with as high a tick count // as reasonable when doing nothing. dat->amgivingback=0; if (talkdir) turn(cn,talkdir); if (dat->last_talk+TICKS*30<ticker) { if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_LEFT,ret,lastact)) return; } do_idle(cn,TICKS); }