コード例 #1
0
ファイル: Vector.cpp プロジェクト: timcsy/Physics-Engine
Vector Vector::projectVector(const Vector & v) const // projection vector w.r.t v
{
	if(v.length() == 0) return Vector(0,0);
	return (((*this)*v) / (v*v))*v;
}
コード例 #2
0
ファイル: tentacle.cpp プロジェクト: FaucetDC/HLDC_SDK
	void SetObjectCollisionBox( void )
	{
		pev->absmin = pev->origin + Vector(-400, -400, 0);
		pev->absmax = pev->origin + Vector(400, 400, 850);
	}
コード例 #3
0
ファイル: primitives.cpp プロジェクト: h94h12/MT-Terrain
//normalize this vector
Vector Vector::normalize(){
    Vector v = Vector((double)dx / mag, (double)dy / mag, (double)dz / mag);  
    v.mag = 1;
    return v;
}
コード例 #4
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : timeDelta - 
//-----------------------------------------------------------------------------
//void C_ASW_Flare_Projectile::Update( float timeDelta )
void C_ASW_Flare_Projectile::ClientThink( void )
{
	if ( m_pFlareEffect.GetObject() == NULL )
	{	
		//m_flTimePulse = gpGlobals->curtime + asw_buffgrenade_pulse_interval.GetFloat();

		m_pFlareEffect = ParticleProp()->Create( "flare_fx_main", PATTACH_ABSORIGIN_FOLLOW, -1, GetEffectOrigin() - GetAbsOrigin() );
		//flare_fx_main
	}

	float	baseScale = m_flScale;

	//Account for fading out
	if ( ( m_flTimeBurnOut != -1.0f ) && ( ( m_flTimeBurnOut - gpGlobals->curtime ) <= 10.0f ) )
	{
		baseScale *= ( ( m_flTimeBurnOut - gpGlobals->curtime ) / 10.0f );

		CSoundEnvelopeController::GetController().SoundChangeVolume( m_pBurnSound, clamp<float>(0.6f * baseScale, 0.0f, 0.6f), 0 );
	}

	if ( baseScale < 0.01f )
		return;
	//
	// Dynamic light
	//

	if ( m_bLight )
	{
		if (m_fStartLightTime == 0)
		{
			m_fStartLightTime = gpGlobals->curtime;
		}
		if (!m_pDLight)
		{
			m_pDLight = effects->CL_AllocDlight( index );
			m_pDLight->color.r = asw_flare_r.GetInt();
			m_pDLight->color.g = asw_flare_g.GetInt();
			m_pDLight->color.b = asw_flare_b.GetInt();
			m_pDLight->color.exponent = 3;
		}

		m_pDLight->origin	= GetAbsOrigin() + Vector(0, 0, 5);	// make the dlight slightly higher than the flare, so it doesn't bury the light being so close to the ground

		float flTimeLeft = MAX( 2.0, m_flTimeBurnOut - gpGlobals->curtime );
		if (m_fLightRadius < 8.0f)
		{
			m_fLightRadius += flTimeLeft * (1.0f + random->RandomFloat() * 36.0f);
			if (m_fLightRadius > 8.0f)
				m_fLightRadius = 8.0f;
		}
		m_pDLight->radius = MAX( 64.0, baseScale * 120 * (m_fLightRadius/8.0f) );

		if ( ( m_flTimeBurnOut != -1.0f ) && ( ( m_flTimeBurnOut - gpGlobals->curtime ) <= 4.0f ) )
		{
			// flicker as we're going out
			//m_pDLight->die		= gpGlobals->curtime;
			//m_pDLight = NULL;
		}
		else
		{
			m_pDLight->die		= gpGlobals->curtime + 30.0f;
		}
	}
	else
	{
		m_fStartLightTime = 0;
	}

	SetNextClientThink(gpGlobals->curtime + 0.1f);
}
コード例 #5
0
void CBasePlayerItem :: SetObjectCollisionBox( void )
{
	pev->absmin = pev->origin + Vector(-24, -24, 0);
	pev->absmax = pev->origin + Vector(24, 24, 16); 
}
コード例 #6
0
ファイル: MarkovModel.cpp プロジェクト: cran/Boom
 void MarkovModel::fix_pi0_uniform() {
   uint S = state_space_size();
   set_pi0(Vector(S, 1.0 / S));
   pi0_status = Uniform;
 }
