| 920 | */ |
| 921 | |
| 922 | void NPC_SetWeapons( gentity_t *ent ) |
| 923 | { |
| 924 | int bestWeap = WP_NONE; |
| 925 | int weapons = NPC_WeaponsForTeam( ent->client->playerTeam, ent->spawnflags, ent->NPC_type ); |
| 926 | |
| 927 | ent->client->ps.stats[STAT_WEAPONS] = 0; |
| 928 | for ( int curWeap = WP_SABER; curWeap < WP_NUM_WEAPONS; curWeap++ ) |
| 929 | { |
| 930 | if ( (weapons & ( 1 << curWeap )) ) |
| 931 | { |
| 932 | ent->client->ps.stats[STAT_WEAPONS] |= ( 1 << curWeap ); |
| 933 | RegisterItem( FindItemForWeapon( (weapon_t)(curWeap) ) ); //precache the weapon |
| 934 | ent->NPC->currentAmmo = ent->client->ps.ammo[weaponData[curWeap].ammoIndex] = 100;//FIXME: max ammo |
| 935 | |
| 936 | if ( bestWeap == WP_SABER ) |
| 937 | { |
| 938 | // still want to register other weapons -- force saber to be best weap |
| 939 | continue; |
| 940 | } |
| 941 | |
| 942 | if ( curWeap == WP_MELEE ) |
| 943 | { |
| 944 | if ( bestWeap == WP_NONE ) |
| 945 | {// We'll only consider giving Melee since we haven't found anything better yet. |
| 946 | bestWeap = curWeap; |
| 947 | } |
| 948 | } |
| 949 | else if ( curWeap > bestWeap || bestWeap == WP_MELEE ) |
| 950 | { |
| 951 | // This will never override saber as best weap. Also will override WP_MELEE if something better comes later in the list |
| 952 | bestWeap = curWeap; |
| 953 | } |
| 954 | } |
| 955 | } |
| 956 | |
| 957 | ent->client->ps.weapon = bestWeap; |
| 958 | } |
| 959 | |
| 960 | /* |
| 961 | ------------------------- |
no test coverage detected