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 warpbonus_driver(int in,int cn) { int ID,n,old_n=0,old_val=0,level,in2=0,in3; struct warped_ppd *ppd; if (!cn) return; ppd=set_data(cn,DRD_WARP_PPD,sizeof(struct warped_ppd)); if (!ppd) return; // oops... if (!ppd->base) ppd->base=40; if (ppd->base>139) { log_char(cn,LOG_SYSTEM,0,"You're done. Finished. It's over. You're there. You've solved the final level."); return; } ID=(int)it[in].x+((int)(it[in].y)<<8)+(areaID<<16); for (n=0; n<MAXWARPBONUS; n++) { if (ppd->bonusID[n]==ID) break; if (realtime-ppd->bonuslast_used[n]>old_val) { old_val=realtime-ppd->bonuslast_used[n]; old_n=n; } } if (n==MAXWARPBONUS) n=old_n; else if (ppd->bonuslast_used[n]>=ppd->base) { log_char(cn,LOG_SYSTEM,0,"Nothing happened."); return; } if (ppd->points+1>=ppd->base/4 && (!(in2=ch[cn].citem) || it[in2].ID!=IID_AREA25_TELEKEY)) { log_char(cn,LOG_SYSTEM,0,"Nothing happened. You sense that you'll need one of the spheres this time."); return; } ppd->bonusID[n]=ID; ppd->bonuslast_used[n]=ppd->base; level=min(ch[cn].level,(int)(ppd->base*0.80)); ppd->points++; if (ppd->points>=ppd->base/4) { ppd->points=0; ppd->base+=5; ppd->nostepexp=0; if (ppd->base>139) log_char(cn,LOG_SYSTEM,0,"You've finished the final level."); else if (ppd->base>134) log_char(cn,LOG_SYSTEM,0,"You've reached the final level."); else log_char(cn,LOG_SYSTEM,0,"You advanced a level! Take care!"); if (in2 && it[in2].ID==IID_AREA25_TELEKEY) { switch(it[in2].drdata[0]) { case 1: give_exp_bonus(cn,level_value(level)/7); log_char(cn,LOG_SYSTEM,0,"You received experience."); break; case 2: if (ch[cn].saves<10 && !(ch[cn].flags&CF_HARDCORE)) { ch[cn].saves++; log_char(cn,LOG_SYSTEM,0,"You received a save."); } break; case 3: log_char(cn,LOG_SYSTEM,0,"You received military rank."); give_military_pts_no_npc(cn,level,0); break; case 4: ch[cn].gold+=level*level*10; ch[cn].flags|=CF_ITEMS; log_char(cn,LOG_SYSTEM,0,"You received %d gold.",level*level/10); break; case 5: in3=create_item("lollipop"); if (give_char_item(cn,in3)) log_char(cn,LOG_SYSTEM,0,"You received a lollipop."); else destroy_item(in3); break; } } if (ppd->base>139) return; } else if (!ppd->nostepexp) give_exp_bonus(cn,level_value(level)/70); log_char(cn,LOG_SYSTEM,0,"You are at level %d, and you have %d of %d points.",(ppd->base-35)/5,ppd->points,ppd->base/4); }
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); }