?? trigger.cpp
字號:
// this cannot be done
volume = ev->GetFloat( 1 );
}
void TriggerPlaySound::SetAttenuation
(
Event *ev
)
{
attenuation = ev->GetFloat( 1 );
}
void TriggerPlaySound::SetChannel
(
Event *ev
)
{
channel = ev->GetInteger( 1 );
}
TriggerPlaySound::TriggerPlaySound()
{
//
// this is here so that a baseline is created for this
//
edict->s.effects = EF_FORCEBASELINE;
//
// this is here so that it gets sent over at least once
//
showModel();
ambient = false;
pitch = 1.0f;
timeofs = 0;
fadetime = 0;
volume = G_GetFloatArg( "volume", 1.0 );
channel = G_GetIntArg( "channel", CHAN_VOICE );
state = 0;
respondto = spawnflags ^ TRIGGER_PLAYERS;
if (spawnflags & 2)
channel |= CHAN_RELIABLE;
if (spawnflags & 33)
{
ambient = true;
attenuation = G_GetFloatArg( "attenuation", ATTN_IDLE );
if (spawnflags & 1)
{
ToggleSound( NULL );
}
}
else
{
attenuation = G_GetFloatArg( "attenuation", ATTN_NORM );
}
}
/*****************************************************************************/
/*SINED trigger_speaker (0.3 0.1 0.6) (-8 -8 -8) (8 8 8) AMBIENT-ON RELIABLE NOT_PLAYERS MONSTERS PROJECTILES AMBIENT-OFF x TOGGLE
play a sound when it is used
AMBIENT-ON specifies an ambient sound that starts on
RELIABLE should only be set for crucial voice-overs or sounds
AMBIENT-OFF specifies an ambient sound that starts off
if (AMBIENT-?) is not set, then the sound is sent over explicitly this creates more net traffic
"volume" how loud 0-4 (1 default full volume, ambients do not respond to volume)
"noise" sound to play
"channel" channel on which to play sound (0 auto, 1 weapon, 2 voice, 3 item, 4 body, 8 don't use PHS) (voice is default)
"pitch" the pitch of the sample ( default 1, no pitch-shift )
"fadetime" fade the sound in over a time period in seconds ( default 0, no fade )
"timeofs" start time offset in milli-seconds into this sound ( default 0, no timeofs )
"attenuation" attenuation factor (0 becomes 1 for non-ambients, 2 for ambients)
-1 - none, send to whole level
0 - default (normal or ambient)
1 - normal fighting sounds
2 - idle monster sounds
3 - ambient sounds
"key" The item needed to activate this. (default nothing)
"thread" name of thread to trigger. This can be in a different script file as well\
by using the '::' notation.
Normal sounds play each time the target is used.
Ambient Looped sounds have an attenuation of 2 by default, volume 1, and the use function toggles it on/off.
Multiple identical ambient looping sounds will just increase volume without any speed cost.
The attenuation factor can be over-ridden by specifying an attenuation factor.
If NOT_PLAYERS is set, the trigger does not respond to players
If MONSTERS is set, the trigger will respond to monsters
If PROJECTILES is set, the trigger will respond to projectiles (rockets, grenades, etc.)
/*****************************************************************************/
CLASS_DECLARATION( TriggerPlaySound, TriggerSpeaker, "trigger_speaker" );
ResponseDef TriggerSpeaker::Responses[] =
{
{ &EV_Touch, NULL },
{ NULL, NULL }
};
TriggerSpeaker::TriggerSpeaker()
{
if (attenuation == -1)
attenuation = 0;
pitch = G_GetFloatArg( "pitch", 1.0 );
fadetime = G_GetFloatArg( "fadetime", 0 );
timeofs = G_GetFloatArg( "timeofs", 0 );
}
/*****************************************************************************/
/*SINED trigger_randomspeaker (0.3 0.1 0.6) (-8 -8 -8) (8 8 8) x RELIABLE NOT_PLAYERS MONSTERS PROJECTILES x x
play a sound at random times
RELIABLE should only be set for crucial voice-overs or sounds
"mindelay" minimum delay between sound triggers (default 3)
"maxdelay" maximum delay between sound triggers (default 10)
"volume" how loud 0-4 (1 default full volume)
"noise" sound to play
"channel" channel on which to play sound (0 auto, 1 weapon, 2 voice, 3 item, 4 body, 8 don't use PHS) (voice is default)
"pitch" the pitch of the sample ( default 1, no pitch-shift )
"fadetime" fade the sound in over a time period in seconds ( default 0, no fade )
"timeofs" start time offset in milli-seconds into this sound ( default 0, no timeofs )
"attenuation" attenuation factor
-1 - none, send to whole level
0 - default (normal)
1 - normal fighting sounds
2 - idle monster sounds
3 - ambient sounds
"key" The item needed to activate this. (default nothing)
Normal sounds play each time the target is used.
If NOT_PLAYERS is set, the trigger does not respond to players
If MONSTERS is set, the trigger will respond to monsters
If PROJECTILES is set, the trigger will respond to projectiles (rockets, grenades, etc.)
/*****************************************************************************/
CLASS_DECLARATION( TriggerSpeaker, RandomSpeaker, "trigger_randomspeaker" );
Event EV_TriggerRandomSpeaker_TriggerSound( "triggersound" );
ResponseDef RandomSpeaker::Responses[] =
{
{ &EV_Trigger_Effect, ( Response )RandomSpeaker::TriggerSound },
{ &EV_Touch, NULL },
{ NULL, NULL }
};
void RandomSpeaker::TriggerSound
(
Event *ev
)
{
ScheduleSound();
TriggerPlaySound::ToggleSound( ev );
}
void RandomSpeaker::ScheduleSound
(
void
)
{
CancelEventsOfType( EV_Trigger_Effect );
PostEvent( EV_Trigger_Effect, mindelay + G_Random( maxdelay-mindelay ) );
}
RandomSpeaker::RandomSpeaker()
{
mindelay = G_GetFloatArg( "mindelay", 3 );
maxdelay = G_GetFloatArg( "maxdelay", 10 );
ScheduleSound();
}
/*****************************************************************************/
/*SINED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION x NOT_PLAYERS MONSTERS PROJECTILES
When the player touches this, he gets sent to the map listed in the "map" variable.
Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission
spot and display stats.
"spawnspot" name of the spawn location to start at in next map.
"key" The item needed to activate this. (default nothing)
"thread" This defaults to "LevelComplete" and should point to a thread that is called just
before the level ends.
If NOT_PLAYERS is set, the trigger does not respond to players
If MONSTERS is set, the trigger will respond to monsters
If PROJECTILES is set, the trigger will respond to projectiles (rockets, grenades, etc.)
/*****************************************************************************/
CLASS_DECLARATION( Trigger, TriggerChangeLevel, "trigger_changelevel" );
ResponseDef TriggerChangeLevel::Responses[] =
{
{ &EV_Trigger_Effect, ( Response )TriggerChangeLevel::ChangeLevel },
{ NULL, NULL }
};
TriggerChangeLevel::TriggerChangeLevel()
{
map = G_GetStringArg( "map" );
if ( !map.length() && !LoadingSavegame )
{
error( "Init", "changelevel trigger doesn't have map" );
}
// We have to handle calling the thread ourselves, so clear out Trigger's tread variable
thread = "";
changethread = G_GetStringArg( "thread", "LevelComplete" );
spawnspot = G_GetStringArg( "spawnspot" );
respondto = spawnflags ^ TRIGGER_PLAYERS;
}
void TriggerChangeLevel::ChangeLevel
(
Event *ev
)
{
Entity *other;
other = ev->GetEntity( 1 );
if ( level.intermissiontime )
{
// already activated
return;
}
// if noexit, do a ton of damage to other
if ( deathmatch->value && DM_FLAG( DF_SAME_LEVEL ) && other != world )
{
other->Damage( this, other, 10 * other->max_health, other->worldorigin, vec_zero, vec_zero, 1000, 0, MOD_CRUSH, -1, -1, 1.0f );
return;
}
// if multiplayer, let everyone know who hit the exit
if ( deathmatch->value )
{
if ( other && other->edict->client )
{
gi.bprintf( PRINT_HIGH, "%s exited the level.\n", other->edict->client->pers.netname );
}
}
// tell the script that the player's not ready so that if we return to this map,
// we can do something about it.
Director.PlayerNotReady();
//
// make sure we execute the thread before changing
//
if ( changethread.length() )
{
ExecuteThread( changethread );
}
G_BeginIntermission( map.c_str() );
}
const char *TriggerChangeLevel::Map
(
void
)
{
return map.c_str();
}
const char *TriggerChangeLevel::SpawnSpot
(
void
)
{
return spawnspot.c_str();
}
/*****************************************************************************/
/*SINED trigger_use (0.5 0.5 0.5) ? VISIBLE x NOT_PLAYERS MONSTERS
Activates targets when 'used' by an entity
"key" The item needed to activate this. (default nothing)
"thread" name of thread to trigger. This can be in a different script file as well\
by using the '::' notation.
If NOT_PLAYERS is set, the trigger does not respond to players
If MONSTERS is set, the trigger will respond to monsters
/*****************************************************************************/
CLASS_DECLARATION( Trigger, TriggerUse, "trigger_use" );
ResponseDef TriggerUse::Responses[] =
{
{ &EV_Use, ( Response )TriggerUse::TriggerStuff },
{ &EV_Touch, NULL },
{ NULL, NULL }
};
TriggerUse::TriggerUse()
{
if ( spawnflags & VISIBLE )
{
showModel();
setMoveType( MOVETYPE_PUSH );
setSolidType( SOLID_BSP );
}
respondto = ( spawnflags ^ TRIGGER_PLAYERS ) & ~TRIGGER_PROJECTILES;
}
/*****************************************************************************/
/*SINED trigger_useonce (0.5 0.5 0.5) ? VISIBLE x NOT_PLAYERS MONSTERS
Activates targets when 'used' by an entity, but only once
"key" The item needed to activate this. (default nothing)
"thread" name of thread to trigger. This can be in a different script file as well\
by using the '::' notation.
If NOT_PLAYERS is set, the trigger does not respond to players
If MONSTERS is set, the trigger will respond to monsters
/*****************************************************************************/
CLASS_DECLARATION( TriggerUse, TriggerUseOnce, "trigger_useonce" );
ResponseDef TriggerUseOnce::Responses[] =
{
{ &EV_Touch, NULL },
{ NULL, NULL }
};
TriggerUseOnce::TriggerUseOnce()
{
// Only allow 1 use.
count = 1;
respondto = ( spawnflags ^ TRIGGER_PLAYERS ) & ~TRIGGER_PROJECTILES;
}
/*****************************************************************************/
/*SINED trigger_hurt (0.5 0.5 0.5) ? x x NOT_PLAYERS NOT_MONSTERS PROJECTILES
"damage" amount of damage to cause. (default 10)
"key" The item needed to activate this. (default nothing)
If NOT_PLAYERS is set, the trigger does not hurt players
If NOT_MONSTERS is set, the trigger does not hurt monsters
If PROJECTILES is set, the trigger will hurt projectiles (rockets, grenades, etc.)
/*****************************************************************************/
Event EV_TriggerHurt_SetDamage( "setdamage" );
CLASS_DECLARATION( TriggerUse, TriggerHurt, "trigger_hurt" );
ResponseDef TriggerHurt::Responses[] =
{
{ &EV_Trigger_Effect, ( Response )TriggerHurt::Hurt },
{ &EV_TriggerHurt_SetDamage, ( Response )TriggerHurt::SetDamage },
{ &EV_Touch, ( Response )Trigger::TriggerStuff },
{ NULL, NULL }
};
TriggerHurt::TriggerHurt()
{
damage = G_GetFloatArg( "damage", 10 );
respondto = spawnflags ^ ( TRIGGER_PLAYERS | TRIGGER_MONSTERS );
}
void TriggerHurt::SetDamage
(
Event *ev
)
{
damage = ev->GetInteger( 1 );
}
void TriggerHurt::Hurt
(
Event *ev
)
{
Entity *other;
other = ev->GetEntity( 1 );
if ( ( damage != 0 ) && !other->deadflag && !( other->flags & FL_GODMODE ) )
{
other->Damage( this, other, damage, other->worldorigin, vec_zero, vec_zero, 0, DAMAGE_NO_ARMOR|DAMAGE_NO_SKILL, MOD_CRUSH, -1, -1, 1.0f );
}
}
/*****************************************************************************/
/*SINED trigger_damagetargets (0.5 0.5 0.5) ? SOLID x NOT_PLAYERS NOT_MONSTERS PROJECTILES
"damage" amount of damage to cause. If no damage is specified, objects\
are damaged by the current health+1
"key" The item needed to activate this. (default nothing)
if a trigger_damagetargets is shot at and the SOLID flag is set,\
the damage is passed on to the targets
If NOT_PLAYERS is set, the trigger does not hurt players
If NOT_MONSTERS is set, the trigger does not hurt monsters
If PROJECTILES is set, the trigger will hurt projectiles (rockets, grenades, etc.)
/*****************************************************************************/
CLASS_DECLARATION( Trigger, TriggerDamageTargets, "trigger_damagetargets" );
ResponseDef TriggerDamageTargets::Responses[] =
{
{ &EV_Trigger_ActivateTargets, ( Response )TriggerDamageTargets::DamageTargets },
{ &EV_Damage, ( Response )TriggerDamageTargets::PassDamage },
{ &EV_Touch, NULL },
{ NULL, NULL }
};
TriggerDamageTargets::TriggerDamageTargets()
{
damage = G_GetFloatArg( "damage", 0 );
respondto = spawnflags ^ ( TRIGGER_PLAYERS | TRIGGER_MONSTERS );
if (spawnflags & 1)
{
health = 60;
max_health = health;
takedamage = DAMAGE_YES;
setSolidType( SOLID_BBOX );
}
else
{
takedamage = DAMAGE_NO;
setSolidType( SOLID_NOT );
}
}
void TriggerDamageTargets::PassDamage
(
Event *ev
)
{
Entity *attacker;
int dmg;
Entity *ent;
const char *name;
int num;
dmg = ev->GetInteger( 1 );
attacker = ev->GetEntity( 3 );
//
// damage the targets
//
name = Target();
if ( name && strcmp( name, "" ) )
{
num = 0;
do
{
num = G_FindTarget( num, name );
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -