Exemplo n.º 1
0
/*
================
idTrigger_Multi::Event_Trigger

the trigger was just activated
activated should be the entity that originated the activation sequence (ie. the original target)
activator should be set to the activator so it can be held through a delay
so wait for the delay time before firing
================
*/
void idTrigger_Multi::Event_Trigger( idEntity *activator ) {
// RAVEN BEGIN
// bdube: moved trigger first
    if ( triggerFirst ) {
        triggerFirst = false;
        return;
    }

    if ( nextTriggerTime > gameLocal.time ) {
        // can't retrigger until the wait is over
        return;
    }

    // see if this trigger requires an item
    if ( !gameLocal.RequirementMet( activator, requires, removeItem ) ) {
        return;
    }

    if ( !CheckFacing( activator ) ) {
        return;
    }
// RAVEN END

    // don't allow it to trigger twice in a single frame
    nextTriggerTime = gameLocal.time + 1;

    if ( delay > 0 ) {
        // don't allow it to trigger again until our delay has passed
        nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() );
        PostEventSec( &EV_TriggerAction, delay, activator );
    } else {
        TriggerAction( activator );
    }
}
Exemplo n.º 2
0
/*
================
idTrigger_Multi::Event_Touch
================
*/
void idTrigger_Multi::Event_Touch( idEntity *other, trace_t *trace )
{
	if( triggerFirst )
	{
		return;
	}
	
	bool player = other->IsType( idPlayer::Type );
	if( player )
	{
		if( !touchClient )
		{
			return;
		}
		if( static_cast< idPlayer * >( other )->spectating )
		{
			return;
		}
	}
	else if( !touchOther )
	{
		return;
	}
	
	if( nextTriggerTime > gameLocal.time )
	{
		// can't retrigger until the wait is over
		return;
	}
	
	// see if this trigger requires an item
	if( !gameLocal.RequirementMet( other, requires, removeItem ) )
	{
		return;
	}
	
	if( !CheckFacing( other ) )
	{
		return;
	}
	
	if( spawnArgs.GetBool( "toggleTriggerFirst" ) )
	{
		triggerFirst = true;
	}
	
	nextTriggerTime = gameLocal.time + 1;
	if( delay > 0 )
	{
		// don't allow it to trigger again until our delay has passed
		nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() );
		PostEventSec( &EV_TriggerAction, delay, other );
	}
	else
	{
		TriggerAction( other );
	}
}
Exemplo n.º 3
0
/*
================
idTrigger_Multi::Event_Trigger

the trigger was just activated
activated should be the entity that originated the activation sequence (ie. the original target)
activator should be set to the activator so it can be held through a delay
so wait for the delay time before firing
================
*/
void idTrigger_Multi::Event_Trigger( idEntity *activator ) {
	if ( nextTriggerTime > gameLocal.time ) {
		// can't retrigger until the wait is over
		return;
	}

	// see if this trigger requires an item
	if ( !gameLocal.RequirementMet( activator, requires, removeItem ) ) {
		return;
	}

	if ( !CheckFacing( activator ) ) {
		return;
	}

	if ( triggerFirst ) {
		triggerFirst = false;
		return;
	}

	// don't allow it to trigger twice in a single frame
	nextTriggerTime = gameLocal.time + 1;

	if ( delay > 0 ) {
		// don't allow it to trigger again until our delay has passed
		nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() );
		PostEventSec( &EV_TriggerAction, delay, activator );
	} else {
		TriggerAction( activator );
	}


	//BC recording.
	idEntity *recordEnt;
	recordEnt = gameLocal.FindEntity( "world1" );
	if (recordEnt)
	{
		if (this->spawnArgs.GetBool("recordable", "0"))
		{
			static_cast<idWorldManager *>( recordEnt )->RecordFrob(this->GetName());
		}
	}
}
Exemplo n.º 4
0
/*
================
idTrigger_Multi::Event_Touch
================
*/
void idTrigger_Multi::Event_Touch( idEntity *other, trace_t *trace ) {
    if( triggerFirst ) {
        return;
    }

// RAVEN BEGIN
// jdischler: vehicle only trigger
    if ( touchVehicle ) {
        if ( !other->IsType(rvVehicle::GetClassType()) ) {
            return;
        }
    } else {
// RAVEN BEGIN
// jnewquist: Use accessor for static class type
        bool player = other->IsType( idPlayer::GetClassType() );
// RAVEN END
        if ( player ) {
            if ( !touchClient ) {
                return;
            }
            if ( static_cast< idPlayer * >( other )->spectating ) {
                return;
            }

            // Buy zone handling
            if ( buyZoneTrigger /*&& gameLocal.mpGame.mpGameState.gameState.currentState != 1*/ ) {
                idPlayer *p = static_cast< idPlayer * >( other );
                if ( buyZoneTrigger-1 == p->team || buyZoneTrigger == 3)
                {
                    p->inBuyZone = true;
                    p->inBuyZonePrev = true;
                }
            }

            // Control zone handling
            if ( controlZoneTrigger > 0 ) {
                idPlayer *p = static_cast< idPlayer * >( other );
                if ( p->PowerUpActive(POWERUP_DEADZONE) || !spawnArgs.GetBool("requiresDeadZonePowerup", "1") )
                    playersInTrigger.Append(p);
            }

        } else if ( !touchOther ) {
            return;
        }
    }

    if ( nextTriggerTime > gameLocal.time ) {
        // can't retrigger until the wait is over
        return;
    }

    // see if this trigger requires an item
    if ( !gameLocal.RequirementMet( other, requires, removeItem ) ) {
        return;
    }

    if ( !CheckFacing( other ) ) {
        return;
    }

    if ( spawnArgs.GetBool( "toggleTriggerFirst" ) ) {
        triggerFirst = true;
    }

// RAVEN BEGIN
// rjohnson: added block
    if ( developer.GetBool() && *spawnArgs.GetString ( "message" ) ) {
        gameLocal.DPrintf ( "Trigger: %s\n", spawnArgs.GetString ( "message" ) );
    }
// RAVEN END

    nextTriggerTime = gameLocal.time + 1;
    if ( delay > 0 ) {
        // don't allow it to trigger again until our delay has passed
        nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() );
        PostEventSec( &EV_TriggerAction, delay, other );
    } else {
        TriggerAction( other );
    }
}
Exemplo n.º 5
0
void OcclusionBuffer::DrawTriangle(Vector4* vertices)
{
    unsigned clipMask = 0;
    unsigned andClipMask = 0;
    bool drawOk = false;
    Vector3 projected[3];
    
    // Build the clip plane mask for the triangle
    for (unsigned i = 0; i < 3; ++i)
    {
        unsigned vertexClipMask = 0;
        
        if (vertices[i].x_ > vertices[i].w_)
            vertexClipMask |= CLIPMASK_X_POS;
        if (vertices[i].x_ < -vertices[i].w_)
            vertexClipMask |= CLIPMASK_X_NEG;
        if (vertices[i].y_ > vertices[i].w_)
            vertexClipMask |= CLIPMASK_Y_POS;
        if (vertices[i].y_ < -vertices[i].w_)
            vertexClipMask |= CLIPMASK_Y_NEG;
        if (vertices[i].z_ > vertices[i].w_)
            vertexClipMask |= CLIPMASK_Z_POS;
        if (vertices[i].z_ < 0.0f)
            vertexClipMask |= CLIPMASK_Z_NEG;
        
        clipMask |= vertexClipMask;
        
        if (!i)
            andClipMask = vertexClipMask;
        else
            andClipMask &= vertexClipMask;
    }
    
    // If triangle is fully behind any clip plane, can reject quickly
    if (andClipMask)
        return;
    
    // Check if triangle is fully inside
    if (!clipMask)
    {
        projected[0] = ViewportTransform(vertices[0]);
        projected[1] = ViewportTransform(vertices[1]);
        projected[2] = ViewportTransform(vertices[2]);
        
        if (CheckFacing(projected[0], projected[1], projected[2]))
        {
            DrawTriangle2D(projected);
            drawOk = true;
        }
    }
    else
    {
        bool triangles[64];
        
        // Initial triangle
        triangles[0] = true;
        unsigned numTriangles = 1;
        
        if (clipMask & CLIPMASK_X_POS)
            ClipVertices(Vector4(-1.0f, 0.0f, 0.0f, 1.0f), vertices, triangles, numTriangles);
        if (clipMask & CLIPMASK_X_NEG)
            ClipVertices(Vector4(1.0f, 0.0f, 0.0f, 1.0f), vertices, triangles, numTriangles);
        if (clipMask & CLIPMASK_Y_POS)
            ClipVertices(Vector4(0.0f, -1.0f, 0.0f, 1.0f), vertices, triangles, numTriangles);
        if (clipMask & CLIPMASK_Y_NEG)
            ClipVertices(Vector4(0.0f, 1.0f, 0.0f, 1.0f), vertices, triangles, numTriangles);
        if (clipMask & CLIPMASK_Z_POS)
            ClipVertices(Vector4(0.0f, 0.0f, -1.0f, 1.0f), vertices, triangles, numTriangles);
        if (clipMask & CLIPMASK_Z_NEG)
            ClipVertices(Vector4(0.0f, 0.0f, 1.0f, 0.0f), vertices, triangles, numTriangles);
        
        // Draw each accepted triangle
        for (unsigned i = 0; i < numTriangles; ++i)
        {
            if (triangles[i])
            {
                unsigned index = i * 3;
                projected[0] = ViewportTransform(vertices[index]);
                projected[1] = ViewportTransform(vertices[index + 1]);
                projected[2] = ViewportTransform(vertices[index + 2]);
                
                if (CheckFacing(projected[0], projected[1], projected[2]))
                {
                    DrawTriangle2D(projected);
                    drawOk = true;
                }
            }
        }
    }
    
    if (drawOk)
        ++numTriangles_;
}
Exemplo n.º 6
0
/*
================
idTrigger_Multi::Event_Touch
================
*/
void idTrigger_Multi::Event_Touch( idEntity *other, trace_t *trace ) {
	if( triggerFirst ) {
		return;
	}

	bool player = other->IsType( idPlayer::Type );
	if ( player ) {
		if ( !touchClient ) {
			return;
		}
		if ( static_cast< idPlayer * >( other )->spectating ) {
			return;
		}
	} else if ( !touchOther ) {
		return;
	}

	if ( nextTriggerTime > gameLocal.time ) {
		// can't retrigger until the wait is over
		return;
	}

	// see if this trigger requires an item
	if ( !gameLocal.RequirementMet( other, requires, removeItem ) ) {
		return;
	}

	if ( !CheckFacing( other ) ) {
		return;
	}

	if ( spawnArgs.GetBool( "toggleTriggerFirst" ) ) {
		triggerFirst = true;
	}

	if (player && spawnArgs.GetBool( "falltrigger" ))
	{
		StartSound(  "snd_camerasnap" , SND_CHANNEL_ANY, 0, false, NULL );
		

		

		if (gameLocal.GetLocalPlayer()->inDeck)
		{
			//kick player out of deck.
			//cvarSystem->SetCVarBool("deckActive", true, 0);
			//gameLocal.GetLocalPlayer()->deckEnt.GetEntity()->GetPhysics()->SetOrigin(popcornpos);
			
			//gameLocal.sessionCommand = "stopgui";


			
			gameLocal.GetLocalPlayer()->ExitDeck(true);
		}


		const char *manualPos = this->spawnArgs.GetString("target");
		if (manualPos)
		{
			idEntity *manualEnt = gameLocal.FindEntity( manualPos );
			if (manualEnt)
			{
				other->SetOrigin( manualEnt->GetPhysics()->GetOrigin() + idVec3(0,0,1) );
				other->GetPhysics()->PutToRest();
				return;
			}
		}


		//current.velocity.Zero();

		idVec3 popcornpos = static_cast< idPlayer * >( other )->popcornPosition;
		

		if (popcornpos == vec3_zero)
		{
			//no valid popcorn position.

			//reset player to spawn point.
			int spawnIndex = 0;
			idEntity *recordEnt;
			recordEnt = gameLocal.FindEntity( "world1" );
			if (recordEnt)
			{
				spawnIndex = static_cast<idWorldManager *>( recordEnt )->index;
			}

			idEntity *spawnEnt;
			spawnEnt = gameLocal.FindEntity( va("heliinsertion%d", spawnIndex) );
			
			if (spawnEnt)
			{
				other->SetOrigin( spawnEnt->GetPhysics()->GetOrigin() + idVec3(0,0,1) );
				other->GetPhysics()->PutToRest();
			}
		}
		else
		{
			other->SetOrigin( popcornpos + idVec3(0,0,1) );
			other->GetPhysics()->PutToRest();
		}
	}

	nextTriggerTime = gameLocal.time + 1;
	if ( delay > 0 ) {
		// don't allow it to trigger again until our delay has passed
		nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() );
		PostEventSec( &EV_TriggerAction, delay, other );
	} else {
		TriggerAction( other );
	}
}