Ejemplo n.º 1
0
void warpteleport_driver(int in,int cn)
{
    int in2,target,n,flag=0;

    if (!cn) return;

    if (!it[in].drdata[0]) {
        switch(it[in].drdata[1]) {
        case 1:
            flag=teleport_char_driver(cn,242,252);
            break;
        case 2:
            flag=teleport_char_driver(cn,247,66);
            break;
        case 3:
            flag=teleport_char_driver(cn,251,16);
            break;
        case 4:
            flag=teleport_char_driver(cn,152,7);
            break;
        case 5:
            flag=teleport_char_driver(cn,183,250);
            break;

        default:
            log_char(cn,LOG_SYSTEM,0,"You found BUG #31as5.");
        }
        if (!flag) log_char(cn,LOG_SYSTEM,0,"Target is busy, please try again soon.");
        return;
    }

    if (!(in2=ch[cn].citem) || it[in2].ID!=IID_AREA25_TELEKEY) {
        log_char(cn,LOG_SYSTEM,0,"Nothing happened.");
        return;
    }

    target=(it[in].drdata[0]-1)*5+(it[in2].drdata[0]-1);

    //log_char(cn,LOG_SYSTEM,0,"target=%d",target);
    if (teleport_char_driver(cn,tl[target].x,tl[target].y)) {
        ch[cn].citem=0;
        ch[cn].flags|=CF_ITEMS;
        destroy_item(in2);
        flag++;

        for (n=0; n<INVENTORYSIZE; n++) {
            if ((in2=ch[cn].item[n]) && it[in2].ID==IID_AREA25_TELEKEY) {
                remove_item_char(in2);
                destroy_item(in2);
                flag++;
            }
        }
        if (flag) log_char(cn,LOG_SYSTEM,0,"Your sphere%s vanished.",flag>0 ? "s" : "");
    }
}
Ejemplo n.º 2
0
void backtofire(int in,int cn)
{
	if (!cn) return;
	if (!it[in].carried) return;	// can only use if item is carried
	
	if (teleport_char_driver(cn,it[in].drdata[0],it[in].drdata[1])) {
		if (ch[cn].flags&CF_PLAYER) dlog(cn,in,"dropped because it was used");
		remove_item_char(in);
		destroy_item(in);
		log_char(cn,LOG_SYSTEM,0,"The scroll vanished.");
	}
}
Ejemplo n.º 3
0
int warpkeydoor_driver(int in,int cn)
{
    int in2,dx,dy;

    if (!cn) return 1;

    dx=it[in].x-ch[cn].x;
    dy=it[in].y-ch[cn].y;
    if (!dx && !dy) {
        log_char(cn,LOG_SYSTEM,0,"Bug #329i, sorry.");
        return 2;
    }

    in2=has_item(cn,IID_AREA25_DOORKEY);

    if (!in2) {
        log_char(cn,LOG_SYSTEM,0,"The door is locked and you do not have the right key.");
        return 2;
    }

    if (teleport_char_driver(cn,it[in].x+dx,it[in].y+dy)) {
        log_char(cn,LOG_SYSTEM,0,"A %s vanished.",it[in2].name);
        remove_item_char(in2);
        destroy_item(in2);
        switch(ch[cn].dir) {
        case DX_RIGHT:
            ch[cn].dir=DX_LEFT;
            break;
        case DX_LEFT:
            ch[cn].dir=DX_RIGHT;
            break;
        case DX_UP:
            ch[cn].dir=DX_DOWN;
            break;
        case DX_DOWN:
            ch[cn].dir=DX_UP;
            break;
        }
        return 1;
    } else {
        log_char(cn,LOG_SYSTEM,0,"Oops. Please try again.");
        return 2;
    }
}
Ejemplo n.º 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);
}
Ejemplo n.º 5
0
int enhance_item(int in,int cn)
{
	int in2,spr,m,need,price;

        if (!(in2=ch[cn].citem)) return 0;

	if (it[in2].flags&IF_NOENHANCE) return 0;

	if (!(spr=enhance_item_sprite(in2))) return 0;

	if ((spr>=59200 && spr<59299) || spr==59474) {	// silver item
		if (it[in].drdata[0]!=2) {	// needs gold
			log_char(cn,LOG_SYSTEM,0,"This item has already been enhanced once. For further enhancements, you need gold.");
			return 1;
		}
	} else {			// normal item
		if (it[in].drdata[0]!=1) {	// needs silver
			log_char(cn,LOG_SYSTEM,0,"To enhance this item, you need silver.");
			return 1;
		}
	}

	need=enhance_item_price(in2);
	if (need>*(unsigned int*)(it[in].drdata+1)) {
		log_char(cn,LOG_SYSTEM,0,"You do not have enough %s to enhance this item. You need %d units.",it[in].name,need);
		return 1;
	}

	if (enhance_cannot_use(in2,cn) && (*(unsigned int *)(it[in].drdata+8)!=in2 || realtime-*(unsigned int *)(it[in].drdata+12)>15)) {
		log_char(cn,LOG_SYSTEM,0,"Enhancing this item would make it unusable for you. Click again if this is what you want.");
		*(unsigned int *)(it[in].drdata+8)=in2;
		*(unsigned int *)(it[in].drdata+12)=realtime;
		return 1;
	}

	price=it[in].value*need/(*(unsigned int*)(it[in].drdata+1));
	*(unsigned int*)(it[in].drdata+1)-=need;
	if (*(unsigned int*)(it[in].drdata+1)<1) {
		if (ch[cn].flags&CF_PLAYER) dlog(cn,in,"dropped because it was used to enhance item");
		remove_item_char(in);
		destroy_item(in);
	} else {
		it[in].value-=price;	//it[in].value*(*(unsigned int*)(it[in].drdata+1))/(need+(*(unsigned int*)(it[in].drdata+1)));
		sprintf(it[in].description,"%d units of %s.",*(unsigned int*)(it[in].drdata+1),it[in].name);
	}
	
	it[in2].sprite=spr;
	it[in2].value=it[in2].value+price;

	for (m=0; m<MAXMOD; m++) {
		if (it[in2].mod_value[m]) {
			switch(it[in2].mod_index[m]) {
				case -V_ARMORSKILL:	it[in2].mod_value[m]+=10; break;
				case -V_DAGGER:		it[in2].mod_value[m]+=10; break;
				case -V_STAFF:		it[in2].mod_value[m]+=10; break;
				case -V_SWORD:          it[in2].mod_value[m]+=10; break;
				case -V_TWOHAND:	it[in2].mod_value[m]+=10; break;
				case V_ARMOR:		it[in2].mod_value[m]+=armorbonus(in2); break;
				case V_WEAPON:		it[in2].mod_value[m]+=10; break;
				default:		if (it[in2].mod_index[m]>=0 && it[in2].mod_value[m]<20) it[in2].mod_value[m]++;
							break;
			}
		}
	}
	set_item_requirements(in2);
	ch[cn].flags|=CF_ITEMS;

	look_item(cn,it+in2);
	log_char(cn,LOG_SYSTEM,0,"You used %d units to enhance your %s.",need,it[in2].name);

	return 1;
}