Add missing code from JKO for enemy aim at player

This commit is contained in:
Simon 2023-03-20 21:34:26 +00:00
parent 3fcbf553d6
commit 1534cad9cf

View file

@ -28,6 +28,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include "wp_saber.h"
#include "g_functions.h"
#include "../cgame/cg_local.h" // Evil? Maybe. Necessary? Absolutely.
extern void G_AddVoiceEvent( gentity_t *self, int event, int speakDebounceTime );
extern void G_SetEnemy( gentity_t *self, gentity_t *enemy );
extern qboolean NPC_CheckLookTarget( gentity_t *self );
@ -2253,7 +2255,16 @@ int NPC_ShotEntity( gentity_t *ent, vec3_t impactPos )
{
CalcEntitySpot( NPC, SPOT_WEAPON, muzzle );
}
CalcEntitySpot( ent, SPOT_CHEST, targ );
int location = Q_irand(0, 9);
if (location <= 4 || cg.renderingThirdPerson ||
ent->client == NULL || ent->client->ps.clientNum != 0) { //50% chance (unless ent is not the player, then always go for chest, which is original behaviour)
CalcEntitySpot(ent, SPOT_CHEST, targ);
} else if (location <= 7) { //30% chance
CalcEntitySpot(ent, SPOT_LEGS, targ);
} else { // 20% chance
CalcEntitySpot(ent, SPOT_HEAD, targ);
}
// add aim error
// use weapon instead of specific npc types, although you could add certain npc classes if you wanted