| 983 | //-------------------------------------------------------------- |
| 984 | extern qboolean stop_icarus; |
| 985 | void NPC_Begin (gentity_t *ent) |
| 986 | { |
| 987 | vec3_t spawn_origin, spawn_angles; |
| 988 | gclient_t *client; |
| 989 | usercmd_t ucmd; |
| 990 | gentity_t *spawnPoint = NULL; |
| 991 | |
| 992 | memset( &ucmd, 0, sizeof( ucmd ) ); |
| 993 | |
| 994 | if ( !(ent->spawnflags & SFB_NOTSOLID) ) |
| 995 | {//No NPCs should telefrag |
| 996 | if ( Q_stricmp( ent->NPC_type, "nullDriver") == 0 ) |
| 997 | {//FIXME: should be a better way to check this |
| 998 | } |
| 999 | else if( SpotWouldTelefrag( ent, TEAM_FREE ) )//(team_t)(ent->client->playerTeam) |
| 1000 | { |
| 1001 | if ( ent->wait < 0 ) |
| 1002 | {//remove yourself |
| 1003 | Quake3Game()->DebugPrint( IGameInterface::WL_ERROR, "NPC %s could not spawn, firing target3 (%s) and removing self\n", ent->targetname, ent->target3 ); |
| 1004 | //Fire off our target3 |
| 1005 | G_UseTargets2( ent, ent, ent->target3 ); |
| 1006 | |
| 1007 | //Kill us |
| 1008 | ent->e_ThinkFunc = thinkF_G_FreeEntity; |
| 1009 | ent->nextthink = level.time + 100; |
| 1010 | } |
| 1011 | else |
| 1012 | { |
| 1013 | Quake3Game()->DebugPrint( IGameInterface::WL_ERROR, "NPC %s at (%5.0f %5.0f %5.0f) couldn't spawn, waiting %4.2f secs to try again\n", |
| 1014 | ent->targetname, ent->s.origin[0], ent->s.origin[1], ent->s.origin[2], ent->wait/1000.0f ); |
| 1015 | ent->e_ThinkFunc = thinkF_NPC_Begin; |
| 1016 | ent->nextthink = level.time + ent->wait;//try again in half a second |
| 1017 | } |
| 1018 | return; |
| 1019 | } |
| 1020 | } |
| 1021 | //Spawn effect |
| 1022 | NPC_SpawnEffect( ent ); |
| 1023 | |
| 1024 | VectorCopy( ent->client->ps.origin, spawn_origin); |
| 1025 | VectorCopy( ent->s.angles, spawn_angles); |
| 1026 | spawn_angles[YAW] = ent->NPC->desiredYaw; |
| 1027 | |
| 1028 | client = ent->client; |
| 1029 | |
| 1030 | // increment the spawncount so the client will detect the respawn |
| 1031 | client->ps.persistant[PERS_SPAWN_COUNT]++; |
| 1032 | |
| 1033 | client->airOutTime = level.time + 12000; |
| 1034 | |
| 1035 | client->ps.clientNum = ent->s.number; |
| 1036 | // clear entity values |
| 1037 | |
| 1038 | if ( ent->health ) // Was health supplied in map |
| 1039 | { |
| 1040 | ent->max_health = client->pers.maxHealth = client->ps.stats[STAT_MAX_HEALTH] = ent->health; |
| 1041 | } |
| 1042 | else if ( ent->NPC->stats.health ) // Was health supplied in NPC.cfg? |
no test coverage detected