• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ I2X函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中I2X函数的典型用法代码示例。如果您正苦于以下问题:C++ I2X函数的具体用法?C++ I2X怎么用?C++ I2X使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了I2X函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ChargeFusion

//	-----------------------------------------------------------------------------
//	Fire Laser:  Registers a laser fire, and performs special stuff for the fusion
//				    cannon.
void ChargeFusion (void)
{
if ((LOCALPLAYER.energy < I2X (2)) && (gameData.fusion.xAutoFireTime == 0)) {
	gameData.laser.nGlobalFiringCount = 0;
	}
else {
	gameData.fusion.xFrameTime += gameData.time.xFrame;
	if (!gameData.FusionCharge ())
		LOCALPLAYER.energy -= I2X (2);
	fix h = (gameData.fusion.xFrameTime <= LOCALPLAYER.energy) ? gameData.fusion.xFrameTime : LOCALPLAYER.energy;
	gameData.SetFusionCharge (gameData.FusionCharge () + h);
	LOCALPLAYER.energy -= h;
	if (LOCALPLAYER.energy > 0) 
		gameData.fusion.xAutoFireTime = gameData.time.xGame + gameData.fusion.xFrameTime / 2 + 1;
	else {
		LOCALPLAYER.energy = 0;
		gameData.fusion.xAutoFireTime = gameData.time.xGame - 1;	//	Fire now!
		}
	if (gameStates.limitFPS.bFusion && !gameStates.app.tick40fps.bTick)
		return;

	float fScale = float (gameData.FusionCharge () >> 11) / 64.0f;
	tRgbaColorf* colorP = gameData.weapons.color + FUSION_ID;

	if (gameData.FusionCharge () < I2X (2)) 
		paletteManager.BumpEffect (colorP->red * fScale, colorP->green * fScale, colorP->blue * fScale);
	else 
		paletteManager.BumpEffect (colorP->blue * fScale, colorP->red * fScale, colorP->green * fScale);
	if (gameData.time.xGame < gameData.fusion.xLastSoundTime)		//gametime has wrapped
		gameData.fusion.xNextSoundTime = gameData.fusion.xLastSoundTime = gameData.time.xGame;
	if (gameData.fusion.xNextSoundTime < gameData.time.xGame) {
		if (gameData.FusionCharge () > I2X (2)) {
			audio.PlaySound (11);
			gameData.objs.consoleP->ApplyDamageToPlayer (gameData.objs.consoleP, d_rand () * 4);
			}
		else {
			CreateAwarenessEvent (gameData.objs.consoleP, WEAPON_ROBOT_COLLISION);
			audio.PlaySound (SOUND_FUSION_WARMUP);
			if (IsMultiGame)
				MultiSendPlaySound (SOUND_FUSION_WARMUP, I2X (1));
				}
		gameData.fusion.xLastSoundTime = gameData.time.xGame;
		gameData.fusion.xNextSoundTime = gameData.time.xGame + I2X (1) / 8 + d_rand () / 4;
		}
	gameData.fusion.xFrameTime = 0;
	}
}
开发者ID:stephengeorgewest,项目名称:diiscent,代码行数:50,代码来源:fusion.cpp


示例2: I2X

void CHUD::DrawCloak (void)
{
if (cockpit->Hide ())
	return;

	static int nIdCloak = 0;


if ((LOCALPLAYER.flags & PLAYER_FLAGS_CLOAKED) &&
	 ((LOCALPLAYER.cloakTime + CLOAK_TIME_MAX - gameData.time.xGame > I2X (3)) || (gameData.time.xGame & 0x8000))) {
	int	y = CCanvas::Current ()->Height ();

	if (IsMultiGame)
		y -= 7 * m_info.nLineSpacing;
	else
		y -= 4 * m_info.nLineSpacing;
	if ((LOCALPLAYER.flags & PLAYER_FLAGS_AFTERBURNER) && !gameOpts->render.cockpit.bTextGauges)
		y -= m_info.nLineSpacing + gameStates.render.fonts.bHires + 1;
	fontManager.SetColorRGBi (GREEN_RGBA, 1, 0, 0);
	nIdCloak = GrPrintF (&nIdCloak, 2, y, "%s", TXT_CLOAKED);
	}
}
开发者ID:paud,项目名称:d2x-xl,代码行数:22,代码来源:hud.cpp


示例3: BitBlt

void CStatusBar::DrawAfterburnerBar (void)
{
if (gameStates.app.bD1Mission)
	return;

	int nEraseHeight;

CCanvas::Push ();
fontManager.SetScale (floor (float (CCanvas::Current ()->Width ()) / 640.0f));
CCanvas::SetCurrent (CurrentGameScreen ());
BitBlt (SB_GAUGE_AFTERBURNER, SB_AFTERBURNER_GAUGE_X, SB_AFTERBURNER_GAUGE_Y);
nEraseHeight = FixMul ((I2X (1) - gameData.physics.xAfterburnerCharge), SB_AFTERBURNER_GAUGE_H);

if (nEraseHeight > 0) {
	glDisable (GL_BLEND);
	Rect (SB_AFTERBURNER_GAUGE_X, SB_AFTERBURNER_GAUGE_Y, 
			SB_AFTERBURNER_GAUGE_X + SB_AFTERBURNER_GAUGE_W - 1, SB_AFTERBURNER_GAUGE_Y + nEraseHeight - 1);
	glEnable (GL_BLEND);
	}
fontManager.SetScale (1.0f);
CCanvas::Pop ();
}
开发者ID:paud,项目名称:d2x-xl,代码行数:22,代码来源:statusbar.cpp


示例4: StartSound

