/* ================ idLight::Event_Off ================ */ void idLight::Event_Off( void ) { Off(); }
/* ================ idLight::Spawn ================ */ void idLight::Spawn( void ) { bool start_off; bool needBroken; const char *demonic_shader; // do the parsing the same way dmap and the editor do gameEdit->ParseSpawnArgsToRenderLight( &spawnArgs, &renderLight ); // we need the origin and axis relative to the physics origin/axis localLightOrigin = ( renderLight.origin - GetPhysics()->GetOrigin() ) * GetPhysics()->GetAxis().Transpose(); localLightAxis = renderLight.axis * GetPhysics()->GetAxis().Transpose(); // set the base color from the shader parms baseColor.Set( renderLight.shaderParms[ SHADERPARM_RED ], renderLight.shaderParms[ SHADERPARM_GREEN ], renderLight.shaderParms[ SHADERPARM_BLUE ] ); // set the number of light levels spawnArgs.GetInt( "levels", "1", levels ); currentLevel = levels; if ( levels <= 0 ) { gameLocal.Error( "Invalid light level set on entity #%d(%s)", entityNumber, name.c_str() ); } // make sure the demonic shader is cached if ( spawnArgs.GetString( "mat_demonic", NULL, &demonic_shader ) ) { declManager->FindType( DECL_MATERIAL, demonic_shader ); } // game specific functionality, not mirrored in // editor or dmap light parsing // also put the light texture on the model, so light flares // can get the current intensity of the light renderEntity.referenceShader = renderLight.shader; lightDefHandle = -1; // no static version yet // see if an optimized shadow volume exists // the renderer will ignore this value after a light has been moved, // but there may still be a chance to get it wrong if the game moves // a light before the first present, and doesn't clear the prelight renderLight.prelightModel = 0; if ( name[ 0 ] ) { // this will return 0 if not found renderLight.prelightModel = renderModelManager->CheckModel( va( "_prelight_%s", name.c_str() ) ); } spawnArgs.GetBool( "start_off", "0", start_off ); if ( start_off ) { Off(); } health = spawnArgs.GetInt( "health", "0" ); spawnArgs.GetString( "broken", "", brokenModel ); spawnArgs.GetBool( "break", "0", breakOnTrigger ); spawnArgs.GetInt( "count", "1", count ); triggercount = 0; fadeFrom.Set( 1, 1, 1, 1 ); fadeTo.Set( 1, 1, 1, 1 ); fadeStart = 0; fadeEnd = 0; // if we have a health make light breakable if ( health ) { idStr model = spawnArgs.GetString( "model" ); // get the visual model if ( !model.Length() ) { gameLocal.Error( "Breakable light without a model set on entity #%d(%s)", entityNumber, name.c_str() ); } fl.takedamage = true; // see if we need to create a broken model name needBroken = true; if ( model.Length() && !brokenModel.Length() ) { int pos; needBroken = false; pos = model.Find( "." ); if ( pos < 0 ) { pos = model.Length(); } if ( pos > 0 ) { model.Left( pos, brokenModel ); } brokenModel += "_broken"; if ( pos > 0 ) { brokenModel += &model[ pos ]; } } // make sure the model gets cached if ( !renderModelManager->CheckModel( brokenModel ) ) { if ( needBroken ) { gameLocal.Error( "Model '%s' not found for entity %d(%s)", brokenModel.c_str(), entityNumber, name.c_str() ); } else { brokenModel = ""; } } GetPhysics()->SetContents( spawnArgs.GetBool( "nonsolid" ) ? 0 : CONTENTS_SOLID ); // make sure the collision model gets cached idClipModel::CheckModel( brokenModel ); } PostEventMS( &EV_PostSpawn, 0 ); UpdateVisuals(); }
/* ================ idLight::Event_Hide ================ */ void idLight::Event_Hide( void ) { Hide(); PresentModelDefChange(); Off(); }
void FGTurbine::Calculate(void) { double thrust; RunPreFunctions(); ThrottlePos = in.ThrottlePos[EngineNumber]; if (ThrottlePos > 1.0) { AugmentCmd = ThrottlePos - 1.0; ThrottlePos -= AugmentCmd; } else { AugmentCmd = 0.0; } // When trimming is finished check if user wants engine OFF or RUNNING if ((phase == tpTrim) && (in.TotalDeltaT > 0)) { if (Running && !Starved) { phase = tpRun; N1_factor = MaxN1 - IdleN1; N2_factor = MaxN2 - IdleN2; N2 = IdleN2 + ThrottlePos * N2_factor; N1 = IdleN1 + ThrottlePos * N1_factor; OilTemp_degK = 366.0; Cutoff = false; } else { phase = tpOff; Cutoff = true; EGT_degC = in.TAT_c; } } if (!Running && Cutoff && Starter) { if (phase == tpOff) phase = tpSpinUp; } // start if ((Starter == true) || (in.qbar > 30.0)) { if (!Running && !Cutoff && (N2 > 15.0)) phase = tpStart; } if (Cutoff && (phase != tpSpinUp)) phase = tpOff; if (in.TotalDeltaT == 0) phase = tpTrim; if (Starved) phase = tpOff; if (Stalled) phase = tpStall; if (Seized) phase = tpSeize; switch (phase) { case tpOff: thrust = Off(); break; case tpRun: thrust = Run(); break; case tpSpinUp: thrust = SpinUp(); break; case tpStart: thrust = Start(); break; case tpStall: thrust = Stall(); break; case tpSeize: thrust = Seize(); break; case tpTrim: thrust = Trim(); break; default: thrust = Off(); } Thruster->Calculate(thrust); // allow thruster to modify thrust (i.e. reversing) RunPostFunctions(); }
//----------------------------------------------------------------------------- // Purpose: // Input : *pActivator - // *pCaller - // useType - // value - //----------------------------------------------------------------------------- void CNewWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // Make sure that we have a caller if (!pActivator) return; // if it's not a player, ignore if ( !pActivator->IsPlayer() ) return; CBasePlayer *pPlayer = dynamic_cast<CBasePlayer *>(pActivator); // Reset to a state of continuous use. m_iCaps = FCAP_CONTINUOUS_USE; if ( m_iOn ) { float flCharges = CHARGES_PER_SECOND; float flCalls = CALLS_PER_SECOND; m_flJuice -= flCharges / flCalls; StudioFrameAdvance(); } // if there is no juice left, turn it off if (m_iJuice <= 0) { ResetSequence( LookupSequence( "emptyclick" ) ); m_nState = 1; Off(); } // if the player doesn't have the suit, or there is no juice left, make the deny noise. // disabled HEV suit dependency for now. //if ((m_iJuice <= 0) || (!(pActivator->m_bWearingSuit))) if (m_iJuice <= 0) { if (m_flSoundTime <= gpGlobals->curtime) { m_flSoundTime = gpGlobals->curtime + 0.62; EmitSound( "WallHealth.Deny" ); } return; } if( pActivator->GetHealth() >= pActivator->GetMaxHealth() ) { if( pPlayer ) { pPlayer->m_afButtonPressed &= ~IN_USE; } // Make the user re-use me to get started drawing health. m_iCaps = FCAP_IMPULSE_USE; EmitSound( "WallHealth.Deny" ); return; } SetNextThink( gpGlobals->curtime + CHARGE_RATE ); SetThink( &CNewWallHealth::Off ); // Time to recharge yet? if (m_flNextCharge >= gpGlobals->curtime) return; // Play the on sound or the looping charging sound if (!m_iOn) { m_iOn++; EmitSound( "WallHealth.Start" ); m_flSoundTime = 0.56 + gpGlobals->curtime; m_OnPlayerUse.FireOutput( pActivator, this ); } if ((m_iOn == 1) && (m_flSoundTime <= gpGlobals->curtime)) { m_iOn++; CPASAttenuationFilter filter( this, "WallHealth.LoopingContinueCharge" ); filter.MakeReliable(); EmitSound( filter, entindex(), "WallHealth.LoopingContinueCharge" ); } // charge the player if ( pActivator->TakeHealth( 1, DMG_GENERIC ) ) { m_iJuice--; } // Send the output. float flRemaining = m_iJuice / sk_healthcharger.GetFloat(); m_OutRemainingHealth.Set(flRemaining, pActivator, this); // govern the rate of charge m_flNextCharge = gpGlobals->curtime + 0.1; }
/* <c630e> ../cstrike/dlls/h_battery.cpp:107 */ void CRecharge::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { // if it's not a player, ignore if (!FClassnameIs(pActivator->pev, "player")) return; // if there is no juice left, turn it off if (m_iJuice <= 0) { pev->frame = 1; Off(); } // if the player doesn't have the suit, or there is no juice left, make the deny noise if (m_iJuice <= 0 || !(pActivator->pev->weapons & (1 << WEAPON_SUIT))) { if (m_flSoundTime <= gpGlobals->time) { m_flSoundTime = gpGlobals->time + 0.62; EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/suitchargeno1.wav", 0.85, ATTN_NORM); } return; } pev->nextthink = pev->ltime + 0.25; SetThink(&CRecharge::Off); // Time to recharge yet? if (m_flNextCharge >= gpGlobals->time) return; // Make sure that we have a caller if (!pActivator) return; m_hActivator = pActivator;//EHANDLE::CBaseEntity *operator= //only recharge the player if (!m_hActivator->IsPlayer()) return; // Play the on sound or the looping charging sound if (!m_iOn) { m_iOn++; EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/suitchargeok1.wav", 0.85, ATTN_NORM); m_flSoundTime = gpGlobals->time + 0.56; } if (m_iOn == 1 && m_flSoundTime <= gpGlobals->time) { m_iOn++; EMIT_SOUND(ENT(pev), CHAN_STATIC, "items/suitcharge1.wav", 0.85, ATTN_NORM); } // charge the player if (m_hActivator->pev->armorvalue < 100) { m_iJuice--; m_hActivator->pev->armorvalue += 1; if (m_hActivator->pev->armorvalue > 100) m_hActivator->pev->armorvalue = 100; } // govern the rate of charge m_flNextCharge = gpGlobals->time + 0.1; }
/* ================ idLight::ReadFromSnapshot ================ */ void idLight::ReadFromSnapshot( const idBitMsgDelta &msg ) { idVec4 shaderColor; int oldCurrentLevel = currentLevel; idVec3 oldBaseColor = baseColor; GetPhysics()->ReadFromSnapshot( msg ); ReadBindFromSnapshot( msg ); currentLevel = msg.ReadByte(); if ( currentLevel != oldCurrentLevel ) { // need to call On/Off for flickering lights to start/stop the sound // while doing it this way rather than through events, the flickering is out of sync between clients // but at least there is no question about saving the event and having them happening globally in the world if ( currentLevel ) { On(); } else { Off(); } } UnpackColor( msg.ReadInt(), baseColor ); // lightParentEntityNum = msg.ReadBits( GENTITYNUM_BITS ); /* // only helps prediction UnpackColor( msg.ReadInt(), fadeFrom ); UnpackColor( msg.ReadInt(), fadeTo ); fadeStart = msg.ReadInt(); fadeEnd = msg.ReadInt(); */ // FIXME: read renderLight.shader renderLight.lightRadius[0] = msg.ReadFloat( 5, 10 ); renderLight.lightRadius[1] = msg.ReadFloat( 5, 10 ); renderLight.lightRadius[2] = msg.ReadFloat( 5, 10 ); UnpackColor( msg.ReadInt(), shaderColor ); renderLight.shaderParms[SHADERPARM_RED] = shaderColor[0]; renderLight.shaderParms[SHADERPARM_GREEN] = shaderColor[1]; renderLight.shaderParms[SHADERPARM_BLUE] = shaderColor[2]; renderLight.shaderParms[SHADERPARM_ALPHA] = shaderColor[3]; renderLight.shaderParms[SHADERPARM_TIMESCALE] = msg.ReadFloat( 5, 10 ); renderLight.shaderParms[SHADERPARM_TIMEOFFSET] = msg.ReadInt(); //renderLight.shaderParms[SHADERPARM_DIVERSITY] = msg.ReadFloat(); renderLight.shaderParms[SHADERPARM_MODE] = msg.ReadShort(); ReadColorFromSnapshot( msg ); if ( msg.HasChanged() ) { if ( ( currentLevel != oldCurrentLevel ) || ( baseColor != oldBaseColor ) ) { SetLightLevel(); } else { PresentLightDefChange(); PresentModelDefChange(); } } }
void FGTurboProp::Calculate(void) { RunPreFunctions(); TAT = in.TAT_c; ThrottlePos = in.ThrottlePos[EngineNumber]; /* The thruster controls the engine RPM because it encapsulates the gear ratio and other transmission variables */ RPM = Thruster->GetEngineRPM(); if (thrusterType == FGThruster::ttPropeller) { ((FGPropeller*)Thruster)->SetAdvance(in.PropAdvance[EngineNumber]); ((FGPropeller*)Thruster)->SetFeather(in.PropFeather[EngineNumber]); ((FGPropeller*)Thruster)->SetReverse(Reversed); if (Reversed) { ((FGPropeller*)Thruster)->SetReverseCoef(ThrottlePos); } else { ((FGPropeller*)Thruster)->SetReverseCoef(0.0); } if (Reversed) { if (ThrottlePos < BetaRangeThrottleEnd) { ThrottlePos = 0.0; // idle when in Beta-range } else { // when reversed: ThrottlePos = (ThrottlePos-BetaRangeThrottleEnd)/(1-BetaRangeThrottleEnd) * ReverseMaxPower; } } } // When trimming is finished check if user wants engine OFF or RUNNING if ((phase == tpTrim) && (in.TotalDeltaT > 0)) { if (Running && !Starved) { phase = tpRun; N2 = IdleN2; N1 = IdleN1; OilTemp_degK = 366.0; Cutoff = false; } else { phase = tpOff; Cutoff = true; Eng_ITT_degC = TAT; Eng_Temperature = TAT; OilTemp_degK = TAT+273.15; } } if (!Running && Starter) { if (phase == tpOff) { phase = tpSpinUp; if (StartTime < 0) StartTime=0; } } if (!Running && !Cutoff && (N1 > 15.0)) { phase = tpStart; StartTime = -1; } if (Cutoff && (phase != tpSpinUp)) phase = tpOff; if (in.TotalDeltaT == 0) phase = tpTrim; if (Starved) phase = tpOff; if (Condition >= 10) { phase = tpOff; StartTime=-1; } // limiter intervention wanted? if (Ielu_max_torque > 0.0) { double torque = 0.0; if (thrusterType == FGThruster::ttPropeller) { torque = ((FGPropeller*)(Thruster))->GetTorque(); } else if (thrusterType == FGThruster::ttRotor) { torque = ((FGRotor*)(Thruster))->GetTorque(); } if (Condition < 1) { if ( abs(torque) > Ielu_max_torque && ThrottlePos >= OldThrottle ) { ThrottlePos = OldThrottle - 0.1 * in.TotalDeltaT; //IELU down Ielu_intervent = true; } else if ( Ielu_intervent && ThrottlePos >= OldThrottle) { ThrottlePos = OldThrottle + 0.05 * in.TotalDeltaT; //IELU up Ielu_intervent = true; } else { Ielu_intervent = false; } } else { Ielu_intervent = false; } OldThrottle = ThrottlePos; } switch (phase) { case tpOff: HP = Off(); break; case tpRun: HP = Run(); break; case tpSpinUp: HP = SpinUp(); break; case tpStart: HP = Start(); break; default: HP = 0; } LoadThrusterInputs(); Thruster->Calculate(HP * hptoftlbssec); RunPostFunctions(); }
int main() { int i; printf("hello world\n"); printf("start of out_test\n"); Wait(SEC_1); // initialize if (!OutputInit()) printf("output init returned false\n"); ResetAllTachoCounts(OUT_ABCD); // OutputSetType(OUT_A, DEVICE_TYPE_TACHO); // OutputSetType(OUT_B, DEVICE_TYPE_TACHO); // OutputSetType(OUT_C, DEVICE_TYPE_MINITACHO); OutputSetTypes(DEVICE_TYPE_TACHO, DEVICE_TYPE_TACHO, DEVICE_TYPE_TACHO, DEVICE_TYPE_TACHO); SetPower(OUT_A, 90); SetSpeed(OUT_B, 40); SetPower(OUT_C, 60); SetPower(OUT_D, -60); On(OUT_ALL); bool isBusy = false; for(i=0; i < 10; i++) { printf("OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A)); printf("OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B)); printf("OUT_C: %d %d %d\n", MotorRotationCount(OUT_C), MotorTachoCount(OUT_C), MotorActualSpeed(OUT_C)); printf("OUT_D: %d %d %d\n", MotorRotationCount(OUT_D), MotorTachoCount(OUT_D), MotorActualSpeed(OUT_D)); Wait(SEC_1); isBusy = MotorBusy(OUT_ALL); printf("Any output isBusy = %d\n", (byte)isBusy); } // Wait(SEC_5); printf("Float(OUT_ALL)\n"); Float(OUT_ALL); printf("Wait(SEC_2)\n"); Wait(SEC_2); printf("ResetAllTachoCounts(OUT_ALL)\n"); ResetAllTachoCounts(OUT_ALL); printf("OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A)); printf("OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B)); printf("OUT_C: %d %d %d\n", MotorRotationCount(OUT_C), MotorTachoCount(OUT_C), MotorActualSpeed(OUT_C)); printf("OUT_D: %d %d %d\n", MotorRotationCount(OUT_D), MotorTachoCount(OUT_D), MotorActualSpeed(OUT_D)); printf("Wait(SEC_1)\n"); Wait(SEC_1); printf("RotateMotorNoWait(OUT_AB, 75, 7200)\n"); RotateMotorNoWait(OUT_AB, 75, 7200); printf("OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A)); printf("OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B)); isBusy = MotorBusy(OUT_AB); printf("A or B isBusy = %d\n", (byte)isBusy); printf("Wait(SEC_20)\n"); Wait(SEC_20); printf("OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A)); printf("OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B)); printf("resetting all tacho counters\n"); ResetAllTachoCounts(OUT_ALL); printf("Wait(SEC_1)\n"); Wait(SEC_1); printf("OnForSync(OUT_AB, SEC_10, 75)\n"); OnForSync(OUT_AB, SEC_10, 75); for(i=0; i < 10; i++) { printf("OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A)); printf("OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B)); isBusy = MotorBusy(OUT_AB); printf("A or B isBusy = %d\n", (byte)isBusy); isBusy = MotorBusy(OUT_CD); printf("C or D isBusy = %d\n", (byte)isBusy); Wait(SEC_1); } printf("Wait(SEC_2)\n"); Wait(SEC_2); printf("OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A)); printf("OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B)); // synchronized motor movement without tacho or time limitation printf("OnFwdSync(OUT_AB, 75)\n"); OnFwdSync(OUT_AB, 75); printf("Wait(SEC_2)\n"); Wait(SEC_2); printf("OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A)); printf("OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B)); printf("Off(OUT_AB)\n"); Off(OUT_AB); // stop with braking printf("OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A)); printf("OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B)); printf("Wait(SEC_1)\n"); Wait(SEC_1); /* * Turn ratio is how tight you turn and to what direction you turn * - 0 value is moving straight forward * - Negative values turns to the left * - Positive values turns to the right * - Value -100 stops the left motor * - Value +100 stops the right motor * - Values less than -100 makes the left motor run the opposite * direction of the right motor (Spin) * - Values greater than +100 makes the right motor run the opposite * direction of the left motor (Spin) */ printf("OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A)); printf("OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B)); printf("OnFwdSyncEx(OUT_AB, 75, -20, RESET_NONE)\n"); OnFwdSyncEx(OUT_AB, 75, -20, RESET_NONE); printf("Wait(SEC_2)\n"); Wait(SEC_2); printf("OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A)); printf("OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B)); printf("OnFwdSync(OUT_AB, 50, -50, RESET_NONE)"); OnFwdSyncEx(OUT_AB, 50, -50, RESET_NONE); printf("Wait(SEC_2)\n"); Wait(SEC_2); printf("OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A)); printf("OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B)); printf("OnFwdSync(OUT_AB, 20, -100, RESET_NONE)\n"); OnFwdSyncEx(OUT_AB, 20, -100, RESET_NONE); printf("Wait(SEC_2)\n"); Wait(SEC_2); printf("OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A)); printf("OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B)); printf("OnFwdSync(OUT_AB, 80, -150, RESET_NONE)\n"); OnFwdSyncEx(OUT_AB, 80, -150, RESET_NONE); printf("Wait(SEC_2)\n"); Wait(SEC_2); printf("OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A)); printf("OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B)); printf("OnFwdSync(OUT_AB, 30, -200, RESET_NONE)\n"); OnFwdSyncEx(OUT_AB, 30, -200, RESET_NONE); printf("Wait(SEC_2)\n"); Wait(SEC_2); printf("OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A)); printf("OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B)); printf("Off(OUT_AB)\n"); Off(OUT_AB); printf("Wait(SEC_2)\n"); Wait(SEC_2); printf("OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A)); printf("OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B)); printf("ResetAllTachoCounts(OUT_AB)\n"); ResetAllTachoCounts(OUT_AB); printf("Wait(SEC_2)\n"); Wait(SEC_2); printf("OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A)); printf("OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B)); // a blocking version of RotateMotor (function call does not return // until the motor rotation is complete) printf("RotateMotor(OUT_AB, 75, 1800)"); RotateMotor(OUT_AB, 75, 1800); // 5 rotations // by the time the function above returns the motors are no longer busy isBusy = MotorBusy(OUT_AB); printf("A or B isBusy = %d\n", isBusy); // this call starts the motors running Forward without regulation or // synchronization and the function call does not return until the // specified amount of time has elapsed. // at the end of the elapsed time the motors are stopped with braking. printf("OnFor(OUT_AB, SEC_3)\n"); OnFor(OUT_AB, SEC_3); printf("Off(OUT_AB)\n"); Off(OUT_AB); printf("Wait(SEC_5)\n"); Wait(SEC_5); OutputClose(); OutputExit(); printf("end of out_test\n"); return 0; }
void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { // if it's not a player, ignore if ( !pActivator->IsPlayer() ) return; // if there is no juice left, turn it off if (m_iJuice <= 0) { m_nState = 1; Off(); } // if the player doesn't have the suit, or there is no juice left, make the deny noise if ( m_iJuice <= 0 ) { if (m_flSoundTime <= gpGlobals->curtime) { m_flSoundTime = gpGlobals->curtime + 0.62; EmitSound( "SuitRecharge.Deny" ); } return; } SetNextThink( gpGlobals->curtime + 0.25 ); SetThink(Off); // Time to recharge yet? if (m_flNextCharge >= gpGlobals->curtime) return; // Make sure that we have a caller if (!pActivator) return; m_hActivator = pActivator; //only recharge the player if (!m_hActivator->IsPlayer() ) return; // Play the on sound or the looping charging sound if (!m_iOn) { m_iOn++; EmitSound( "SuitRecharge.Start" ); m_flSoundTime = 0.56 + gpGlobals->curtime; } if ((m_iOn == 1) && (m_flSoundTime <= gpGlobals->curtime)) { m_iOn++; CPASAttenuationFilter filter( this, "SuitRecharge.ChargingLoop" ); filter.MakeReliable(); EmitSound( filter, entindex(), "SuitRecharge.ChargingLoop" ); } CBasePlayer *pl = (CBasePlayer *) m_hActivator.Get(); // charge the player if (pl->ArmorValue() < 100) { m_iJuice--; pl->IncrementArmorValue( 1, 100 ); } // Send the output. float flRemaining = m_iJuice / sk_suitcharger.GetFloat(); m_OutRemainingCharge.Set(flRemaining, pActivator, this); // govern the rate of charge m_flNextCharge = gpGlobals->curtime + 0.1; }