// ----------------------------------------------------------------------------- //check if a particular refP on a CWall is a transparent pixel //returns 1 if can pass though the CWall, else 0 int CSide::CheckForTranspPixel (CFixVector& intersection, short iFace) { fix u, v; int nTranspType; HitPointUV (&u, &v, NULL, intersection, iFace); // Don't compute light value. if (m_nOvlTex) { nTranspType = PixelTranspType (m_nOvlTex, m_nOvlOrient, m_nFrame, u, v); if (nTranspType < 0) return 1; if (!nTranspType) return 0; } nTranspType = PixelTranspType (m_nBaseTex, 0, m_nFrame, u, v) != 0; return nTranspType; }
// ----------------------------------------------------------------------------- //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)); if (!bPermaTrigger) m_sides [nSide].m_nOvlTex = nBitmap; //replace with destoyed } } else { if (!bPermaTrigger) m_sides [nSide].m_nOvlTex = gameData.pig.tex.tMapInfoP [tm].destroyed; //assume this is a light, and play light sound audio.CreateSegmentSound (SOUND_LIGHT_BLOWNUP, Index (), 0, vHit); } return 1; //blew up! }