コード例 #7
0
ファイル: soundscape.cpp プロジェクト: newroob/bg2-2007
// CONSIDER: if player in water state, autoset and underwater soundscape? 
void CEnvSoundscape::Update()
{
	bool bUpdated = UpdatePlayersInPVS();

	if ( !IsEnabled() )
		return;

	// Only update soundscapes in multiplayer when the PVS gets updated
	if ( g_pGameRules->IsMultiplayer() && !bUpdated && !soundscape_debug.GetBool() )
		return;

	bool bDebugThis = soundscape_debug.GetInt() == 1;

	for ( int i=0; i < m_hPlayersInPVS.Count(); i++ )
	{
		CBasePlayer *pPlayer = m_hPlayersInPVS[i];
		if ( !pPlayer )
			continue;

		if ( !InRangeOfPlayer( pPlayer ) )
			continue;

		// check to see if this is the sound entity that is 
		// currently affecting this player
		audioparams_t &audio = pPlayer->GetAudioParams();

		// if we got this far, we're looking at an entity that is contending
		// for current player sound. the closest entity to player wins.
		CEnvSoundscape *pCurrent = (CEnvSoundscape *)audio.ent.Get();
		if ( !pCurrent || 
			!pCurrent->IsEnabled() || 
			!pCurrent->InRangeOfPlayer( pPlayer ) ) 
		{
			// The old one is obscured or out of range.. take over.
			WriteAudioParamsTo( audio );
		}
		else if ( pCurrent && 
			EarPosition().DistTo( pPlayer->EarPosition() ) < pCurrent->EarPosition().DistTo( pPlayer->EarPosition() ) )
		{
			// new entity is closer to player, so it wins.
			WriteAudioParamsTo( audio );
		}

		if ( !bDebugThis )
		{
			bDebugThis = soundscape_debug.GetInt() == 2;
		}
	} 

	if ( bDebugThis )
	{

		// draw myself
		NDebugOverlay::Box(GetAbsOrigin(), Vector(-10,-10,-10), Vector(10,10,10),  255, 0, 255, 64, NDEBUG_PERSIST_TILL_NEXT_SERVER );

		// Don't use GetLocalPlayer(), because that prevents multiplayer games using this for testing with a single client in the game
		CBasePlayer *pPlayer = UTIL_PlayerByIndex(1);
 		if ( pPlayer )
		{
			audioparams_t &audio = pPlayer->GetAudioParams();
			if ( audio.ent.Get() != this )
			{
				if ( InRangeOfPlayer( pPlayer ) )
				{
					NDebugOverlay::Line( GetAbsOrigin(), pPlayer->WorldSpaceCenter(), 255, 255, 255, true, NDEBUG_PERSIST_TILL_NEXT_SERVER );
				}
				else
				{
					NDebugOverlay::Line( GetAbsOrigin(), pPlayer->WorldSpaceCenter(), 255, 0, 0, true, NDEBUG_PERSIST_TILL_NEXT_SERVER  );
				}
			}
			else
			{
				if ( InRangeOfPlayer( pPlayer ) )
				{
					NDebugOverlay::Line( GetAbsOrigin(), pPlayer->WorldSpaceCenter(), 0, 255, 0, true, NDEBUG_PERSIST_TILL_NEXT_SERVER  );
				}
  				else
				{
					NDebugOverlay::Line( GetAbsOrigin(), pPlayer->WorldSpaceCenter(), 255, 170, 0, true, NDEBUG_PERSIST_TILL_NEXT_SERVER  );
				}

				// also draw lines to each sound position.
				// we don't store the number of local sound positions, just a bitvector of which ones are on.
				unsigned int soundbits = audio.localBits.Get();
				float periodic = 2.0f * sin((fmod(gpGlobals->curtime,2.0f) - 1.0f) * M_PI); // = -4f .. 4f
				for (int ii = 0 ; ii < NUM_AUDIO_LOCAL_SOUNDS ; ++ii )
				{
					if ( soundbits & (1 << ii) )
					{
						const Vector &soundLoc = audio.localSound.Get(ii);
						NDebugOverlay::Line( GetAbsOrigin(), soundLoc, 0, 32 , 255 , false, NDEBUG_PERSIST_TILL_NEXT_SERVER );
						NDebugOverlay::Cross3D( soundLoc, 16.0f + periodic, 0, 0, 255, false, NDEBUG_PERSIST_TILL_NEXT_SERVER );
					}
				}
			}
		}

		NDebugOverlay::EntityTextAtPosition( GetAbsOrigin(), 0, STRING(m_soundscapeName), NDEBUG_PERSIST_TILL_NEXT_SERVER );
	}

}
コード例 #8
0
ファイル: game.cpp プロジェクト: CecilHarvey/RealBot
// GAME: Update global vars (called by StartFrame)
void cGame::UpdateGameStatus() {

   // Used variables
   edict_t *pEnt;
   pEnt = NULL;

   // ------------------
   // Update: Dropped C4
   // ------------------
   // Its not dropped unless stated otherwise.
   vDroppedC4 = Vector(9999, 9999, 9999);

   // Find the dropped bomb
   while ((pEnt = UTIL_FindEntityByClassname(pEnt, "weaponbox")) != NULL) {
      // when DROPPED C4
      if ((FStrEq(STRING(pEnt->v.model), "models/w_backpack.mdl"))) {
         vDroppedC4 = pEnt->v.origin;   // this is the origin.
         break;
      }
   }

   // ------------------
   // Update: Is the bomb planted?
   // ------------------
   // Same as dropped c4, its NOT, unless stated otherwise.
   pEnt = NULL;
   Vector vVec = Vector(9999, 9999, 9999);
   bool bPlanted = bBombPlanted;        // is it planted?

   while ((pEnt = UTIL_FindEntityByClassname(pEnt, "grenade")) != NULL) {
      if (UTIL_GetGrenadeType(pEnt) == 4) {
         // Found planted bomb:
         bPlanted = true;
         float fDist = 200;
         int iBot = -1, k = 1;
         vVec = pEnt->v.origin;

         // FIND:
         // Find the player near this bomb
         for (; k <= gpGlobals->maxClients; k++) {
            edict_t *pPlayer = INDEXENT(k);
            // skip invalid players
            if ((pPlayer) && (!pPlayer->free)) {
               // skip this player if not alive (i.e. dead or dying)
               if (!IsAlive(pPlayer))
                  continue;

               if (!(pPlayer->v.flags & FL_THIRDPARTYBOT))
                  continue;

               // skip real players (or NOT realbot's)
               if (UTIL_GetBotPointer(pPlayer) == NULL)
                  continue;

               // Check the distance
               if (func_distance(vVec, pPlayer->v.origin) < fDist) {
                  iBot = k;     // remember this ID
                  fDist = func_distance(vVec, pPlayer->v.origin);       // update distance
               }
            }
         } // End of search

         // all counter-terrorists should know this, and they should head for the bomb
         if (bPlanted && bPlanted != bBombPlanted) {
            int i;
            for (i = 1; i <= gpGlobals->maxClients; i++) {
               edict_t *pPlayer = INDEXENT(i);
               cBot *bot = UTIL_GetBotPointer(pPlayer);

               if (bot)         // valid bot
               {
                  if (UTIL_GetTeam(bot->pEdict) == 1)   // Counter-Terrorists
                  {
                     bot->bot_pathid = -1;
                     bot->iGoalNode = NodeMachine.node_goal(GOAL_BOMBSPOT);
                  }             // ct
               }                // bot
            }                   // through all clients

            // It is not yet discovered
            bBombDiscovered = false;

            // Now update bBombPlanted
            bBombPlanted = bPlanted;
         }                      // planted, and not planted before
      }
   }

   // When bPlanted = false, we set bBombPlanted to false
   if (bPlanted == false) {
	   bBombPlanted = false;
   }
}	// UpdateGameStatus()
コード例 #9
0
ファイル: game.cpp プロジェクト: CecilHarvey/RealBot
// GAME: Init
void
cGame::Init() {

   // Default Bot Skill
   iDefaultBotSkill = -1;       // random
   iOverrideBotSkill = GAME_YES;

   // Randomized skill boundries
   iRandomMinSkill = 0;
   iRandomMaxSkill = 10;

   // Internet simulation
   iMinPlayRounds = 5;
   iMaxPlayRounds = 25;

   // New round stuff
   bNewRound = false;

   // Broadcasting
   iVersionBroadcasting = BROADCAST_ROUND;
   iKillsBroadcasting = BROADCAST_KILLS_FULL;
   iDeathsBroadcasting = BROADCAST_DEATHS_FULL;
   bSpeechBroadcasting = false; // @ default we do NOT broadcast this shit every round to the listen server

   // Installed into correct directory
   bInstalledCorrectly = true;

   // Round time
   fRoundTime = 0.0;

   // Dropped C4 location
   vDroppedC4 = Vector(9999, 9999, 9999);

   // May we walk with knife (when bots want to), default = yes (3600 seconds)
   fWalkWithKnife = 3600;

   // Bomb planted
   bBombPlanted = false;
   bBombDiscovered = false;

   // Chat related
   iMaxSentences = 1;           // max sentences produced by chatengine per second (1=default)
   iProducedSentences = 0;      // currently produced sentences

   // DEBUG RELATED
   bDoNotShoot = false;         // ... guess
   bDebug = false;              // ... prints debug messages
   bEngineDebug = false;        // ... prints engine debug messages (for figuring out engine interceptions)
   bPistols = false;            // pistols only mode

   // Speech sentences (from POD and a *few* own made)
   strcpy(cSpeechSentences[0], "hello user,communication is acquired");
   strcpy(cSpeechSentences[1], "your presence is acknowledged");
   strcpy(cSpeechSentences[2], "high man, your in command now");
   strcpy(cSpeechSentences[3], "blast your hostile for good");
   strcpy(cSpeechSentences[4], "high man, kill some idiot here");
   strcpy(cSpeechSentences[5], "is there a doctor in the area");
   strcpy(cSpeechSentences[6], "warning, experimental materials detected");
   strcpy(cSpeechSentences[7], "high amigo, shoot some but");
   strcpy(cSpeechSentences[8], "attention, hours of work software, detected");
   strcpy(cSpeechSentences[9], "time for some bad ass explosion");
   strcpy(cSpeechSentences[10],"bad ass son of a breach device activated");
   strcpy(cSpeechSentences[11],"high, do not question this great service");
   strcpy(cSpeechSentences[12],"engine is operative, hello and goodbye");
   strcpy(cSpeechSentences[13],"high amigo, your administration has been great last day");
   strcpy(cSpeechSentences[14],"attention, expect experimental armed hostile presence");
   strcpy(cSpeechSentences[15],"warning,medical attention required");

}                               // Init()
コード例 #10
0
ファイル: Vector.cpp プロジェクト: timcsy/Physics-Engine
Vector Vector::operator*(double c) const // Scalar multiplication
{
	return Vector(x * c, y * c);
}
コード例 #11
0
ファイル: Vector.cpp プロジェクト: timcsy/Physics-Engine
Vector operator*(double c,const Vector & v) // Scalar multiplication (It is friend function)
{
	return Vector(c * v.getX(), c * v.getY());
}
コード例 #12
0
ファイル: Vector.cpp プロジェクト: timcsy/Physics-Engine
Vector Vector::operator-(const Vector & v) const // Subtraction
{
	return Vector(x - v.getX(), y - v.getY());
}
コード例 #13
0
ファイル: Vector.cpp プロジェクト: timcsy/Physics-Engine
Vector Vector::operator+(const Vector & v) const // Addition
{
	return Vector(x + v.getX(), y + v.getY());
}
コード例 #14
0
ファイル: Vector.cpp プロジェクト: timcsy/Physics-Engine
Vector Vector::perp() const // perpendicular vector(on the right hand side !!
{
	return Vector(y,-x);
}
コード例 #15
0
PlannerObjectiveBase* LoadPlannerObjective(AnyCollection& msg,Robot* robot)
{
  string type;
  bool res = msg["type"].as<string>(type);
  if(!res) {
    fprintf(stderr,"LoadPlannerObjective: message didn't contain 'type' member\n");
    return NULL;
  }
  if(type == "time") {
    return new TimeObjective();
  }
  else if(type == "term_time") {
    return new TerminalTimeObjective((Real)msg["data"]);
  }
  else if(type == "config") {
    vector<Real> q;
    if(!msg["data"].asvector(q)) {
      fprintf(stderr,"LoadPlannerObjective: config message didn't contain 'data' member\n");
      return NULL;
    }
    if(robot && q.size() != robot->links.size()) {
      fprintf(stderr,"LoadPlannerObjective: config message contains desired configuration of incorrect length %d vs %d\n",(int)q.size(),(int)robot->links.size());
      return NULL;
    }
    return new ConfigObjective(Vector(q));
  }
  else if(type == "velocity") {
    vector<Real> v;
    if(!msg["data"].asvector(v)) {
      fprintf(stderr,"LoadPlannerObjective: velocity  message didn't contain 'data' member\n");
      return NULL;
    }
    if(robot && v.size() != robot->links.size()) {
      fprintf(stderr,"LoadPlannerObjective: velocity message contains desired velocity of incorrect length %d vs %d\n",(int)v.size(),(int)robot->links.size());
      return NULL;
    }
    return new VelocityObjective(Vector(v));
  }
  else if(type == "composite") {
    vector<SmartPointer<AnyCollection> > items;
    AnyCollection msgcomp = msg["components"];
    if(msgcomp.depth() == 0) {
      fprintf(stderr,"LoadPlannerObjective: composite message didn't contain 'components' member\n");
      return NULL;
    }
    msgcomp.enumerate(items);
    vector<SmartPointer<PlannerObjectiveBase> > components;
    for(size_t i=0;i<items.size();i++) {
      components.push_back(LoadPlannerObjective(*items[i],robot));
      if(components.back()==NULL) return NULL;
    }
    CompositeObjective* obj = new CompositeObjective;
    if(msg["norm"].as<Real>(obj->norm)) {}
    if(msg["weights"].asvector(obj->weights)) {}
    else obj->weights.resize(components.size(),1);
    obj->components=components;
    return obj;
  }
  else {
    fprintf(stderr,"LoadPlannerObjective: message of unknown type %s\n",type.c_str());
    return NULL;
  }
}
コード例 #16
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &origin - 
//			&normal - 
//			scale - 
//-----------------------------------------------------------------------------
void FX_AirboatGunImpact( const Vector &origin, const Vector &normal, float scale )
{
#ifdef _XBOX

	Vector offset = origin + ( normal * 1.0f );

	CSmartPtr<CTrailParticles> sparkEmitter = CTrailParticles::Create( "FX_MetalSpark 1" );

	if ( sparkEmitter == NULL )
		return;

	//Setup our information
	sparkEmitter->SetSortOrigin( offset );
	sparkEmitter->SetFlag( bitsPARTICLE_TRAIL_VELOCITY_DAMPEN );
	sparkEmitter->SetVelocityDampen( 8.0f );
	sparkEmitter->SetGravity( 800.0f );
	sparkEmitter->SetCollisionDamped( 0.25f );
	sparkEmitter->GetBinding().SetBBox( offset - Vector( 32, 32, 32 ), offset + Vector( 32, 32, 32 ) );

	int	numSparks = random->RandomInt( 4, 8 );

	TrailParticle	*pParticle;
	PMaterialHandle	hMaterial = sparkEmitter->GetPMaterial( "effects/spark" );
	Vector			dir;

	float	length	= 0.1f;

	//Dump out sparks
	for ( int i = 0; i < numSparks; i++ )
	{
		pParticle = (TrailParticle *) sparkEmitter->AddParticle( sizeof(TrailParticle), hMaterial, offset );

		if ( pParticle == NULL )
			return;

		pParticle->m_flLifetime	= 0.0f;
		pParticle->m_flDieTime	= random->RandomFloat( 0.05f, 0.1f );

		float	spreadOfs = random->RandomFloat( 0.0f, 2.0f );

		dir[0] = normal[0] + random->RandomFloat( -(0.5f*spreadOfs), (0.5f*spreadOfs) );
		dir[1] = normal[1] + random->RandomFloat( -(0.5f*spreadOfs), (0.5f*spreadOfs) );
		dir[2] = normal[2] + random->RandomFloat( -(0.5f*spreadOfs), (0.5f*spreadOfs) );

		VectorNormalize( dir );

		pParticle->m_flWidth		= random->RandomFloat( 1.0f, 4.0f );
		pParticle->m_flLength		= random->RandomFloat( length*0.25f, length );

		pParticle->m_vecVelocity	= dir * random->RandomFloat( (128.0f*(2.0f-spreadOfs)), (512.0f*(2.0f-spreadOfs)) );

		Color32Init( pParticle->m_color, 255, 255, 255, 255 );
	}

#else

	// Normal metal spark
	FX_MetalSpark( origin, normal, normal, (int) scale );

#endif // _XBOX

	// Add a quad to highlite the hit point
	FX_AddQuad( origin, 
				normal, 
				random->RandomFloat( 16, 32 ),
				random->RandomFloat( 32, 48 ),
				0.75f, 
				1.0f,
				0.0f,
				0.4f,
				random->RandomInt( 0, 360 ), 
				0,
				Vector( 1.0f, 1.0f, 1.0f ), 
				0.05f, 
				"effects/combinemuzzle2_nocull",
				(FXQUAD_BIAS_SCALE|FXQUAD_BIAS_ALPHA) );
}
コード例 #17
0
ファイル: MarkovModel.cpp プロジェクト: cran/Boom
 void MarkovSuf::resize(uint p) {
   if (state_space_size() != p) {
     trans_ = Matrix(p, p, 0.0);
     init_ = Vector(p, 0.0);
   }
 }
