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

Function NPC_CheckCharmed

codeJK2/game/NPC_utils.cpp:1438–1457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1436*/
1437extern void G_AddVoiceEvent( gentity_t *self, int event, int speakDebounceTime );
1438void NPC_CheckCharmed( void )
1439{
1440 if ( NPC->client->playerTeam == TEAM_PLAYER && NPCInfo->charmedTime && NPCInfo->charmedTime < level.time && NPC->client )
1441 {//we were charmed, set us back!
1442 //NOTE: presumptions here...
1443 team_t savTeam = NPC->client->enemyTeam;
1444 NPC->client->enemyTeam = NPC->client->playerTeam;
1445 NPC->client->playerTeam = savTeam;
1446 NPC->client->leader = NULL;
1447 if ( NPCInfo->tempBehavior == BS_FOLLOW_LEADER )
1448 {
1449 NPCInfo->tempBehavior = BS_DEFAULT;
1450 }
1451 G_ClearEnemy( NPC );
1452 NPCInfo->charmedTime = 0;
1453 //say something to let player know you've snapped out of it
1454 G_AddVoiceEvent( NPC, Q_irand(EV_CONFUSE1, EV_CONFUSE3), 2000 );
1455 }
1456
1457}
1458

Callers 1

NPC_RunBehaviorFunction · 0.70

Calls 3

Q_irandFunction · 0.85
G_ClearEnemyFunction · 0.70
G_AddVoiceEventFunction · 0.70

Tested by

no test coverage detected