예제 #1
0
/*
==============================
G_FireAllTargetsOf

"activator" should be set to the entity that initiated the firing.

For all t in the entities, where t.targetnames[i] matches
ent.targets[j] for any (i,j) pairs, call the t.use function.
==============================
*/
void G_EventFireEntity( gentity_t *self, gentity_t *activator, gentityCallEvent_t eventType )
{
	gentity_t *currentTarget = NULL;
	int targetIndex;
	gentityCall_t call;
	call.activator = activator;

	if ( self->shaderKey && self->shaderReplacement )
	{
		G_SetShaderRemap( self->shaderKey, self->shaderReplacement, level.time * 0.001 );
		trap_SetConfigstring( CS_SHADERSTATE, BuildShaderStateConfig() );
	}

	while( ( currentTarget = G_IterateCallEndpoints( currentTarget, &targetIndex, self ) ) != NULL )
	{
		if( eventType && self->calltargets[ targetIndex ].eventType != eventType )
		{
			continue;
		}

		call.caller = self; //reset the caller in case there have been nested calls
		call.definition = &self->calltargets[ targetIndex ];

		G_CallEntity(currentTarget, &call);

		if ( !self->inuse )
		{
			G_Printf( S_WARNING "entity was removed while using targets\n" );
			return;
		}
	}
}
/*
==============================
G_UseTargets

"activator" should be set to the entity that initiated the firing.

Search for (string)targetname in all entities that
match (string)self.target and call their .use function

==============================
*/
void G_UseTargets( gentity_t *ent, gentity_t *activator ) {
	gentity_t		*t;
	
	if ( !ent ) {
		return;
	}

	if (ent->targetShaderName && ent->targetShaderNewName) {
		float f = level.time * 0.001;
		AddRemap(ent->targetShaderName, ent->targetShaderNewName, f);
		trap_SetConfigstring(CS_SHADERSTATE, BuildShaderStateConfig());
	}

	if ( !ent->target ) {
		return;
	}

	t = NULL;
	while ( (t = G_Find (t, FOFS(targetname), ent->target)) != NULL ) {
		if ( t == ent ) {
			G_Printf ("WARNING: Entity used itself.\n");
		} else {
			if ( t->use ) {
				t->use (t, ent, activator);
			}
		}
		if ( !ent->inuse ) {
			G_Printf("entity was removed while using targets\n");
			return;
		}
	}
}
예제 #3
0
static int GLua_Sys_RemapShader(lua_State *L) {
	int supressupdate = lua_toboolean(L,3);
	AddRemap(luaL_checkstring(L,1), luaL_checkstring(L,2), level.time);
	if (!supressupdate) {
		trap_SetConfigstring(CS_SHADERSTATE, BuildShaderStateConfig());
	}
	return 0;
}
예제 #4
0
void gfx_shader_mod_act( gentity_t *self, gentity_t *other, gentity_t *activator )
{
	if ( !self->shaderKey || !self->shaderReplacement || !self->enabled )
	{
		return;
	}

	G_SetShaderRemap( self->shaderKey, self->shaderReplacement, level.time * 0.001 );
	trap_SetConfigstring( CS_SHADERSTATE, BuildShaderStateConfig() );

	self->active = true;
}
void G_RemapTeamShaders( void ) {
#ifdef MISSIONPACK
	char string[1024];
	float f = level.time * 0.001;
	Com_sprintf( string, sizeof(string), "team_icon/%s_red", g_redteam.string );
	AddRemap("textures/ctf2/redteam01", string, f); 
	AddRemap("textures/ctf2/redteam02", string, f); 
	Com_sprintf( string, sizeof(string), "team_icon/%s_blue", g_blueteam.string );
	AddRemap("textures/ctf2/blueteam01", string, f); 
	AddRemap("textures/ctf2/blueteam02", string, f); 
	trap_SetConfigstring(CS_SHADERSTATE, BuildShaderStateConfig());
#endif
}
예제 #6
0
/*
==============================
G_UseTargets

"activator" should be set to the entity that initiated the firing.

Search for (string)targetname in all entities that
match (string)self.target and call their .use function

==============================
*/
void G_UseTargets( gentity_t *ent, gentity_t *activator ) {
	gentity_t       *t;

	if ( !ent ) {
		return;
	}

	if ( ent->targetShaderName && ent->targetShaderNewName ) {
		float f = level.time * 0.001;
		AddRemap( ent->targetShaderName, ent->targetShaderNewName, f );
		trap_SetConfigstring( CS_SHADERSTATE, BuildShaderStateConfig() );
	}

	if ( !ent->target ) {
		return;
	}

	t = NULL;
	while ( ( t = G_Find( t, FOFS( targetname ), ent->target ) ) != NULL ) {
		if ( t == ent ) {
			G_Printf( "WARNING: Entity used itself.\n" );
		} else {
			if ( t->use ) {
				//G_Printf ("ent->classname %s ent->targetname %s t->targetname %s t->s.number %d\n", ent->classname, ent->targetname, t->targetname, t->s.number);

				t->flags |= ( ent->flags & FL_KICKACTIVATE ); // (SA) If 'ent' was kicked to activate, pass this along to it's targets.
				//		It may become handy to put a "KICKABLE" flag in ents so that it knows whether to pass this along or not
				//		Right now, the only situation where it would be weird would be an invisible_user that is a 'button' near
				//		a rotating door that it triggers.  Kick the switch and the door next to it flies open.

				t->flags |= ( ent->flags & FL_SOFTACTIVATE ); // (SA) likewise for soft activation

				if (    activator &&
					(   ( Q_stricmp( t->classname, "func_door" ) == 0 ) ||
					( Q_stricmp( t->classname, "func_door_rotating" ) == 0 )
					)
					) {
						// check door usage rules before allowing any entity to trigger a door open
						G_TryDoor( t, ent, activator );       // (door,other,activator)
				} else {
					t->use( t, ent, activator );
				}
			}
		}
		if ( !ent->inuse ) {
			G_Printf( "entity was removed while using targets\n" );
			return;
		}
	}
}
예제 #7
0
void gfx_shader_mod_reset( gentity_t *self )
{
	if ( !self->shaderKey || !self->shaderReplacement )
	{
		return;
	}

	if( !self->active ) // initial reset doesnt need a remap
	{
		return;
	}

	G_SetShaderRemap( self->shaderKey, self->shaderKey, level.time * 0.001 );
	trap_SetConfigstring( CS_SHADERSTATE, BuildShaderStateConfig() );

	self->active = false;
}
예제 #8
0
/*
==============================
G_ToggleTargetsEnabled

"activator" should be set to the entity that initiated the firing.

Search for (string)targetname in all entities that
match (string)self.target and toggle their FL_DISABLED flag

==============================
*/
void G_ToggleTargetsEnabled( gentity_t *ent, gentity_t *activator ) {
	gentity_t		*t;
	
	if ( !ent ) {
		return;
	}

	if (ent->targetShaderName && ent->targetShaderNewName) {
		float f = level.time * 0.001;
		AddRemap(ent->targetShaderName, ent->targetShaderNewName, f);
		trap_SetConfigstring(CS_SHADERSTATE, BuildShaderStateConfig());
	}

	if ( !ent->target ) {
		return;
	}

	t = NULL;
	while ( (t = G_Find (t, FOFS(targetname), ent->target)) != NULL ) {
		if ( t == ent ) {
			G_Printf ("WARNING: Entity targets itself.\n");
		} else {
			G_Printf("entity found\n");
			if ( ( ent->spawnflags & 4 ) )	
				t->flags |= FL_DISABLED; //always_disable spawnflag is set, so set the disabled bit
			else if ( ( ent->spawnflags & 8 ) )
				t->flags &= ~FL_DISABLED;	//always_enable spawnflag is set, so clear the disabled bit
			else
				t->flags ^= FL_DISABLED;	//no spawnflag is set, so toggle
		}
		if ( !ent->inuse ) {
			G_Printf("entity was removed while using targets\n");
			return;
		}
	}
}