// Volume 0-I2X (1)
int CAudio::StartSound (short nSound, int nSoundClass, fix nVolume, int nPan, int bLooping, 
								int nLoopStart, int nLoopEnd, int nSoundObj, int nSpeed, 
								const char *pszWAV, CFixVector* vPos)
{
	CAudioChannel*	channelP;

if (!gameStates.app.bUseSound)
	return -1;
if (!m_info.bAvailable) 
	return -1;
if (((nSoundObj > -1) || bLooping || (nVolume > I2X (1))) && !nSoundClass)
	nSoundClass = -1;
if (!(channelP = FindFreeChannel (nSoundClass)))
	return -1;
if (0 > channelP->Start (nSound, nSoundClass, nVolume, nPan, bLooping, nLoopStart, nLoopEnd, nSoundObj, nSpeed, pszWAV, vPos)) {
	return -1;
	}
int i = m_info.nFreeChannel;
if (++m_info.nFreeChannel >= MAX_SOUND_CHANNELS)
	m_info.nFreeChannel = 0;
return i;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:23,代码来源:audio.cpp


示例5: I2X

int CParticleSystem::Update (void)
{
if (!m_bValid)
	return 0;

	CParticleEmitter	*emitterP;
	int					i = 0;

if ((m_nObject == 0x7fffffff) && (m_nType == SMOKE_PARTICLES) &&
	 (gameStates.app.nSDLTicks - m_nBirth > (MAX_SHRAPNEL_LIFE / I2X (1)) * 1000))
	SetLife (0);
#if DBG
if ((m_nObject >= 0) && (m_nObject < 0x70000000) && (OBJECTS [m_nObject].info.nType == 255))
	i = i;
#endif
if ((emitterP = m_emitters.Buffer ())) {
	bool bKill = (m_nObject < 0) || ((m_nObject < 0x70000000) &&
					 ((OBJECTS [m_nObject].info.nSignature != m_nSignature) || (OBJECTS [m_nObject].info.nType == OBJ_NONE)));
	for (i = 0; i < m_nEmitters; ) {
		if (!m_emitters)
			return 0;
		if (emitterP->IsDead (gameStates.app.nSDLTicks)) {
			if (!RemoveEmitter (i)) {
				//particleManager.Destroy (m_nId);
				m_bDestroy = true;
				break;
				}
			}
		else {
			if (bKill)
				emitterP->SetLife (0);
			emitterP->Update (gameStates.app.nSDLTicks, -1);
			emitterP++, i++;
			}
		}
	}
return i;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:38,代码来源:particles.cpp


示例6: DrawObjectRodTexPoly

//------------------------------------------------------------------------------
//draw an CObject that is a texture-mapped rod
void DrawObjectRodTexPoly (CObject *objP, tBitmapIndex bmi, int bLit, int iFrame)
{
	CBitmap *bmP = gameData.pig.tex.bitmaps [0] + bmi.index;
	fix light;
	CFixVector delta, top_v, bot_v;
	g3sPoint top_p, bot_p;

LoadBitmap (bmi.index, 0);
if ((bmP->Type () == BM_TYPE_STD) && bmP->Override ()) {
	bmP->SetupTexture (1, gameOpts->render.bDepthSort <= 0);
	bmP = bmP->Override (iFrame);
	}
delta = objP->info.position.mOrient.UVec () * objP->info.xSize;
top_v = objP->info.position.vPos + delta;
bot_v = objP->info.position.vPos - delta;
G3TransformAndEncodePoint (&top_p, top_v);
G3TransformAndEncodePoint (&bot_p, bot_v);
if (bLit)
	light = ComputeObjectLight (objP, &top_p.p3_vec);
else
	light = I2X (1);
G3DrawRodTexPoly (bmP, &bot_p, objP->info.xSize, &top_p, objP->info.xSize, light, NULL);
}
开发者ID:paud,项目名称:d2x-xl,代码行数:25,代码来源:objrender.cpp


示例7: RenderPowerupCorona

void RenderPowerupCorona (CObject *objP, float red, float green, float blue, float alpha)
{
if ((IsEnergyPowerup (objP->info.nId) ? gameOpts->render.coronas.bPowerups : gameOpts->render.coronas.bWeapons) && LoadGlare ()) {
	static tRgbaColorf keyColors [3] = {
	 {0.2f, 0.2f, 0.9f, 0.2f},
	 {0.9f, 0.2f, 0.2f, 0.2f},
	 {0.9f, 0.8f, 0.2f, 0.2f}
		};

	tRgbaColorf color;
	fix			xSize;
	float			fScale;

	if ((objP->info.nId >= POW_KEY_BLUE) && (objP->info.nId <= POW_KEY_GOLD)) {
		int i = objP->info.nId - POW_KEY_BLUE;

		color = keyColors [(((i < 0) || (i > 2)) ? 3 : i)];
		xSize = I2X (12);
		}
	else {
		float b = (float) sqrt ((red * 3 + green * 5 + blue * 2) / 10);
		color.red = red / b;
		color.green = green / b;
		color.blue = blue / b;
		xSize = 2 * objP->info.xSize; //I2X (8);
		}
	color.alpha = alpha;
	fScale = coronaIntensities [gameOpts->render.coronas.nObjIntensity] / 2;
	color.red *= fScale;
	color.green *= fScale;
	color.blue *= fScale;
	bmpGlare->SetColor (&color);
	ogl.RenderSprite (bmpGlare, objP->info.position.vPos, xSize, xSize, alpha, LIGHTTRAIL_BLENDMODE, 5);
	bmpGlare->SetColor (NULL);
	}
}
开发者ID:stephengeorgewest,项目名称:diiscent,代码行数:36,代码来源:lighttrails.cpp


示例8: BitBlt

void CCockpit::DrawAfterburnerBar (void)
{
#if 1
if (!(LOCALPLAYER.flags & PLAYER_FLAGS_AFTERBURNER))
	return;		//don't draw if don't have
if (!gameData.physics.xAfterburnerCharge)
	return;
#endif
//CCanvas::Current ()->SetColorRGB (255, 255, 255, 255);
BitBlt (GAUGE_AFTERBURNER, AFTERBURNER_GAUGE_X, AFTERBURNER_GAUGE_Y);
int yMax = FixMul (I2X (1) - gameData.physics.xAfterburnerCharge, AFTERBURNER_GAUGE_H);
if (yMax) {
	int		x [4], y [4];
	ubyte*	tableP = gameStates.video.nDisplayMode ? afterburnerBarTableHires : afterburnerBarTable;

	y [0] = y [1] = ScaleY (AFTERBURNER_GAUGE_Y);
	y [3] = ScaleY (AFTERBURNER_GAUGE_Y + yMax) - 1;
	x [1] = ScaleX (AFTERBURNER_GAUGE_X + tableP [0]);
	x [0] = ScaleX (AFTERBURNER_GAUGE_X + tableP [1] + 1);
	x [2] = x [1];
	y [2] = 0;
	for (int i = 1; i < yMax - 1; i++)
		if (x [2] >= tableP [2 * i]) {
			x [2] = tableP [2 * i];
			y [2] = i;
			}
	x [2] = ScaleX (AFTERBURNER_GAUGE_X + x [2] + 1);
	y [2] = ScaleY (AFTERBURNER_GAUGE_Y + y [2]);
	x [3] = ScaleX (AFTERBURNER_GAUGE_X + tableP [2 * yMax - 1] + 1);
	gameStates.render.grAlpha = 1.0f;
	glEnable (GL_BLEND);
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	OglDrawFilledPoly (x, y, 4, gaugeFadeColors [0], 1);
	glDisable (GL_BLEND);
	}
}
开发者ID:paud,项目名称:d2x-xl,代码行数:36,代码来源:cockpit.cpp


示例9: PowerupToModel

int CObject::PowerupToDevice (void)
{
	CAngleVector	a;
	short				nModel, nId;
	int				bHasModel = 0;

if (!SHOW_OBJ_FX)
	return 0;
if (!gameOpts->render.powerups.b3D)
	return 0;
if (info.controlType == CT_WEAPON)
	return 1;
if ((info.nType != OBJ_POWERUP) && (info.nType != OBJ_WEAPON))
	return 0;
nModel = PowerupToModel (info.nId);
if (nModel)
	nId = info.nId;
else {
	nId = PowerupToObject (info.nId);
	if (nId >= 0) {
		nModel = gameData.weapons.info [nId].nModel;
		bHasModel = 1;
		}
	}
if (!bHasModel && ((info.nType != OBJ_WEAPON) || !gameData.objs.bIsMissile [info.nId]) &&
	 !(nModel && HaveReplacementModel (nModel)))
		return 0;

if (gameData.demo.nState != ND_STATE_PLAYBACK) {
	a[PA] = (rand () % I2X (1)) - I2X (1) / 2;
	a[BA] = (rand () % I2X (1)) - I2X (1) / 2;
	a[HA] = (rand () % I2X (1)) - I2X (1) / 2;
	info.position.mOrient = CFixMatrix::Create(a);
	}
mType.physInfo.mass = I2X (1);
mType.physInfo.drag = 512;
mType.physInfo.brakes = 0;
#if 0
if ((info.nType == OBJ_WEAPON) && gameData.objs.bIsMissile [info.nId])
#endif
 {
	mType.physInfo.rotVel[X] = 0;
	mType.physInfo.rotVel[Y] =
	mType.physInfo.rotVel[Z] = gameOpts->render.powerups.nSpin ? I2X (1) / (5 - gameOpts->render.powerups.nSpin) : 0;
	}
#if 0
else {
	mType.physInfo.rotVel[X] =
	mType.physInfo.rotVel[Z] = 0;
	mType.physInfo.rotVel[Y] = gameOpts->render.powerups.nSpin ? I2X (1) / (5 - gameOpts->render.powerups.nSpin) : 0;
	}
#endif
info.controlType = CT_WEAPON;
info.renderType = RT_POLYOBJ;
info.movementType = MT_PHYSICS;
mType.physInfo.flags = PF_BOUNCE | PF_FREE_SPINNING;
rType.polyObjInfo.nModel = nModel;
#if 1
if (bHasModel)
	info.xSize = gameData.models.polyModels [0][rType.polyObjInfo.nModel].Rad ();
#endif
rType.polyObjInfo.nTexOverride = -1;
info.xLifeLeft = IMMORTAL_TIME;
return 1;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:65,代码来源:objrender.cpp


示例10: DoPlayerSmoke

void DoPlayerSmoke (tObject *objP, int i)
{
	int				h, j, d, nParts, nType;
	float				nScale;
	tCloud			*pCloud;
	vmsVector		fn, mn, vDir, *vDirP;
	tThrusterInfo	ti;

	static int	bForward = 1;

if (i < 0)
	i = objP->info.nId;
if ((gameData.multiplayer.players [i].flags & PLAYER_FLAGS_CLOAKED) ||
	 (gameStates.render.automap.bDisplay && IsMultiGame && !AM_SHOW_PLAYERS)) {
	KillObjectSmoke (i);
	return;
	}
j = OBJ_IDX (objP);
if (gameOpts->render.smoke.bDecreaseLag && (i == gameData.multiplayer.nLocalPlayer)) {
	fn = objP->info.position.mOrient[FVEC];
	mn = objP->info.position.vPos - objP->info.vLastPos;
	vmsVector::Normalize(fn);
	vmsVector::Normalize(mn);
	d = vmsVector::Dot(fn, mn);
	if (d >= -F1_0 / 2)
		bForward = 1;
	else {
		if (bForward) {
			if ((h = gameData.smoke.objects [j]) >= 0) {
				KillObjectSmoke (j);
				DestroySmoke (h);
				}
			bForward = 0;
			nScale = 0;
			return;
			}
		}
	}
#if 0
if (EGI_FLAG (bThrusterFlames, 1, 1, 0)) {
	if ((a <= F1_0 / 4) && (a || !gameStates.input.bControlsSkipFrame))	//no thruster flames if moving backward
		DropAfterburnerBlobs (objP, 2, I2X (1), -1, gameData.objs.consoleP, 1); //F1_0 / 4);
	}
#endif
if ((gameData.app.nGameMode & GM_NETWORK) && !gameData.multiplayer.players [i].connected)
	nParts = 0;
else if (objP->info.nFlags & (OF_SHOULD_BE_DEAD | OF_DESTROYED))
	nParts = 0;
else if ((i == gameData.multiplayer.nLocalPlayer) && (gameStates.app.bPlayerIsDead || (gameData.multiplayer.players [i].shields < 0)))
	nParts = 0;
else {
	h = X2IR (gameData.multiplayer.players [i].shields);
	nParts = 10 - h / 5;
	nScale = X2F (objP->info.xSize);
	if (h <= 25)
		nScale /= 1.5;
	else if (h <= 50)
		nScale /= 2;
	else
		nScale /= 3;
	if (nParts <= 0) {
		nType = 2;
		//nParts = (gameStates.entropy.nTimeLastMoved < 0) ? 250 : 125;
		}
	else {
		CreateDamageExplosion (nParts, j);
		nType = (h > 25);
		nParts *= 25;
		nParts += 75;
		}
	nParts = objP->mType.physInfo.thrust.IsZero() ? SHIP_MAX_PARTS : SHIP_MAX_PARTS / 2;
	if (SHOW_SMOKE && nParts && gameOpts->render.smoke.bPlayers) {
		if (gameOpts->render.smoke.bSyncSizes) {
			nParts = -MAX_PARTICLES (nParts, gameOpts->render.smoke.nDens [0]);
			nScale = PARTICLE_SIZE (gameOpts->render.smoke.nSize [0], nScale);
			}
		else {
			nParts = -MAX_PARTICLES (nParts, gameOpts->render.smoke.nDens [1]);
			nScale = PARTICLE_SIZE (gameOpts->render.smoke.nSize [1], nScale);
			}
		if (!objP->mType.physInfo.thrust.IsZero ())
			vDirP = NULL;
		else {	// if the ship is standing still, let the thruster smoke move away from it
			nParts /= 2;
			nScale /= 2;
			vDir = OBJPOS (objP)->mOrient [FVEC] * (F1_0 / 8);
			vDir = -vDir;
			vDirP = &vDir;
			}
		if (0 > (h = gameData.smoke.objects [j])) {
			//PrintLog ("creating tPlayer smoke\n");
			h = SetSmokeObject (j,
					CreateSmoke (&objP->info.position.vPos, vDirP, NULL, objP->info.nSegment, 2, nParts, nScale,
									 gameOpts->render.smoke.nSize [1],
									 2, PLR_PART_LIFE / (nType + 1) * (vDirP ? 2 : 1), PLR_PART_SPEED, SMOKE_PARTICLES, j, smokeColors + nType, 1, -1));
			}
		else {
			if (vDirP)
				SetSmokeDir (h, vDirP);
			SetSmokeLife (h, PLR_PART_LIFE / (nType + 1) * (vDirP ? 2 : 1));
//.........这里部分代码省略.........
开发者ID:paud,项目名称:d2x-xl,代码行数:101,代码来源:objsmoke.cpp


示例11: ReadFlyingControls

void ReadFlyingControls (CObject *objP)
{
	fix		forwardThrustTime;
	CObject*	gmObjP;
	int		bMulti;

if (gameData.time.xFrame <= 0)
	return;

if (gameStates.app.bPlayerIsDead || gameStates.app.bEnterGame) {
	StopPlayerMovement ();
	FlushInput ();
/*
	VmVecZero(&objP->mType.physInfo.rotThrust);
	VmVecZero(&objP->mType.physInfo.thrust);
	VmVecZero(&objP->mType.physInfo.velocity);
*/
	gameStates.app.bEnterGame--;
	return;
	}

if ((objP->info.nType != OBJ_PLAYER) || (objP->info.nId != gameData.multiplayer.nLocalPlayer))
	return;	//references to CPlayerShip require that this obj be the CPlayerData

tGuidedMissileInfo *gmiP = gameData.objs.guidedMissile + gameData.multiplayer.nLocalPlayer;
gmObjP = gmiP->objP;
if (gmObjP && (gmObjP->info.nSignature == gmiP->nSignature)) {
	CAngleVector	vRotAngs;
	CFixMatrix		mRot, mOrient;
	fix				speed;

	//this is a horrible hack.  guided missile stuff should not be
	//handled in the middle of a routine that is dealing with the CPlayerData
	objP->mType.physInfo.rotThrust.SetZero ();
	vRotAngs [PA] = Controls [0].pitchTime / 2 + gameStates.gameplay.seismic.nMagnitude / 64;
	vRotAngs [BA] = Controls [0].bankTime / 2 + gameStates.gameplay.seismic.nMagnitude / 16;
	vRotAngs [HA] = Controls [0].headingTime / 2 + gameStates.gameplay.seismic.nMagnitude / 64;
	mRot = CFixMatrix::Create (vRotAngs);
	mOrient = gmObjP->info.position.mOrient * mRot;
	gmObjP->info.position.mOrient = mOrient;
	speed = WI_speed (gmObjP->info.nId, gameStates.app.nDifficultyLevel);
	gmObjP->mType.physInfo.velocity = gmObjP->info.position.mOrient.FVec () * speed;
	if(IsMultiGame)
		MultiSendGuidedInfo (gmObjP, 0);
	}
else {
#if DBG
	if (Controls [0].headingTime)
		Controls [0].headingTime = Controls [0].headingTime;
#endif
	objP->mType.physInfo.rotThrust = CFixVector::Create (Controls [0].pitchTime,
	                                                     Controls [0].headingTime, //Controls [0].headingTime ? I2X (1) / 4 : 0; //Controls [0].headingTime;
	                                                     Controls [0].bankTime);
	}
forwardThrustTime = Controls [0].forwardThrustTime;
if ((LOCALPLAYER.flags & PLAYER_FLAGS_AFTERBURNER) && (d_rand () < OBJECTS [gameData.multiplayer.nLocalPlayer].DriveDamage ())) {
	if (Controls [0].afterburnerState) {			//CPlayerData has key down
		fix afterburner_scale;
		int oldCount,newCount;

		//add in value from 0..1
		afterburner_scale = I2X (1) + min (I2X (1) / 2, gameData.physics.xAfterburnerCharge) * 2;
		forwardThrustTime = FixMul (gameData.time.xFrame, afterburner_scale);	//based on full thrust
		oldCount = (gameData.physics.xAfterburnerCharge / (DROP_DELTA_TIME / AFTERBURNER_USE_SECS));
		if (!gameStates.gameplay.bAfterburnerCheat)
			gameData.physics.xAfterburnerCharge -= gameData.time.xFrame / AFTERBURNER_USE_SECS;
		if (gameData.physics.xAfterburnerCharge < 0)
			gameData.physics.xAfterburnerCharge = 0;
		newCount = (gameData.physics.xAfterburnerCharge / (DROP_DELTA_TIME / AFTERBURNER_USE_SECS));
		if (gameStates.app.bNostalgia && (oldCount != newCount))
			gameStates.render.bDropAfterburnerBlob = 1;	//drop blob (after physics called)
		}
	else {
		fix xChargeUp = min (gameData.time.xFrame / 8, I2X (1) - gameData.physics.xAfterburnerCharge);	//recharge over 8 seconds
		if (xChargeUp > 0) {
			fix xCurEnergy = LOCALPLAYER.energy - I2X (10);
			xCurEnergy = max (xCurEnergy, 0) / 10;	//don't drop below 10
			if (xCurEnergy > 0) {	//maybe limit charge up by energy
				xChargeUp = min (xChargeUp, xCurEnergy / 10);
				if (xChargeUp > 0) {
					gameData.physics.xAfterburnerCharge += xChargeUp;
					LOCALPLAYER.energy -= xChargeUp * 100 / 10;	//full charge uses 10% of energy
					}
				}
			}
		}
	}
// Set CObject's thrust vector for forward/backward
objP->mType.physInfo.thrust = objP->info.position.mOrient.FVec () * forwardThrustTime;
// slide left/right
objP->mType.physInfo.thrust += objP->info.position.mOrient.RVec () * Controls [0].sidewaysThrustTime;
// slide up/down
objP->mType.physInfo.thrust += objP->info.position.mOrient.UVec () * Controls [0].verticalThrustTime;
objP->mType.physInfo.thrust *= 2 * objP->DriveDamage ();
if (!gameStates.input.bSkipControls)
	memcpy (&gameData.physics.playerThrust, &objP->mType.physInfo.thrust, sizeof (gameData.physics.playerThrust));
bMulti = IsMultiGame;
if ((objP->mType.physInfo.flags & PF_WIGGLE) && !gameData.objs.speedBoost [objP->Index ()].bBoosted) {
#if 1//!DBG
	WiggleObject (objP);
//.........这里部分代码省略.........
开发者ID:stephengeorgewest,项目名称:diiscent,代码行数:101,代码来源:controls.cpp


示例12: Wall

//	-----------------------------------------------------------------------------
//if an effect is hit, and it can blow up, then blow it up
//returns true if it blew up
int CSegment::CheckEffectBlowup (int nSide, CFixVector& vHit, CObject* blowerP, int bForceBlowup)
{
	int				tm, tmf, ec, nBitmap = 0;
	int				bOkToBlow = 0, nSwitchType = -1;
	short				nSound, bPermaTrigger;
	ubyte				vc;
	fix				u, v;
	fix				xDestSize;
	tEffectClip*	ecP = NULL;
	CBitmap*			bmP;
	CWall*			wallP;
	CTrigger*		trigP;
	CObject*			parentP = (!blowerP || (blowerP->cType.laserInfo.parent.nObject < 0)) ? NULL : OBJECTS + blowerP->cType.laserInfo.parent.nObject;
	//	If this CWall has a CTrigger and the blowerP-upper is not the CPlayerData or the buddy, abort!

if (parentP) {
	if ((parentP->info.nType == OBJ_ROBOT) && ROBOTINFO (parentP->info.nId).companion)
		bOkToBlow = 1;
	if (!(bOkToBlow || (parentP->info.nType == OBJ_PLAYER)) &&
		 ((wallP = Wall (nSide)) && (wallP->nTrigger < gameData.trigs.m_nTriggers)))
		return 0;
	}

if (!(tm = m_sides [nSide].m_nOvlTex))
	return 0;

tmf = m_sides [nSide].m_nOvlOrient;		//tm flags
ec = gameData.pig.tex.tMapInfoP [tm].nEffectClip;
if (ec < 0) {
	if (gameData.pig.tex.tMapInfoP [tm].destroyed == -1)
		return 0;
	nBitmap = -1;
	nSwitchType = 0;
	}
else {
	ecP = gameData.eff.effectP + ec;
	if (ecP->flags & EF_ONE_SHOT)
		return 0;
	nBitmap = ecP->nDestBm;
	if (nBitmap < 0)
		return 0;
	nSwitchType = 1;
	}
//check if it's an animation (monitor) or casts light
bmP = gameData.pig.tex.bitmapP + gameData.pig.tex.bmIndexP [tm].index;
LoadBitmap (gameData.pig.tex.bmIndexP [tm].index, gameStates.app.bD1Data);
//this can be blown up...did we hit it?
if (!bForceBlowup) {
	HitPointUV (nSide, &u, &v, NULL, vHit, 0);	//evil: always say face zero
	bForceBlowup = !PixelTranspType (tm, tmf,  m_sides [nSide].m_nFrame, u, v);
	}
if (!bForceBlowup)
	return 0;

if (IsMultiGame && netGame.bIndestructibleLights && !nSwitchType)
	return 0;
//note: this must get called before the texture changes,
//because we use the light value of the texture to change
//the static light in the CSegment
wallP = Wall (nSide);
bPermaTrigger = (trigP = Trigger (nSide)) && (trigP->flags & TF_PERMANENT);
if (!bPermaTrigger)
	SubtractLight (Index (), nSide);
if (gameData.demo.nState == ND_STATE_RECORDING)
	NDRecordEffectBlowup (Index (), nSide, vHit);
if (nSwitchType) {
	xDestSize = ecP->xDestSize;
	vc = ecP->nDestVClip;
	}
else {
	xDestSize = I2X (20);
	vc = 3;
	}
/*Object*/CreateExplosion (short (Index ()), vHit, xDestSize, vc);
if (nSwitchType) {
	if ((nSound = gameData.eff.vClipP [vc].nSound) != -1)
		audio.CreateSegmentSound (nSound, Index (), 0, vHit);
	if ((nSound = ecP->nSound) != -1)		//kill sound
		audio.DestroySegmentSound (Index (), nSide, nSound);
	if (!bPermaTrigger && (ecP->nDestEClip != -1) && (gameData.eff.effectP [ecP->nDestEClip].nSegment == -1)) {
		tEffectClip	*newEcP = gameData.eff.effectP + ecP->nDestEClip;
		int nNewBm = newEcP->changingWallTexture;
		if (ChangeTextures (-1, nNewBm)) {
			newEcP->xTimeLeft = EffectFrameTime (newEcP);
			newEcP->nCurFrame = 0;
			newEcP->nSegment = Index ();
			newEcP->nSide = nSide;
			newEcP->flags |= EF_ONE_SHOT | ecP->flags;
			newEcP->flags &= ~EF_INITIALIZED;
			newEcP->nDestBm = ecP->nDestBm;

			Assert ((nNewBm != 0) && (m_sides [nSide].m_nOvlTex != 0));
			m_sides [nSide].m_nOvlTex = nNewBm;		//replace with destoyed
			}
		}
	else {
		Assert ((nBitmap != 0) && (m_sides [nSide].m_nOvlTex != 0));
//.........这里部分代码省略.........
开发者ID:paud,项目名称:d2x-xl,代码行数:101,代码来源:segment.cpp


示例13: NetworkHandlePingReturn

void NetworkHandlePingReturn (ubyte nPlayer)
{
if ((nPlayer >= gameData.multiplayer.nPlayers) || !pingStats [nPlayer].launchTime) {
#if 1			
	 console.printf (CON_DBG, "Got invalid PING RETURN from %s!\n", gameData.multiplayer.players [nPlayer].callsign);
#endif
   return;
	}
xPingReturnTime = TimerGetFixedSeconds ();
pingStats [nPlayer].ping = X2I (FixMul (xPingReturnTime - pingStats [nPlayer].launchTime, I2X (1000)));
if (!gameStates.render.cockpit.bShowPingStats)
	HUDInitMessage ("Ping time for %s is %d ms!", gameData.multiplayer.players [nPlayer].callsign, pingStats [nPlayer].ping);
pingStats [nPlayer].launchTime = 0;
pingStats [nPlayer].received++;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:15,代码来源:network.cpp


示例14: NetworkDoFrame

void NetworkDoFrame (int bForce, int bListen)
{
	tFrameInfoShort shortSyncPack;
	static fix xLastEndlevel = 0;
	int i;

if (!(gameData.app.nGameMode & GM_NETWORK)) 
	return;
if ((networkData.nStatus == NETSTAT_PLAYING) && !gameStates.app.bEndLevelSequence) { // Don't send postion during escape sequence...
	if (nakedData.nLength) {
		Assert (nakedData.nDestPlayer >- 1);
		if (gameStates.multi.nGameType >= IPX_GAME) 
			IPXSendPacketData (reinterpret_cast<ubyte*> (nakedData.buf), nakedData.nLength, 
									netPlayers.players [nakedData.nDestPlayer].network.ipx.server, 
									netPlayers.players [nakedData.nDestPlayer].network.ipx.node, 
									gameData.multiplayer.players [nakedData.nDestPlayer].netAddress);
		nakedData.nLength = 0;
		nakedData.nDestPlayer = -1;
		}
	if (networkData.refuse.bWaitForAnswer && TimerGetApproxSeconds ()> (networkData.refuse.xTimeLimit+ (I2X (12))))
		networkData.refuse.bWaitForAnswer=0;
	networkData.xLastSendTime += gameData.time.xFrame;
	networkData.xLastTimeoutCheck += gameData.time.xFrame;

	// Send out packet PacksPerSec times per second maximum... unless they fire, then send more often...
	if ((networkData.xLastSendTime > I2X (1) / PacketsPerSec ()) || 
		(gameData.multigame.laser.bFired) || bForce || networkData.bPacketUrgent) {        
		if (LOCALPLAYER.connected) {
			int nObject = LOCALPLAYER.nObject;
			networkData.bPacketUrgent = 0;
			if (bListen) {
				MultiSendRobotFrame (0);
				MultiSendFire ();              // Do firing if needed..
				}
			networkData.xLastSendTime = 0;
			if (netGame.bShortPackets) {
#if defined (WORDS_BIGENDIAN) || defined (__BIG_ENDIAN__)
				ubyte send_data [MAX_PACKETSIZE];
#endif
				memset (&shortSyncPack, 0, sizeof (shortSyncPack));
				CreateShortPos (&shortSyncPack.objPos, OBJECTS+nObject, 0);
				shortSyncPack.nType = PID_PDATA;
				shortSyncPack.nPlayer = gameData.multiplayer.nLocalPlayer;
				shortSyncPack.objRenderType = OBJECTS [nObject].info.renderType;
				shortSyncPack.nLevel = gameData.missions.nCurrentLevel;
				shortSyncPack.dataSize = networkData.syncPack.dataSize;
				memcpy (shortSyncPack.data, networkData.syncPack.data, networkData.syncPack.dataSize);
				networkData.syncPack.nPackets = INTEL_INT (gameData.multiplayer.players [0].nPacketsSent++);
				shortSyncPack.nPackets = networkData.syncPack.nPackets;
#if !(defined (WORDS_BIGENDIAN) || defined (__BIG_ENDIAN__))
				IpxSendGamePacket (
					reinterpret_cast<ubyte*> (&shortSyncPack), 
					sizeof (tFrameInfoShort) - networkData.nMaxXDataSize + networkData.syncPack.dataSize);
#else
				SquishShortFrameInfo (shortSyncPack, send_data);
				IpxSendGamePacket (
					reinterpret_cast<ubyte*> (send_data), 
					IPX_SHORT_INFO_SIZE-networkData.nMaxXDataSize+networkData.syncPack.dataSize);
#endif
				}
			else {// If long packets
					int send_dataSize;

				networkData.syncPack.nType = PID_PDATA;
				networkData.syncPack.nPlayer = gameData.multiplayer.nLocalPlayer;
				networkData.syncPack.objRenderType = OBJECTS [nObject].info.renderType;
				networkData.syncPack.nLevel = gameData.missions.nCurrentLevel;
				networkData.syncPack.nObjSeg = OBJECTS [nObject].info.nSegment;
				networkData.syncPack.objPos = OBJECTS [nObject].info.position.vPos;
				networkData.syncPack.objOrient = OBJECTS [nObject].info.position.mOrient;
				networkData.syncPack.physVelocity = OBJECTS [nObject].mType.physInfo.velocity;
				networkData.syncPack.physRotVel = OBJECTS [nObject].mType.physInfo.rotVel;
				send_dataSize = networkData.syncPack.dataSize;                  // do this so correct size data is sent
#if defined (WORDS_BIGENDIAN) || defined (__BIG_ENDIAN__)                        // do the swap stuff
				if (gameStates.multi.nGameType >= IPX_GAME) {
					networkData.syncPack.nObjSeg = INTEL_SHORT (networkData.syncPack.nObjSeg);
					INTEL_VECTOR (networkData.syncPack.objPos);
					INTEL_MATRIX (networkData.syncPack.objOrient);
					INTEL_VECTOR (networkData.syncPack.physVelocity);
					INTEL_VECTOR (networkData.syncPack.physRotVel);
					networkData.syncPack.dataSize = INTEL_SHORT (networkData.syncPack.dataSize);
					}
#endif
				networkData.syncPack.nPackets = INTEL_INT (gameData.multiplayer.players [0].nPacketsSent++);
				IpxSendGamePacket (
					reinterpret_cast<ubyte*> (&networkData.syncPack), 
					sizeof (tFrameInfo) - networkData.nMaxXDataSize + send_dataSize);
				}
			networkData.syncPack.dataSize = 0;               // Start data over at 0 length.
			networkData.bD2XData = 0;
			if (gameData.reactor.bDestroyed) {
				if (gameStates.app.bPlayerIsDead)
					LOCALPLAYER.connected=3;
				if (TimerGetApproxSeconds () > (xLastEndlevel+ (I2X (1)/2))) {
					NetworkSendEndLevelPacket ();
					xLastEndlevel = TimerGetApproxSeconds ();
					}
				}
			}
		}
//.........这里部分代码省略.........
开发者ID:paud,项目名称:d2x-xl,代码行数:101,代码来源:network.cpp


示例15: WallAlpha

float WallAlpha (short nSegment, short nSide, short nWall, ubyte widFlags, int bIsMonitor, ubyte bAdditive,
					  tRgbaColorf *colorP, int *nColor, ubyte *bTextured, ubyte *bCloaked, ubyte* bTransparent)
{
	static tRgbaColorf cloakColor = {1, 1, 1, 0};

	CWall	*wallP;
	float fAlpha, fMaxColor;
	short	c;

if (!IS_WALL (nWall))
	return 1;
#if DBG
if ((nSegment == nDbgSeg) && ((nDbgSide < 0) || (nSide == nDbgSide)))
	nDbgSeg = nDbgSeg;
#endif
if (!(wallP = WALLS + nWall))
	return 1;
if (SHOW_DYN_LIGHT) {
	*bTransparent = (wallP->state == WALL_DOOR_CLOAKING) || (wallP->state == WALL_DOOR_DECLOAKING);
	*bCloaked = !*bTransparent && ((widFlags & WID_CLOAKED_FLAG) != 0);
	}
else {
	*bTransparent = 0;
	*bCloaked = (wallP->state == WALL_DOOR_CLOAKING) || (wallP->state == WALL_DOOR_DECLOAKING) || ((widFlags & WID_CLOAKED_FLAG) != 0);
	}
if (*bCloaked || *bTransparent || (widFlags & WID_TRANSPARENT_FLAG)) {
	if (bIsMonitor)
		return 1;
	c = wallP->cloakValue;
	if (*bCloaked || *bTransparent) {
		*colorP = cloakColor;
		*nColor = 1;
		*bTextured = !*bCloaked;
		colorP->alpha = (c >= FADE_LEVELS) ? 0 : 1.0f - float (c) / float (FADE_LEVELS);
		if (*bTransparent)
			colorP->red =
			colorP->green =
			colorP->blue = colorP->alpha;
#if DBG
		if (colorP->alpha < 1)
			return colorP->alpha;
#endif
		return colorP->alpha;
		}
	if (!gameOpts->render.color.bWalls)
		c = 0;
	if (WALLS [nWall].hps)
		fAlpha = (float) fabs ((1.0f - (float) WALLS [nWall].hps / ((float) I2X (100))));
	else if (IsMultiGame && gameStates.app.bHaveExtraGameInfo [1])
		fAlpha = COMPETITION ? 0.5f : (float) (FADE_LEVELS - extraGameInfo [1].grWallTransparency) / (float) FADE_LEVELS;
	else
		fAlpha = 1.0f - extraGameInfo [0].grWallTransparency / (float) FADE_LEVELS;
	if (fAlpha < 1) {
		//fAlpha = (float) sqrt (fAlpha);
		paletteManager.Game ()->ToRgbaf ((ubyte) c, *colorP);
		if (bAdditive) {
			colorP->red /= fAlpha;
			colorP->green /= fAlpha;
			colorP->blue /= fAlpha;
			}
		fMaxColor = colorP->red;
		if (fMaxColor < colorP->green)
			fMaxColor = colorP->green;
		if (fMaxColor < colorP->blue)
			fMaxColor = colorP->blue;
		if (fMaxColor > 1) {
			colorP->red /= fMaxColor;
			colorP->green /= fMaxColor;
			colorP->blue /= fMaxColor;
			}
		*bTextured = 0;
		*nColor = 1;
		}
	return colorP->alpha = fAlpha;
	}
if (gameStates.app.bD2XLevel) {
	c = wallP->cloakValue;
	return colorP->alpha = (c && (c < FADE_LEVELS)) ? (float) (FADE_LEVELS - c) / (float) FADE_LEVELS : 1;
	}
if (gameOpts->render.effects.bAutoTransparency && IsTransparentTexture (SEGMENTS [nSegment].m_sides [nSide].m_nBaseTex))
	return colorP->alpha = 0.8f;
return colorP->alpha = 1;
}
开发者ID:paud,项目名称:d2x-xl,代码行数:83,代码来源:renderlib.cpp


示例16: AIFireLaserAtPlayer

// --------------------------------------------------------------------------------------------------------------------
//	Note: Parameter gameData.ai.vVecToPlayer is only passed now because guns which aren't on the forward vector from the
//	center of the robot will not fire right at the player.  We need to aim the guns at the player.  Barring that, we cheat.
//	When this routine is complete, the parameter gameData.ai.vVecToPlayer should not be necessary.
void AIFireLaserAtPlayer (CObject *objP, CFixVector *vFirePoint, int nGun, CFixVector *vBelievedPlayerPos)
{
	short				nShot, nObject = objP->Index ();
	tAILocalInfo	*ailP = gameData.ai.localInfo + nObject;
	tRobotInfo		*botInfoP = &ROBOTINFO (objP->info.nId);
	CFixVector		vFire;
	CFixVector		bpp_diff;
	short				nWeaponType;
	fix				aim, dot;
	int				count, i;

Assert (nObject >= 0);
//	If this robot is only awake because a camera woke it up, don't fire.
if (objP->cType.aiInfo.SUB_FLAGS & SUB_FLAGS_CAMERA_AWAKE)
	return;
if (!gameStates.app.cheats.bRobotsFiring)
	return;
if (objP->info.controlType == CT_MORPH)
	return;
//	If player is exploded, stop firing.
if (gameStates.app.bPlayerExploded)
	return;
if (objP->cType.aiInfo.xDyingStartTime)
	return;		//	No firing while in death roll.
//	Don't let the boss fire while in death roll.  Sorry, this is the easiest way to do this.
//	If you try to key the boss off objP->cType.aiInfo.xDyingStartTime, it will hose the endlevel stuff.
if (ROBOTINFO (objP->info.nId).bossFlag) {
	i = gameData.bosses.Find (nObject);
	if ((i < 0) || (gameData.bosses [i].m_nDyingStartTime))
		return;
	}
//	If CPlayerData is cloaked, maybe don't fire based on how long cloaked and randomness.
if (LOCALPLAYER.flags & PLAYER_FLAGS_CLOAKED) {
	fix	xCloakTime = gameData.ai.cloakInfo [nObject % MAX_AI_CLOAK_INFO].lastTime;
	if ((gameData.time.xGame - xCloakTime > CLOAK_TIME_MAX/4) &&
		 (d_rand () > FixDiv (gameData.time.xGame - xCloakTime, CLOAK_TIME_MAX)/2)) {
		SetNextFireTime (objP, ailP, botInfoP, nGun);
		return;
		}
	}
//	Handle problem of a robot firing through a CWall because its gun tip is on the other
//	CSide of the CWall than the robot's center.  For speed reasons, we normally only compute
//	the vector from the gun point to the player.  But we need to know whether the gun point
//	is separated from the robot's center by a CWall.  If so, don't fire!
if (objP->cType.aiInfo.SUB_FLAGS & SUB_FLAGS_GUNSEG) {
	//	Well, the gun point is in a different CSegment than the robot's center.
	//	This is almost always ok, but it is not ok if something solid is in between.
	int	nGunSeg = FindSegByPos (*vFirePoint, objP->info.nSegment, 1, 0);
	//	See if these segments are connected, which should almost always be the case.
	short nConnSide = SEGMENTS [nGunSeg].ConnectedSide (&SEGMENTS [objP->info.nSegment]);
	if (nConnSide != -1) {
		//	They are connected via nConnSide in CSegment objP->info.nSegment.
		//	See if they are unobstructed.
		if (!(SEGMENTS [objP->info.nSegment].IsDoorWay (nConnSide, NULL) & WID_FLY_FLAG)) {
			//	Can't fly through, so don't let this bot fire through!
			return;
			}
		}
	else {
		//	Well, they are not directly connected, so use FindVectorIntersection to see if they are unobstructed.
		tFVIQuery	fq;
		tFVIData		hit_data;
		int			fate;

		fq.startSeg			= objP->info.nSegment;
		fq.p0					= &objP->info.position.vPos;
		fq.p1					= vFirePoint;
		fq.radP0				=
		fq.radP1				= 0;
		fq.thisObjNum		= objP->Index ();
		fq.ignoreObjList	= NULL;
		fq.flags				= FQ_TRANSWALL;

		fate = FindVectorIntersection (&fq, &hit_data);
		if (fate != HIT_NONE) {
			Int3 ();		//	This bot's gun is poking through a CWall, so don't fire.
			MoveTowardsSegmentCenter (objP);		//	And decrease chances it will happen again.
			return;
			}
		}
	}
//	Set position to fire at based on difficulty level and robot's aiming ability
aim = I2X (FIRE_K) - (FIRE_K-1)* (botInfoP->aim << 8);	//	I2X (1) in bitmaps.tbl = same as used to be.  Worst is 50% more error.
//	Robots aim more poorly during seismic disturbance.
if (gameStates.gameplay.seismic.nMagnitude) {
	fix temp = I2X (1) - abs (gameStates.gameplay.seismic.nMagnitude);
	if (temp < I2X (1)/2)
		temp = I2X (1)/2;
	aim = FixMul (aim, temp);
	}
//	Lead the CPlayerData half the time.
//	Note that when leading the CPlayerData, aim is perfect.  This is probably acceptable since leading is so hacked in.
//	Problem is all robots will lead equally badly.
if (d_rand () < 16384) {
	if (LeadPlayer (objP, vFirePoint, vBelievedPlayerPos, nGun, &vFire))		//	Stuff direction to fire at in vFirePoint.
		goto player_led;
//.........这里部分代码省略.........
开发者ID:paud,项目名称:d2x-xl,代码行数:101,代码来源:aifire.cpp


示例17: RenderLaserCorona

void RenderLaserCorona (CObject *objP, tRgbaColorf *colorP, float alpha, float fScale)
{
if (!SHOW_OBJ_FX)
	return;
if (SHOW_SHADOWS && (gameStates.render.nShadowPass != 1))
	return;
if (gameOpts->render.coronas.bShots && LoadGlare ()) {
	tHitbox*			phb = &gameData.models.hitboxes [objP->rType.polyObjInfo.nModel].hitboxes [0];
	float				fLength = X2F (phb->vMax [Z] - phb->vMin [Z]) / 2;
	tRgbaColorf		color;

	static CFloatVector	vEye = CFloatVector::ZERO;

	colorP->alpha = alpha;
	float fScale = coronaIntensities [gameOpts->render.coronas.nObjIntensity] / 2;
	color = *colorP;
	colorP = &color;
	color.red *= fScale;
	color.green *= fScale;
	color.blue *= fScale;
	bmpGlare->SetColor (colorP);
	ogl.RenderSprite (bmpGlare, objP->info.position.vPos + objP->info.position.mOrient.FVec () * (F2X (fLength - 0.5f)), I2X (1), I2X (1), alpha, LIGHTTRAIL_BLENDMODE, 1);
	bmpGlare->SetColor (NULL);
	}
}
开发者ID:stephengeorgewest,项目名称:diiscent,代码行数:25,代码来源:lighttrails.cpp


示例18: GetCloakInfo

int GetCloakInfo (CObject *objP, fix xCloakStartTime, fix xCloakEndTime, tCloakInfo *ciP)
{
	tCloakInfo	ci = {0, CLOAKED_FADE_LEVEL, I2X (1), I2X (1), I2X (1), 0, 0};
	int			i;

if (!(xCloakStartTime || xCloakEndTime)) {
	if (objP->info.nType == OBJ_PLAYER) {
		xCloakStartTime = gameData.multiplayer.players [objP->info.nId].cloakTime;
		xCloakEndTime = gameData.multiplayer.players [objP->info.nId].cloakTime + CLOAK_TIME_MAX;
		}
	else if (objP->info.nType == OBJ_ROBOT) {
		if (!ROBOTINFO (objP->info.nId).bossFlag) {
			xCloakStartTime = gameData.time.xGame - I2X (10);
			xCloakEndTime = gameData.time.xGame + I2X (10);
			}
		else if (0 <= (i = gameData.bosses.Find (objP->Index ()))) {
			xCloakStartTime = gameData.bosses [i].m_nCloakStartTime;
			xCloakEndTime = gameData.bosses [i].m_nCloakEndTime;
			}
		}
	}
if (xCloakStartTime != 0x7fffffff)
	ci.xTotalTime = xCloakEndTime - xCloakStartTime;
else
	ci.xTotalTime = gameData.time.xGame;
if (objP->info.nType == OBJ_PLAYER) {
	ci.xFadeinDuration = CLOAK_FADEIN_DURATION_PLAYER;
	ci.xFadeoutDuration = CLOAK_FADEOUT_DURATION_PLAYER;
	}
else if (objP->info.nType == OBJ_ROBOT) {
	ci.xFadeinDuration = CLOAK_FADEIN_DURATION_ROBOT;
	ci.xFadeoutDuration = CLOAK_FADEOUT_DURATION_ROBOT;
	}
else
	return 0;

ci.xDeltaTime = gameData.time.xGame - ((xCloakStartTime == 0x7fffffff) ? 0 : xCloakStartTime);
#if 0
if (ci.xDeltaTime < ci.xFadeinDuration) {	// make object transparent during second half
	ci.nFadeValue = X2I (FixDiv (ci.xFadeinDuration - ci.xDeltaTime, ci.xFadeinDuration) * CLOAKED_FADE_LEVEL);
	ci.bFading = 1;
	}
#else
// only decrease light during first half of cloak initiation time
if (ci.xDeltaTime < ci.xFadeinDuration / 2) {
	ci.xLightScale = FixDiv (ci.xFadeinDuration / 2 - ci.xDeltaTime, ci.xFadeinDuration / 2);
	ci.bFading = -1;
	}
else if (ci.xDeltaTime < ci.xFadeinDuration) {	// make object transparent during second half
	ci.nFadeValue = X2I (FixDiv (ci.xDeltaTime - ci.xFadeinDuration / 2, ci.xFadeinDuration / 2) * CLOAKED_FADE_LEVEL);
	ci.bFading = 1;
	}
#endif
else if ((xCloakStartTime == 0x7fffffff) || (gameData.time.xGame < xCloakEndTime - ci.xFadeoutDuration)) {
	static int nCloakDelta = 0, nCloakDir = 1;
	static fix xCloakTimer = 0;

	//note, if more than one cloaked CObject is visible at once, the
	//pulse rate will change!
	xCloakTimer -= gameData.time.xFrame;
	while (xCloakTimer < 0) {
		xCloakTimer += ci.xFadeoutDuration / 12;
		nCloakDelta += nCloakDir;
		if (nCloakDelta == 0 || nCloakDelta == 4)
			nCloakDir = -nCloakDir;
		}
	ci.nFadeValue = CLOAKED_FADE_LEVEL - nCloakDelta;
	}
else if (gameData.time.xGame < xCloakEndTime - ci.xFadeoutDuration / 2) {
	ci.nFadeValue = X2I (FixDiv (ci.xTotalTime - ci.xFadeoutDuration / 2 - ci.xDeltaTime, ci.xFadeoutDuration / 2) * CLOAKED_FADE_LEVEL);
	ci.bFading = -1;
	}
else {
	ci.xLightScale = (fix) ((float) (ci.xFadeoutDuration / 2 - (ci.xTotalTime - ci.xDeltaTime) / (float) (ci.xFadeoutDuration / 2)));
	ci.bFading = 1;
	}
if (ciP)
	*ciP = ci;
return ci.bFading;
}

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ I810_CONTEXT函数代码示例发布时间:2022-05-30
下一篇:
C++ I2C_start函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap