CObject *CObject::CreateExplBlast (void) { short nObject, id; CObject *objP; if (!gameOpts->render.effects.bExplBlasts) return NULL; nObject = CreateFireball (0, info.nSegment, info.position.vPos, 2 * info.xSize, RT_EXPLBLAST); if (nObject < 0) return NULL; objP = OBJECTS + nObject; objP->info.xLifeLeft = BLAST_LIFE; objP->cType.explInfo.nSpawnTime = -1; objP->cType.explInfo.nDeleteObj = -1; objP->cType.explInfo.nDeleteTime = -1; objP->info.xSize = info.xSize; objP->info.xSize /= 3; if ((info.nType == OBJ_WEAPON) && (gameData.objs.bIsMissile [id = info.nId])) { if ((id == EARTHSHAKER_ID) || (id == ROBOT_EARTHSHAKER_ID)) { objP->info.xSize = I2X (5) / 2; // objP->info.xLifeLeft = 3 * BLAST_LIFE / 2; } else if ((id == MEGAMSL_ID) || (id == ROBOT_MEGAMSL_ID) || (id == EARTHSHAKER_MEGA_ID)) objP->info.xSize = I2X (2); else if ((id == SMARTMSL_ID) || (id == ROBOT_SMARTMSL_ID)) objP->info.xSize = I2X (3) / 2; else { //objP->info.xLifeLeft /= 2; objP->info.xSize = I2X (1); } } return objP; }
int CShrapnelManager::Create (CObject* objP) { if (!SHOW_SMOKE) return 0; if (!gameOpts->render.effects.nShrapnels) return 0; if (objP->info.nFlags & OF_ARMAGEDDON) return 0; if ((objP->info.nType != OBJ_PLAYER) && (objP->info.nType != OBJ_ROBOT)) return 0; short nObject = CreateFireball (0, objP->info.nSegment, objP->info.position.vPos, 1, RT_SHRAPNELS); if (0 > nObject) return 0; return m_data.buffer [nObject].Create (objP, OBJECTS + nObject); }
void GameState::ReceiveCreateFireball(Packet *p) { CreateFireballStruct *s = ((CreateFireballStruct *) p->data); assert(p->length == sizeof(CreateFireballStruct)); // Get the spell corresponding to the fireball spell FireballSpell* fireballSpell = (FireballSpell*) players[user->GetOppositeTeam()-1].GetSpell(FIREBALL_SPELL_INDEX); // Set the throw power according to the power fireballSpell->SetThrowPower(s->throwPower); // Create the fireball (which uses the throw power) Fireball * fireball = CreateFireball(s->rayOrg, s->rayDir, user->GetOppositeTeam()); // Update the fireball for lag fireball->Update(getTime() - s->timeStamp); }
CObject *CreateLighting (CObject *parentObjP) { short nObject; CObject *objP; if (!EGI_FLAG (bUseLightning, 0, 0, 1)) return NULL; nObject = CreateFireball (0, parentObjP->info.nSegment, parentObjP->info.position.vPos, 2 * parentObjP->info.xSize, RT_LIGHTNING); if (nObject < 0) return NULL; objP = OBJECTS + nObject; objP->info.xLifeLeft = IMMORTAL_TIME; objP->cType.explInfo.nSpawnTime = -1; objP->cType.explInfo.nDeleteObj = -1; objP->cType.explInfo.nDeleteTime = -1; objP->info.xSize = 1; return objP; }
void GameState::MouseButtonJustReleased(int button) { // The user released the mouse button if (button==0 && currentState==GAME_IN_PROGRESS) { bool clickHandled=false; // If over a widget then handle that if (CanLevelUp() && levelUp.GetMouseStateIndex()==MOUSE_PRESSED) { HandleLevelUp(); clickHandled=true; } else if (CanChoosePerk()) { // Check to see if we are over a perk name for (int i=0; i < numberOfPerksToChooseFrom; i++) if (perkWidgets[i].GetMouseStateIndex()==MOUSE_PRESSED) { GivePerkToPlayer(perks[i], user->GetTeam(), false); clickHandled=true; break; } } // we can cast the fireball spell for the user's team if (clickHandled==false && players[user->GetTeam()-1].CanCastSpell(FIREBALL_SPELL_INDEX)) { D3DXVECTOR3 fireballStartPoint, rayDir; GetFireballStartPoint(&fireballStartPoint, &rayDir); CreateFireball(fireballStartPoint, rayDir, user->GetTeam()); // Play the mouse cursor attack animation user->mouseCursor.PlayAttackAnimation(); } } }
CObject* CreateExplosion (CObject* parentP, short nSegment, CFixVector& vPos, fix xSize, ubyte nVClip, fix xMaxDamage, fix xMaxDistance, fix xMaxForce, short nParent) { short nObject; CObject *explObjP, *objP; fix dist, force, damage; CFixVector vHit, vForce; int nType, id; int flash = parentP ? static_cast<int> (gameData.weapons.info [parentP->info.nId].flash) : 0; nObject = CreateFireball (nVClip, nSegment, vPos, xSize, RT_FIREBALL); if (nObject < 0) { #if TRACE console.printf (1, "Can'nType create CObject in /*Object*/CreateExplosionSub.\n"); #endif return NULL; } explObjP = OBJECTS + nObject; //now set explosion-specific data explObjP->info.xLifeLeft = gameData.eff.vClips [0][nVClip].xTotalTime; explObjP->cType.explInfo.nSpawnTime = -1; explObjP->cType.explInfo.nDeleteObj = -1; explObjP->cType.explInfo.nDeleteTime = -1; if (xMaxDamage <= 0) return explObjP; // -- now legal for xBadAss explosions on a CWall. Assert (this != NULL); FORALL_OBJS (objP, i) { nType = objP->info.nType; id = objP->info.nId; // Weapons used to be affected by xBadAss explosions, but this introduces serious problems. // When a smart bomb blows up, if one of its children goes right towards a nearby CWall, it will // blow up, blowing up all the children. So I remove it. MK, 09/11/94 if (objP == parentP) continue; if (objP->info.nFlags & OF_SHOULD_BE_DEAD) continue; if (nType == OBJ_WEAPON) { if (!WeaponIsMine (objP->info.nId)) continue; } else if (nType == OBJ_ROBOT) { if (nParent < 0) continue; if ((OBJECTS [nParent].info.nType == OBJ_ROBOT) && (OBJECTS [nParent].info.nId == id)) continue; } else if ((nType != OBJ_REACTOR) && (nType != OBJ_PLAYER)) continue; dist = CFixVector::Dist (objP->info.position.vPos, explObjP->info.position.vPos); // Make damage be from 'xMaxDamage' to 0.0, where 0.0 is 'xMaxDistance' away; if (dist >= xMaxDistance) continue; if (!ObjectToObjectVisibility (explObjP, objP, FQ_TRANSWALL)) continue; damage = xMaxDamage - FixMulDiv (dist, xMaxDamage, xMaxDistance); force = xMaxForce - FixMulDiv (dist, xMaxForce, xMaxDistance); // Find the force vector on the CObject CFixVector::NormalizedDir(vForce, objP->info.position.vPos, explObjP->info.position.vPos); vForce *= force; // Find where the point of impact is... (vHit) vHit = explObjP->info.position.vPos - objP->info.position.vPos; vHit *= (FixDiv (objP->info.xSize, objP->info.xSize + dist)); if (nType == OBJ_WEAPON) { objP->ApplyForce (vForce); if (WeaponIsMine (objP->info.nId) && (FixMul (dist, force) > I2X (8000))) { //prox bombs have chance of blowing up objP->Die (); objP->ExplodeBadassWeapon (objP->info.position.vPos); } } else if (nType == OBJ_ROBOT) { CFixVector vNegForce; fix xScale = -2 * (7 - gameStates.app.nDifficultyLevel) / 8; objP->ApplyForce (vForce); // If not a boss, stun for 2 seconds at 32 force, 1 second at 16 force if (flash && !ROBOTINFO (objP->info.nId).bossFlag) { tAIStaticInfo *aip = &objP->cType.aiInfo; int nForce = X2I (FixDiv (vForce.Mag () * flash, gameData.time.xFrame) / 128) + 2; if (explObjP->cType.aiInfo.SKIP_AI_COUNT * gameData.time.xFrame >= I2X (1)) aip->SKIP_AI_COUNT--; else { aip->SKIP_AI_COUNT += nForce; objP->mType.physInfo.rotThrust [X] = ((d_rand () - 16384) * nForce) / 16; objP->mType.physInfo.rotThrust [Y] = ((d_rand () - 16384) * nForce) / 16; objP->mType.physInfo.rotThrust [Z] = ((d_rand () - 16384) * nForce) / 16; objP->mType.physInfo.flags |= PF_USES_THRUST; } } vNegForce [X] = vForce [X] * xScale; vNegForce [Y] = vForce [Y] * xScale; vNegForce [Z] = vForce [Z] * xScale; objP->ApplyRotForce (vNegForce); if (objP->info.xShields >= 0) { if (ROBOTINFO (objP->info.nId).bossFlag && bossProps [gameStates.app.bD1Mission][ROBOTINFO (objP->info.nId).bossFlag - BOSS_D2].bInvulKinetic) damage /= 4; if (objP->ApplyDamageToRobot (damage, nParent)) { if (!gameStates.gameplay.bNoBotAI && parentP && (nParent == LOCALPLAYER.nObject)) cockpit->AddPointsToScore (ROBOTINFO (objP->info.nId).scoreValue); } } if (!flash && ROBOTINFO (objP->info.nId).companion) BuddyOuchMessage (damage); } else if (nType == OBJ_REACTOR) { if (objP->info.xShields >= 0) objP->ApplyDamageToReactor (damage, nParent); } else if (nType == OBJ_PLAYER) { CObject* killerP = NULL; CFixVector vRotForce; // Hack!Warning!Test code! if (flash && (objP->info.nId == gameData.multiplayer.nLocalPlayer)) { int fe = min (I2X (4), force * flash / 32); // For four seconds or less if (parentP->cType.laserInfo.parent.nSignature == gameData.objs.consoleP->info.nSignature) { fe /= 2; force /= 2; } if (force > I2X (1)) { paletteManager.SetFlashDuration (fe); force = PK1 + X2I (PK2 * force); paletteManager.BumpEffect (force, force, force); #if TRACE console.printf (CON_DBG, "force = %7.3f, adding %i\n", X2F (force), PK1 + X2I (PK2*force)); #endif } } if (parentP && IsMultiGame && (parentP->info.nType == OBJ_PLAYER)) killerP = parentP; vRotForce = vForce; if (nParent > -1) { killerP = OBJECTS + nParent; if (killerP != gameData.objs.consoleP) // if someone else whacks you, cut force by 2x vRotForce [X] /= 2; vRotForce [Y] /= 2; vRotForce [Z] /= 2; } vRotForce [X] /= 2; vRotForce [Y] /= 2; vRotForce [Z] /= 2; objP->ApplyForce (vForce); objP->ApplyRotForce (vRotForce); if (gameStates.app.nDifficultyLevel == 0) damage /= 4; if (objP->info.xShields >= 0) objP->ApplyDamageToPlayer (killerP, damage); } }