コード例 #18
0
ファイル: Vector.cpp プロジェクト: thevoiceless/trackball
Vector Vector::plus(Vector& v2)
{
	return Vector((x + v2.x),
		(y + v2.y),
		(z + v2.z));
}
コード例 #19
0
ファイル: MarkovModel.cpp プロジェクト: cran/Boom
 void MarkovModel::resize(uint S) {
   suf()->resize(S);
   set_pi0(Vector(S, 1.0 / S));
   set_Q(Matrix(S, S, 1.0 / S));
 }
コード例 #20
0
ファイル: Vector.cpp プロジェクト: thevoiceless/trackball
Vector Vector::minus(Vector& v2)
{
	return Vector((x - v2.x),
		(y - v2.y),
		(z - v2.z));
}
コード例 #21
0
//-----------------------------------------------------------------------------
// Purpose: Pulls physical objects towards the vortex center, killing them if they come too near
//-----------------------------------------------------------------------------
void CGravityVortexController::PullThink( void )
{
	// Pull any players close enough to us
	PullPlayersInRange();

	Vector mins, maxs;
	mins = GetAbsOrigin() - Vector( m_flRadius, m_flRadius, m_flRadius );
	maxs = GetAbsOrigin() + Vector( m_flRadius, m_flRadius, m_flRadius );

	// Draw debug information
	if ( g_debug_hopwire.GetBool() )
	{
		NDebugOverlay::Box( GetAbsOrigin(), mins - GetAbsOrigin(), maxs - GetAbsOrigin(), 0, 255, 0, 16, 4.0f );
	}

	CBaseEntity *pEnts[128];
	int numEnts = UTIL_EntitiesInBox( pEnts, 128, mins, maxs, 0 );

	for ( int i = 0; i < numEnts; i++ )
	{
		IPhysicsObject *pPhysObject = NULL;

		// Attempt to kill and ragdoll any victims in range
		if ( KillNPCInRange( pEnts[i], &pPhysObject ) == false )
		{	
			// If we didn't have a valid victim, see if we can just get the vphysics object
			pPhysObject = pEnts[i]->VPhysicsGetObject();
			if ( pPhysObject == NULL )
				continue;
		}

		float mass;

		CRagdollProp *pRagdoll = dynamic_cast< CRagdollProp* >( pEnts[i] );
		if ( pRagdoll != NULL )
		{
			ragdoll_t *pRagdollPhys = pRagdoll->GetRagdoll();
			mass = 0.0f;
			
			// Find the aggregate mass of the whole ragdoll
			for ( int j = 0; j < pRagdollPhys->listCount; ++j )
			{
				mass += pRagdollPhys->list[j].pObject->GetMass();
			}
		}
		else
		{
			mass = pPhysObject->GetMass();
		}

		Vector	vecForce = GetAbsOrigin() - pEnts[i]->WorldSpaceCenter();
		Vector	vecForce2D = vecForce;
		vecForce2D[2] = 0.0f;
		float	dist2D = VectorNormalize( vecForce2D );
		float	dist = VectorNormalize( vecForce );
		
		// FIXME: Need a more deterministic method here
		if ( dist < 48.0f )
		{
			ConsumeEntity( pEnts[i] );
			continue;
		}

		// Must be within the radius
		if ( dist > m_flRadius )
			continue;

		// Find the pull force
		vecForce *= ( 1.0f - ( dist2D / m_flRadius ) ) * m_flStrength * mass;
		
		if ( pEnts[i]->VPhysicsGetObject() )
		{
			// Pull the object in
			pEnts[i]->VPhysicsTakeDamage( CTakeDamageInfo( this, this, vecForce, GetAbsOrigin(), m_flStrength, DMG_BLAST ) );
		}
	}

	// Keep going if need-be
	if ( m_flEndTime > gpGlobals->curtime )
	{
		SetThink( &CGravityVortexController::PullThink );
		SetNextThink( gpGlobals->curtime + 0.1f );
	}
	else
	{
		//Msg( "Consumed %.2f kilograms\n", m_flMass );
		//CreateDenseBall();
	}
}
コード例 #22
0
ファイル: c_strider.cpp プロジェクト: Bubbasacs/FinalProj
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &origin - 
//			&normal - 
//			scale - 
//-----------------------------------------------------------------------------
void StriderBlood( const Vector &origin, const Vector &normal, float scale )
{
	VPROF_BUDGET( "StriderBlood", VPROF_BUDGETGROUP_PARTICLE_RENDERING );
	
	Vector	offset;
	
	CSmartPtr<CSplashParticle> pSimple = CSplashParticle::Create( "splish" );
	pSimple->SetSortOrigin( origin );

	Vector	color[3];
	color[0] = color[1] = color[2] = Vector( 1, 1, 1 );

	float	colorRamp;

	int i;
	float	flScale = scale / 8.0f;

	PMaterialHandle	hMaterial = ParticleMgr()->GetPMaterial( "effects/slime1" );

	float	length = 0.1f;
	Vector	vForward, vRight, vUp;
	Vector	offDir;

	TrailParticle	*tParticle;

	CSmartPtr<CTrailParticles> sparkEmitter = CTrailParticles::Create( "splash" );

	if ( !sparkEmitter )
		return;

	sparkEmitter->SetSortOrigin( origin );
	sparkEmitter->m_ParticleCollision.SetGravity( 800.0f );
	sparkEmitter->SetFlag( bitsPARTICLE_TRAIL_VELOCITY_DAMPEN );
	sparkEmitter->SetVelocityDampen( 2.0f );

	//Dump out drops
	for ( i = 0; i < 64; i++ )
	{
		offset = origin;
		offset[0] += random->RandomFloat( -16.0f, 16.0f ) * flScale;
		offset[1] += random->RandomFloat( -16.0f, 16.0f ) * flScale;

		tParticle = (TrailParticle *) sparkEmitter->AddParticle( sizeof(TrailParticle), hMaterial, offset );

		if ( tParticle == NULL )
			break;

		tParticle->m_flLifetime	= 0.0f;
		tParticle->m_flDieTime	= 1.0f;

		offDir = normal + RandomVector( -1.0f, 1.0f );

		tParticle->m_vecVelocity = offDir * random->RandomFloat( BLOOD_MIN_SPEED * flScale * 2.0f, BLOOD_MAX_SPEED * flScale * 2.0f );
		tParticle->m_vecVelocity[2] += random->RandomFloat( 8.0f, 32.0f ) * flScale;

		tParticle->m_flWidth		= random->RandomFloat( 12.0f, 16.0f ) * flScale;
		tParticle->m_flLength		= random->RandomFloat( length*0.5f, length ) * flScale;

		colorRamp = random->RandomFloat( 0.5f, 2.0f );

		int randomColor = random->RandomInt( 0, 2 );

		tParticle->m_color.r = min( 1.0f, color[randomColor].x * colorRamp ) * 255;
		tParticle->m_color.g = min( 1.0f, color[randomColor].y * colorRamp ) * 255;
		tParticle->m_color.b = min( 1.0f, color[randomColor].z * colorRamp ) * 255;
		tParticle->m_color.a = 255;
	}
}
コード例 #23
0
//=========================================================
//=========================================================
void CWeaponBox::SetObjectCollisionBox( void )
{
	pev->absmin = pev->origin + Vector(-16, -16, 0);
	pev->absmax = pev->origin + Vector(16, 16, 16); 
}
コード例 #24
0
ファイル: c_strider.cpp プロジェクト: Bubbasacs/FinalProj
//-----------------------------------------------------------------------------
// Purpose: Recompute my rendering box
//-----------------------------------------------------------------------------
void C_Strider::ClientThink()
{
	int i;
	Vector vecMins, vecMaxs;
	Vector vecAbsMins, vecAbsMaxs;
	matrix3x4_t worldToStrider, hitboxToStrider;
	Vector vecBoxMins, vecBoxMaxs;
	Vector vecBoxAbsMins, vecBoxAbsMaxs;
	mstudiohitboxset_t *set;
	CBoneCache *pCache = NULL;

	// The reason why this is here, as opposed to in SetObjectCollisionBox,
	// is because of IK. The code below recomputes bones so as to get at the hitboxes,
	// which causes IK to trigger, which causes raycasts against the other entities to occur,
	// which is illegal to do while in the Relink phase.

	CStudioHdr *pStudioHdr = GetModelPtr();
	if (!pStudioHdr)
		goto doneWithComputation;

	set = pStudioHdr->pHitboxSet( m_nHitboxSet );
	if ( !set || !set->numhitboxes )
		goto doneWithComputation;

	pCache = GetBoneCache( pStudioHdr );

	matrix3x4_t *hitboxbones[MAXSTUDIOBONES];
	pCache->ReadCachedBonePointers( hitboxbones, pStudioHdr->numbones() );

	// Compute a box in world space that surrounds this entity
	m_vecRenderMins.Init( FLT_MAX, FLT_MAX, FLT_MAX );
	m_vecRenderMaxs.Init( -FLT_MAX, -FLT_MAX, -FLT_MAX );

	MatrixInvert( EntityToWorldTransform(), worldToStrider );

	for ( i = 0; i < set->numhitboxes; i++ )
	{
		mstudiobbox_t *pbox = set->pHitbox(i);
		ConcatTransforms( worldToStrider, *hitboxbones[pbox->bone], hitboxToStrider );

		TransformAABB( hitboxToStrider, pbox->bbmin, pbox->bbmax, vecBoxMins, vecBoxMaxs );
		VectorMin( m_vecRenderMins, vecBoxMins, m_vecRenderMins );
		VectorMax( m_vecRenderMaxs, vecBoxMaxs, m_vecRenderMaxs );
	}

	// UNDONE: Disabled this until we can get closer to a final map and tune
#if 0
	// Cut ropes.
	if ( gpGlobals->curtime >= m_flNextRopeCutTime )
	{
		// Blow the bbox out a little.
		Vector vExtendedMins = vecMins - Vector( 50, 50, 50 );
		Vector vExtendedMaxs = vecMaxs + Vector( 50, 50, 50 );

		C_RopeKeyframe *ropes[512];
		int nRopes = C_RopeKeyframe::GetRopesIntersectingAABB( ropes, ARRAYSIZE( ropes ), GetAbsOrigin() + vExtendedMins, GetAbsOrigin() + vExtendedMaxs );
		for ( int i=0; i < nRopes; i++ )
		{
			C_RopeKeyframe *pRope = ropes[i];

			if ( pRope->GetEndEntity() )
			{
				Vector vPos;
				if ( pRope->GetEndPointPos( 1, vPos ) )
				{
					// Detach the endpoint.
					pRope->SetEndEntity( NULL );
					
					// Make some spark effect here..
					g_pEffects->Sparks( vPos );
				}				
			}
		}

		m_flNextRopeCutTime = gpGlobals->curtime + 0.5;
	}
#endif

doneWithComputation:	
	// True argument because the origin may have stayed the same, but the size is expected to always change
	g_pClientShadowMgr->AddToDirtyShadowList( this, true );
}
コード例 #25
0
ファイル: tentacle.cpp プロジェクト: FaucetDC/HLDC_SDK
//
// TentacleThink
//
void CTentacle :: Cycle( void )
{
	// ALERT( at_console, "%s %.2f %d %d\n", STRING( pev->targetname ), pev->origin.z, m_MonsterState, m_IdealMonsterState );
	pev->nextthink = gpGlobals-> time + 0.1;

	// ALERT( at_console, "%s %d %d %d %f %f\n", STRING( pev->targetname ), pev->sequence, m_iGoalAnim, m_iDir, pev->framerate, pev->health );

	if (m_MonsterState == MONSTERSTATE_SCRIPT || m_IdealMonsterState == MONSTERSTATE_SCRIPT)
	{
		pev->angles.y = m_flInitialYaw;
		pev->ideal_yaw = m_flInitialYaw;	
		ClearConditions( IgnoreConditions() );
		MonsterThink( );
		m_iGoalAnim = TENTACLE_ANIM_Pit_Idle;
		return;
	}

	DispatchAnimEvents( );
	StudioFrameAdvance( );

	ChangeYaw( pev->yaw_speed );

	CSound *pSound;

	Listen( );

	// Listen will set this if there's something in my sound list
	if ( HasConditions( bits_COND_HEAR_SOUND ) )
		pSound = PBestSound();
	else
		pSound = NULL;

	if ( pSound )
	{
		Vector vecDir;
		if (gpGlobals->time - m_flPrevSoundTime < 0.5)
		{
			float dt = gpGlobals->time - m_flPrevSoundTime;
			vecDir = pSound->m_vecOrigin + (pSound->m_vecOrigin - m_vecPrevSound) / dt - pev->origin;
		}
		else
		{
			vecDir = pSound->m_vecOrigin - pev->origin;
		}
		m_flPrevSoundTime = gpGlobals->time;
		m_vecPrevSound = pSound->m_vecOrigin;

		m_flSoundYaw = UTIL_VecToYaw ( vecDir ) - m_flInitialYaw;
		m_iSoundLevel = Level( vecDir.z );

		if (m_flSoundYaw < -180)
			m_flSoundYaw += 360;
		if (m_flSoundYaw > 180)
			m_flSoundYaw -= 360;

		// ALERT( at_console, "sound %d %.0f\n", m_iSoundLevel, m_flSoundYaw );
		if (m_flSoundTime < gpGlobals->time)
		{
			// play "I hear new something" sound
			char *sound;	

			switch( RANDOM_LONG(0,1) )
			{
			case 0: sound = "tentacle/te_alert1.wav"; break;
			case 1: sound = "tentacle/te_alert2.wav"; break;
			}

			// UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), sound, 1.0, ATTN_NORM, 0, 100);
		}
		m_flSoundTime = gpGlobals->time + RANDOM_FLOAT( 5.0, 10.0 );
	}

	// clip ideal_yaw
	float dy = m_flSoundYaw;
	switch( pev->sequence )
	{
	case TENTACLE_ANIM_Floor_Rear:
	case TENTACLE_ANIM_Floor_Rear_Idle:
	case TENTACLE_ANIM_Lev1_Rear:
	case TENTACLE_ANIM_Lev1_Rear_Idle:
	case TENTACLE_ANIM_Lev2_Rear:
	case TENTACLE_ANIM_Lev2_Rear_Idle:
	case TENTACLE_ANIM_Lev3_Rear:
	case TENTACLE_ANIM_Lev3_Rear_Idle:
		if (dy < 0 && dy > -m_flMaxYaw)
			dy = -m_flMaxYaw;
		if (dy > 0 && dy < m_flMaxYaw)
			dy = m_flMaxYaw;
		break;
	default:
		if (dy < -m_flMaxYaw)
			dy = -m_flMaxYaw;
		if (dy > m_flMaxYaw)
			dy = m_flMaxYaw;
	}
	pev->ideal_yaw = m_flInitialYaw + dy;

	if (m_fSequenceFinished)
	{
		// ALERT( at_console, "%s done %d %d\n", STRING( pev->targetname ), pev->sequence, m_iGoalAnim );
		if (pev->health <= 1)
		{
			m_iGoalAnim = TENTACLE_ANIM_Pit_Idle;
			if (pev->sequence == TENTACLE_ANIM_Pit_Idle)
			{
				pev->health = 75;
			}
		}
		else if ( m_flSoundTime > gpGlobals->time )
		{
			if (m_flSoundYaw >= -(m_flMaxYaw + 30) && m_flSoundYaw <= (m_flMaxYaw + 30))
			{
				// strike
				m_iGoalAnim = LookupActivity( ACT_T_STRIKE + m_iSoundLevel );
			}
			else if (m_flSoundYaw >= -m_flMaxYaw * 2 && m_flSoundYaw <= m_flMaxYaw * 2) 
			{
				// tap
				m_iGoalAnim = LookupActivity( ACT_T_TAP + m_iSoundLevel );
			}
			else
			{
				// go into rear idle
				m_iGoalAnim = LookupActivity( ACT_T_REARIDLE + m_iSoundLevel );
			}
		}
		else if (pev->sequence == TENTACLE_ANIM_Pit_Idle)
		{
			// stay in pit until hear noise
			m_iGoalAnim = TENTACLE_ANIM_Pit_Idle;
		}
		else if (pev->sequence == m_iGoalAnim)
		{
			if (MyLevel() >= 0 && gpGlobals->time < m_flSoundTime)
			{
				if (RANDOM_LONG(0,9) < m_flSoundTime - gpGlobals->time)
				{
					// continue stike
					m_iGoalAnim = LookupActivity( ACT_T_STRIKE + m_iSoundLevel );
				}
				else
				{
					// tap
					m_iGoalAnim = LookupActivity( ACT_T_TAP + m_iSoundLevel );
				}
			}
			else if (MyLevel( ) < 0)
			{
				m_iGoalAnim = LookupActivity( ACT_T_IDLE + 0 );
			}
			else
			{
				if (m_flNextSong < gpGlobals->time)
				{
					// play "I hear new something" sound
					char *sound;	

					switch( RANDOM_LONG(0,1) )
					{
					case 0: sound = "tentacle/te_sing1.wav"; break;
					case 1: sound = "tentacle/te_sing2.wav"; break;
					}

					EMIT_SOUND(ENT(pev), CHAN_VOICE, sound, 1.0, ATTN_NORM);

					m_flNextSong = gpGlobals->time + RANDOM_FLOAT( 10, 20 );
				}

				if (RANDOM_LONG(0,15) == 0)
				{
					// idle on new level
					m_iGoalAnim = LookupActivity( ACT_T_IDLE + RANDOM_LONG(0,3) );
				}
				else if (RANDOM_LONG(0,3)  == 0)
				{
					// tap
					m_iGoalAnim = LookupActivity( ACT_T_TAP + MyLevel( ) );
				}
				else
				{
					// idle
					m_iGoalAnim = LookupActivity( ACT_T_IDLE + MyLevel( ) );
				}
			}
			if (m_flSoundYaw < 0)
				m_flSoundYaw += RANDOM_FLOAT( 2, 8 );
			else
				m_flSoundYaw -= RANDOM_FLOAT( 2, 8 );
		}

		pev->sequence = FindTransition( pev->sequence, m_iGoalAnim, &m_iDir );

		if (m_iDir > 0)
		{
			pev->frame = 0;
		}
		else
		{
			m_iDir = -1; // just to safe
			pev->frame = 255;
		}
		ResetSequenceInfo( );

		m_flFramerateAdj = RANDOM_FLOAT( -0.2, 0.2 );
		pev->framerate = m_iDir * 1.0 + m_flFramerateAdj;

		switch( pev->sequence)
		{
		case TENTACLE_ANIM_Floor_Tap:
		case TENTACLE_ANIM_Lev1_Tap:
		case TENTACLE_ANIM_Lev2_Tap:
		case TENTACLE_ANIM_Lev3_Tap:
			{
				Vector vecSrc;
				UTIL_MakeVectors( pev->angles );

				TraceResult tr1, tr2;

				vecSrc = pev->origin + Vector( 0, 0, MyHeight() - 4);
				UTIL_TraceLine( vecSrc, vecSrc + gpGlobals->v_forward * 512, ignore_monsters, ENT( pev ), &tr1 );

				vecSrc = pev->origin + Vector( 0, 0, MyHeight() + 8);
				UTIL_TraceLine( vecSrc, vecSrc + gpGlobals->v_forward * 512, ignore_monsters, ENT( pev ), &tr2 );

				// ALERT( at_console, "%f %f\n", tr1.flFraction * 512, tr2.flFraction * 512 );

				m_flTapRadius = SetBlending( 0, RANDOM_FLOAT( tr1.flFraction * 512, tr2.flFraction * 512 ) );
			}
			break;
		default:
			m_flTapRadius = 336; // 400 - 64
			break;
		}
		pev->view_ofs.z = MyHeight( );
		// ALERT( at_console, "seq %d\n", pev->sequence );
	}

	if (m_flPrevSoundTime + 2.0 > gpGlobals->time)
	{
		// 1.5 normal speed if hears sounds
		pev->framerate = m_iDir * 1.5 + m_flFramerateAdj;
	}
	else if (m_flPrevSoundTime + 5.0 > gpGlobals->time)
	{
		// slowdown to normal
		pev->framerate = m_iDir + m_iDir * (5 - (gpGlobals->time - m_flPrevSoundTime)) / 2 + m_flFramerateAdj;
	}
}
コード例 #26
0
ファイル: 2clc.cpp プロジェクト: pbl64k/icfpc2009
	Action ChaserCalculatingActuator::actuate(IoPage &outp,
			bool interactive) {
		fuel_ = outp[fuelOutPort];

		Action act = Action();

		Vector tgt(outp[tsxOutPort], outp[tsyOutPort]);

		Vector g;
		
		if (me_.r_ > 0) {
			g = PhysUtil::scaleVectorToLength(me_.pos_, PhysUtil::calcFreefallAcceleration(me_.r_));
		}

		Scalar dist = PhysUtil::calcModulus(tgt);

		me_.pushPos(Vector(outp[msxOutPort], outp[msyOutPort]));
		him_.pushPos(PhysUtil::subtractVectors(me_.pos_, tgt));

		bool newLine = (delay_ > 0);

		/*
		if (dist < 50000) {
			wait_ = false;
			secondThrust_ = true;
		}
		*/

		if (me_.lastR_ < 1) { // little is known about the world
			if (interactive) {
				std:: cout << std::endl << "Just starting..." <<
					std::endl;
				newLine = true;
			}

			//waypoint_ = 200000.0;
			waypoint_ = 0.0;
			me_.targetR_ = him_.r_;

			// long haul tweak
			if (him_.r_ > 20000000) {
				delay_ = 5416;
				//waypoint_ = (me_.targetR_ - me_.r_);
				//Word aa;std::cin>>aa;
			}

			// 2001
			//delay_ = 15925;
			
			// 2002
			//delay_ = 5416;

			// 2003
			//delay_ = 34140;
			
			// 2004
			//delay_ = 14727;

			makeFreefallAction(act);
		}
		else if (((delay_ == 0) || (waypoint_ != 0)) && wait_) {
std::cout<<"D0: "<<(dist / 1000)<<" sgn: "<<PhysUtil::calcCodirectionality(me_.mov_,tgt)<<std::endl;
//Word aa;std::cin>>aa;
			//if (dist < (std::abs(me_.r_ - him_.r_) * 1.5)) {
			if ((dist < (std::abs(waypoint_) * 4)) || (dist > (std::abs(waypoint_) * 25)) ||
					((PhysUtil::calcCodirectionality(me_.mov_, tgt) / waypoint_) < 0)) {
				if (interactive) {
					std::cout << std::endl << std::endl <<
							"*** WAYPOINT  ***" <<
							std::endl << std::endl;
					//Word aa;std::cin>>aa;
				}

				//waypoint_ = ((waypoint_ < dist) ? 100000 : (waypoint_ / 2));
				//waypoint_ -= 25000.0;
				//waypoint_ /= 4.0;
				
				waypoint_ = (dist / 8) * PhysUtil::calcCodirectionality(me_.mov_, tgt);

				if (interactive) {
					std::cout << std::endl << "dist: " << dist << " cod: " <<
							PhysUtil::calcCodirectionality(me_.mov_, tgt);
					std::cout << std::endl << "selected new waypoint: " <<
							waypoint_ << std::endl;
				}

				wait_ = false;

				if (dist < 50000) {
					secondThrust_ = true;
				}
			}

			if (delay_ == 0) {
				Vector vd = PhysUtil::addVectors(PhysUtil::scaleAndRotateVector(me_.pos_, PhysUtil::calcCircOrbitalSpeed(me_.r_), me_.mov_), PhysUtil::multVector(g, 0.5));
				Vector vn = PhysUtil::addVectors(me_.mov_, g);
	
				Vector cThrust = PhysUtil::subtractVectors(vd, vn);

				//std::cout << std::endl << "ct:" << PhysUtil::calcModulus(cThrust) << std::endl;
				//Word aa;std::cin >> aa;

				if (PhysUtil::calcModulus(cThrust) > 0.1) {
					delay_ = 3;

					makeThrusterCorrectionAction(act, cThrust);
				}
				else {
					makeFreefallAction(act);
				}
			}
			else {
				makeFreefallAction(act);
			}
		}
		else if (((delay_ == 0) || (waypoint_ != 0)) && !firstThrust_) {
			firstThrust_ = true;

			me_.targetR_ = him_.r_ - waypoint_;

			calcThrusts(me_.r_, me_.targetR_);

			Vector vThrust = PhysUtil::scaleVectorToLength(me_.mov_,
					firstThrustDv_);

			makeThrusterAction(act, vThrust);
		}
		else if (!secondThrust_) {
			if ((std::abs(me_.h_) < orbitalTolerance) &&
					(std::abs(me_.lastH_) < std::abs(me_.h_))) {
				if (interactive) {
					std::cout << std::endl << std::endl <<
							"Second thrust!" << std::endl << std::endl;
					newLine = true;
				}

				Vector vThrust = PhysUtil::scaleVectorToLength(me_.mov_,
						secondThrustDv_);

				makeThrusterAction(act, vThrust);
	
				//if (waypoint_ > 0) {
					firstThrust_ = false;
					waypoint_ = 0.1;

					wait_ = true;
					delay_ = 10;
				//}
				//else {
				//	secondThrust_ = true;
				//	delay_ = 10;
				//}
			}
			else {
				makeFreefallAction(act);
			}
		}
		else {
			makeFreefallAction(act);
		}

		if ((delay_ == 0) && secondThrust_) { // chase!
			if (reserveFuel_ == 0) {
				reserveFuel_ = fuel_ - 15000;
			}

			Vector g = PhysUtil::scaleVectorToLength(me_.pos_, PhysUtil::calcFreefallAcceleration(me_.r_));
	
			if (fuel_ > reserveFuel_) {
				Vector toTgt = PhysUtil::scaleVectorToLength(tgt, ((dist > 100) ? (dist * 0.1) : 0));
	
				Vector fixSpd = PhysUtil::subtractVectors(him_.mov_, me_.mov_);
	
				//Vector cThrust = PhysUtil::subtractVectors(PhysUtil::addVectors(toTgt, fixSpd), g);
				Vector cThrust = PhysUtil::addVectors(toTgt, fixSpd);
				
				if ((dist < 100) && PhysUtil::calcModulus(PhysUtil::subtractVectors(him_.mov_, me_.mov_)) < 1) {
				//(PhysUtil::calcModulus(cThrust) < 1)
					reserveFuel_ = 1000000;
				}

				makeThrusterCorrectionAction(act, cThrust);

				if (interactive) {
					std::cout << std::endl;
				}
	
				delay_ = 5;
			}
			/*
			if (dist > 100) {
				Vector toTgt = PhysUtil::scaleVectorToLength(PhysUtil::addVectors(tgt, PhysUtil::addVectors(him_.mov_, him_.mov_)), dist * 0.5);

				Vector cThrust = PhysUtil::subtractVectors(PhysUtil::subtractVectors(toTgt, PhysUtil::addVectors(me_.mov_, me_.mov_)), g);

				makeThrusterCorrectionAction(act, cThrust);
	
				delay_ = 2;
			}
			else {
				Vector dv = PhysUtil::subtractVectors(him_.mov_, me_.mov_);

				if (PhysUtil::calcModulus(dv) > 0.5) {
					makeThrusterCorrectionAction(act, dv);
				}
				else {
					makeFreefallAction(act);
				}
			}
			*/
		}

		Word iDist = dist;
		Word kmDist = iDist / 1000;
		Word mDist = iDist % 1000;

		if (kmDist) {
			cnt_ = 0;
		}
		else {
			++cnt_;
		}

		if (interactive) {
			std::cout.precision(0);
			std::cout << std::fixed <<
					" f: " << fuel_ <<
					" mR: " << me_.r_ <<
					" dmH: " << me_.dH_ <<
					" tR: " << him_.r_ <<
					" dtH: " << him_.dH_ <<
					" dist: " << (kmDist ? kmDist : mDist) << (kmDist ? " km " : " m ") <<
					" div: " << PhysUtil::calcModulus(PhysUtil::subtractVectors(him_.mov_, me_.mov_)) <<
					" cnt: " << cnt_ <<
					" g: " << PhysUtil::calcModulus(g) <<
					"        " <<
					"\r";
					//(delay_ ? "\n" : "\r");

			//std::cout<<std::endl;Word aa;std::cin>>aa;
		}

		if (delay_ > 0) {
			--delay_;
		}

		return act;
	}
