Hendricks266, on 18 April 2015 - 01:52 PM, said:
Perhaps this line should Xcalloc instead:
g_tile[j].proj = (projectile_t *) Xmalloc(sizeof(projectile_t));
I don't think that's the issue. We copy DefaultProjectile into it right afterwards:
if (g_tile[j].proj == NULL)
{
g_tile[j].proj = (projectile_t *) Xmalloc(sizeof(projectile_t));
*g_tile[j].proj = *(projectile_t *)&DefaultProjectile;
g_numProjectiles += 2;
}
It's more that the default projectile's extra is 100. That thing is an amalgamation of different projectiles!
Quote
Either way, you would need to define PROJ_EXTRA and PROJ_EXTRA_RAND.
Right. "Extra" = health, one forgets this quickly :-/. This would make the first attempt as follows:
defineprojectile SHOTSPARK1 PROJ_WORKSLIKE 1 // NOTE: w/o PROJECTILE_ACCURATE_AUTOAIM
// (omitted properties hopefully same as hard-coded or unused ...)
// See A_Spawn()/BULLETHOLE__STATIC:
defineprojectile SHOTSPARK1 PROJ_XREPEAT 3
defineprojectile SHOTSPARK1 PROJ_YREPEAT 3
// (omitted properties hopefully same as hard-coded or unused ...)
defineprojectile SHOTSPARK1 PROJ_EXTRA PISTOL_WEAPON_STRENGTH // <- def from USER.CON
defineprojectile SHOTSPARK1 PROJ_EXTRA_RAND 6
// (omitted properties hopefully same as hard-coded or unused ...)
However, omitting PROJECTILE_ACCURATE_AUTOAIM from PROJ_WORKSLIKE does not prevent auto-aim, which might be considered a bug. This is because in P_PreFireHitscan(), we call G_GetAutoAimAngle() unconditionally of the former:
// Prepare hitscan weapon fired from player p.
static void P_PreFireHitscan(int32_t i, int32_t p, int32_t atwith,
vec3_t *srcvect, int32_t *zvel, int16_t *sa,
int32_t accurate_autoaim_p,
int32_t not_accurate_p)
{
int32_t angRange=32;
int32_t zRange=256;
int32_t j = GetAutoAimAngle(i, p, atwith, 5<<8, 0+1, srcvect, 256, zvel, sa);
// (...)
if (accurate_autoaim_p)
{
if (!ps->auto_aim)
{
(...)
}
if (j == -1)
{
*zvel = (100-ps->horiz-ps->horizoff)<<5;
Proj_MaybeAddSpread(not_accurate_p, zvel, sa, zRange, angRange);
}
Anyhow, for the problem at hand, setting AUTOAIMANGLE in EVENT_GETAUTOAIMANGLE is much more intuitive.