예제 #1
0
void edemonswitch_driver(int in,int cn)
{
	if (!cn) {
		if (fire) return;
		
		if (ticker>pause_till) {
			remove_item_light(in);
			fire=1;
			it[in].sprite--;
			it[in].mod_value[0]=64;
			add_item_light(in);
		}
		return;
	}
	if (!fire) {
		log_char(cn,LOG_SYSTEM,0,"The lever seems stuck.");
		return;
	}
	
	remove_item_light(in);
	fire=0;
	it[in].sprite++;
	it[in].mod_value[0]=0;
	pause_till=ticker+TICKS*60*5;
	add_item_light(in);

	call_item(it[in].driver,in,0,pause_till+1);
}
예제 #2
0
void edemonblock_driver(int in,int cn)
{
	int m,m2,dx,dy,dir,nr;

	if (cn) {	// player using item
		m=it[in].x+it[in].y*MAXMAP;
		dir=ch[cn].dir;
		dx2offset(dir,&dx,&dy,NULL);
		m2=(it[in].x+dx)+(it[in].y+dy)*MAXMAP;

		if ((map[m2].flags&(MF_MOVEBLOCK|MF_TMOVEBLOCK)) || map[m2].it || map[m2].gsprite<12150 || map[m2].gsprite>12158) {
			log_char(cn,LOG_SYSTEM,0,"It won't move.");
			return;
		}
		map[m].flags&=~MF_TMOVEBLOCK;
		map[m].it=0;
		set_sector(it[in].x,it[in].y);

		map[m2].flags|=MF_TMOVEBLOCK;
		map[m2].it=in;
		it[in].x+=dx; it[in].y+=dy;
		set_sector(it[in].x,it[in].y);

		// hack to avoid using the chest over and over
		if ((nr=ch[cn].player)) {
			player_driver_halt(nr);
		}

		*(unsigned int*)(it[in].drdata)=ticker;

		return;
	} else {	// timer call
		if (!(*(unsigned int*)(it[in].drdata+4))) {	// no coords set, so its first call. remember coords
			*(unsigned short*)(it[in].drdata+4)=it[in].x;
			*(unsigned short*)(it[in].drdata+6)=it[in].y;
		}

		// if 15 minutes have passed without anyone touching the chest, beam it back.
		if (ticker-*(unsigned int*)(it[in].drdata)>TICKS*60*15 &&
		    (*(unsigned short*)(it[in].drdata+4)!=it[in].x ||
		     *(unsigned short*)(it[in].drdata+6)!=it[in].y)) {
			
			m=it[in].x+it[in].y*MAXMAP;
			m2=(*(unsigned short*)(it[in].drdata+4))+(*(unsigned short*)(it[in].drdata+6))*MAXMAP;

			if (!(map[m2].flags&(MF_MOVEBLOCK|MF_TMOVEBLOCK)) && !map[m2].it) {
				map[m].flags&=~MF_TMOVEBLOCK;
				map[m].it=0;
				set_sector(it[in].x,it[in].y);
	
				map[m2].flags|=MF_TMOVEBLOCK;
				map[m2].it=in;
				it[in].x=*(unsigned short*)(it[in].drdata+4);
				it[in].y=*(unsigned short*)(it[in].drdata+6);
				set_sector(it[in].x,it[in].y);
			}
                }
		call_item(it[in].driver,in,0,ticker+TICKS*5);
	}
}
예제 #3
0
void edemonlight_driver(int in,int cn)
{
	int nr,light,sprite;

	if (cn) return;

	nr=it[in].drdata[0];

	if (sect[nr] && sect[nr]<249) {
		light=200;
		sprite=14191;
	} else {
		light=0;
		sprite=14189;
	}

	if (it[in].sprite!=sprite) {
		it[in].sprite=sprite;
		set_sector(it[in].x,it[in].y);
	}

	if (it[in].mod_value[0]!=light) {
		remove_item_light(in);
		it[in].mod_value[0]=light;
		add_item_light(in);
	}
	call_item(it[in].driver,in,cn,ticker+TICKS);
}
예제 #4
0
void meltingkey(int in,int cn)
{
	int sprite;

        if (cn) return;
	if (!it[in].carried) return;	// can only use if item is carried
	
	it[in].drdata[1]++;
	if (it[in].drdata[1]>=it[in].drdata[0]) {
		if (it[in].carried) log_char(it[in].carried,LOG_SYSTEM,0,"Your %s melted away.",it[in].name);
		if (ch[cn].flags&CF_PLAYER) dlog(cn,in,"dropped because it melted");
		remove_item(in);
		destroy_item(in);
		return;
	}
	sprite=50494+it[in].drdata[1]*5/it[in].drdata[0];

	if (it[in].sprite!=sprite) {
		it[in].sprite=sprite;
		if (it[in].carried) {
			ch[it[in].carried].flags|=CF_ITEMS;
			if (sprite==50495) {
				log_char(it[in].carried,LOG_SYSTEM,0,"Your %s starts to melt.",it[in].name);
			}
		}
	}
			
	call_item(it[in].driver,in,0,ticker+TICKS*10);
}
예제 #5
0
void edemonloader_driver(int in,int cn)
{
	int nr,pwr,sprite,in2,ani,m,gsprite;

        nr=it[in].drdata[0];	// section number
	pwr=it[in].drdata[1];	// power status
	ani=it[in].drdata[2];

	if (cn) {	// player using item
		if (pwr) {
			if (ch[cn].citem) log_char(cn,LOG_SYSTEM,0,"There is already a crystal, you cannot add another item.");				
			else log_char(cn,LOG_SYSTEM,0,"The crystal is stuck.");
			return;
		}
		if (!(in2=ch[cn].citem)) {
			log_char(cn,LOG_SYSTEM,0,"Nothing happens.");
			return;
		}
		if (it[in2].ID!=IID_AREA6_YELLOWCRYSTAL) {
			log_char(cn,LOG_SYSTEM,0,"That doesn't fit.");
			return;
		}
		pwr=it[in2].drdata[0];
		ani=7;
		if (ch[cn].flags&CF_PLAYER) dlog(cn,in2,"dropped into edemonloader");
		ch[cn].citem=0;
		ch[cn].flags|=CF_ITEMS;
		destroy_item(in2);
		sound_area(it[in].x,it[in].y,41);
	} else {	// timer call
		if (pwr) pwr--;
		if (ani) ani--;

		call_item(it[in].driver,in,0,ticker+TICKS);
	}
	
	it[in].drdata[2]=ani;
	it[in].drdata[1]=pwr;

	m=it[in].x+it[in].y*MAXMAP;
	gsprite=map[m].gsprite&0x0000ffff;
	
	if (ani) gsprite|=(14247-ani)<<16;
	else if (pwr) gsprite|=14248<<16;
	else gsprite|=14240<<16;

	if (pwr) { sprite=14257+5-(pwr/43); sect[nr]=pwr; }	//50467
	else { sprite=14234; sect[nr]=0; } // 50466;

	if (it[in].sprite!=sprite || map[m].gsprite!=gsprite) {
		it[in].sprite=sprite;
		map[m].gsprite=gsprite;
		set_sector(it[in].x,it[in].y);
		if (sprite==14234) sound_area(it[in].x,it[in].y,43);	// power off
	}
}
예제 #6
0
void staffer_spiketrap(int in,int cn)
{
	if (cn && !it[in].drdata[1]) {
		it[in].sprite++;
		it[in].drdata[1]=1;

		hurt(cn,it[in].drdata[2]*POWERSCALE,0,1,75,75);

		call_item(it[in].driver,in,0,ticker+TICKS);
		return;
	}
	if (!cn && it[in].drdata[1]) {
		it[in].sprite--;
		it[in].drdata[1]=0;
		set_sector(it[in].x,it[in].y);
		return;
	}
}
예제 #7
0
void staffer_fireball_machine(int in,int cn)
{
	int dx,dy,power,fn,dxs,dys,frequency;

	if (cn) return;

        dx=it[in].drdata[1]-128;
	dy=it[in].drdata[2]-128;
	power=it[in].drdata[3];
	frequency=it[in].drdata[4];

        if (frequency) call_item(it[in].driver,in,0,ticker+frequency);

	if (dx>0) dxs=1;
	else if (dx<0) dxs=-1;
	else dxs=0;

	if (dy>0) dys=1;
	else if (dy<0) dys=-1;
	else dys=0;

	fn=create_fireball(0,it[in].x+dxs,it[in].y+dys,it[in].x+dx,it[in].y+dy,power);
	notify_area(it[in].x,it[in].y,NT_SPELL,0,V_FIRE,fn);
}
예제 #8
0
void edemontube_driver(int in,int cn)
{
	int nr,in2,x,y,n,co,next,light,sprite;

	nr=it[in].drdata[0];

	if (cn) {	// character using it
		teleport_char_driver(cn,*(unsigned short*)(it[in].drdata+2),*(unsigned short*)(it[in].drdata+4));
	} else {	// timer call
		if (sect[nr] && sect[nr]<249) {
			light=200;
			sprite=14138;
		} else {
			light=0;
			sprite=14137;
		}
	
		if (it[in].sprite!=sprite) {
			it[in].sprite=sprite;
			set_sector(it[in].x,it[in].y);
		}
	
		if (it[in].mod_value[0]!=light) {
			remove_item_light(in);
			it[in].mod_value[0]=light;
			add_item_light(in);
		}



		if (!(*(unsigned short*)(it[in].drdata+2))) {
			for (in2=1; in2<MAXITEM; in2++) {
				if (it[in2].driver==IDR_EDEMONLOADER && it[in2].drdata[0]==nr) {
					
					// find teleport target (up or down of item)
					x=it[in2].x; y=it[in2].y;					
					if (!(map[x+y*MAXMAP+MAXMAP].flags&(MF_MOVEBLOCK|MF_TMOVEBLOCK))) y++;
					else if (!(map[x+y*MAXMAP-MAXMAP].flags&(MF_MOVEBLOCK|MF_TMOVEBLOCK))) y--;

					// remember target
					*(unsigned short*)(it[in].drdata+2)=x;
					*(unsigned short*)(it[in].drdata+4)=y;

					//xlog("%s (%d) found %s (%d) at %d,%d",it[in].name,in,it[in2].name,in2,it[in2].x,it[in2].y);
				}
			}
		}
		if (sect[nr]>250) {
			for (n=0; n<25;  n++) {
				for (co=getfirst_char_sector(it[in].x+offx[n],it[in].y+offy[n]); co; co=next) {
					
					next=ch[co].sec_next;

					if (!(ch[co].flags&CF_PLAYER)) continue;

					if (abs(ch[co].x-it[in].x)>10 || abs(ch[co].y-it[in].y)>10) continue;

					if (char_see_item(co,in)) {
						teleport_char_driver(co,*(unsigned short*)(it[in].drdata+2),*(unsigned short*)(it[in].drdata+4));
						log_char(co,LOG_SYSTEM,0,"The strange tube teleported you.");
					}
				}
			}
		}
		call_item(it[in].driver,in,0,ticker+TICKS);
	}
}
예제 #9
0
int edemondoor_driver(int in,int cn)
{
	int m,in2,n,nr;

	if (!it[in].x) return 2;

	if (!cn) {	// called by timer
		if (it[in].drdata[39]) it[in].drdata[39]--;	// timer counter
                if (!it[in].drdata[0]) return 2;		// if the door is closed already, don't open it again
		if (it[in].drdata[39]) return 2;		// we have more outstanding timer calls, dont close now
	}

	if (!cn && it[in].drdata[5]) return 2;	// no auto-close for this door

        m=it[in].x+it[in].y*MAXMAP;

	if (it[in].drdata[0] && (map[m].flags&(MF_MOVEBLOCK|MF_TMOVEBLOCK))) {	// doorway is blocked
		if (!cn) {	// timer callback - restart
			it[in].drdata[39]++;	// timer counter
			if (!it[in].drdata[5]) call_item(it[in].driver,in,0,ticker+TICKS*5);			
		}
		return 2;
	}

	// if the door needs a key, check if the character has it
	if (cn && (it[in].drdata[1] || it[in].drdata[2])) {
		for (n=30; n<INVENTORYSIZE; n++)
			if ((in2=ch[cn].item[n]))
				if (*(unsigned int*)(it[in].drdata+1)==it[in2].ID) break;
		if (n==INVENTORYSIZE) {
			if (!(in2=ch[cn].citem) || *(unsigned int*)(it[in].drdata+1)!=it[in2].ID) {
				log_char(cn,LOG_SYSTEM,0,"You need a key to use this door.");
				return 2;
			}
		}
		log_char(cn,LOG_SYSTEM,0,"You use %s to %slock the door.",it[in2].name,it[in].drdata[0] ? "" :  "un");
	}

	nr=it[in].drdata[6];
	if (!sect[nr] && cn) {
		log_char(cn,LOG_SYSTEM,0,"The door won't move. It seems somehow lifeless.");
		return 2;
	}

	remove_lights(it[in].x,it[in].y);

	if (cn) sound_area(it[in].x,it[in].y,3);
	else sound_area(it[in].x,it[in].y,2);

        if (it[in].drdata[0]) {	// it is open, close
		it[in].flags|=*(unsigned long long*)(it[in].drdata+30);
		if (it[in].flags&IF_MOVEBLOCK) map[m].flags|=MF_TMOVEBLOCK;
		if (it[in].flags&IF_SIGHTBLOCK) map[m].flags|=MF_TSIGHTBLOCK;
		if (it[in].flags&IF_SOUNDBLOCK) map[m].flags|=MF_TSOUNDBLOCK;
		if (it[in].flags&IF_DOOR) map[m].flags|=MF_DOOR;
                it[in].drdata[0]=0;
		it[in].sprite--;
	} else { // it is closed, open
		*(unsigned long long*)(it[in].drdata+30)=it[in].flags&(IF_MOVEBLOCK|IF_SIGHTBLOCK|IF_DOOR|IF_SOUNDBLOCK);
		it[in].flags&=~(IF_MOVEBLOCK|IF_SIGHTBLOCK|IF_DOOR|IF_SOUNDBLOCK);
		map[m].flags&=~(MF_TMOVEBLOCK|MF_TSIGHTBLOCK|MF_DOOR|MF_TSOUNDBLOCK);
		it[in].drdata[0]=1;
		it[in].sprite++;

		it[in].drdata[39]++;	// timer counter
		if (!it[in].drdata[5]) call_item(it[in].driver,in,0,ticker+TICKS*10);		
	}

        reset_los(it[in].x,it[in].y);
        if (!it[in].drdata[38] && !reset_dlight(it[in].x,it[in].y)) it[in].drdata[38]=1;
	add_lights(it[in].x,it[in].y);

	return 1;
}
예제 #10
0
void edemongate_driver(int in,int cn)
{
	int n,co,ser,nr;
	char name[80];
        if (cn) return;

	nr=it[in].drdata[0];

        if (nr==0) {
		static int pos[14]={
			62,157,
			62,164,
			62,174,
			62,184,
			62,191,
			56,174,
			67,174};
	
		for (n=0; n<7; n++) {
			co=*(unsigned short*)(it[in].drdata+4+n*4);
			ser=*(unsigned short*)(it[in].drdata+6+n*4);
	
			if (!co || !ch[co].flags || (unsigned short)ch[co].serial!=(unsigned short)ser) {
				sprintf(name,"edemon2s");
				co=create_char(name,0);
				if (!co) break;
	
				if (item_drop_char(in,co)) {
					
					ch[co].tmpx=pos[n*2];
					ch[co].tmpy=pos[n*2+1];
					
					update_char(co);
					
					ch[co].hp=ch[co].value[0][V_HP]*POWERSCALE;
					ch[co].endurance=ch[co].value[0][V_ENDURANCE]*POWERSCALE;
					ch[co].mana=ch[co].value[0][V_MANA]*POWERSCALE;
					
					ch[co].dir=DX_RIGHTDOWN;
		
					*(unsigned short*)(it[in].drdata+4+n*4)=co;
					*(unsigned short*)(it[in].drdata+6+n*4)=ch[co].serial;
					break;	// only one spawn per call
				} else {
					destroy_char(co);
					break;
				}
			}
		}
		call_item(it[in].driver,in,0,ticker+TICKS*10);
	} else if (nr==1) {
		static int pos[100]={0},co_nr[100],serial[100],maxpos=0;

		if (!maxpos) {
			for (n=1; n<MAXITEM; n++) {
				if (!it[n].flags) continue;
				if (it[n].driver!=IDR_EDEMONLIGHT) continue;
				if (it[n].drdata[0]!=4) continue;
                                pos[maxpos++]=it[n].x+it[n].y*MAXMAP;
			}
		}
		for (n=0; n<maxpos; n++) {
			if (!(co=co_nr[n]) || !ch[co].flags || ch[co].serial!=serial[n]) {
				co=create_char("edemon6s",0);
				if (!co) break;

				if (item_drop_char(in,co)) {
					
					ch[co].tmpx=pos[n]%MAXMAP;
					ch[co].tmpy=pos[n]/MAXMAP;
					
					update_char(co);
					
					ch[co].hp=ch[co].value[0][V_HP]*POWERSCALE;
					ch[co].endurance=ch[co].value[0][V_ENDURANCE]*POWERSCALE;
					ch[co].mana=ch[co].value[0][V_MANA]*POWERSCALE;
					
					ch[co].dir=DX_RIGHTDOWN;
		
					co_nr[n]=co;
					serial[n]=ch[co].serial;
					break;	// only one spawn per call
				} else {
					destroy_char(co);
					break;
				}
			}
		}
		call_item(it[in].driver,in,0,ticker+TICKS*20);
	}		
}
예제 #11
0
void edemonball_driver(int in,int cn)
{
	int co,n,m,base;
	int dx,dy,ox=0,oy=0,tx=0,ty=0;
	int dir,dist,left,step,eta,str;

	if (cn) return;

	base=it[in].drdata[1];
	str=it[in].drdata[2];

	// disable/enable for part 1
	if (it[in].drdata[0]==0) {
		if (!fire) {
			if (it[in].sprite!=14160) {
				it[in].sprite=14160;
				set_sector(it[in].x,it[in].y);
			}		
			call_item(it[in].driver,in,0,ticker+10);
			return;
		} else {
			it[in].sprite=14159;
			set_sector(it[in].x,it[in].y);
		}
	}

	// disable/enable for part 5
	if (it[in].drdata[0]>=2 && it[in].drdata[0]<=9) {
		if (sect[it[in].drdata[0]-2]==0 || sect[it[in].drdata[0]-2]>248) {	// turned off
			if (it[in].sprite!=14160) {
				it[in].sprite=14160;
				set_sector(it[in].x,it[in].y);
			}		
			call_item(it[in].driver,in,0,ticker+10);
			return;
		} else {
			it[in].sprite=14161;
			set_sector(it[in].x,it[in].y);
		}
	}

	for (n=0; n<25;  n++) {
		for (co=getfirst_char_sector(it[in].x+offx[n],it[in].y+offy[n]); co; co=ch[co].sec_next) {

                        if (abs(ch[co].x-it[in].x)>10 || abs(ch[co].y-it[in].y)>10) continue;

			if (abs(ch[co].x-it[in].x)>abs(ch[co].y-it[in].y)) {
				if (ch[co].x>it[in].x) ox=1;
				if (ch[co].x<it[in].x) ox=-1;
				oy=0;
			} else {
				if (ch[co].y>it[in].y) oy=1;
				if (ch[co].y<it[in].y) oy=-1;
				ox=0;
			}
	
                        if (ch[co].action!=AC_WALK) { tx=ch[co].x; ty=ch[co].y; }
			else {
	
				dir=ch[co].dir;
				dx2offset(dir,&dx,&dy,NULL);
				dist=map_dist(it[in].x,it[in].y,ch[co].x,ch[co].y);
			
				eta=dist*1.5;
				
				left=ch[co].duration-ch[co].step;
				step=ch[co].duration;
			
				eta-=left;
				if (eta<=0) { tx=ch[co].tox; ty=ch[co].toy; }
				else {
					for (m=1; m<10; m++) {
						eta-=step;
						if (eta<=0) { tx=ch[co].x+dx*m; ty=ch[co].y+dy*m; break; }
					}
			
					// too far away, time-wise to make any prediction. give up.
					if (m==10) { tx=ch[co].x; ty=ch[co].y; }
				}
			}
		
                        if (can_hit(in,co,it[in].x+ox,it[in].y+oy,tx,ty)) {				
				break;
			}
		}

                if (co) {
                        create_edemonball(0,it[in].x+ox,it[in].y+oy,tx,ty,str,base);
	
			call_item(it[in].driver,in,0,ticker+8);
			
			return;
		}
	}

	if (it[in].drdata[3]==0 && !free_line(it[in].x,it[in].y+1,0,1)) it[in].drdata[3]=3;
	if (it[in].drdata[3]==3 && !free_line(it[in].x,it[in].y-1,0,-1)) it[in].drdata[3]=6;
	if (it[in].drdata[3]==6 && !free_line(it[in].x+1,it[in].y,1,0)) it[in].drdata[3]=9;
	if (it[in].drdata[3]==9 && !free_line(it[in].x-1,it[in].y,-1,0)) it[in].drdata[3]=12;

        switch(it[in].drdata[3]) {	
		case 0:         create_edemonball(0,it[in].x,it[in].y+1,it[in].x,it[in].y+10,str,base); it[in].drdata[3]++; break;
		case 1:		create_edemonball(0,it[in].x,it[in].y+1,it[in].x+1,it[in].y+10,str,base); it[in].drdata[3]++; break;
		case 2:		create_edemonball(0,it[in].x,it[in].y+1,it[in].x-1,it[in].y+10,str,base); it[in].drdata[3]++; break;

		case 3:         create_edemonball(0,it[in].x,it[in].y-1,it[in].x,it[in].y-10,str,base); it[in].drdata[3]++; break;
		case 4:		create_edemonball(0,it[in].x,it[in].y-1,it[in].x+1,it[in].y-10,str,base); it[in].drdata[3]++; break;
		case 5:		create_edemonball(0,it[in].x,it[in].y-1,it[in].x-1,it[in].y-10,str,base); it[in].drdata[3]++; break;

		case 6:         create_edemonball(0,it[in].x+1,it[in].y,it[in].x+10,it[in].y,str,base); it[in].drdata[3]++; break;
		case 7:		create_edemonball(0,it[in].x+1,it[in].y,it[in].x+10,it[in].y+1,str,base); it[in].drdata[3]++; break;
		case 8:		create_edemonball(0,it[in].x+1,it[in].y,it[in].x+10,it[in].y-1,str,base); it[in].drdata[3]++; break;

		case 9:         create_edemonball(0,it[in].x-1,it[in].y,it[in].x-10,it[in].y,str,base); it[in].drdata[3]++; break;
		case 10:	create_edemonball(0,it[in].x-1,it[in].y,it[in].x-10,it[in].y+1,str,base); it[in].drdata[3]++; break;
		case 11:	create_edemonball(0,it[in].x-1,it[in].y,it[in].x-10,it[in].y-1,str,base); it[in].drdata[3]++; break;
		default:	it[in].drdata[3]=0; break;
	}

	call_item(it[in].driver,in,0,ticker+16);
}
예제 #12
0
void minewall(int in,int cn)
{
	int in2,amount,co;
	char buf[80];

        if (!cn) {
		if (!it[in].drdata[4]) {
                        it[in].drdata[4]=1;
			switch((it[in].x+it[in].y)%3) {
				case 0:		it[in].sprite=15070; break;
				case 1:		it[in].sprite=15078; break;
				case 2:		it[in].sprite=15086; break;
			}
			
		}

                if (it[in].drdata[3]==8) {
			if ((map[it[in].x+it[in].y*MAXMAP].flags&MF_TMOVEBLOCK) || map[it[in].x+it[in].y*MAXMAP].it) {
				call_item(it[in].driver,in,0,ticker+TICKS);
				return;
			}
			it[in].sprite-=8;
			it[in].drdata[3]=0;
			it[in].flags|=IF_USE;
			it[in].flags&=~IF_VOID;
			
			remove_lights(it[in].x,it[in].y);
			map[it[in].x+it[in].y*MAXMAP].it=in;
			map[it[in].x+it[in].y*MAXMAP].flags|=MF_TSIGHTBLOCK|MF_TMOVEBLOCK;
			it[in].flags|=IF_SIGHTBLOCK;
			reset_los(it[in].x,it[in].y);
			add_lights(it[in].x,it[in].y);
                        set_sector(it[in].x,it[in].y);
		}
		return;
	}

	if (ch[cn].citem) {
		log_char(cn,LOG_SYSTEM,0,"Please empty your hand (mouse cursor) first.");
		player_driver_dig_off(cn);
		return;
	}
	
	
	if (it[in].drdata[3]<9) {
		if (ch[cn].endurance<POWERSCALE) {
			log_char(cn,LOG_SYSTEM,0,"You're too exhausted to continue digging.");
			player_driver_dig_off(cn);
			return;
		}
		ch[cn].endurance-=POWERSCALE/4-(ch[cn].prof[P_MINER]*POWERSCALE/(4*25));

                it[in].drdata[3]++;
		it[in].drdata[5]=0;
		it[in].sprite++;
		
		if (it[in].drdata[3]==8) {
                        map[it[in].x+it[in].y*MAXMAP].it=0;
			map[it[in].x+it[in].y*MAXMAP].flags&=~MF_TMOVEBLOCK;
			it[in].flags&=~IF_USE;
			it[in].flags|=IF_VOID;
			call_item(it[in].driver,in,0,ticker+TICKS*60*5+RANDOM(TICKS*60*25));

			if (!RANDOM(15)) {
				in2=create_item("silver");
				if (!in2) elog("silver not found");

				amount=RANDOM(it[in].drdata[0]*2+1)+it[in].drdata[0];
				//xlog("amount=%d",amount);
				if (ch[cn].prof[P_MINER]) amount+=amount*ch[cn].prof[P_MINER]/10;
				//xlog("amount=%d",amount);
				if (!amount && in2) {
					destroy_item(in2);
				}
			} else if (!RANDOM(50)) {
				in2=create_item("gold");
				if (!in2) elog("gold not found");

				amount=RANDOM(it[in].drdata[1]*2+1)+it[in].drdata[1];
				if (ch[cn].prof[P_MINER]) amount+=amount*ch[cn].prof[P_MINER]/10;
				if (!amount && in2) {
					destroy_item(in2);
				}
			} else amount=in2=0;

			if (amount && in2) {
				it[in2].value*=amount;
				*(unsigned int*)(it[in2].drdata+1)=amount;
				sprintf(it[in2].description,"%d units of %s.",*(unsigned int*)(it[in2].drdata+1),it[in2].name);

				if (ch[cn].flags&CF_PLAYER) dlog(cn,in2,"took from minewall");
				ch[cn].citem=in2;
				it[in2].carried=cn;
				ch[cn].flags|=CF_ITEMS;

				log_char(cn,LOG_SYSTEM,0,"You found %d units of %s.",amount,it[in2].name);

				if (it[in2].drdata[0]==1) check_military_silver(cn,amount);
			}

			if (!RANDOM(10)) {
				sprintf(buf,"miner%d",it[in].drdata[2]);
				co=create_char(buf,0);
				if (!co) elog("%s not found",buf);

				if (co) {
					if (drop_char(co,it[in].x,it[in].y,0)) {
						ch[co].tmpx=ch[co].x;
						ch[co].tmpy=ch[co].y;
						
						update_char(co);
						
						ch[co].hp=ch[co].value[0][V_HP]*POWERSCALE;
						ch[co].endurance=ch[co].value[0][V_ENDURANCE]*POWERSCALE;
						ch[co].mana=ch[co].value[0][V_MANA]*POWERSCALE;
						
						ch[co].dir=DX_RIGHTDOWN;
					} else {
						destroy_char(co);
					}
				}
			}
		}
		
		set_sector(it[in].x,it[in].y);

		if (it[in].drdata[3]==3) {
			remove_lights(it[in].x,it[in].y);
			map[it[in].x+it[in].y*MAXMAP].flags&=~MF_TSIGHTBLOCK;
			it[in].flags&=~IF_SIGHTBLOCK;
			reset_los(it[in].x,it[in].y);
			add_lights(it[in].x,it[in].y);
		}
	}
	
	if (it[in].drdata[3]<8) player_driver_dig_on(cn);
	else player_driver_dig_off(cn);
}
예제 #13
0
void minedoor(int in,int cn)
{
	int in2,nr,ret;

        // gather information about door system
	if (!door_init) {
		for (in2=1; in2<MAXITEM; in2++) {
			if (!it[in2].flags) continue;
			if (it[in2].driver!=IDR_MINEDOOR) continue;

			nr=it[in2].drdata[0];
			//xlog("found something at %d,%d",it[in2].x,it[in2].y);

			if (!it[in2].drdata[1]) {	// source door
				if (it[in2].drdata[3]) {	// usable source door
					if (sdoor[nr]) xlog("confused: two source doors");
                                        sdoor[nr]=in2;
					//xlog("source %d is at %d,%d",it[in2].drdata[0],it[in2].x,it[in2].y);
				}
			} else {	// target door
				if (tdoor[nr]) xlog("confused: two target doors");
				tdoor[nr]=in2;
				//xlog("target %d is at %d,%d",it[in2].drdata[0],it[in2].x,it[in2].y);
			}
		}
		door_init=1;
	}

	nr=it[in].drdata[0];
	
	if (!cn) {	// timer call
		call_item(it[in].driver,in,0,ticker+TICKS*30);

		if (it[in].drdata[3]) return;	// we're already open, dont do anything

		// dont change it when the surrounding walls have been dug away
		if (!(map[it[in].x+it[in].y*MAXMAP+1].flags&(MF_SIGHTBLOCK|MF_TSIGHTBLOCK)) ||
		    !(map[it[in].x+it[in].y*MAXMAP-1].flags&(MF_SIGHTBLOCK|MF_TSIGHTBLOCK)) ||
		    !(map[it[in].x+it[in].y*MAXMAP+MAXMAP].flags&(MF_SIGHTBLOCK|MF_TSIGHTBLOCK)) ||
		    !(map[it[in].x+it[in].y*MAXMAP-MAXMAP].flags&(MF_SIGHTBLOCK|MF_TSIGHTBLOCK)) ||
		    !(map[it[in].x+it[in].y*MAXMAP+1+MAXMAP].flags&(MF_SIGHTBLOCK|MF_TSIGHTBLOCK)) ||
		    !(map[it[in].x+it[in].y*MAXMAP+1-MAXMAP].flags&(MF_SIGHTBLOCK|MF_TSIGHTBLOCK)) ||
		    !(map[it[in].x+it[in].y*MAXMAP-1+MAXMAP].flags&(MF_SIGHTBLOCK|MF_TSIGHTBLOCK)) ||
		    !(map[it[in].x+it[in].y*MAXMAP-1-MAXMAP].flags&(MF_SIGHTBLOCK|MF_TSIGHTBLOCK))) {
			//xlog("dug out 1");
                        return;
		}
                if ((in2=sdoor[nr])) {	// there is a source door already, close it
			if (!(map[it[in2].x+it[in2].y*MAXMAP+1].flags&(MF_MOVEBLOCK|MF_TMOVEBLOCK)) ||
			    !(map[it[in2].x+it[in2].y*MAXMAP-1].flags&(MF_MOVEBLOCK|MF_TMOVEBLOCK)) ||
			    !(map[it[in2].x+it[in2].y*MAXMAP+MAXMAP].flags&(MF_MOVEBLOCK|MF_TMOVEBLOCK)) ||
			    !(map[it[in2].x+it[in2].y*MAXMAP-MAXMAP].flags&(MF_MOVEBLOCK|MF_TMOVEBLOCK)) ||
			    !(map[it[in2].x+it[in2].y*MAXMAP+1+MAXMAP].flags&(MF_MOVEBLOCK|MF_TMOVEBLOCK)) ||
			    !(map[it[in2].x+it[in2].y*MAXMAP+1-MAXMAP].flags&(MF_MOVEBLOCK|MF_TMOVEBLOCK)) ||
			    !(map[it[in2].x+it[in2].y*MAXMAP-1+MAXMAP].flags&(MF_MOVEBLOCK|MF_TMOVEBLOCK)) ||
			    !(map[it[in2].x+it[in2].y*MAXMAP-1-MAXMAP].flags&(MF_MOVEBLOCK|MF_TMOVEBLOCK))) {
				//xlog("dug out 2");
				return;
			}
			if (RANDOM(20)) return;	// some randomness

			it[in2].sprite=15000;
			it[in2].flags&=~IF_USE;
			it[in2].drdata[3]=0;
			set_sector(it[in2].x,it[in2].y);
			//xlog("closed source door %d at %d,%d",nr,it[in2].x,it[in2].y);
		}

		switch(it[in].drdata[2]) {
			case DX_UP:
			case DX_DOWN:	it[in].sprite=20124; break;
			case DX_RIGHT:
			case DX_LEFT:	it[in].sprite=20122; break;
		}
		it[in].flags|=IF_USE;
		it[in].drdata[3]=1;
		set_sector(it[in].x,it[in].y);
		sdoor[nr]=in;
		//xlog("opened source door %d at %d,%d",nr,it[in].x,it[in].y);

		return;
	}
	
	// find target
	if (it[in].drdata[1]) in2=sdoor[nr];
	else in2=tdoor[nr];

	// teleport character to target
	ret=0;
	switch(it[in2].drdata[2]) {
		case DX_UP:	ret=teleport_char_driver(cn,it[in2].x,it[in2].y-1); break;
		case DX_DOWN:	ret=teleport_char_driver(cn,it[in2].x,it[in2].y+1); break;
		case DX_RIGHT:	ret=teleport_char_driver(cn,it[in2].x-1,it[in2].y); break;
		case DX_LEFT:	ret=teleport_char_driver(cn,it[in2].x+1,it[in2].y); break;
	}
	if (!ret) {
		log_char(cn,LOG_SYSTEM,0,"The mine has collapsed behind this door. Some friendly spirit grabs you and teleports you somewhere else.");
		if (areaID!=31) teleport_char_driver(cn,230,240);
		else teleport_char_driver(cn,211,231);
	}
}
예제 #14
0
void lab5_item(int in, int cn)
{
        struct lab5_player_data *pd;
        char *drdata,dx,dy;
        int in2;

        drdata=it[in].drdata;

        if (!numchestboxes) count_chestboxes();

        if (!cn) {

                // fireface
                if (drdata[0]==2) {
                        if (it[in].sprite==11135) { dx=1; dy=0; }
                        else if (it[in].sprite==11136) { dx=0; dy=-1; }
                        else if (it[in].sprite==11137) { dx=-1; dy=0; }
                        else /*if (it[in].sprite==11138)*/ { dx=0; dy=1; }
                        create_fireball(0,it[in].x+dx,it[in].y+dy,it[in].x+dx+dx,it[in].y+dy+dy,50);

                        if (drdata[1]==0) {
                                drdata[1]=1;
                                call_item(it[in].driver,in,0,ticker+(((it[in].x+it[in].y)%17)+1)*TICKS);
                        }
                        else call_item(it[in].driver,in,0,ticker+5*TICKS);
                }

                // lightface
                if (drdata[0]==13) {
                        if (it[in].sprite==11135) { dx=1; dy=0; }
                        else if (it[in].sprite==11136) { dx=0; dy=-1; }
                        else if (it[in].sprite==11137) { dx=-1; dy=0; }
                        else /*if (it[in].sprite==11138)*/ { dx=0; dy=1; }
                        create_ball(0,it[in].x+dx,it[in].y+dy,it[in].x+dx+dx,it[in].y+dy+dy,40);

                        if (drdata[1]==0) {
                                drdata[1]=1;
                                call_item(it[in].driver,in,0,ticker+(((it[in].x+it[in].y)%10)+1)*TICKS);
                        }
                        else if (drdata[2]==4) {
                                call_item(it[in].driver,in,0,ticker+9*TICKS);
                                drdata[2]=0;
                        }
                        else {
                                call_item(it[in].driver,in,0,ticker+7*TICKS/4);
                                drdata[2]++;
                        }
                }

                // chestbox
                if (drdata[0]==3) {
                        if (!drdata[3]) return;
                        drdata[3]=0;
                        it[in].sprite--;
                        set_sector(it[in].x,it[in].y);
                }

                // nameplate
                if (drdata[0]==5) {
                        namecoordx[(int)drdata[1]]=it[in].x;
                        namecoordy[(int)drdata[1]]=it[in].y;
                }

                // entrance
                if (drdata[0]==7) {
                        it[in].sprite=0;
                        set_sector(it[in].x,it[in].y);
                }

                // backdoor
                if (drdata[0]==8) {
                        static int bcnt=0;
                        daemondoorx[bcnt]=it[in].x;
                        daemondoory[bcnt]=it[in].y;
                        bcnt++;
                }

                // gun
                if (drdata[0]==9) {
                        if (!drdata[1]) return;
                        drdata[1]--;
                        it[in].sprite--;
                        set_sector(it[in].x,it[in].y);
                        if (drdata[1]) call_item(it[in].driver,in,0,ticker+GUNRELOAD);
                }

                // pike
                if (drdata[0]==10) {
                        if (!drdata[1]) return;
                        drdata[1]=0;
                        it[in].sprite--;
                        set_sector(it[in].x,it[in].y);
                }

        }
        else {

                // obelisk
                if (drdata[0]==1) {
                        ch[cn].hp=ch[cn].value[0][V_HP]*POWERSCALE;
                        ch[cn].mana=ch[cn].value[0][V_MANA]*POWERSCALE;
                        ch[cn].endurance=ch[cn].value[0][V_ENDURANCE]*POWERSCALE;
                        ch[cn].lifeshield=get_lifeshield_max(cn)*POWERSCALE;
                        sound_area(ch[cn].x,ch[cn].y,41);
                }

                // chestbox
                if (drdata[0]==3) {

                        char *str;

                        if (drdata[3]) return;
                        if (ch[cn].citem) return;

                        // check if it was already opened
                        if (check_chestbox(cn,in)) { log_char(cn,LOG_SYSTEM,0,"Thou canst not open the chest again."); return; }

                        // open box (and call close timer)
                        drdata[3]=1;
                        it[in].sprite++;
                        set_sector(it[in].x,it[in].y);
                        call_item(it[in].driver,in,0,ticker+2*TICKS);

                        // which item
                        switch(drdata[1]) {
                                case 1: str="lab5_combopotion"; break;
                                case 2: str="lab5_staff"; break;
                                case 3: str="lab5_dagger"; break;
                                case 4: str="lab5_sword"; break;
                                case 5: str="lab5_twohanded"; break;
                                case 6: str="lab5_manapotion"; break;
                                case 7: str="lab5_manslayer"; break;
                                default: str="oops"; break;
                        }

                        // create and give potion to player
                        in2=create_item(str);
                        log_char(cn,LOG_SYSTEM,0,"You received a %s.",it[in2].name);

                        if (!in2) { xlog("failed to create '%s' item in %s %d",str,__FILE__,__LINE__); return; }

                        ch[cn].citem=in2;
                        ch[cn].flags|=CF_ITEMS;
                        it[in2].carried=cn;
                }

                // combopotion
                if (drdata[0]==4) {
                        ch[cn].hp=ch[cn].value[0][V_HP]*POWERSCALE;
                        ch[cn].mana=ch[cn].value[0][V_MANA]*POWERSCALE;
                        ch[cn].endurance=ch[cn].value[0][V_ENDURANCE]*POWERSCALE;
                        if (ch[cn].value[1][V_MAGICSHIELD]) ch[cn].lifeshield=get_lifeshield_max(cn)*POWERSCALE;
                        log_area(ch[cn].x,ch[cn].y,LOG_INFO,cn,10,"%s drinks a potion.",ch[cn].name);
                        remove_item(in);
                        free_item(in);
                }

                // manapotion
                if (drdata[0]==12) {
                        // ch[cn].hp=ch[cn].value[0][V_HP]*POWERSCALE;
                        ch[cn].mana=ch[cn].value[0][V_MANA]*POWERSCALE;
                        // ch[cn].endurance=ch[cn].value[0][V_ENDURANCE]*POWERSCALE;
                        if (ch[cn].value[1][V_MAGICSHIELD]) ch[cn].lifeshield=get_lifeshield_max(cn)*POWERSCALE;
                        log_area(ch[cn].x,ch[cn].y,LOG_INFO,cn,10,"%s drinks a potion.",ch[cn].name);
                        remove_item(in);
                        free_item(in);
                }

                // nameplate
                if (drdata[0]==5) {

                        // get pd
                        pd=set_data(cn,DRD_LAB5_PLAYER,sizeof(struct lab5_player_data));
                        if (!pd) return;

                        if (pd->ritualstate==0) {
                                sound_area(ch[cn].x,ch[cn].y,41);
                                pd->ritualdaemon=drdata[1];
                                pd->ritualstate=1;
                                log_char(cn,LOG_SYSTEM,0,"Thou canst read the symbols now. They form the words:");
                                log_char(cn,LOG_SYSTEM,0,"°c3The Ritual of %s started.°c0",daemonname[pd->ritualdaemon]);
                        }
                        else ritual_hurt(cn,pd,it[in].x,it[in].y);

                }

                // realnameplate
                if (drdata[0]==6) {

                        // get pd
                        pd=set_data(cn,DRD_LAB5_PLAYER,sizeof(struct lab5_player_data));
                        if (!pd) return;

                        if (pd->ritualstate==0) { log_char(cn,LOG_SYSTEM,0,"Nothing happens."); return; }

                        if (pd->ritualstate==1 && pd->ritualdaemon==drdata[1]) {
                                sound_area(ch[cn].x,ch[cn].y,41);
                                pd->ritualstate=2;
                                log_char(cn,LOG_SYSTEM,0,"Thou canst read the symbols now. They form the words:");
                                log_char(cn,LOG_SYSTEM,0,"°c3The ritual of %s is the Ritual of %s.°c0",daemonname[pd->ritualdaemon],daemonreal[pd->ritualdaemon]);
                        }
                        else ritual_hurt(cn,pd,it[in].x,it[in].y);

                }

                // entrance
                if (drdata[0]==7) {

                        static int hurttrans[4]={2,3,0,1};

                        // get pd
                        pd=set_data(cn,DRD_LAB5_PLAYER,sizeof(struct lab5_player_data));
                        if (!pd) return;

                        if (pd->ritualstate==0) return;

                        if (pd->ritualstate==2 && pd->ritualdaemon==drdata[1]){
                                sound_area(ch[cn].x,ch[cn].y,41);
                                pd->ritualdaemon=drdata[1];
                                pd->ritualstate=3;
                                log_char(cn,LOG_SYSTEM,0,"Mathor tells you: \"The ritual continues. Well done so far, %s.\"",ch[cn].name);
                                // log_char(cn,LOG_SYSTEM,0,"°c3The Ritual of %s continues.°c0",daemonname[pd->ritualdaemon]);
                        }
                        else {
				if (drdata[1]==2) log_char(cn,LOG_SYSTEM,0,"Mathor tells you: \"Sorry. But a strange power forced me.\"");
                                ritual_hurt(cn,pd,namecoordx[hurttrans[(int)drdata[1]]],namecoordy[hurttrans[(int)drdata[1]]]);
                        }

                }

                // backdoor
                if (drdata[0]==8) {
                        // watch the syntax!
                        if (!teleport_char_driver(cn,namecoordx[2],namecoordy[1]))
                                if (!teleport_char_driver(cn,namecoordx[0],namecoordy[0]))
                                if (!teleport_char_driver(cn,namecoordx[1],namecoordy[1]))
                                if (!teleport_char_driver(cn,namecoordx[2],namecoordy[2]))
                                teleport_char_driver(cn,namecoordx[3],namecoordy[3]);
                }

                // gun
                if (drdata[0]==9) {
                        if (drdata[1]) { log_char(cn,LOG_SYSTEM,0,"Thou canst not push the lever."); return; }
                        drdata[1]=7;
                        it[in].sprite+=7;
                        set_sector(it[in].x,it[in].y);
                        call_item(it[in].driver,in,0,ticker+GUNRELOAD);

                        create_fireball(cn,it[in].x+2,it[in].y,it[in].x+60,it[in].y,100);
                }

                // pike
                if (drdata[0]==10) {
                        hurt(cn,5*POWERSCALE,0,1,0,0);
                        if (drdata[1]) return;
                        drdata[1]++;
                        it[in].sprite++;
                        set_sector(it[in].x,it[in].y);
                        call_item(it[in].driver,in,0,ticker+5*TICKS);
                }

                // no potion door
                if (drdata[0]==11) {
                        if (ch[cn].x<it[in].x && has_potion(cn) ) {
                                log_char(cn,LOG_SYSTEM,0,"°c3Thou canst not enter carrying a mana, healing or combo potion!°c0");
                                return;
                        }

                        if (ch[cn].x<it[in].x) teleport_char_driver(cn,it[in].x-9,it[in].y-7);
                        else teleport_char_driver(cn,it[in].x+9,it[in].y+7);
                }
        }

}