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

Function NPC_PrecacheWeapons

code/game/NPC_stats.cpp:1367–1394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1365
1366extern int NPC_WeaponsForTeam( team_t team, int spawnflags, const char *NPC_type );
1367void NPC_PrecacheWeapons( team_t playerTeam, int spawnflags, char *NPCtype )
1368{
1369 int weapons = NPC_WeaponsForTeam( playerTeam, spawnflags, NPCtype );
1370 gitem_t *item;
1371 for ( int curWeap = WP_SABER; curWeap < WP_NUM_WEAPONS; curWeap++ )
1372 {
1373 if ( (weapons & ( 1 << curWeap )) )
1374 {
1375 item = FindItemForWeapon( ((weapon_t)(curWeap)) ); //precache the weapon
1376 CG_RegisterItemSounds( (item-bg_itemlist) );
1377 CG_RegisterItemVisuals( (item-bg_itemlist) );
1378 //precache the in-hand/in-world ghoul2 weapon model
1379
1380 char weaponModel[64];
1381
1382 strcpy (weaponModel, weaponData[curWeap].weaponMdl);
1383 if (char *spot = strstr(weaponModel, ".md3") ) {
1384 *spot = 0;
1385 spot = strstr(weaponModel, "_w");//i'm using the in view weapon array instead of scanning the item list, so put the _w back on
1386 if (!spot) {
1387 strcat (weaponModel, "_w");
1388 }
1389 strcat (weaponModel, ".glm"); //and change to ghoul2
1390 }
1391 gi.G2API_PrecacheGhoul2Model( weaponModel ); // correct way is item->world_model
1392 }
1393 }
1394}
1395
1396/*
1397void NPC_PrecacheByClassName ( char *NPCName )

Callers 1

CG_NPC_PrecacheFunction · 0.70

Calls 4

NPC_WeaponsForTeamFunction · 0.70
FindItemForWeaponFunction · 0.70
CG_RegisterItemSoundsFunction · 0.50
CG_RegisterItemVisualsFunction · 0.50

Tested by

no test coverage detected