コード例 #1
0
ファイル: omega.c プロジェクト: paud/d2x-xl
if (gameStates.limitFPS.bOmega && !gameStates.app.tick40fps.bTick)
#if 1
	return;
if (SlowMotionActive ()) {
	if (nDelay > 0) {
		nDelay -= 2;
		if	(nDelay > 0)
			return;
		}
	nDelay += gameOpts->gameplay.nSlowMotionSpeedup;
	}
#else
	nTargetObj = -1;
else
#endif
	nTargetObj = FindHomingObject (vFiringPos, weaponObjP);
nParentSeg = bSpectate ? gameStates.app.nPlayerSegment : parentObjP->nSegment;

if (0 > (nFiringSeg = FindSegByPoint (vFiringPos, nParentSeg, 1, 0))) {
	DestroyOmegaLightnings ();
	return;
	}
//	Play sound.
if (parentObjP == gameData.objs.viewer)
	DigiPlaySample (gameData.weapons.info [weaponObjP->id].flashSound, F1_0);
else
	DigiLinkSoundToPos (gameData.weapons.info [weaponObjP->id].flashSound, 
							  weaponObjP->nSegment, 0, &weaponObjP->position.vPos, 0, F1_0);
//	Delete the original tObject.  Its only purpose in life was to determine which tObject to home in on.
ReleaseObject (OBJ_IDX (weaponObjP));
if (nTargetObj != -1)
コード例 #2
0
int FireWeaponDelayedWithSpread (
	CObject *objP,
	ubyte nLaserType,
	int nGun,
	fix xSpreadR,
	fix xSpreadU,
	fix xDelay,
	int bMakeSound,
	int bHarmless,
	short	nLightObj)
{
	short					nLaserSeg;
	int					nFate;
	CFixVector			vLaserPos, vLaserDir, *vGunPoints;
	CHitQuery			fq;
	CHitData				hitData;
	int					nObject;
	CObject*				laserP;
#if FULL_COCKPIT_OFFS
	int bLaserOffs = ((gameStates.render.cockpit.nType == CM_FULL_COCKPIT) &&
							(objP->Index () == LOCALPLAYER.nObject));
#else
	int bLaserOffs = 0;
#endif
	CFixMatrix				m;
	int						bSpectate = SPECTATOR (objP);
	tObjTransformation*	posP = bSpectate ? &gameStates.app.playerPos : &objP->info.position;

#if DBG
if (nLaserType == SMARTMINE_BLOB_ID)
	nLaserType = nLaserType;
#endif
CreateAwarenessEvent (objP, PA_WEAPON_WALL_COLLISION);
// Find the initial vPosition of the laser
if (!(vGunPoints = GetGunPoints (objP, nGun)))
	return 0;
TransformGunPoint (objP, vGunPoints, nGun, xDelay, nLaserType, &vLaserPos, &m);

//--------------- Find vLaserPos and nLaserSeg ------------------
fq.p0					= &posP->vPos;
fq.startSeg			= bSpectate ? gameStates.app.nPlayerSegment : objP->info.nSegment;
fq.p1					= &vLaserPos;
fq.radP0				=
fq.radP1				= 0x10;
fq.thisObjNum		= objP->Index ();
fq.ignoreObjList	= NULL;
fq.flags				= FQ_CHECK_OBJS | FQ_IGNORE_POWERUPS;
fq.bCheckVisibility = false;
nFate = FindHitpoint (&fq, &hitData);
nLaserSeg = hitData.hit.nSegment;
if (nLaserSeg == -1) {	//some sort of annoying error
	return -1;
	}
//SORT OF HACK... IF ABOVE WAS CORRECT THIS WOULDNT BE NECESSARY.
if (CFixVector::Dist (vLaserPos, posP->vPos) > 3 * objP->info.xSize / 2) {
	return -1;
	}
if (nFate == HIT_WALL) {
	return -1;
	}
#if 0
//as of 12/6/94, we don't care if the laser is stuck in an object. We
//just fire away normally
if (nFate == HIT_OBJECT) {
	if (OBJECTS [hitData.hitObject].nType == OBJ_ROBOT)
		OBJECTS [hitData.hitObject].Die ();
	if (OBJECTS [hitData.hitObject].nType != OBJ_POWERUP)
		return;
	}
#endif
//	Now, make laser spread out.
vLaserDir = m.FVec ();
if (xSpreadR || xSpreadU) {
	vLaserDir += m.RVec () * xSpreadR;
	vLaserDir += m.UVec () * xSpreadU;
	}
if (bLaserOffs)
	vLaserDir += m.UVec () * LASER_OFFS;
nObject = CreateNewWeapon (&vLaserDir, &vLaserPos, nLaserSeg, objP->Index (), nLaserType, bMakeSound);
//	Omega cannon is a hack, not surprisingly.  Don't want to do the rest of this stuff.
if (nLaserType == OMEGA_ID)
	return -1;
if (nObject == -1)
	return -1;
//TrackWeaponObject (nObject, int (objP->info.nId));
laserP = OBJECTS + nObject;
if ((nLaserType == GUIDEDMSL_ID) && gameData.multigame.bIsGuided)
	gameData.objs.guidedMissile [objP->info.nId].objP = laserP;
gameData.multigame.bIsGuided = 0;
if (gameData.objs.bIsMissile [nLaserType] && (nLaserType != GUIDEDMSL_ID)) {
	if (!gameData.objs.missileViewerP && (objP->info.nId == gameData.multiplayer.nLocalPlayer))
		gameData.objs.missileViewerP = laserP;
	}
//	If this weapon is supposed to be silent, set that bit!
if (!bMakeSound)
	laserP->info.nFlags |= OF_SILENT;
//	If this weapon is supposed to be silent, set that bit!
if (bHarmless)
	laserP->info.nFlags |= OF_HARMLESS;

//	If the object firing the laser is the CPlayerData, then indicate the laser object so robots can dodge.
//	New by MK on 6/8/95, don't let robots evade proximity bombs, thereby decreasing uselessness of bombs.
if ((objP == gameData.objs.consoleP) && !WeaponIsPlayerMine (laserP->info.nId))
	gameStates.app.bPlayerFiredLaserThisFrame = nObject;

if (gameStates.app.cheats.bHomingWeapons || gameData.weapons.info [nLaserType].homingFlag) {
	if (objP == gameData.objs.consoleP) {
		laserP->cType.laserInfo.nHomingTarget = FindHomingObject (&vLaserPos, laserP);
		gameData.multigame.laser.nTrack = laserP->cType.laserInfo.nHomingTarget;
		}
	else {// Some other CPlayerData shot the homing thing
		Assert (IsMultiGame);
		laserP->cType.laserInfo.nHomingTarget = gameData.multigame.laser.nTrack;
		}
	}
lightClusterManager.Add (nObject, nLightObj);
return nObject;
}
コード例 #3
0
ファイル: omega.cpp プロジェクト: paud/d2x-xl
if (gameStates.limitFPS.bOmega && !gameStates.app.tick40fps.bTick)
#if 1
	return;
if (SlowMotionActive ()) {
	if (nDelay > 0) {
		nDelay -= 2;
		if	(nDelay > 0)
			return;
		}
	nDelay += gameOpts->gameplay.nSlowMotionSpeedup;
	}
#else
	nTargetObj = -1;
else
#endif
	nTargetObj = FindHomingObject (vMuzzle, weaponObjP);
nParentSeg = bSpectate ? gameStates.app.nPlayerSegment : parentObjP->info.nSegment;

if (0 > (nFiringSeg = FindSegByPos (*vMuzzle, nParentSeg, 1, 0))) {
	omegaLightnings.Destroy (OBJ_IDX (parentObjP));
	return;
	}
//	Play sound.
if (parentObjP == gameData.objs.viewerP)
	audio.PlaySound (gameData.weapons.info [weaponObjP->info.nId].flashSound);
else
	audio.CreateSegmentSound (gameData.weapons.info [weaponObjP->info.nId].flashSound,
							  weaponObjP->info.nSegment, 0, weaponObjP->info.position.vPos, 0, I2X (1));
//	Delete the original CObject.  Its only purpose in life was to determine which CObject to home in on.
ReleaseObject (OBJ_IDX (weaponObjP));
if (nTargetObj != -1)