- chickenarrow and movefireball.

This commit is contained in:
Christoph Oelckers 2020-10-22 19:59:38 +02:00
parent a3860de440
commit c5f7c29ead
2 changed files with 32 additions and 29 deletions

View file

@ -1553,30 +1553,32 @@ void movestandables_d(void)
//
//---------------------------------------------------------------------------
static bool movefireball(int i)
static bool movefireball(DDukeActor* actor)
{
auto s = &sprite[i];
auto ht = &hittype[i];
auto s = &actor->s;
auto Owner = actor->GetOwner();
if (sector[s->sectnum].lotag == 2)
{
deletesprite(i);
deletesprite(actor);
return true;
}
if (sprite[s->owner].picnum != FIREBALL)
if (!Owner || Owner->s.picnum != FIREBALL)
{
if (ht->temp_data[0] >= 1 && ht->temp_data[0] < 6)
if (actor->temp_data[0] >= 1 && actor->temp_data[0] < 6)
{
float siz = 1.0f - (ht->temp_data[0] * 0.2f);
int trail = ht->temp_data[1];
int j = ht->temp_data[1] = fi.spawn(i, FIREBALL);
auto spr = &sprite[j];
float siz = 1.0f - (actor->temp_data[0] * 0.2f);
// This still needs work- it stores an actor reference in a general purpose integer field.
int trail = actor->temp_data[1];
auto ball = spawn(actor, FIREBALL);
auto spr = &ball->s;
actor->temp_data[1] = ball->GetIndex();
spr->xvel = s->xvel;
spr->yvel = s->yvel;
spr->zvel = s->zvel;
if (ht->temp_data[0] > 1)
if (actor->temp_data[0] > 1)
{
FireProj* proj = fire.CheckKey(trail);
if (proj != nullptr)
@ -1589,15 +1591,16 @@ static bool movefireball(int i)
spr->zvel = proj->zv;
}
}
spr->yrepeat = spr->xrepeat = (short)(sprite[i].xrepeat * siz);
spr->cstat = sprite[i].cstat;
spr->yrepeat = spr->xrepeat = (short)(s->xrepeat * siz);
spr->cstat = s->cstat;
spr->extra = 0;
FireProj proj = { spr->x, spr->y, spr->z, spr->xvel, spr->yvel, spr->zvel };
fire.Insert(j, proj);
changespritestat((short)j, (short)4);
fire.Insert(ball->GetIndex(), proj);
changespritestat(ball, STAT_PROJECTILE);
}
ht->temp_data[0]++;
actor->temp_data[0]++;
}
if (s->zvel < 15000)
s->zvel += 200;
@ -1799,7 +1802,7 @@ static void weaponcommon_d(int i)
break;
case FIREBALL:
if (movefireball(i)) return;
if (movefireball(&hittype[i])) return;
break;
}

View file

@ -1103,27 +1103,27 @@ void movestandables_r(void)
//
//---------------------------------------------------------------------------
static void chickenarrow(int i)
static void chickenarrow(DDukeActor* actor)
{
auto s = &sprite[i];
auto s = &actor->s;
s->hitag++;
if (hittype[i].picnum != BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2)
if (actor->picnum != BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2)
{
int j = fi.spawn(i, SMALLSMOKE);
sprite[j].z += (1 << 8);
auto spawned = spawn(actor, SMALLSMOKE);
spawned->s.z += (1 << 8);
if ((krand() & 15) == 2)
{
j = fi.spawn(i, 1310);
spawn(actor, MONEY);
}
}
if (sprite[s->lotag].extra <= 0)
auto ts = &hittype[s->lotag]; // Grrrr...
if (ts->s.extra <= 0)
s->lotag = 0;
if (s->lotag != 0 && s->hitag > 5)
{
spritetype* ts;
int ang, ang2, ang3;
ts = &sprite[s->lotag];
ang = getangle(ts->x - s->x, ts->y - s->y);
ang = getangle(ts->s.x - s->x, ts->s.y - s->y);
ang2 = ang - s->ang;
ang3 = abs(ang2);
if (ang2 < 100)
@ -1401,7 +1401,7 @@ static void weaponcommon_r(int i)
break;
case RPG2:
if (!isRRRA()) break;
chickenarrow(i);
chickenarrow(&hittype[i]);
break;
case RRTILE1790: