예제 #1
0
void winner_gets_item(int cc,int co)
{
	int in,rnd;

        if (!(ch[cc].flags&CF_USED)) return;
	if (!(ch[cc].flags&CF_PLAYER)) return;
	
	if (!(ch[co].flags&CF_USED)) return;
	if (!(ch[co].flags&CF_PLAYER)) return;

        rnd=RANDOM(12);

        if (!(in=ch[co].item[rnd])) return;
	if (!count_enhancements(in)) return;
        if (give_char_item(cc,in)) {
		ch[co].item[rnd]=0;
		ch[co].flags|=CF_ITEMS;
		dlog(cc,in,"won in teufelheim PK from %s",ch[co].name);
		dlog(co,in,"lost in teufelheim PK to %s",ch[cc].name);
		log_char(cc,LOG_SYSTEM,0,"You won a %s from %s!",it[in].name,ch[co].name);
		log_char(co,LOG_SYSTEM,0,"%s won a %s from you!",ch[cc].name,it[in].name);
	}
}
예제 #2
0
void ruby_driver(int cn,int retval,int lastact)
{
        struct ruby_driver_data *dat;
	struct sidestory_ppd *ppd;
	struct msg *msg,*next;
	int co,ret,in;
	char *ptr;

        dat=set_data(cn,DRD_RUBYDRIVER,sizeof(struct ruby_driver_data));
	if (!dat) return;	// oops...

        // loop through our messages
	for (msg=ch[cn].msg; msg; msg=next) {
		next=msg->next;

                if (msg->type==NT_CREATE) {
                        ;
                }

		if (msg->type==NT_CHAR) {
                        co=msg->dat1;

			if ((ch[co].flags&CF_PLAYER) &&
			    ch[co].driver!=CDR_LOSTCON &&
			    char_dist(cn,co)<16 &&
			    char_see_char(cn,co) &&
			    (ticker-dat->last_time>TICKS*30 || dat->last_char==co) &&
			    (ppd=set_data(co,DRD_SIDESTORY_PPD,sizeof(struct sidestory_ppd)))) {
				switch(areaID) {
					case 2:		ret=do_story(cn,co,ppd,&ppd->ruby2,ruby2_story); break;
					case 3:		ret=ruby_aston_char(cn,co,ppd); break;
					case 5:		ret=do_story(cn,co,ppd,&ppd->ruby5,ruby5_story); break;
					case 6:		ret=do_story(cn,co,ppd,&ppd->ruby6,ruby6_story); break;
					case 8:		ret=do_story(cn,co,ppd,&ppd->ruby8,ruby8_story); break;
					case 10:	ret=do_story(cn,co,ppd,&ppd->ruby10,ruby10_story); break;
					case 11:	ret=do_story(cn,co,ppd,&ppd->ruby11,ruby11_story); break;
					case 12:	ret=do_story(cn,co,ppd,&ppd->ruby12,ruby12_story); break;
					case 15:	ret=do_story(cn,co,ppd,&ppd->ruby15,ruby15_story); break;
					case 16:	ret=do_story(cn,co,ppd,&ppd->ruby16,ruby16_story); break;
					case 17:	ret=do_story(cn,co,ppd,&ppd->ruby17,ruby17_story); break;

					default:	ret=0; break;
				}
				if (ret==1) {
					dat->last_char=co;
					dat->last_time=ticker;
				} else if (ret==2) {
					dat->last_char=dat->last_time=0;
				}
                        }
		}

		if (msg->type==NT_TEXT) {
			ptr=(char*)msg->dat2;
			co=msg->dat3;

			if ((ch[co].flags&CF_PLAYER) &&
			    ch[co].driver!=CDR_LOSTCON &&
			    char_dist(cn,co)<16 &&
			    char_see_char(cn,co) &&
			    (ppd=set_data(co,DRD_SIDESTORY_PPD,sizeof(struct sidestory_ppd)))) {
				switch(areaID) {
					case 2:		hear_story(cn,co,ppd,&ppd->ruby2,ruby2_story,ptr); break;
					case 3:		ruby_aston_text(cn,co,ppd,ptr); break;
					case 5:		hear_story(cn,co,ppd,&ppd->ruby5,ruby5_story,ptr); break;
					case 6:		hear_story(cn,co,ppd,&ppd->ruby6,ruby6_story,ptr); break;
					case 8:		hear_story(cn,co,ppd,&ppd->ruby8,ruby8_story,ptr); break;
					case 10:	hear_story(cn,co,ppd,&ppd->ruby10,ruby10_story,ptr); break;
					case 11:	hear_story(cn,co,ppd,&ppd->ruby11,ruby11_story,ptr); break;
					case 12:	hear_story(cn,co,ppd,&ppd->ruby12,ruby12_story,ptr); break;
					case 15:	hear_story(cn,co,ppd,&ppd->ruby15,ruby15_story,ptr); break;
					case 16:	hear_story(cn,co,ppd,&ppd->ruby16,ruby16_story,ptr); break;
					case 17:	hear_story(cn,co,ppd,&ppd->ruby17,ruby17_story,ptr); break;

				}

                        }
			
		}
		
		if (msg->type==NT_GIVE) {
			co=msg->dat1;

                        if ((in=ch[cn].citem)) {
				if ((ch[co].flags&CF_PLAYER) && (ppd=set_data(co,DRD_SIDESTORY_PPD,sizeof(struct sidestory_ppd)))) {
					switch(areaID) {
						case 2:		ret=give_story(cn,co,ppd,&ppd->ruby2,ruby2_story,in); break;
						case 5:		ret=give_story(cn,co,ppd,&ppd->ruby5,ruby5_story,in); break;
						case 6:		ret=give_story(cn,co,ppd,&ppd->ruby6,ruby6_story,in); break;
						case 8:		ret=give_story(cn,co,ppd,&ppd->ruby8,ruby8_story,in); break;
						case 10:	ret=give_story(cn,co,ppd,&ppd->ruby10,ruby10_story,in); break;
						case 11:	ret=give_story(cn,co,ppd,&ppd->ruby11,ruby11_story,in); break;
						case 12:	ret=give_story(cn,co,ppd,&ppd->ruby12,ruby12_story,in); break;
						case 15:	ret=give_story(cn,co,ppd,&ppd->ruby15,ruby15_story,in); break;
						case 16:	ret=give_story(cn,co,ppd,&ppd->ruby16,ruby16_story,in); break;
						case 17:	ret=give_story(cn,co,ppd,&ppd->ruby17,ruby17_story,in); break;


						default:	ret=0; break;
					}
				} else ret=0;
				
				ch[cn].citem=0;
				if (ret || !give_char_item(co,in)) {
					destroy_item(in);
				}
			}
		}

                standard_message_driver(cn,msg,0,0);
                remove_message(cn,msg);
	}

        // do something. whenever possible, call do_idle with as high a tick count
	// as reasonable when doing nothing.

        fight_driver_update(cn);

        if (fight_driver_attack_visible(cn,0)) return;
	if (fight_driver_follow_invisible(cn)) return;

	if (spell_self_driver(cn)) return;
	if (regenerate_driver(cn)) return;

	if (dat->last_time && map_dist(ch[cn].x,ch[cn].y,ch[cn].tmpx,ch[cn].tmpy)>16) dat->last_time=0;

	if (dat->last_char && !char_see_char(cn,dat->last_char)) dat->last_char=dat->last_time=0;

	if (ticker-dat->last_time<TICKS*60) {
		int dir;

		co=dat->last_char;

                dir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
	
		if (tile_char_dist(cn,co)>2 && move_driver(cn,ch[co].x,ch[co].y,2)) return;
		turn(cn,dir);		
	} else if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_RIGHT,retval,lastact)) return;

        do_idle(cn,TICKS/2);
}
예제 #3
0
int ruby_aston_char(int cn,int co,struct sidestory_ppd *ppd)
{
	int bitcount=0,bitvalue=0,n,didsay=0,in,val;
	unsigned int bit;

        if (realtime-ppd->ruby3.last_say<7) return 0;
	
	if (realtime-ppd->ruby3.last_see>60*5) ppd->ruby3.state=0;
	ppd->ruby3.last_see=realtime;

	for (n=0; n<32; n++) {
		bit=1u<<n;
		if (ppd->bits&bit) {
			bitcount++;
			switch(bit) {
				case BIT_ZOMBIE:	bitvalue+=40; break;
				case BIT_SHROOM1:       bitvalue+=10; break;
				case BIT_SHROOM2:	bitvalue+=10; break;
				case BIT_SHROOM3:	bitvalue+=10; break;
				case BIT_OCRYSTAL:	bitvalue+=20; break;
				case BIT_RCRYSTAL:	bitvalue+=20; break;
				case BIT_FSCROLL:	bitvalue+=20; break;
				case BIT_ISLENA:	bitvalue+=50; break;
				case BIT_TORCH:		bitvalue+=20; break;
				case BIT_SWAMP:		bitvalue+=20; break;
				case BIT_FOREST:	bitvalue+=20; break;
				case BIT_GOVERNOR:	bitvalue+=20; break;


			} // sum=260
		}
	}
	//say(cn,"IN: bitvalue=%d, bitcount=%d, state=%d",bitvalue,bitcount,ppd->ruby3.state);

	switch(ppd->ruby3.state) {
		case 0:		if (bitvalue>=30) ppd->ruby3.state=3;
				else ppd->ruby3.state++;
				break;
		case 1:		if (!bitvalue) quiet_say(cn,"Hello, %s. I'm %s, and this is my house. The door is over there...",ch[co].name,ch[cn].name);
				else quiet_say(cn,"Hello, %s. I'm %s. Nice to see thee again. I'm kinda busy now, so if thou wouldst come by again later?",ch[co].name,ch[cn].name);
				ppd->ruby3.state++; didsay=1;
				break;
		case 2:		if (bitvalue>=30) ppd->ruby3.state=0;
				break;
		case 3:		quiet_say(cn,"Oh, hello again, %s. I guess I owe thee something for thine help. I collect weapons of all kinds. Maybe thou'd take one of them for all thy trouble?",ch[co].name);
				ppd->ruby3.state++; didsay=1;
				break;
		case 4:		if (find_weapon(co,&ppd->ruby3.skl,&ppd->ruby3.level)) ppd->ruby3.state++;
				else {
					quiet_say(cn,"Uh, I'm confused. Please come back later.");
                                        ppd->ruby3.state=0;
					didsay=1;
				}
				break;
		case 5:         if (ppd->ruby3.skl<V_DAGGER || ppd->ruby3.skl>V_TWOHAND) { ppd->ruby3.state=0; break; }
				if (ppd->ruby3.skl==V_HAND) quiet_say(cn,"I guess I have some Gloves somewhere.");
				else if (ppd->ruby3.skl==V_TWOHAND) quiet_say(cn,"I guess I have some two-handed weapons with a requirement of %d somewhere.",ppd->ruby3.level);
				else quiet_say(cn,"I guess I have some %ss with a requirement of %d somewhere.",skill[ppd->ruby3.skl].name,ppd->ruby3.level);
                                ppd->ruby3.state++;
				didsay=1;
				break;
		case 6:		if (ppd->ruby3.skl<V_DAGGER || ppd->ruby3.skl>V_TWOHAND) { ppd->ruby3.state=0; break; }
				quiet_say(cn,"What modifier wouldst thou like? [ °c4Tactics°c0 / °c4%s°c0 / °c4Pulse°c0 ]",skill[ppd->ruby3.skl].name);
				ppd->ruby3.state++;
				didsay=1;
				break;
		case 7:		if (ppd->ruby3.skl<V_DAGGER || ppd->ruby3.skl>V_TWOHAND) { ppd->ruby3.state=0; break; }
				break;
		case 8:		if (ppd->ruby3.skl<V_DAGGER || ppd->ruby3.skl>V_TWOHAND) { ppd->ruby3.state=0; break; }
				if (ppd->ruby3.mod1<0 || ppd->ruby3.mod1>=V_MAX) { ppd->ruby3.state=0; break; }
				quiet_say(cn,"Ok, %s it is. What other modifier wouldst thou like? [ °c4Wisdom°c0 / °c4Intuition°c0 / °c4Agility°c0 / °c4Strength°c0 ]",skill[ppd->ruby3.mod1].name);
				ppd->ruby3.state++;
				didsay=1;
				break;
		case 9:		if (ppd->ruby3.skl<V_DAGGER || ppd->ruby3.skl>V_TWOHAND) { ppd->ruby3.state=0; break; }
				if (ppd->ruby3.mod1<0 || ppd->ruby3.mod1>=V_MAX) { ppd->ruby3.state=0; break; }
				break;
		case 10:	if (ppd->ruby3.skl<V_DAGGER || ppd->ruby3.skl>V_TWOHAND) { ppd->ruby3.state=0; break; }
				if (ppd->ruby3.mod1<0 || ppd->ruby3.mod1>=V_MAX) { ppd->ruby3.state=0; break; }
				if (ppd->ruby3.mod2<0 || ppd->ruby3.mod2>=V_MAX) { ppd->ruby3.state=0; break; }
				quiet_say(cn,"Ok, %s it is.",skill[ppd->ruby3.mod2].name);
				ppd->ruby3.state++;
				//didsay=1;
				break;
		case 11:	if (ppd->ruby3.skl<V_DAGGER || ppd->ruby3.skl>V_TWOHAND) { ppd->ruby3.state=0; break; }
				if (ppd->ruby3.mod1<0 || ppd->ruby3.mod1>=V_MAX) { ppd->ruby3.state=0; break; }
				if (ppd->ruby3.mod2<0 || ppd->ruby3.mod2>=V_MAX) { ppd->ruby3.state=0; break; }
				
                                if (ch[co].level<15) val=4;
				else if (ch[co].level<17) val=5;
				else if (ch[co].level<20) val=6;
				else if (ch[co].level<23) val=7;
				else if (ch[co].level<26) val=8;
				else if (ch[co].level<30) val=9;
				else if (ch[co].level<33) val=10;
				else if (ch[co].level<36) val=11;
				else if (ch[co].level<40) val=12;
				else if (ch[co].level<43) val=13;
				else if (ch[co].level<46) val=14;
				else if (ch[co].level<50) val=15;
				else if (ch[co].level<53) val=16;
				else if (ch[co].level<56) val=17;
				else if (ch[co].level<60) val=18;
				else if (ch[co].level<63) val=19;
                                else val=20;
				if (!(ch[co].flags&CF_ARCH)) val=min(val,9);

				ppd->ruby3.add=min(val,bitvalue*20/260);
				
				if (ppd->ruby3.skl==V_HAND) quiet_say(cn,"I have a pair of gloves, with %s+%d and %s+%d. [ °c4That'd be great!°c0 / °c4Uh, no, but thanks anyway.°c0 ]",skill[ppd->ruby3.mod1].name,ppd->ruby3.add,skill[ppd->ruby3.mod2].name,ppd->ruby3.add);
				else if (ppd->ruby3.skl==V_TWOHAND) quiet_say(cn,"I have a two-handed sword with %s+%d and %s+%d and with a requirement of %d. [ °c4That'd be great!°c0 / °c4Uh, no, but thanks anyway.°c0 ]",skill[ppd->ruby3.mod1].name,ppd->ruby3.add,skill[ppd->ruby3.mod2].name,ppd->ruby3.add,ppd->ruby3.level);
				else quiet_say(cn,"I have a %s with with %s+%d and %s+%d and a requirement of %d. [ °c4That'd be great!°c0 / °c4Uh, no, but thanks anyway.°c0 ]",skill[ppd->ruby3.skl].name,skill[ppd->ruby3.mod1].name,ppd->ruby3.add,skill[ppd->ruby3.mod2].name,ppd->ruby3.add,ppd->ruby3.level);
				ppd->ruby3.state++;
				didsay=1;
				break;
		case 12:	break;
		case 13:	quiet_say(cn,"Oh. Alright. Feel free to visit me again, I might have something different for thee then. Just say 'repeat'.");
				ppd->ruby3.state++;
				didsay=1;
				break;
		case 14:	break;
		case 15:	quiet_say(cn,"Here you go...");
				in=ruby_create_item(&ppd->ruby3);
				if (!in) {
					quiet_say(cn,"Uh, I'm confused. Please come back later.");
                                        ppd->ruby3.state=0;
					didsay=1;
				}
				if (!give_char_item(co,in)) {
					quiet_say(cn,"Uh, try again when your inventory isn't full.");
                                        ppd->ruby3.state=0;
					didsay=1;
				}
                                bzero(&ppd->ruby2,sizeof(struct story_npc));
				bzero(&ppd->ruby5,sizeof(struct story_npc));
				bzero(&ppd->ruby6,sizeof(struct story_npc));
				bzero(&ppd->ruby8,sizeof(struct story_npc));
				bzero(&ppd->ruby10,sizeof(struct story_npc));
				bzero(&ppd->ruby11,sizeof(struct story_npc));
				bzero(&ppd->ruby12,sizeof(struct story_npc));
				bzero(&ppd->ruby15,sizeof(struct story_npc));
				bzero(&ppd->ruby16,sizeof(struct story_npc));
				bzero(&ppd->ruby17,sizeof(struct story_npc));
				bzero(&ppd->ruby18,sizeof(struct story_npc));
				ppd->bits=0;
				
				log_char(co,LOG_SYSTEM,0,"You sense that %s has forgotten all about you...",ch[cn].name);
				ppd->ruby3.state=0;
				didsay=1;
                                break;
	}
	//say(cn,"OUT: bitvalue=%d, state=%d",bitvalue,ppd->ruby3.state);

	if (didsay) ppd->ruby3.last_say=realtime;
        return didsay;
}
예제 #4
0
void cmd_steal(int cn)
{
	int co,x,y,n,cnt,in=0,chance,dice,diff,m;

	if (!ch[cn].prof[P_THIEF]) {
		log_char(cn,LOG_SYSTEM,0,"You are not a thief, you cannot steal.");
		return;
	}
	if (ch[cn].action!=AC_IDLE) {
		log_char(cn,LOG_SYSTEM,0,"You can only steal when standing still.");
		return;
	}

	if (ch[cn].citem) {
		log_char(cn,LOG_SYSTEM,0,"Please free your hand (mouse cursor) first.");
		return;
	}

	dx2offset(ch[cn].dir,&x,&y,NULL);
	
	x+=ch[cn].x;
	y+=ch[cn].y;

	if (x<1 || x>=MAXMAP-1 || y<1 || y>=MAXMAP-1) {
		log_char(cn,LOG_SYSTEM,0,"Out of map.");
		return;
	}
	
	m=x+y*MAXMAP;
	co=map[m].ch;
	if (!co) {
		log_char(cn,LOG_SYSTEM,0,"There's no one to steal from.");
		return;
	}

	if (!can_attack(cn,co)) {
		log_char(cn,LOG_SYSTEM,0,"You cannot steal from someone you are not allowed to attack.");
		return;
	}
	if (map[m].flags&(MF_ARENA|MF_CLAN)) {
		log_char(cn,LOG_SYSTEM,0,"You cannot steal inside an arena.");
		return;
	}
	if (!(ch[co].flags&CF_PLAYER)) {
		log_char(cn,LOG_SYSTEM,0,"You can only steal from players.");
		return;
	}
	if (ch[co].driver==CDR_LOSTCON) {
		log_char(cn,LOG_SYSTEM,0,"You cannot steal from lagging players.");
		return;
	}
	if (areaID==20) {
		log_char(cn,LOG_SYSTEM,0,"You cannot steal in Live Quests.");
		return;
	}

	if (ch[co].action!=AC_IDLE || ticker-ch[co].regen_ticker<TICKS) {
		log_char(cn,LOG_SYSTEM,0,"You cannot steal from someone if your victim is not standing still.");
		return;
	}
	
	for (n=cnt=0; n<INVENTORYSIZE; n++) {
		if (n>=12 && n<30) continue;
		if ((in=ch[co].item[n]) && !(it[in].flags&IF_QUEST) && can_carry(cn,in,1)) cnt++;
	}
	if (!cnt) {
		log_char(cn,LOG_SYSTEM,0,"You could not find anything to steal.");
		return;
	}
	cnt=RANDOM(cnt);

	for (n=cnt=0; n<INVENTORYSIZE; n++) {
		if (n>=12 && n<30) continue;
		if ((in=ch[co].item[n]) && !(it[in].flags&IF_QUEST) && can_carry(cn,in,1)) {
			if (cnt<1) break;
			cnt--;
		}		
	}
	if (n==INVENTORYSIZE) {
		log_char(cn,LOG_SYSTEM,0,"You could not find anything to steal (2).");
		return;
	}

	diff=(ch[cn].value[0][V_STEALTH]-ch[co].value[0][V_PERCEPT])/2;
	chance=40+diff;
	if (chance<10) {
		log_char(cn,LOG_SYSTEM,0,"You'd get caught for sure. You decide not to try.");
		return;
	}
	chance=min(chance,ch[cn].prof[P_THIEF]*3);

        dice=RANDOM(100);
	diff=chance-dice;

        if (diff<-20) {
		log_char(cn,LOG_SYSTEM,0,"%s noticed your attempt and stopped you from stealing.",ch[co].name);
		ch[cn].endurance=1;
		if (ch[co].flags&CF_PLAYER) {
			log_char(co,LOG_SYSTEM,0,"°c3%s tried to steal from you!",ch[cn].name);
		} else notify_char(co,NT_GOTHIT,cn,0,0);
		return;
	}

	dlog(co,in,"dropped because %s stole it",ch[cn].name);
	remove_item_char(in);
	if (!give_char_item(cn,in)) {
		destroy_item(in);
		elog("had to destroy item in cmd_steal()!");
		return;
	}

	add_pk_steal(cn);

	if (diff<0) {
		log_char(cn,LOG_SYSTEM,0,"%s noticed your theft, but you managed to steal a %s anyway.",ch[co].name,it[in].name);
		ch[cn].endurance=1;
		if (ch[co].flags&CF_PLAYER) {
			log_char(co,LOG_SYSTEM,0,"°c3%s stole your %s!",ch[cn].name,it[in].name);
		} else notify_char(co,NT_GOTHIT,cn,0,0);
	} else log_char(cn,LOG_SYSTEM,0,"You stole a %s without %s noticing.",it[in].name,ch[co].name);
}
예제 #5
0
void dwarfsmith_driver(int cn,int ret,int lastact)
{
	struct dwarfsmith_data *dat;
	struct staffer_ppd *ppd;
        int co,in,didsay=0,talkdir=0,in2;
	struct msg *msg,*next;

        dat=set_data(cn,DRD_DWARFSMITHDRIVER,sizeof(struct dwarfsmith_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->dwarfsmith_state) {
					case 0:         quiet_say(cn,"Welcome to my smithy! If you are in need of my services, come to me and I will see what I can do for you. For now though, I'm afraid I can't do a whole lot.");
							ppd->dwarfsmith_state++; didsay=1;
                                                        break;
					case 1:         break;	// waiting for mold
					case 2:		break;	// waiting for silver
				}
				if (didsay) {
					dat->last_talk=ticker;
					talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
					dat->current_victim=co;
				}
			}
		}

                // 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->dwarfsmith_state<=3) { dat->last_talk=0; ppd->dwarfsmith_state=0; }
                                                        //break;
					case 3:		if (ch[co].flags&CF_GOD) { say(cn,"reset done"); ppd->dwarfsmith_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;
			
			ppd=set_data(co,DRD_STAFFER_PPD,sizeof(struct staffer_ppd));

                        if ((in=ch[cn].citem)) {	// we still have it
				if (it[in].ID==IID_LIZARDMOLD && ppd && ppd->dwarfsmith_state<=1) {
					ppd->dwarfsmith_state=2;
					ppd->dwarfsmith_type=it[in].drdata[0];
					quiet_say(cn,"What's this? A mold from the lizards? I guess I can make a key out of this, but I will need 5,000 silver to make it. You can't expect me to sacrifice my own ore for your adventuring!");
				} else if (it[in].driver==IDR_ENHANCE && it[in].drdata[0]==1 && *(unsigned int*)(it[in].drdata+1)==5000 && ppd && ppd->dwarfsmith_state==2) {
                                        quiet_say(cn,"There you go, one key for the adventurer.");
					switch(ppd->dwarfsmith_type) {
						case 1:		in2=create_item("lizard_elite_key1"); break;
						case 2:		in2=create_item("lizard_elite_key2"); break;
						case 3:		in2=create_item("lizard_elite_key3"); break;
						default:	in2=0; quiet_say(cn,"oops. bug # 3266/%d",ppd->dwarfsmith_type); break;
					}
					if (in2) {
						if (!give_char_item(co,in2)) destroy_item(in2);						
                                        }
					ppd->dwarfsmith_state=1;
					ppd->dwarfsmith_type=0;
					
				} else if (give_char_item(co,in)) {
					if (it[in].driver==IDR_ENHANCE) {
						if (it[in].drdata[0]!=1) quiet_say(cn,"I'll need silver, not any other material.");
						else if (*(unsigned int*)(it[in].drdata+1)!=5000) quiet_say(cn,"I'll need exactly 5000 units of silver.");
						else quiet_say(cn,"I'll need a mold first.");
					} else quiet_say(cn,"Thou hast better use for this than I do. Well, if there is use for it at all.");
					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.

	if (talkdir) turn(cn,talkdir);

	if (dat->last_talk+TICKS*30<ticker) {
		if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_RIGHT,ret,lastact)) return;
	}

        do_idle(cn,TICKS);
}
예제 #6
0
void dwarfshaman_driver(int cn,int ret,int lastact)
{
	struct dwarfshaman_data *dat;
	struct staffer_ppd *ppd;
        int co,in,didsay=0,talkdir=0;
	struct msg *msg,*next;

        dat=set_data(cn,DRD_DWARFSHAMANDRIVER,sizeof(struct dwarfshaman_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->dwarfshaman_state) {
					case 0:         quiet_say(cn,"Welcome to Grimroot stranger. To make it here you must have battled some strong foes, though they're nothing compared to what you're about to face, should you accept the quest I am about to give you.");
							questlog_open(co,51);
							ppd->dwarfshaman_state++; didsay=1;
                                                        break;
					case 1:		quiet_say(cn,"But before I give you the quest, I want to see if you can fight the lizards you will be facing. Bring me back 9 lizard's teeth, and I will see that as proof of your strength.");
                                                        ppd->dwarfshaman_state++; didsay=1;
							break;
                                        case 2:         break;	// waiting for teeth
					
					case 3:		if (questlog_isdone(co,52)) { ppd->dwarfshaman_state=6; break; }
							quiet_say(cn,"Ah! I see you've come back with all your teeth, and those of the lizards. I guess you are strong enough after all to do the quest I am about to give you. You see, I've seen the lizards come out with brown berries out of the water.");
							questlog_open(co,52);
                                                        ppd->dwarfshaman_state++; didsay=1;
                                                        break;
                                        case 4:		quiet_say(cn,"Since I hate water, I need others like you to grab them for me. If you want to breath underwater, you will have to combine 3 flowers. I'll leave it up to you to figure out which ones. Now go get me 9 brown berries!");
                                                        ppd->dwarfshaman_state++; didsay=1;
                                                        break;
					case 5:		break; // waiting for berries
					
					case 6:		if (questlog_isdone(co,53)) { ppd->dwarfshaman_state=10; break; }
							quiet_say(cn,"It's good that you can swim, you have no idea how much I hate water. Thanks for the berries. As I suspected, they seem to have magic properties, which I may be able to use.");
							questlog_open(co,53);
							ppd->dwarfshaman_state++; didsay=1;
                                                        break;
					case 7:		quiet_say(cn,"Also, I managed to learn some of the lizard's tongue, and overheard them talking in fear of an 'elite lizard'... If you can find it and bring it's head to me, I can learn more about these lizards, and why they're so varied.");
                                                        ppd->dwarfshaman_state++; didsay=1;
                                                        break;
					case 8:		break; // waiting for elite head
					
					case 9:		quiet_say(cn,"This is quite amazing! The reason these lizards are so varied is due to them being able to somehow absorb magical energy. To much of it seems to affect their mind however, as was the case with this elite lizard.");
							ppd->dwarfshaman_state++; didsay=1;
                                                        break;
					case 10:	quiet_say(cn,"Thank you for helping out! I guess you are sturdier than you look, even though your kind looks skinnier than a dwarven skeleton!");
                                                        ppd->dwarfshaman_state++; didsay=1;
                                                        break;
					case 11:	break; // all done

				}
				if (didsay) {
					dat->last_talk=ticker;
					talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
					dat->current_victim=co;
				}
			}
		}

                // 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->dwarfshaman_state<=2) { dat->last_talk=0; ppd->dwarfshaman_state=0; }
                                                        if (ppd && ppd->dwarfshaman_state>=3 && ppd->dwarfshaman_state<=5) { dat->last_talk=0; ppd->dwarfshaman_state=3; }
							if (ppd && ppd->dwarfshaman_state>=6 && ppd->dwarfshaman_state<=8) { dat->last_talk=0; ppd->dwarfshaman_state=6; }
							if (ppd && ppd->dwarfshaman_state>=9 && ppd->dwarfshaman_state<=11) { dat->last_talk=0; ppd->dwarfshaman_state=9; }
                                                        break;
					case 3:		if (ch[co].flags&CF_GOD) { say(cn,"reset done"); ppd->dwarfshaman_state=0; ppd->dwarfshaman_count=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;
			
			ppd=set_data(co,DRD_STAFFER_PPD,sizeof(struct staffer_ppd));

                        if ((in=ch[cn].citem)) {	// we still have it
				if (it[in].ID==IID_LIZARDTOOTH && ppd && ppd->dwarfshaman_state<3) {
					ppd->dwarfshaman_count++;
					if (ppd->dwarfshaman_count>=9) {
						ppd->dwarfshaman_state=3;
						ppd->dwarfshaman_count=0;
						dat->last_talk=0;
						questlog_done(co,51);						
					} else {
						quiet_say(cn,"%d done, %d to go.",ppd->dwarfshaman_count,9-ppd->dwarfshaman_count);
					}
				} else if (it[in].ID==IID_BROWNBERRY && ppd && ppd->dwarfshaman_state>=3 && ppd->dwarfshaman_state<=5) {
					ppd->dwarfshaman_count++;
					if (ppd->dwarfshaman_count>=9) {
						ppd->dwarfshaman_state=6;
						ppd->dwarfshaman_count=0;
						dat->last_talk=0;
						questlog_done(co,52);
					} else {
						quiet_say(cn,"%d done, %d to go.",ppd->dwarfshaman_count,9-ppd->dwarfshaman_count);
					}
				} else if (it[in].ID==IID_LIZARDHEAD && ppd && ppd->dwarfshaman_state>=6 && ppd->dwarfshaman_state<=8) {
                                        ppd->dwarfshaman_state=9;
					dat->last_talk=0;
					questlog_done(co,53);
					destroy_item_byID(co,IID_LIZARDHEAD);
				} else if (give_char_item(co,in)) {
					quiet_say(cn,"Thou hast better use for this than I do. Well, if there is use for it at all.");
					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.

	if (talkdir) turn(cn,talkdir);

	if (dat->last_talk+TICKS*30<ticker) {
		if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_RIGHT,ret,lastact)) return;
	}

        do_idle(cn,TICKS);
}
예제 #7
0
void dwarfchief_driver(int cn,int ret,int lastact)
{
	struct dwarfchief_data *dat;
	struct staffer_ppd *ppd;
        int co,in,didsay=0,talkdir=0;
	struct msg *msg,*next;

        dat=set_data(cn,DRD_DWARFCHIEFDRIVER,sizeof(struct dwarfchief_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->dwarfchief_state) {
					case 0:         quiet_say(cn,"Welcome, stranger, to Grimroot, home of the dwarves. I would introduce you to our town further, but I have urgent matters to attend to.");
							questlog_open(co,47);
							ppd->dwarfchief_state++; didsay=1;
                                                        break;
					case 1:		quiet_say(cn,"Four of our miners have gone missing, one each in one of the 4 mine areas, and we can only think it's because of those bothersome golems...");
                                                        ppd->dwarfchief_state++; didsay=1;
							break;
                                        case 2:         quiet_say(cn,"If you wish, here's a scroll so you can help one of them. Give this one to the miner in the first section, then come back for another scroll for the next miner.");
                                                        ppd->dwarfchief_state++; didsay=1;
							if (!has_item(co,IID_DWARFRECALL1)) {
								in=create_item("dwarf_recall90");
								if (in) give_char_item(co,in);
							}
                                                        break;
					case 3:		break; // waiting for player to save first miner
					
					case 4:		questlog_done(co,47);
                                                        ppd->dwarfchief_state++;
							// fall-through intended
					case 5:		if (questlog_isdone(co,48)) { ppd->dwarfchief_state=8; break; }
							quiet_say(cn,"Not too bad for a human, you people are sturdier than I thought... Don't cheer up though, the miner in the next section is surrounded by stronger golems. Don't let them hurt your precious nails!");
							questlog_open(co,48);
                                                        ppd->dwarfchief_state++; didsay=1;
                                                        if (!has_item(co,IID_DWARFRECALL2)) {
								in=create_item("dwarf_recall100");
								if (in) give_char_item(co,in);
							}
                                                        break;
					case 6:		break; // waiting for player to save second miner
					
					case 7:		questlog_done(co,48);
                                                        ppd->dwarfchief_state++;
							// fall-through intended
					case 8:		if (questlog_isdone(co,49)) { ppd->dwarfchief_state=11; break; }
							quiet_say(cn,"A job well done! It's that we have enough hands already, otherwise I'd ask you to go out there and mine for us. Anyway, back to business. Go and find the next miner, and you will be rewarded again.");
							questlog_open(co,49);
                                                        ppd->dwarfchief_state++; didsay=1;
                                                        if (!has_item(co,IID_DWARFRECALL2)) {
								in=create_item("dwarf_recall110");
								if (in) give_char_item(co,in);
							}
                                                        break;
					case 9:		break; // waiting for player to save third miner
					
					case 10:	questlog_done(co,49);
                                                        ppd->dwarfchief_state++;
							// fall-through intended
					case 11:	if (questlog_isdone(co,50)) { ppd->dwarfchief_state=14; break; }
							quiet_say(cn,"Just in time! If you had been any later, he wouldn't have had his dinner, and trust me, you don't want to see a dwarf hungry, it's not a pretty sight. The fourth miner should be ok, he always packs more than the others, but do hurry and find him.");
							questlog_open(co,50);
                                                        ppd->dwarfchief_state++; didsay=1;
                                                        if (!has_item(co,IID_DWARFRECALL2)) {
								in=create_item("dwarf_recall120");
								if (in) give_char_item(co,in);
							}
                                                        break;
					case 12:	break; // waiting for player to save fourth miner

					case 13:	questlog_done(co,50);
                                                        ppd->dwarfchief_state++;
							// fall-through intended
					case 14:	quiet_say(cn,"Thank you for saving the last one! You have been of great help to us. Now let's hope they can stay out of the hands of those golems once and for all. Those recall scrolls aren't cheap you know!");
                                                        ppd->dwarfchief_state++; didsay=1;
                                                        break;
					case 15:	break; // all done

				}
				if (didsay) {
					dat->last_talk=ticker;
					talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
					dat->current_victim=co;
				}
			}
		}

                // 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->dwarfchief_state<=3) { dat->last_talk=0; ppd->dwarfchief_state=0; }
                                                        if (ppd && ppd->dwarfchief_state>=5 && ppd->dwarfchief_state<=6) { dat->last_talk=0; ppd->dwarfchief_state=5; }
							if (ppd && ppd->dwarfchief_state>=8 && ppd->dwarfchief_state<=9) { dat->last_talk=0; ppd->dwarfchief_state=8; }
							if (ppd && ppd->dwarfchief_state>=11 && ppd->dwarfchief_state<=12) { dat->last_talk=0; ppd->dwarfchief_state=11; }
							if (ppd && ppd->dwarfchief_state>=14 && ppd->dwarfchief_state<=15) { dat->last_talk=0; ppd->dwarfchief_state=14; }
                                                        break;
					case 3:		if (ch[co].flags&CF_GOD) { say(cn,"reset done"); ppd->dwarfchief_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
				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)) 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.

	if (talkdir) turn(cn,talkdir);

	if (dat->last_talk+TICKS*30<ticker) {
		if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_RIGHT,ret,lastact)) return;
	}

        do_idle(cn,TICKS);
}
예제 #8
0
void clubmaster_driver(int cn,int ret,int lastact)
{
	struct clubmaster_driver_data *dat;
        int co,in,n,rank,cc,val;
        struct msg *msg,*next;
	char *ptr,tmp[80],name[80];

        dat=set_data(cn,DRD_CLUBMASTERDRIVER,sizeof(struct clubmaster_driver_data));
	if (!dat) return;	// oops...

        if (ch[cn].arg) {
                clubmaster_driver_parse(cn,dat);
		ch[cn].arg=NULL;
	}

        // 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 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; }

			// dont talk to the same person twice
			if (mem_check_driver(cn,co,7)) { remove_message(cn,msg); continue; }

			if (!get_char_club(cn) && !get_char_clan(cn)) quiet_say(cn,"Hello %s! Would you like to found a °c4club°c0?",ch[co].name);
			mem_add_driver(cn,co,7);
		}

                // talk back
		if (msg->type==NT_TEXT) {
			analyse_text_driver(cn,msg->dat1,(char*)msg->dat2,msg->dat3);

                        if ((msg->dat1==1 || msg->dat1==2) && (co=msg->dat3)!=cn) {	// talk, and not our talk				
                                if ((ptr=strcasestr((char*)msg->dat2,"found:"))) {
					if (!(ch[co].flags&CF_PAID)) {
						quiet_say(cn,"I'm sorry, %s, but only paying players may found clubs.",ch[co].name);
					} else if (!get_char_clan(co) && !get_char_club(co)) {
						if (ch[co].gold>=10000*100) {
							ptr+=6;
							while (isspace(*ptr)) ptr++;
							for (n=0; n<79; n++) {
								if (!(isalpha(*ptr) || *ptr==' ')) break;
								name[n]=*ptr++;
							}
							name[n]=0;
							
							if ((n=create_club(name))) {
								take_money(co,10000*100);
								ch[co].clan=n+CLUBOFFSET;
								ch[co].clan_serial=club[n].serial;
								ch[co].clan_rank=2;
								quiet_say(cn,"Congratulations, %s, you are now the leader of the club %s.",ch[co].name,club[n].name);
								dlog(co,0,"created club %d %s",n,club[n].name);
							} else quiet_say(cn,"Something's wrong with the name.");
						} else quiet_say(cn,"You cannot pay the fee of 10,000 gold.");
					} else quiet_say(cn,"You are already a member of a clan or club. You cannot found a new one.");
				}
				if ((ptr=strcasestr((char*)msg->dat2,"accept:"))) {
					if (!get_char_club(co) || ch[co].clan_rank<1) {
                                                quiet_say(cn,"You are not a club leader, %s.",ch[co].name);
					} else {
						ptr+=7;
						while (isspace(*ptr)) ptr++;
						for (n=0; n<79; n++) {
							if (!*ptr || *ptr=='"') break;
							dat->accept[n]=*ptr++;
						}
						dat->accept[n]=0;
						strcpy(dat->join,ch[co].name);
						dat->accept_clan=get_char_club(co);
						dat->accept_cn=co;

						quiet_say(cn,"To join %s's club %s, say: 'join: %s'",dat->join,dat->accept,dat->join);
					}
				}
				if ((ptr=strcasestr((char*)msg->dat2,"join:"))) {
					if (get_char_clan(co) || get_char_club(co)) {
                                                quiet_say(cn,"You are already a clan or club member, %s.",ch[co].name);
					} else {
						ptr+=5;
						while (isspace(*ptr)) ptr++;
						for (n=0; n<79; n++) {
							if (!*ptr || *ptr=='"') break;
							tmp[n]=*ptr++;
						}
						tmp[n]=0;
                                                if (strcasecmp(dat->accept,ch[co].name)) {
							quiet_say(cn,"You have not been invited, %s.",ch[co].name);
						} else if (strcasecmp(dat->join,tmp)) {
							quiet_say(cn,"%s has not invited you, %s.",tmp,ch[co].name);
						} else {
                                                        //add_member(co,dat->accept_clan,dat->join);
							ch[co].clan=dat->accept_clan+CLUBOFFSET;
							ch[co].clan_serial=club[dat->accept_clan].serial;
							ch[co].clan_rank=0;
							quiet_say(cn,"%s, you are now a member of %s's club.",ch[co].name,dat->join);
							dat->accept[0]=0;
							dat->accept_clan=0;
							dat->join[0]=0;
						}
						
					}
				}
				if ((ptr=strcasestr((char*)msg->dat2,"leave!"))) {
					if (!get_char_club(co)) {
                                                quiet_say(cn,"You are not a club member, %s.",ch[co].name);
					} else {
						remove_member(co,co);
						quiet_say(cn,"You are no longer a member of any club, %s",ch[co].name);
					}
				}
				if ((ptr=strcasestr((char*)msg->dat2,"rank:"))) {
					if (!get_char_club(co) || ch[co].clan_rank<2) {
                                                quiet_say(cn,"You are not a club founder, %s.",ch[co].name);
					} else {
						ptr+=6;
						while (isspace(*ptr)) ptr++;
						for (n=0; n<79; n++) {
							if (!*ptr || *ptr=='"' || isspace(*ptr)) break;
							tmp[n]=*ptr++;
						}
						tmp[n]=0;
						
						rank=atoi(ptr);

						if (rank<0 || rank>1) {
							quiet_say(cn,"You must use a rank between 0 and 1.");
							remove_message(cn,msg);
							continue;
						}

						for (cc=getfirst_char(); cc; cc=getnext_char(cc)) {
							if (!strcasecmp(tmp,ch[cc].name) && (ch[cc].flags&CF_PLAYER)) break;
						}
						if (cc) {
							if (!(ch[cc].flags&CF_PAID) && rank>0) {
                                                                quiet_say(cn,"%s is not a paying player, you cannot set the rank higher than 0.",ch[cc].name);
							} else if (ch[cc].clan_rank==2) {
								quiet_say(cn,"%s is the club's founder, cannot change rank.",ch[cc].name);
							} else if (get_char_club(cc)==get_char_club(co)) {
								ch[cc].clan_rank=rank;
								quiet_say(cn,"Set %s's rank to %d.",ch[cc].name,rank);
							} else quiet_say(cn,"You cannot change the rank of those not belonging to your club.");
						} else {
							int uID;

							uID=lookup_name(tmp,NULL);
							if (uID==0) continue;
							if (uID==-1) {
								quiet_say(cn,"Sorry, no player by the name %s found.",tmp);
							} else {
								task_set_clan_rank(uID,ch[co].ID,get_char_club(co)+CLUBOFFSET,rank,ch[co].name);
								quiet_say(cn,"Update scheduled (%s,%d).",tmp,rank);
							}
						}
					}
				}
				if ((ptr=strcasestr((char*)msg->dat2,"fire:"))) {
					if (!get_char_club(co) || ch[co].clan_rank<1) {
                                                quiet_say(cn,"You are not a club leader, %s.",ch[co].name);
					} else {
						ptr+=6;
						while (isspace(*ptr)) ptr++;
						for (n=0; n<79; n++) {
							if (!*ptr || *ptr=='"' || isspace(*ptr)) break;
							tmp[n]=*ptr++;
						}
						tmp[n]=0;
						
                                                for (cc=getfirst_char(); cc; cc=getnext_char(cc)) {
							if (!strcasecmp(tmp,ch[cc].name) && (ch[cc].flags&CF_PLAYER)) break;
						}
						if (cc) {
							if (get_char_club(cc)==get_char_club(co)) {
								if (ch[cc].clan_rank<2) {
									remove_member(cc,co);
									quiet_say(cn,"Fired: %s.",ch[cc].name);
								} else quiet_say(cn,"You cannot fire the founder of the club.");
							} else quiet_say(cn,"You cannot fire those not belonging to your club.");
						} else {
							int uID;

							uID=lookup_name(tmp,NULL);
							if (uID==0) continue;
							if (uID==-1) {
								quiet_say(cn,"Sorry, no player by the name %s found.",tmp);
							} else {
								task_fire_from_clan(uID,ch[co].ID,get_char_club(co)+CLUBOFFSET,ch[co].name);
								quiet_say(cn,"Update scheduled (%s).",tmp);
							}
						}
					}
				}

				if ((ptr=strcasestr((char*)msg->dat2,"deposit:"))) {
					if (!(n=get_char_club(co))) {
                                                quiet_say(cn,"You are not a club member, %s.",ch[co].name);
					} else {
						val=atoi(ptr+8)*100;

						if (val>0 && ch[co].gold>=val) {
							club[n].money+=val;
							take_money(co,val);
							quiet_say(cn,"You have deposited %dG, for a total of %dG, %s.",val/100,club[n].money/100,ch[co].name);
							dlog(co,0,"Deposited %dG into club %d, for a new total of %dG",val/100,n,club[n].money/100);
							db_update_club(n);
						} else quiet_say(cn,"You do not have that much gold, %s.",ch[co].name);
					}
				}
				if ((ptr=strcasestr((char*)msg->dat2,"withdraw:"))) {
					if (!(n=get_char_club(co)) || ch[co].clan_rank<2) {
                                                quiet_say(cn,"You are not a club founder, %s.",ch[co].name);
					} else {
						val=atoi(ptr+9)*100;

						if (val>0 && club[n].money>=val) {
							club[n].money-=val;
							give_money(co,val,"club withdrawal");
							quiet_say(cn,"You have withdrawn %dG, money left in club %dG, %s.",val/100,club[n].money/100,ch[co].name);
							dlog(co,0,"Withdrew %dG from club %d, for a new total of %dG",val/100,n,club[n].money/100);
							db_update_club(n);
						} else quiet_say(cn,"The club does not have that much gold, %s.",ch[co].name);
					}
				}
			}			
		}

		// got an item?
		if (msg->type==NT_GIVE) {
			co=msg->dat1;

                        if ((in=ch[cn].citem)) {	// we still have it
				// try to give it back
                                if (give_char_item(cn,co)) return;
				
				// didnt work, let it vanish, then
				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.

	if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,dat->dir,ret,lastact)) return;

        if (ticker>dat->last_talk+TICKS*60 && !RANDOM(25)) {
		switch(RANDOM(8)) {
			case 0:		murmur(cn,"My back itches."); break;
			case 1:		whisper(cn,"There's something stuck between your teeth."); break;
			case 2:		murmur(cn,"Oh yeah, those were the days."); break;
			case 3:		murmur(cn,"Now where did I put it?"); break;
			case 4:		murmur(cn,"Oh my, life is hard but unfair."); break;
                        case 5:		murmur(cn,"Beware of the fire snails!"); break;
			case 6:         murmur(cn,"I love the clicking of coins."); break;
			case 7:		murmur(cn,"Gold and Silver, Silver and Gold."); break;
			default:	break;
		}
		
		dat->last_talk=ticker;
	}

	if (ticker>dat->memcleartimer) {
		mem_erase_driver(cn,7);
		dat->memcleartimer=ticker+TICKS*60*60*12;
	}

        do_idle(cn,TICKS*2);
}
예제 #9
0
void yoatin_driver(int cn,int ret,int lastact)
{
	struct yoatin_data *dat;
	struct staffer_ppd *ppd;
        int co,in,didsay=0,talkdir=0;
	struct msg *msg,*next;

        dat=set_data(cn,DRD_YOATINDRIVER,sizeof(struct yoatin_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->yoatin_state) {					
					case 0:         quiet_say(cn,"Greetings stranger!");
							questlog_open(co,39);
							ppd->yoatin_state++; didsay=1;
                                                        break;
                                        case 1:		quiet_say(cn,"Wait...I recognize you from the description my brother gave - you must be %s!",ch[co].name);
							ppd->yoatin_state++; didsay=1;
                                                        break;
					case 2:		quiet_say(cn,"My brother's name is Yoakin. It seems you did him a great service slaying the bears of Cameron.");
                                                        ppd->yoatin_state++; didsay=1;
                                                        break;
					case 3:		quiet_say(cn,"Mayhap you could assist me with a problem I have?");
							ppd->yoatin_state++; didsay=1;
                                                        break;
					case 4:		quiet_say(cn,"A family from the town beyond this forest has asked me to hunt down the bear that killed their son.");
							ppd->yoatin_state++; didsay=1;
                                                        break;
					case 5:		quiet_say(cn,"I am not quite the hunter my brother is and well... to be frank, bears scare the living daylights out of me.");
							ppd->yoatin_state++; didsay=1;
                                                        break;
					case 6:		quiet_say(cn,"If you could fetch me proof of the bear being slain, I would reward thee greatly.");
							ppd->yoatin_state++; didsay=1;
                                                        break;
					case 7:		quiet_say(cn,"Take care as you travel! The whole forest is full of bears and bear caves.");
							ppd->yoatin_state++; didsay=1;
                                                        break;
					case 8:		break; // waiting for bear to die
					case 9:		break; // all done
					
					
				}
				if (didsay) {
					dat->last_talk=ticker;
					talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
					dat->current_victim=co;
				}
			}
		}

                // 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->yoatin_state<=8) { dat->last_talk=0; ppd->yoatin_state=0; }
                                                        break;				
					case 3:		if (ch[co].flags&CF_GOD) { say(cn,"reset done"); ppd->yoatin_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

				ppd=set_data(co,DRD_STAFFER_PPD,sizeof(struct staffer_ppd));

				if (it[in].ID==IID_STAFF_BEARHEAD && ppd && ppd->yoatin_state<=8) {
					quiet_say(cn,"Thank you %s! This will be perfect proof. Here, take my belt, you are clearly the greater hunter!",ch[co].name);
					questlog_done(co,39);
					destroy_item_byID(co,IID_STAFF_BEARHEAD);
                                        if ((in=create_item("WS_Hunter_Belt"))) {
						if (!give_char_item(co,in)) destroy_item(in);						
					}
                                        ppd->yoatin_state=9;
				} else {
					say(cn,"Thou hast better use for this than I do. Well, if there is a use for it at all.");
                                        if (!give_char_item(co,ch[cn].citem)) destroy_item(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);
}
예제 #10
0
void aristocrat_driver(int cn,int ret,int lastact)
{
	struct aristocrat_data *dat;
	struct staffer_ppd *ppd;
        int co,in,didsay=0,talkdir=0;
	struct msg *msg,*next;

        dat=set_data(cn,DRD_ARISTOCRATDRIVER,sizeof(struct aristocrat_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->aristocrat_state) {
					case 0:         quiet_say(cn,"Greetings stranger!");
							questlog_open(co,38);
							ppd->aristocrat_state++; didsay=1;
                                                        break;
                                        case 1:		quiet_say(cn,"Say! You look like quite a buoyant adventurer.");
							ppd->aristocrat_state++; didsay=1;
                                                        break;
					case 2:		quiet_say(cn,"Oh no, I didn't mean it that way! Please don't growl at me!");
                                                        ppd->aristocrat_state++; didsay=1;
                                                        break;
					case 3:		quiet_say(cn,"I was watching the local wildlife at a large lake north of here...");
							ppd->aristocrat_state++; didsay=1;
                                                        break;
                                        case 4:		quiet_say(cn,"When one of the larger natives suddenly lurched out of the water and attacked me.");
							ppd->aristocrat_state++; didsay=1;
                                                        break;
					case 5:		quiet_say(cn,"I managed to escape with my life, but alas my Amulet was lost.");
							ppd->aristocrat_state++; didsay=1;
                                                        break;
					case 6:		quiet_say(cn,"I would reward you well if you could retrieve this family heirloom for me.");
							ppd->aristocrat_state++; didsay=1;
                                                        break;
					case 7:		break; // waiting for amulet
					case 8:		break; // all done
				}
				if (didsay) {
					dat->last_talk=ticker;
					talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
					dat->current_victim=co;
				}
			}
		}

                // 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->aristocrat_state<=7) { dat->last_talk=0; ppd->aristocrat_state=0; }
                                                        break;
					case 3:		if (ch[co].flags&CF_GOD) { say(cn,"reset done"); ppd->aristocrat_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

				ppd=set_data(co,DRD_STAFFER_PPD,sizeof(struct staffer_ppd));

				if (it[in].ID==IID_STAFF_ARIAMULET && ppd && ppd->aristocrat_state<=7) {
					int tmp;
                                        quiet_say(cn,"Yes! Many thanks adventurer! Please accept this reward.");
					tmp=questlog_done(co,38);
					destroy_item_byID(co,IID_STAFF_ARIAMULET);
					destroy_item_byID(co,IID_STAFF_ARIKEY);
                                        ppd->aristocrat_state=8;
					if (tmp==1 && (in=create_money_item(1000*100))) {
						if (!give_char_item(co,in)) destroy_item(in);						
					}
				} else {
					say(cn,"Thou hast better use for this than I do. Well, if there is a use for it at all.");
                                        if (!give_char_item(co,ch[cn].citem)) destroy_item(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);
}
예제 #11
0
void warpmaster(int cn,int ret,int lastact)
{
    int co,in,type,in2,flag=0,code,n;
    struct msg *msg,*next;
    struct warped_ppd *ppd;

    // 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 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;
            }

            // dont talk to the same person twice
            if (mem_check_driver(cn,co,7)) {
                remove_message(cn,msg);
                continue;
            }

            if (ch[co].level<30) say(cn,"Hello %s! You'd better leave this area - it is too dangerous for you.",ch[co].name);
            else say(cn,"Hello %s! Welcome to Rodney's °c4Warped World°c0! Would you like to buy some °c4keys°c0?",ch[co].name);
            mem_add_driver(cn,co,7);
        }

        // talk back
        if (msg->type==NT_TEXT) {
            co=msg->dat3;

            if (!(ch[co].flags&CF_PLAYER)) {
                remove_message(cn,msg);
                continue;
            }

            code=analyse_text_driver(cn,msg->dat1,(char*)msg->dat2,co);
            if (code==2 && (ppd=set_data(co,DRD_WARP_PPD,sizeof(struct warped_ppd)))) {	// reset
                ppd->points=0;
                for (n=0; n<MAXWARPBONUS; n++) ppd->bonuslast_used[n]=0;
                ppd->nostepexp=1;
                say(cn,"Done.");
            }
        }

        // got an item?
        if (msg->type==NT_GIVE) {
            co=msg->dat1;

            if ((in=ch[cn].citem)) {

                type=it[in].drdata[0];
                if (it[in].ID==IID_ALCHEMY_INGREDIENT) {
                    if (type==23) {
                        in2=create_item("warped_door_key");
                        if (give_char_item(co,in2)) flag=1;
                        else destroy_item(in2);
                        say(cn,"Here you go, one key.");
                    }
                    if (type==21) {
                        in2=create_item("warped_door_key");
                        if (give_char_item(co,in2)) flag=1;
                        else destroy_item(in2);
                        in2=create_item("warped_door_key");
                        if (give_char_item(co,in2)) flag=1;
                        else destroy_item(in2);
                        say(cn,"Here you go, two keys.");

                    }
                    if (type==22) {
                        in2=create_item("warped_door_key");
                        if (give_char_item(co,in2)) flag=1;
                        else destroy_item(in2);
                        in2=create_item("warped_door_key");
                        if (give_char_item(co,in2)) flag=1;
                        else destroy_item(in2);
                        in2=create_item("warped_door_key");
                        if (give_char_item(co,in2)) flag=1;
                        else destroy_item(in2);
                        say(cn,"Here you go, three keys.");
                    }
                    if (type==24) {
                        in2=create_item("warped_door_key");
                        if (give_char_item(co,in2)) flag=1;
                        else destroy_item(in2);
                        in2=create_item("warped_door_key");
                        if (give_char_item(co,in2)) flag=1;
                        else destroy_item(in2);
                        in2=create_item("warped_door_key");
                        if (give_char_item(co,in2)) flag=1;
                        else destroy_item(in2);
                        in2=create_item("warped_door_key");
                        if (give_char_item(co,in2)) flag=1;
                        else destroy_item(in2);
                        say(cn,"Here you go, four keys.");
                    }
                }
                if (flag || !give_char_item(co,in)) {
                    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.

    if (spell_self_driver(cn)) return;

    if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_RIGHT,ret,lastact)) return;

    if (ticker%345600==0) {
        mem_erase_driver(cn,7);
    }

    do_idle(cn,TICKS);
}
예제 #12
0
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);
}
예제 #13
0
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);
}