MCPcopy Create free account
hub / github.com/JACoders/OpenJK / SP_trigger_multiple

Function SP_trigger_multiple

code/game/g_trigger.cpp:435–477  ·  view source on GitHub ↗

QUAKED trigger_multiple (.1 .5 .1) ? PLAYERONLY FACING USE_BUTTON FIRE_BUTTON NPCONLY LIMITED_PILOT x INACTIVE MULTIPLE PLAYERONLY - only a player can trigger this by touch FACING - Won't fire unless triggering ent's view angles are within 45 degrees of trigger's angles (in addition to any other conditions) USE_BUTTON - Won't fire unless player is in it and pressing use button (in addition to any

Source from the content-addressed store, hash-verified

433"soundSet" Ambient sound set to play when this trigger is activated
434*/
435void SP_trigger_multiple( gentity_t *ent )
436{
437 char buffer[MAX_QPATH];
438 char *s;
439 if ( G_SpawnString( "noise", "*NOSOUND*", &s ) )
440 {
441 Q_strncpyz( buffer, s, sizeof(buffer) );
442 COM_DefaultExtension( buffer, sizeof(buffer), ".wav");
443 ent->noise_index = G_SoundIndex(buffer);
444 }
445
446 G_SpawnFloat( "wait", "0", &ent->wait );//was 0.5 ... but that means wait can never be zero... we should probably put it back to 0.5, though...
447 G_SpawnFloat( "random", "0", &ent->random );
448 G_SpawnInt( "max_pilots", "2", &ent->lastInAirTime );
449
450
451 if ( (ent->wait > 0) && (ent->random >= ent->wait) ) {
452 ent->random = ent->wait - FRAMETIME;
453 gi.Printf(S_COLOR_YELLOW"trigger_multiple has random >= wait\n");
454 }
455
456 ent->delay *= 1000;//1 = 1 msec, 1000 = 1 sec
457 if ( !ent->speed && ent->target2 && ent->target2[0] )
458 {
459 ent->speed = 1000;
460 }
461 else
462 {
463 ent->speed *= 1000;
464 }
465
466 ent->e_TouchFunc = touchF_Touch_Multi;
467 ent->e_UseFunc = useF_Use_Multi;
468
469 if ( ent->team && ent->team[0] )
470 {
471 ent->noDamageTeam = (team_t)GetIDForString( TeamTable, ent->team );
472 ent->team = NULL;
473 }
474
475 InitTrigger( ent );
476 gi.linkentity (ent);
477}
478
479/*QUAKED trigger_once (.5 1 .5) ? PLAYERONLY FACING USE_BUTTON FIRE_BUTTON NPCONLY x x INACTIVE MULTIPLE
480PLAYERONLY - only a player can trigger this by touch

Callers

nothing calls this directly

Calls 8

Q_strncpyzFunction · 0.85
G_SpawnStringFunction · 0.70
G_SoundIndexFunction · 0.70
G_SpawnFloatFunction · 0.70
G_SpawnIntFunction · 0.70
InitTriggerFunction · 0.70
COM_DefaultExtensionFunction · 0.50
GetIDForStringFunction · 0.50

Tested by

no test coverage detected