Exemplo n.º 1
0
static int Leave_DS_Bay(MAP * map, MECH * ds, MECH * mech, dbref frombay)
{
	MECH *car = NULL;

	StopBSuitSwarmers(FindObjectsData(mech->mapindex), mech, 1);
	MechLOSBroadcast(mech, "has left the bay.");
	/* We escape confines of the bay to open air/land! */
	mech_Rsetmapindex(GOD, (void *) mech, tprintf("%d", ds->mapindex));
	if(MechCarrying(mech) > 0)
		car = getMech(MechCarrying(mech));
	if(car)
		mech_Rsetmapindex(GOD, (void *) car, tprintf("%d", ds->mapindex));
	DOCHECKMA0(mech->mapindex == map->mynum,
			   "Fatal error: Unable to find the map 'ship is on.");
	loud_teleport(mech->mynum, mech->mapindex);
	if(car)
		loud_teleport(car->mynum, mech->mapindex);
	mech_notify(mech, MECHALL, "You have left the bay.");
	DS_Place(ds, mech, frombay);
	if(car)
		MirrorPosition(mech, car, 0);
	MechLOSBroadcasti(mech, ds, "has left %s's bay.");
	mech_notify(ds, MECHALL, tprintf("%s has left the bay.",
									 GetMechID(mech)));
	ContinueFlying(mech);
	if(In_Character(mech->mynum) && Location(MechPilot(mech)) != mech->mynum) {
		mech_notify(mech, MECHALL,
					"%ch%cr%cf%ciINTRUDER ALERT! INTRUDER ALERT!%c");
		mech_notify(mech, MECHALL,
					"%ch%cr%cfAutomatic self-destruct sequence initiated.%c");
		mech_shutdown(GOD, (void *) mech, "");
	}
	return 1;
}
Exemplo n.º 2
0
int calcWeatherPilotEffects(MECH * mech)
{
    MAP *map = FindObjectsData(mech->mapindex);
    int onTheGround = 1;
    int mod = 0;

    if (!map)
	return 0;

    onTheGround = (!Jumping(mech) &&
	(MechZ(mech) <= Elevation(map, MechX(mech), MechY(mech))));

    if (onTheGround) {
	if ((MapEffectHvyRain(map) || MapEffectHvySnow(map) ||
		MapEffectHighWinds(map) || MapEffectBlizzard(map)))
	    mod += 1;

	if (MechMove(mech) != MOVE_HOVER) {
	    if (HexHasDeepSnow(map, MechX(mech), MechY(mech)))
		mod += 1;

	    if (HexHasMud(map, MechX(mech), MechY(mech)))
		mod += 1;

	    if (HexHasRapids(map, MechX(mech), MechY(mech)))
		mod += 2;
	}

	return mod;
    }

    return 0;
}
Exemplo n.º 3
0
void mech_createbays(dbref player, void *data, char *buffer)
{
	char *args[NUM_BAYS + 1];
	int argc;
	dbref it;
	int i;
	MECH *ds = (MECH *) data;
	MAP *map;

	DOCHECK((argc =
			 mech_parseattributes(buffer, args,
								  NUM_BAYS + 1)) == (NUM_BAYS + 1),
			"Invalid number of arguments!");
	for(i = 0; i < argc; i++) {
		it = match_thing(player, args[i]);
		DOCHECK(it == NOTHING, tprintf("Argument %d is invalid.", i + 1));
		DOCHECK(!IsMap(it), tprintf("Argument %d is not a map.", i + 1));
		map = FindObjectsData(it);
		AeroBay(ds, i) = it;
		map->onmap = ds->mynum;
	}
	for(i = argc; i < NUM_BAYS; i++)
		AeroBay(ds, i) = -1;
	notify_printf(player, "%d bay(s) set up!", argc);
}
Exemplo n.º 4
0
static int Find_Single_DS_In_MechHex(MECH * mech, long *ref, long *bayn)
{
	MAP *map = FindObjectsData(mech->mapindex);
	int loop;
	MECH *tempMech;
	int count = 0;

	*ref = 0;
	if(!map)
		return 0;
	for(loop = 0; loop < map->first_free; loop++)
		if(map->mechsOnMap[loop] >= 0) {
			if(!(tempMech = getMech(map->mechsOnMap[loop])))
				continue;
			if(!IsDS(tempMech))
				continue;
			if(!Landed(tempMech))
				continue;		/* This might break midflight-aero-DS-docking. But aeros are broken anyway. */
			if(Find_DS_Bay_In_MechHex(mech, tempMech, bayn)) {
				if(count++)
					*ref = -1;
				else
					*ref = tempMech->mynum;
			}
		}
	return count;
}
Exemplo n.º 5
0
void mech_plos_event(EVENT * e)
{
    MECH *mech = (MECH *) e->data, *target;
    MAP *map;
    int mapvis;
    int maplight;
    float range;
    int i;

    if (!Started(mech))
	return;
    if (!(map = getMap(mech->mapindex)))
	return;
    MECHEVENT(mech, EVENT_PLOS, mech_plos_event, PLOS_TICK, 0);
    if (!MechPNumSeen(mech) && !(MechSpecials(mech) & AA_TECH))
	return;
    mapvis = map->mapvis;
    maplight = map->maplight;
    MechPNumSeen(mech) = 0;
    for (i = 0; i < map->first_free; i++)
	if (map->mechsOnMap[i] > 0 && map->mechsOnMap[i] != mech->mynum)
	    if (!(map->LOSinfo[mech->mapnumber][i] & MECHLOSFLAG_SEEN)) {
		target = FindObjectsData(map->mechsOnMap[i]);
		if (!target)
		    continue;
		range = FlMechRange(map, mech, target);
		MechPNumSeen(mech)++;
		Sensor_DoWeSeeNow(mech, &map->LOSinfo[mech->mapnumber][i],
		    range, -1, -1, target, mapvis, maplight,
		    map->cloudbase, 1, 0);

	    }
}
Exemplo n.º 6
0
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);
	}
}
Exemplo n.º 7
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)));

}
Exemplo n.º 8
0
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);
			}
		}
	}
}
Exemplo n.º 9
0
void loadrepairs(FILE * f)
{
    dbref d, player;
    int type;
    int data;
    int time;
    MECH *mech;
    int loaded = 0;
    int fake;

    if (feof(f))
	return;
    fread(&d, sizeof(d), 1, f);
    while (d > 0 && !feof(f)) {
	loaded++;
	CHELO(type);
	CHELO(time);
	CHELO(data);
	fake = (time < 0);
	time = abs(time);
	if (!(mech = FindObjectsData(d)))
	    continue;
	player = data / PLAYERPOS;
	data = data % PLAYERPOS;
	if (fake)
	    FIXEVENT(time, mech, data, very_fake_func, type);
	else
	    switch (type) {
	    case EVENT_REPAIR_MOB:
		FIXEVENT(time, mech, data, event_mech_mountbomb, type);
		break;
	    case EVENT_REPAIR_UMOB:
		FIXEVENT(time, mech, data, event_mech_umountbomb, type);
		break;
	    case EVENT_REPAIR_REPL:
		FIXEVENT(time, mech, data, event_mech_repairpart, type);
		break;
	    case EVENT_REPAIR_REPLG:
		FIXEVENT(time, mech, data, event_mech_replacegun, type);
		break;
	    case EVENT_REPAIR_REPAP:
		FIXEVENT(time, mech, data, event_mech_repairpart, type);
		break;
	    case EVENT_REPAIR_REPENHCRIT:
		FIXEVENT(time, mech, data, event_mech_repairenhcrit, type);
		break;
	    case EVENT_REPAIR_REPAG:
		FIXEVENT(time, mech, data, event_mech_repairgun, type);
		break;
	    case EVENT_REPAIR_REAT:
		FIXEVENT(time, mech, data, event_mech_reattach, type);
		break;
	    case EVENT_REPAIR_RELO:
		FIXEVENT(time, mech, data, event_mech_reload, type);
		break;
	    case EVENT_REPAIR_FIX:
		FIXEVENT(time, mech, data, event_mech_repairarmor, type);
		break;
	    case EVENT_REPAIR_FIXI:
		FIXEVENT(time, mech, data, event_mech_repairinternal,
		    type);
		break;
	    case EVENT_REPAIR_SCRL:
		FIXEVENT(time, mech, data, event_mech_removesection, type);
		break;
	    case EVENT_REPAIR_SCRG:
		FIXEVENT(time, mech, data, event_mech_removegun, type);
		break;
	    case EVENT_REPAIR_SCRP:
		FIXEVENT(time, mech, data, event_mech_removepart, type);
		break;
	    case EVENT_REPAIR_REPSUIT:
		FIXEVENT(time, mech, data, event_mech_replacesuit, type);
		break;
	    }
	CHELO(d);
    }
    if (loaded)
	fprintf(stderr, "LOADED: %d tech events.\n", loaded);
}
Exemplo n.º 10
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");
}