コード例 #27
0
ファイル: tentacle.cpp プロジェクト: FaucetDC/HLDC_SDK
void CTentacle :: HandleAnimEvent( MonsterEvent_t *pEvent )
{
	char *sound;

	switch( pEvent->event )
	{
	case 1:	// bang 
		{
			Vector vecSrc, vecAngles;
			GetAttachment( 0, vecSrc, vecAngles );

			// Vector vecSrc = pev->origin + m_flTapRadius * Vector( cos( pev->angles.y * (3.14192653 / 180.0) ), sin( pev->angles.y * (M_PI / 180.0) ), 0.0 );

			// vecSrc.z += MyHeight( );

			switch( m_iTapSound )
			{
			case TE_SILO:
				UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitSilo ), 1.0, ATTN_NORM, 0, 100);
				break;
			case TE_NONE:
				break;
			case TE_DIRT:
				UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitDirt ), 1.0, ATTN_NORM, 0, 100);
				break;
			case TE_WATER:
				UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitWater ), 1.0, ATTN_NORM, 0, 100);
				break;
			}
          gpGlobals->force_retouch++;
		}
		break;

	case 3: // start killing swing
		m_iHitDmg = 200;
		// UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), "tentacle/te_swing1.wav", 1.0, ATTN_NORM, 0, 100);
		break;

	case 4: // end killing swing
		m_iHitDmg = 25;
		break;

	case 5: // just "whoosh" sound
		// UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), "tentacle/te_swing2.wav", 1.0, ATTN_NORM, 0, 100);
		break;

	case 2:	// tap scrape
	case 6: // light tap
		{
			Vector vecSrc = pev->origin + m_flTapRadius * Vector( cos( pev->angles.y * (M_PI / 180.0) ), sin( pev->angles.y * (M_PI / 180.0) ), 0.0 );

			vecSrc.z += MyHeight( );

			float flVol = RANDOM_FLOAT( 0.3, 0.5 );

			switch( m_iTapSound )
			{
			case TE_SILO:
				UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitSilo ), flVol, ATTN_NORM, 0, 100);
				break;
			case TE_NONE:
				break;
			case TE_DIRT:
				UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitDirt ), flVol, ATTN_NORM, 0, 100);
				break;
			case TE_WATER:
				UTIL_EmitAmbientSound(ENT(pev), vecSrc, RANDOM_SOUND_ARRAY( pHitWater ), flVol, ATTN_NORM, 0, 100);
				break;
			}
		}
		break;


	case 7: // roar
		switch( RANDOM_LONG(0,1) )
		{
		case 0: sound = "tentacle/te_roar1.wav"; break;
		case 1: sound = "tentacle/te_roar2.wav"; break;
		}

		UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), sound, 1.0, ATTN_NORM, 0, 100);
		break;

	case 8: // search
		switch( RANDOM_LONG(0,1) )
		{
		case 0: sound = "tentacle/te_search1.wav"; break;
		case 1: sound = "tentacle/te_search2.wav"; break;
		}

		UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), sound, 1.0, ATTN_NORM, 0, 100);
		break;

	case 9: // swing
		switch( RANDOM_LONG(0,1) )
		{
		case 0: sound = "tentacle/te_move1.wav"; break;
		case 1: sound = "tentacle/te_move2.wav"; break;
		}

		UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), sound, 1.0, ATTN_NORM, 0, 100);
		break;

	default:
		CBaseMonster::HandleAnimEvent( pEvent );
	}
}
コード例 #28
0
Real ConfigObjective::Delta(PlannerObjectiveBase* priorGoal)
{
  if(priorGoal->TypeString() != TypeString()) return Inf;
  return priorGoal->TerminalCost(0.0,qgoal,Vector());
}
コード例 #29
0
ファイル: primitives.cpp プロジェクト: h94h12/MT-Terrain
//return negation of this vector
Vector Vector::negative(){
   return Vector(-dx, -dy, -dz); 
}
コード例 #30
0
ファイル: Vector.cpp プロジェクト: timcsy/Physics-Engine
Vector Vector::unit() const // unit vector of the vector
{
	if(this->length() == 0) return Vector(0,0);
	else return (*this) / this->length();
}