void OnLineManager::FreeInst() { --m_nRefCount; if( m_nRefCount > 0 ) return; KillObject(); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Function Name: Update() // Purpose: No purpose yet... // Original Author: Rueben Massey // Creation Date: 5/12/2012 // Last Modification By: // Last Modification Date: ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CComponent_Health::Update( float fDT ) { // Get the input component of this components parent object CComponent_Input* inputComp = (CComponent_Input*)(CObjectManager::GetInstance()->GetPlayer()->GetComponent( ECOMP_INPUT )); if( !pAnimComponent ) pAnimComponent = (CComponent_Animation*)m_pParent->GetComponent( ECOMP_ANIMATION ); if( !m_pParent->GetAlive() ) { if( pAnimComponent ) { if(pAnimComponent->GetInterpolator().IsAnimationDone()) { m_fDeathTimerTransition += fDT; if( m_fDeathTimerTransition >= 1.5f ) KillObject(); } } else KillObject(); } m_fDamageTimer += fDT; if(!m_pSoundComponent && m_pParent) { m_pSoundComponent = (CComponent_Sound*)(m_pParent->GetComponent(ECOMP_SOUND)); } /*char buffer[100]; sprintf_s( buffer, "DAMAGE TIMER : %f", fDT ); LOG( LOG_DEBUG, "CComponent_GooPitCollision::Update()", buffer );*/ if( m_bInGooPit ) { if(m_fDamageTimer > 1.0f) { m_fDamageTimer = 0.0f; m_pSoundComponent->PlaySound(DLG_PLAYER_HURT); } // Damage the player AddSludge( m_fGooPitDamageVal * fDT ); // Component Safety Check if( inputComp ) { // Slow the player speed inputComp->SetSpeedMod( GOO_SPEED_MODIFIER ); } } else { // Component Safety Check if( inputComp ) { // Set speed back to normal inputComp->SetSpeedMod( PLAYER_SPEED_MODIFIER ); } } if (m_bHealing) { // TODO: // change this to use the heal amount from the water pools RemoveSludge (10.0f * fDT); m_bHealing = false; } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Function Name: AddSludge() // Purpose: Add sludge to the player // Original Author: Rueben Massey // Creation Date: 5/12/2012 // Last Modification By: // Last Modification Date: ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CComponent_Health::AddSludge( float fSludgeAmount ) { if( !m_pParent->GetAlive() ) return; // decrease health m_unHealth -= fSludgeAmount; //char buffer[100]; //sprintf_s( buffer, "HEALTH = %d", m_unHealth ); //LOG( LOG_DEBUG, "CComponent_Health::AddSludge()", buffer ); //If a little goo attacks the player play the small damage animation if(fSludgeAmount == LIGHT_DAMAGE) { CObjectManager::GetInstance()->CreateObject( OBJ_LITTLEHIT_MESHEFFECT, m_pParent->GetPositionMatrix().ma); if(pAnimComponent) { if(pAnimComponent->GetAnimStateMachine()->GetCurrentState() != PudgeSmallDamageState::GetState()) { m_bPlayerHasTakenLightDamage = true; m_bPlayerHasTakenHeavyDamage = false; pAnimComponent->GetAnimStateMachine()->ChangeState(PudgeSmallDamageState::GetState()); } } } //If a junk hunk attacks the player play the big damage animation if(fSludgeAmount == HEAVY_DAMAGE) { CObjectManager::GetInstance()->CreateObject( OBJ_BIGHIT_MESHEFFECT, m_pParent->GetPositionMatrix().ma); if(pAnimComponent) { if(pAnimComponent->GetAnimStateMachine()->GetCurrentState() != PudgeBigDamageState::GetState()) { m_bPlayerHasTakenLightDamage = false; m_bPlayerHasTakenHeavyDamage = true; pAnimComponent->GetAnimStateMachine()->ChangeState(PudgeBigDamageState::GetState()); } } } // if the health is less then 0 if( m_unHealth <= 0.0f ) { // set the parents alive to false m_pParent->SetAlive (false); // set the health to 0 m_unHealth = 0.0f; // play some sound m_pSoundComponent->PlaySound(DLG_PLAYER_DEATH); //KillObject(); if( pAnimComponent ) { // Create the Death Mesh Effect. CObjectManager::GetInstance()->CreateObject( OBJ_PLAYER_DEATH_EFFECT, m_pParent->GetPositionMatrix().ma); // Transition to the Death By Goo Animation if not already dead. pAnimComponent->GetAnimStateMachine()->ChangeState( PudgeDeathByGooState::GetState() ); ((CComponent_Collision*)m_pParent->GetComponent( ECOMP_COLLISION ))->CleanRemoveVelocity(); } else { KillObject(); } } // update the HUD CGamePlayState::GetInstance()->GetHUD()->SetSludgeAmount(m_unHealth); }
bool _HYObjectInspector::ProcessEvent (_HYEvent* e) { _String firstArg; long k,i,f; bool done = false; if (e->EventClass()==_hyMenuSelChangeEvent) { firstArg = e->EventCode().Cut (0,(f=e->EventCode().Find(','))-1); k = firstArg.toNum(); for (i=0; i<components.lLength; i++) { if (((_HYGuiObject*)components(i))->MatchID(k)) { break; } } firstArg = e->EventCode().Cut (f+1,-1); k = firstArg.toNum(); BuildListOfObjects (k); done = true; } else { if (e->EventClass()==_hyTableChangeSelEvent) { k = e->EventCode().toNum(); for (i=0; i<components.lLength; i++) if (((_HYGuiObject*)components(i))->MatchID(k)) { break; } if (i==1) { UpdateButtonsAndInfo (); } done = true; } else { if (e->EventClass()==_hyButtonPushEvent) { firstArg = e->EventCode().Cut (0,(f=e->EventCode().Find(','))-1); k = firstArg.toNum(); for (i=0; i<components.lLength; i++) if (((_HYGuiObject*)components(i))->MatchID(k)) { break; } firstArg = e->EventCode().Cut (f+1,-1); k = firstArg.toNum(); if (i==4) { // button bar _HYButtonBar* bb = (_HYButtonBar*)GetCellObject (0,0); switch (k) { case 0: OpenObjectWindow(); break; case 1: KillObject (); break; case 2: OpenObject (); break; case 3: NewObject (); break; } bb->_UnpushButton(); UpdateButtonsAndInfo(); } done = true; } else { if (e->EventClass()==_hyTableDblClickEvent) { k = e->EventCode().toNum(); for (i=0; i<components.lLength; i++) if (((_HYGuiObject*)components(i))->MatchID(k)) { break; } if (i==1) { OpenObjectWindow(); } done = true; } else if (e->EventClass()==_hyTablePullDownEvent) { firstArg = e->EventCode().Cut (0,(f=e->EventCode().Find(','))-1); k = firstArg.toNum(); for (i=0; i<components.lLength; i++) { if (((_HYGuiObject*)components(i))->MatchID(k)) { break; } } k = e->EventCode().Find(',',f+1,-1); firstArg = e->EventCode().Cut (k+1,-1); if (i==2) { SortObjectsByName (firstArg.toNum()); } done = true; } } } } if (done) { DeleteObject (e); return true; } return _HYTWindow::ProcessEvent(e); }
tObject *ObjectCreateExplosionSub (tObject *objP, short nSegment, vmsVector *vPos, fix xSize, ubyte nVClip, fix xMaxDamage, fix xMaxDistance, fix xMaxForce, short nParent) { short nObject; tObject *explObjP, *obj0P; fix dist, force, damage; vmsVector pos_hit, vForce; int i, t, id; nObject = CreateObject (OBJ_FIREBALL, nVClip, -1, nSegment, vPos, &vmdIdentityMatrix, xSize, CT_EXPLOSION, MT_NONE, RT_FIREBALL, 1); if (nObject < 0) { #if TRACE con_printf (1, "Can't create tObject in ObjectCreateExplosionSub.\n"); #endif return NULL; } explObjP = gameData.objs.objects + nObject; //now set explosion-specific data explObjP->lifeleft = 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 tWall. Assert (objP != NULL); for (i = 0, obj0P = gameData.objs.objects; i <= gameData.objs.nLastObject; i++, obj0P++) { t = obj0P->nType; id = obj0P->id; // 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 tWall, it will // blow up, blowing up all the children. So I remove it. MK, 09/11/94 if (obj0P == objP) continue; if (obj0P->flags & OF_SHOULD_BE_DEAD) continue; if (t == OBJ_WEAPON) { if (!WeaponIsMine (obj0P->id)) continue; } else if (t == OBJ_ROBOT) { if (nParent < 0) continue; if ((gameData.objs.objects [nParent].nType == OBJ_ROBOT) && (gameData.objs.objects [nParent].id == id)) continue; } else if ((t != OBJ_REACTOR) && (t != OBJ_PLAYER)) continue; dist = VmVecDistQuick (&obj0P->position.vPos, &explObjP->position.vPos); // Make damage be from 'xMaxDamage' to 0.0, where 0.0 is 'xMaxDistance' away; if (dist >= xMaxDistance) continue; if (!ObjectToObjectVisibility (explObjP, obj0P, FQ_TRANSWALL)) continue; damage = xMaxDamage - FixMulDiv (dist, xMaxDamage, xMaxDistance); force = xMaxForce - FixMulDiv (dist, xMaxForce, xMaxDistance); // Find the force vector on the tObject VmVecNormalizedDirQuick (&vForce, &obj0P->position.vPos, &explObjP->position.vPos); VmVecScale (&vForce, force); // Find where the point of impact is... (pos_hit) VmVecSub (&pos_hit, &explObjP->position.vPos, &obj0P->position.vPos); VmVecScale (&pos_hit, FixDiv (obj0P->size, obj0P->size + dist)); if (t == OBJ_WEAPON) { PhysApplyForce (obj0P, &vForce); if (WeaponIsMine (obj0P->id) && (FixMul (dist, force) > i2f (8000))) { //prox bombs have chance of blowing up KillObject (obj0P); ExplodeBadassWeapon (obj0P, &obj0P->position.vPos); } } else if (t == OBJ_ROBOT) { vmsVector vNegForce; fix xScale = -2 * (7 - gameStates.app.nDifficultyLevel) / 8; PhysApplyForce (obj0P, &vForce); // If not a boss, stun for 2 seconds at 32 force, 1 second at 16 force if (objP && (!ROBOTINFO (obj0P->id).bossFlag) && (gameData.weapons.info [objP->id].flash)) { tAIStatic *aip = &obj0P->cType.aiInfo; int force_val = f2i (FixDiv (VmVecMagQuick (&vForce) * gameData.weapons.info [objP->id].flash, gameData.time.xFrame)/128) + 2; if (explObjP->cType.aiInfo.SKIP_AI_COUNT * gameData.time.xFrame >= F1_0) aip->SKIP_AI_COUNT--; else { aip->SKIP_AI_COUNT += force_val; obj0P->mType.physInfo.rotThrust.p.x = ((d_rand () - 16384) * force_val)/16; obj0P->mType.physInfo.rotThrust.p.y = ((d_rand () - 16384) * force_val)/16; obj0P->mType.physInfo.rotThrust.p.z = ((d_rand () - 16384) * force_val)/16; obj0P->mType.physInfo.flags |= PF_USES_THRUST; } } vNegForce.p.x = vForce.p.x * xScale; vNegForce.p.y = vForce.p.y * xScale; vNegForce.p.z = vForce.p.z * xScale; PhysApplyRot (obj0P, &vNegForce); if (obj0P->shields >= 0) { if (ROBOTINFO (obj0P->id).bossFlag && bossProps [gameStates.app.bD1Mission][ROBOTINFO (obj0P->id).bossFlag-BOSS_D2].bInvulKinetic) damage /= 4; if (ApplyDamageToRobot (obj0P, damage, nParent) && objP && (nParent == LOCALPLAYER.nObject)) AddPointsToScore (ROBOTINFO (obj0P->id).scoreValue); } if (objP && (ROBOTINFO (obj0P->id).companion) && !gameData.weapons.info [objP->id].flash) { int i, count; char szOuch [6*4 + 2]; count = f2i (damage / 8); if (count > 4) count = 4; else if (count <= 0) count = 1; szOuch [0] = 0; for (i = 0; i < count; i++) { strcat (szOuch, TXT_BUDDY_OUCH); strcat (szOuch, " "); } BuddyMessage (szOuch); } } else if (t == OBJ_REACTOR) { if (obj0P->shields >= 0) ApplyDamageToReactor (obj0P, damage, nParent); } else if (t == OBJ_PLAYER) { tObject *killerP = NULL; vmsVector vForce2; // Hack!Warning!Test code! if (objP && gameData.weapons.info [objP->id].flash && obj0P->id==gameData.multiplayer.nLocalPlayer) { int fe = min (F1_0*4, force*gameData.weapons.info [objP->id].flash/32); // For four seconds or less if (objP->cType.laserInfo.nParentSig == gameData.objs.console->nSignature) { fe /= 2; force /= 2; } if (force > F1_0) { gameData.render.xFlashEffect = fe; PALETTE_FLASH_ADD (PK1 + f2i (PK2*force), PK1 + f2i (PK2*force), PK1 + f2i (PK2*force)); #if TRACE con_printf (CONDBG, "force = %7.3f, adding %i\n", f2fl (force), PK1 + f2i (PK2*force)); #endif } } if (objP && IsMultiGame && (objP->nType == OBJ_PLAYER)) killerP = objP; vForce2 = vForce; if (nParent > -1) { killerP = gameData.objs.objects + nParent; if (killerP != gameData.objs.console) // if someone else whacks you, cut force by 2x vForce2.p.x /= 2; vForce2.p.y /= 2; vForce2.p.z /= 2; } vForce2.p.x /= 2; vForce2.p.y /= 2; vForce2.p.z /= 2; PhysApplyForce (obj0P, &vForce); PhysApplyRot (obj0P, &vForce2); if (gameStates.app.nDifficultyLevel == 0) damage /= 4; if (obj0P->shields >= 0) ApplyDamageToPlayer (obj0P, killerP, damage); } } return explObjP; }
void MultigridSolver_Destruct( MultigridSolver* self ) { assert( self && Stg_CheckType( self, MultigridSolver ) ); MultigridSolver_DestructLevels( self ); KillObject( self->opGen ); }