Thanks for the replies!
Glad to know the changeyaw and pitch functions are not related to the aim function
RenegadeC, would that mean I would have to modifiy and add it to the engine code, or the progs code? I think it'd be harder to somehow make the view gun angle change direction to adjust where its actually aiming at with auto aim turned on. Surely theres *something* in the below code I only have to add or tweak to enable horizontal auto aim? Heres the unchanged pr_aim function:
Code: Select all
/*
=============
PF_aim
Pick a vector for the player to shoot along
vector aim(entity, missilespeed)
=============
*/
cvar_t sv_aim = {"sv_aim", "0.93"};
void PF_aim (void)
{
edict_t *ent, *check, *bestent;
vec3_t start, dir, end, bestdir;
int i, j;
trace_t tr;
float dist, bestdist;
float speed;
ent = G_EDICT(OFS_PARM0);
speed = G_FLOAT(OFS_PARM1);
VectorCopy (ent->v.origin, start);
start[2] += 20;
// try sending a trace straight
VectorCopy (pr_global_struct->v_forward, dir);
VectorMA (start, 2048, dir, end);
tr = SV_Move (start, vec3_origin, vec3_origin, end, false, ent);
if (tr.ent && tr.ent->v.takedamage == DAMAGE_AIM
&& (!teamplay.value || ent->v.team <=0 || ent->v.team != tr.ent->v.team) )
{
VectorCopy (pr_global_struct->v_forward, G_VECTOR(OFS_RETURN));
return;
}
// try all possible entities
VectorCopy (dir, bestdir);
bestdist = sv_aim.value;
bestent = NULL;
check = NEXT_EDICT(sv.edicts);
for (i=1 ; i<sv.num_edicts ; i++, check = NEXT_EDICT(check) )
{
if (check->v.takedamage != DAMAGE_AIM)
continue;
if (check == ent)
continue;
if (teamplay.value && ent->v.team > 0 && ent->v.team == check->v.team)
continue; // don't aim at teammate
for (j=0 ; j<3 ; j++)
end[j] = check->v.origin[j]
+ 0.5*(check->v.mins[j] + check->v.maxs[j]);
VectorSubtract (end, start, dir);
VectorNormalize (dir);
dist = DotProduct (dir, pr_global_struct->v_forward);
if (dist < bestdist)
continue; // to far to turn
tr = SV_Move (start, vec3_origin, vec3_origin, end, false, ent);
if (tr.ent == check)
{ // can shoot at this one
bestdist = dist;
bestent = check;
}
}
if (bestent)
{
VectorSubtract (bestent->v.origin, ent->v.origin, dir);
dist = DotProduct (dir, pr_global_struct->v_forward);
VectorScale (pr_global_struct->v_forward, dist, end);
end[2] = dir[2];
VectorNormalize (end);
VectorCopy (end, G_VECTOR(OFS_RETURN));
}
else
{
VectorCopy (bestdir, G_VECTOR(OFS_RETURN));
}
}
It be handy to get the crosshair to move to where the weapon is autoaiming at too, hopefully that won't be too dissimilar to the weapon angle view modification.
Oh, thought I'd show what it is I'm working on exactly, screenshots taken directly off the PSP
http://bladebattles.com/kurok/kurok_screenshots/
Maps, models (minus the Raptors dino model, borrowing that until I make my own
![Razz :P](./images/smilies/icon_razz.gif)
), sprites and HUD mine, except for the health and ammo boxes I've yet to replace. Fully functional bow and arrow, god coding that so it behaves accurately was a pain.