示例#1
0
void mech_fall_event(EVENT * e)
{
    MECH *mech = (MECH *) e->data;
    int fallspeed = (int) e->data2;
    int fallen_elev;

    if (Started(mech) && fallspeed >= 0)
	return;
    if (fallspeed <= 0 && (!Started(mech) || !(FlyingT(mech)) ||
	    ((AeroFuel(mech) <= 0) && !AeroFreeFuel(mech)) ||
	    ((MechType(mech) == CLASS_VTOL) &&
		(SectIsDestroyed(mech, ROTOR)))))
	fallspeed -= FALL_ACCEL;
    else
	fallspeed += FALL_ACCEL;
    MarkForLOSUpdate(mech);
    if (MechsElevation(mech) > abs(fallspeed)) {
	MechZ(mech) -= abs(fallspeed);
	MechFZ(mech) = MechZ(mech) * ZSCALE;
	MECHEVENT(mech, EVENT_FALL, mech_fall_event, FALL_TICK, fallspeed);
	return;
    }
    /* Time to hit da ground */
    fallen_elev = factoral(abs(fallspeed));
    mech_notify(mech, MECHALL, "You hit the ground!");
    MechLOSBroadcast(mech, "hits the ground!");
    MechFalls(mech, fallen_elev, 0);
    MechStatus(mech) &= ~JUMPING;
}
示例#2
0
文件: ds.bay.c 项目: gtaylor/btmux
static void mech_enterbay_event(MUXEVENT * e)
{
	MECH *mech = (MECH *) e->data, *ds, *tmpm = NULL;
	long ref = (long) e->data2;
	long bayn;
	int x = 5, y = 5;
	MAP *tmpmap;

	if(!Started(mech) || Uncon(mech) || Jumping(mech) ||
	   (MechType(mech) == CLASS_MECH && (Fallen(mech) || Standing(mech))) ||
	   OODing(mech) || (fabs(MechSpeed(mech)) * 5 >= MMaxSpeed(mech) &&
						fabs(MMaxSpeed(mech)) >= MP1)
	   || (MechType(mech) == CLASS_VTOL && AeroFuel(mech) <= 0))
		return;
	tmpmap = getMap(ref);
	if(!(ds = getMech(tmpmap->onmap)))
		return;
	if(!Find_DS_Bay_In_MechHex(mech, ds, &bayn))
		return;
	/* whee */
	ref = AeroBay(ds, bayn);
	StopBSuitSwarmers(FindObjectsData(mech->mapindex), mech, 1);
	mech_notify(mech, MECHALL, "You enter the bay.");
	MechLOSBroadcast(mech, tprintf("has entered %s at %d,%d.",
								   GetMechID(ds), MechX(mech), MechY(mech)));
	MarkForLOSUpdate(mech);
	if(MechType(mech) == CLASS_MW && !In_Character(ref)) {
		enter_mw_bay(mech, ref);
		return;
	}
	if(MechCarrying(mech) > 0)
		tmpm = getMech(MechCarrying(mech));
	mech_Rsetmapindex(GOD, (void *) mech, tprintf("%d", ref));
	mech_Rsetxy(GOD, (void *) mech, tprintf("%d %d", x, y));
	MechLOSBroadcast(mech, "has entered the bay.");
	loud_teleport(mech->mynum, ref);
	if(tmpm) {
		mech_Rsetmapindex(GOD, (void *) tmpm, tprintf("%d", ref));
		mech_Rsetxy(GOD, (void *) tmpm, tprintf("%d %d", x, y));
		loud_teleport(tmpm->mynum, ref);
	}
}
示例#3
0
文件: mech.ecm.c 项目: chazu/btmux
void checkECM(MECH * objMech)
{
	MAP *objMapmap;
	MECH *objOtherMech;
	float range = 0.0;

	int wFriendlyECM = 0;
	int wFriendlyECCM = 0;
	int wUnFriendlyECM = 0;
	int wUnFriendlyECCM = 0;

	int wFriendlyAngelECM = 0;
	int wFriendlyAngelECCM = 0;
	int wUnFriendlyAngelECM = 0;
	int wUnFriendlyAngelECCM = 0;

	int wFriendlyECMDelta = 0;
	int wFriendlyECCMDelta = 0;

	int tCheckECM = 0;
	int tCheckECCM = 0;

	int wIter = 0;
	int tMark = 0;

	if(!(objMapmap = FindObjectsData(objMech->mapindex)))	/* get our map */
		return;

	for(wIter = 0; wIter < objMapmap->first_free; wIter++) {
		if(!(objOtherMech = FindObjectsData(objMapmap->mechsOnMap[wIter])))
			continue;

		if((range = FaMechRange(objOtherMech, objMech)) > ECM_RANGE)
			continue;

		if(MechTeam(objOtherMech) == MechTeam(objMech)) {
			if(ECMEnabled(objOtherMech))
				wFriendlyECM++;

			if(ECCMEnabled(objOtherMech))
				wFriendlyECCM++;

			if(AngelECMEnabled(objOtherMech))
				wFriendlyAngelECM++;

			if(AngelECCMEnabled(objOtherMech))
				wFriendlyAngelECCM++;

			if(range <= 0.5) {
				if(PerECMEnabled(objOtherMech))
					wFriendlyECM++;

				if(PerECCMEnabled(objOtherMech))
					wFriendlyECCM++;
			}
		} else {
			if(ECMEnabled(objOtherMech))
				wUnFriendlyECM++;

			if(ECCMEnabled(objOtherMech))
				wUnFriendlyECCM++;

			if(AngelECMEnabled(objOtherMech))
				wUnFriendlyAngelECM++;

			if(AngelECCMEnabled(objOtherMech))
				wUnFriendlyAngelECCM++;

			if(range <= 0.5) {
				if(PerECMEnabled(objOtherMech))
					wUnFriendlyECM++;

				if(PerECCMEnabled(objOtherMech))
					wUnFriendlyECCM++;
			}
		}
	}

	if((MechStatus2(objMech) & STH_ARMOR_ON) ||
	   checkAllSections(objMech, INARC_ECM_ATTACHED))
		wUnFriendlyECM += 1000;

	/* Generate our deltas */
	wFriendlyECMDelta =
		wFriendlyECM + (2 * wFriendlyAngelECM) - wUnFriendlyECCM -
		(2 * wUnFriendlyAngelECCM);
	wFriendlyECCMDelta =
		wFriendlyECCM + (2 * wFriendlyAngelECCM) - wUnFriendlyECM -
		(2 * wUnFriendlyAngelECM);

	tCheckECM = ((wFriendlyECM != 0) || (wFriendlyAngelECM != 0) ||
				 (wUnFriendlyECCM != 0) || (wUnFriendlyAngelECCM != 0));
	tCheckECCM = ((wFriendlyECCM != 0) || (wFriendlyAngelECCM != 0) ||
				  (wUnFriendlyECM != 0) || (wUnFriendlyAngelECM != 0));

	/* SendDebug(tprintf("Checking unit %d. ECMDelta: %d. ECCMDelta: %d. CheckECM: %d. CheckECCM: %d",objMech->mynum,wFriendlyECMDelta,wFriendlyECCMDelta,tCheckECM,tCheckECCM)); */

	/* Now we do our checks... */
	/* Let's first see if we should just reset our flags... 'cause there's no ECM or ECCM around */
	if(!tCheckECM) {
		if(ECMCountered(objMech)) {
			sendECMNotification(objMech, ECM_NOTIFY_UNCOUNTERED);
			UnSetECMCountered(objMech);
			tMark = 1;
		}

		if(ECMProtected(objMech) || AngelECMProtected(objMech)) {
			UnSetECMProtected(objMech);
			UnSetAngelECMProtected(objMech);
			tMark = 1;
		}
	}

	if(!tCheckECCM) {
		if(AnyECMDisturbed(objMech)) {
			sendECMNotification(objMech, ECM_NOTIFY_UNDISTURBED);
			UnSetECMDisturbed(objMech);
			UnSetAngelECMDisturbed(objMech);
			tMark = 1;
		}
	}

	/* Sanity check so we don't bother to do all the other checks */
	if(!tCheckECM && !tCheckECCM) {
		if(tMark)
			MarkForLOSUpdate(objMech);

		return;
	}

	/* Now we see if our ECM has been countered */
	if(tCheckECM) {
		if(wFriendlyECMDelta <= 0) {	/* They have the same or more ECCM than we have ECM */
			if(!ECMCountered(objMech)) {
				sendECMNotification(objMech, ECM_NOTIFY_COUNTERED);
				SetECMCountered(objMech);
				UnSetECMProtected(objMech);
				UnSetAngelECMProtected(objMech);
			}
		} else {
			if(ECMCountered(objMech)) {
				sendECMNotification(objMech, ECM_NOTIFY_UNCOUNTERED);
				UnSetECMCountered(objMech);
			}

			if(wFriendlyECM > 0)
				SetECMProtected(objMech);
			else
				UnSetECMProtected(objMech);

			if(wFriendlyAngelECM > 0)
				SetAngelECMProtected(objMech);
			else
				UnSetAngelECMProtected(objMech);
		}
	}

	/* Now we see if we're under an enemy ECM umbrella */
	if(tCheckECCM) {
		if(wFriendlyECCMDelta < 0) {	/* They have more ECM than we have ECCM */
			if(!AnyECMDisturbed(objMech)) {
				sendECMNotification(objMech, ECM_NOTIFY_DISTURBED);

				if(wUnFriendlyECM > 0)
					SetECMDisturbed(objMech);
				else
					UnSetECMDisturbed(objMech);

				if(wUnFriendlyAngelECM > 0)
					SetAngelECMDisturbed(objMech);
				else
					UnSetAngelECMDisturbed(objMech);

				MarkForLOSUpdate(objMech);
			}
		} else {
			if(AnyECMDisturbed(objMech)) {
				sendECMNotification(objMech, ECM_NOTIFY_UNDISTURBED);

				UnSetECMDisturbed(objMech);
				UnSetAngelECMDisturbed(objMech);
				MarkForLOSUpdate(objMech);
			}
		}
	}
}