public static short craftNewWeapon(int wtype, int skill) {
		short result = (short) (AGPmain.rand.nextInt() << 6);
		if (wtype == Misc.sword) {result = Calc.setBitPart(result, 0, 1, 1);}
		else if (wtype == Misc.mace) {result = Calc.setBitPart(result, 0, 1, 0);}
		int rarety = 0;
		final int denom = 11;
		for (int i = 0; i < 5; i++) {
			rarety += (AGPmain.rand.nextInt(skill + 1) > denom ? 1 : 0);
			//if (AGPmain.rand.nextInt(skill) > denom) {rarety++;} else {break;}
		}
		if (rarety < 2) {return NULL;} //failed to make famous weapon
		result += ((rarety-2) << 4);
		return result;
	}