static int LaserCreationTimeout (int nId, fix xCreationTime) { if (nId == PHOENIX_ID) return gameData.time.xGame > xCreationTime + (I2X (1) / 3) * gameStates.gameplay.slowmo [0].fSpeed; else if (nId == GUIDEDMSL_ID) return gameData.time.xGame > xCreationTime + (I2X (1) / 2) * gameStates.gameplay.slowmo [0].fSpeed; else if (WeaponIsPlayerMine (nId)) return gameData.time.xGame > xCreationTime + (I2X (4)) * gameStates.gameplay.slowmo [0].fSpeed; else return 0; }
void DoRenderObject (int nObject, int nWindow) { CObject* objP = OBJECTS + nObject; int count = 0; if (!(IsMultiGame || gameOpts->render.debug.bObjects)) return; Assert(nObject < LEVEL_OBJECTS); #if 0 if (!(nWindow || gameStates.render.cameras.bActive) && (gameStates.render.nShadowPass < 2) && (gameData.render.mine.bObjectRendered [nObject] == gameStates.render.nFrameFlipFlop)) //already rendered this... return; #endif if (gameData.demo.nState == ND_STATE_PLAYBACK) { if ((nDemoDoingLeft == 6 || nDemoDoingRight == 6) && objP->info.nType == OBJ_PLAYER) { return; } } if ((count++ > LEVEL_OBJECTS) || (objP->info.nNextInSeg == nObject)) { Int3(); // infinite loop detected objP->info.nNextInSeg = -1; // won't this clean things up? return; // get out of this infinite loop! } if (RenderObject (objP, nWindow, 0)) { gameData.render.mine.bObjectRendered [nObject] = gameStates.render.nFrameFlipFlop; if (!gameStates.render.cameras.bActive) { tWindowRenderedData* wrd = windowRenderedData + nWindow; int nType = objP->info.nType; if ((nType == OBJ_ROBOT) || (nType == OBJ_PLAYER) || ((nType == OBJ_WEAPON) && (WeaponIsPlayerMine (objP->info.nId) || (gameData.objs.bIsMissile [objP->info.nId] && EGI_FLAG (bKillMissiles, 0, 0, 0))))) { if (wrd->nObjects >= MAX_RENDERED_OBJECTS) { Int3(); wrd->nObjects /= 2; } wrd->renderedObjects [wrd->nObjects++] = nObject; } } } for (int i = objP->info.nAttachedObj; i != -1; i = objP->cType.explInfo.attached.nNext) { objP = OBJECTS + i; Assert (objP->info.nType == OBJ_FIREBALL); Assert (objP->info.controlType == CT_EXPLOSION); Assert (objP->info.nFlags & OF_ATTACHED); RenderObject (objP, nWindow, 1); } }
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; }