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

Function NPC_Spawn_Do

code/game/NPC_spawn.cpp:1442–1790  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1440*/
1441
1442gentity_t *NPC_Spawn_Do( gentity_t *ent, qboolean fullSpawnNow )
1443{
1444 gentity_t *newent;
1445 int index;
1446 vec3_t saveOrg;
1447
1448/* //Do extra code for stasis spawners
1449 if ( Q_stricmp( ent->classname, "NPC_Stasis" ) == 0 )
1450 {
1451 if ( NPC_StasisSpawn_Go( ent ) == qfalse )
1452 return;
1453 }
1454*/
1455
1456 // 4/18/03 kef -- don't let guys spawn into other guys
1457 if (ent->spawnflags & 4096)
1458 {
1459 if (!NPC_SafeSpawn(ent, 64))
1460 {
1461 return NULL;
1462 }
1463 }
1464
1465 //Test for drop to floor
1466 if ( ent->spawnflags & NSF_DROP_TO_FLOOR )
1467 {
1468 trace_t tr;
1469 vec3_t bottom;
1470
1471 VectorCopy( ent->currentOrigin, saveOrg );
1472 VectorCopy( ent->currentOrigin, bottom );
1473 bottom[2] = MIN_WORLD_COORD;
1474 gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, bottom, ent->s.number, MASK_NPCSOLID, (EG2_Collision)0, 0 );
1475 if ( !tr.allsolid && !tr.startsolid && tr.fraction < 1.0 )
1476 {
1477 G_SetOrigin( ent, tr.endpos );
1478 }
1479 }
1480
1481 //Check the spawner's count
1482 if( ent->count != -1 )
1483 {
1484 ent->count--;
1485
1486 if( ent->count <= 0 )
1487 {
1488 ent->e_UseFunc = useF_NULL;//never again
1489 //will be removed below
1490 }
1491 }
1492
1493 newent = G_Spawn();
1494
1495 if ( newent == NULL )
1496 {
1497 gi.Printf ( S_COLOR_RED"ERROR: NPC G_Spawn failed\n" );
1498
1499 if ( ent->spawnflags & NSF_DROP_TO_FLOOR )

Callers 2

G_VehicleSpawnFunction · 0.70
NPC_Spawn_GoFunction · 0.70

Calls 15

NPC_SafeSpawnFunction · 0.85
VectorCopyFunction · 0.85
Q_strlwrFunction · 0.85
Q_stricmpFunction · 0.85
VectorClearFunction · 0.85
MallocMethod · 0.80
G_SetOriginFunction · 0.70
G_SpawnFunction · 0.70
G_NewStringFunction · 0.70
BG_VehicleGetIndexFunction · 0.70
Com_PrintfFunction · 0.70
G_FreeEntityFunction · 0.70

Tested by

no test coverage detected