示例#1
0
文件: failures.c 项目: chazu/btmux
void CheckGenericFail(MECH * mech, int type, int *result, int *mod)
{
	int i = GetBrandIndex(type);
	int l = type == -1 ? MechComputer(mech) : MechRadio(mech);
	int roll, in;

	if(result)
		*result = FAIL_NONE;
	if(i < 0)
		return;
	if(mudconf.btech_parts) {
		if(!l)
			l = 5;
	} else
		return;
	if(Number(1, 5000) != 42)
		return;					/* ~1/5000 chance */
	if(Number(1, 100) <= brands[(i + l - 1) * 5 / 6].success)
		return;
	roll = Number(1, 6);
	if(roll == 6)
		roll = Number(1, 6);
	in = i + roll - 1;
	switch (failures[in].flag) {
	case REQ_TARGET:
		if(MechTarget(mech) <= 0)
			return;
		break;
	case REQ_TAC:
		if(MechTacRange(mech) == 0)
			return;
		break;
	case REQ_LRS:
		if(MechLRSRange(mech) == 0)
			return;
		break;
	case REQ_SCANNERS:
		if(MechTacRange(mech) == 0 || MechLRSRange(mech) == 0 ||
		   MechScanRange(mech) == 0)
			return;
		break;
	case REQ_COMPUTER:
		/* */
		break;
	case REQ_RADIO:
		if(MechRadioRange(mech) == 0)
			return;
		break;
	}
	if(failures[in].message && strcmp(failures[in].message, "none"))
		mech_notify(mech, MECHALL, failures[in].message);
	failures[in].func(mech, -1, -1, -1, -1, roll, mod, result);
}
示例#2
0
/* This is just a 'toy' event */
void mech_lock_event(EVENT * e)
{
    MECH *mech = (MECH *) e->data;
    MAP *map;
    MECH *target;

    if (MechTarget(mech) >= 0) {
	map = getMap(mech->mapindex);
	target = FindObjectsData(MechTarget(mech));
	if (!target)
	    return;
	if (!InLineOfSight(mech, target, MechX(target), MechY(target),
		FlMechRange(map, mech, target)))
	    return;
	mech_notify(mech, MECHALL,
	    tprintf("The sensors acquire a stable lock on %s.",
		GetMechToMechID(mech, target)));
    } else if (MechTargX(mech) >= 0 && MechTargY(mech) >= 0)
	mech_notify(mech, MECHALL,
	    tprintf("The sensors acquire a stable lock on (%d,%d).",
		MechTargX(mech), MechTargY(mech)));

}
示例#3
0
void showNetworkTargets(dbref player, MECH * mech, int tIsC3)
{
	MAP *objMap = getMap(mech->mapindex);
	int i, j, wTemp, bearing;
	MECH *otherMech;
	float realRange, c3Range;
	char buff[100];
	char *mech_name;
	char move_type[30];
	char cStatus1, cStatus2, cStatus3, cStatus4, cStatus5;
	char weaponarc;
	int losFlag;
	int arc;
	int wSeeTarget = TARG_LOS_NONE;
	int wC3SeeTarget = TARG_LOS_NONE;
	int tShowStatusInfo = 0;
	char bufflist[MAX_MECHS_PER_MAP][120];
	float rangelist[MAX_MECHS_PER_MAP];
	int buffindex = 0;
	int sbuff[MAX_MECHS_PER_MAP];
	int networkSize;
	dbref myNetwork[C3_NETWORK_SIZE];
	dbref c3Ref;

	buildTempNetwork(mech, myNetwork, &networkSize, 1, 1, 0, tIsC3);

	/*
	 * Send then a 'contacts' style report. This is different from the
	 * normal contacts since it has a 'physical' range in it too.
	 */
	notify_printf(player, "%s Contacts:", tIsC3 ? "C3" : "C3i");

	for(i = 0; i < objMap->first_free; i++) {
		if(!(objMap->mechsOnMap[i] != mech->mynum &&
			 objMap->mechsOnMap[i] != -1))
			continue;

		otherMech = (MECH *) FindObjectsData(objMap->mechsOnMap[i]);

		if(!otherMech)
			continue;

		if(!Good_obj(otherMech->mynum))
			continue;

		tShowStatusInfo = 0;
		realRange = FlMechRange(objMap, mech, otherMech);
		losFlag =
			InLineOfSight(mech, otherMech, MechX(otherMech),
						  MechY(otherMech), realRange);

		/*
		 * If we do see them, let's make sure it's not just a 'something'
		 */
		if(losFlag) {
			if(InLineOfSight_NB(mech, otherMech, MechX(otherMech),
								MechY(otherMech), 0.0))
				wSeeTarget = TARG_LOS_CLEAR;
			else
				wSeeTarget = TARG_LOS_SOMETHING;
		} else
			wSeeTarget = TARG_LOS_NONE;

		/*
		 * If I don't see it, let's see if someone else in the network does
		 */
		if(wSeeTarget != TARG_LOS_CLEAR)
			wC3SeeTarget = mechSeenByNetwork(mech, otherMech, tIsC3);

		/* If noone sees it, we continue */
		if(!wSeeTarget && !wC3SeeTarget)
			continue;

		/* Get our network range */
		c3Range =
			findC3RangeWithNetwork(mech, otherMech, realRange, myNetwork,
								   networkSize, &c3Ref);

		/* Figure out if we show the info or not... ie, do we actually 'see' it */
		if((wSeeTarget != TARG_LOS_CLEAR) && (wC3SeeTarget != TARG_LOS_CLEAR)) {
			tShowStatusInfo = 0;
			mech_name = "something";
		} else {
			tShowStatusInfo = 1;
			mech_name = silly_atr_get(otherMech->mynum, A_MECHNAME);
		}

		bearing =
			FindBearing(MechFX(mech), MechFY(mech), MechFX(otherMech),
						MechFY(otherMech));
		strcpy(move_type, GetMoveTypeID(MechMove(otherMech)));

		/* Get our weapon arc */
		arc = InWeaponArc(mech, MechFX(otherMech), MechFY(otherMech));
		weaponarc = getWeaponArc(mech, arc);

		/* Now get our status chars */
		if(!tShowStatusInfo) {
			cStatus1 = ' ';
			cStatus2 = ' ';
			cStatus3 = ' ';
			cStatus4 = ' ';
			cStatus5 = ' ';
		} else {
			cStatus1 = getStatusChar(mech, otherMech, 1);
			cStatus2 = getStatusChar(mech, otherMech, 2);
			cStatus3 = getStatusChar(mech, otherMech, 3);
			cStatus4 = getStatusChar(mech, otherMech, 4);
			cStatus5 = getStatusChar(mech, otherMech, 5);
		}

		/* Now, build the string */
		sprintf(buff,
				"%s%c%c%c[%s]%c %-11.11s x:%3d y:%3d z:%3d r:%4.1f c:%4.1f b:%3d s:%5.1f h:%3d S:%c%c%c%c%c%s",
				otherMech->mynum == MechTarget(mech) ? "%ch%cr" :
				(tShowStatusInfo &&
				 !MechSeemsFriend(mech, otherMech)) ? "%ch%cy" : "",
				(losFlag & MECHLOSFLAG_SEESP) ? 'P' : ' ',
				(losFlag & MECHLOSFLAG_SEESS) ? 'S' : ' ', weaponarc,
				MechIDS(otherMech, MechSeemsFriend(mech, otherMech) ||
						!tShowStatusInfo), move_type[0], mech_name,
				MechX(otherMech), MechY(otherMech), MechZ(otherMech),
				realRange, c3Range, bearing, MechSpeed(otherMech),
				MechVFacing(otherMech), cStatus1, cStatus2, cStatus3,
				cStatus4, cStatus5, (otherMech->mynum == MechTarget(mech)
									 || !MechSeemsFriend(mech,
														 otherMech)) ? "%c" :
				"");

		rangelist[buffindex] = realRange;
		rangelist[buffindex] +=
			(MechStatus(otherMech) & DESTROYED) ? 10000 : 0;
		strcpy(bufflist[buffindex++], buff);
	}

	for(i = 0; i < buffindex; i++)
		sbuff[i] = i;

	/* print a sorted list of detected mechs */
	/* use the ever-popular bubble sort */
	for(i = 0; i < (buffindex - 1); i++)
		for(j = (i + 1); j < buffindex; j++)
			if(rangelist[sbuff[j]] > rangelist[sbuff[i]]) {
				wTemp = sbuff[i];
				sbuff[i] = sbuff[j];
				sbuff[j] = wTemp;
			}

	for(i = 0; i < buffindex; i++)
		notify(player, bufflist[sbuff[i]]);

	notify_printf(player, "End %s Contact List", tIsC3 ? "C3" : "C3i");
}
示例#4
0
文件: failures.c 项目: chazu/btmux
void FailureComputerTarget(MECH * mech, int weapnum, int weaptype,
						   int section, int critical, int roll, int *modifier,
						   int *type)
{
	MechTarget(mech) = -1;
}