- henstand and bowling.

This commit is contained in:
Christoph Oelckers 2020-10-22 22:31:10 +02:00
parent a31a19d430
commit 2ad31247ec
2 changed files with 198 additions and 207 deletions

View File

@ -38,7 +38,7 @@ BEGIN_DUKE_NS
void dojaildoor();
void moveminecart();
void ballreturn(short spr);
void ballreturn(DDukeActor* spr);
short pinsectorresetdown(short sect);
short pinsectorresetup(short sect);
short checkpins(short sect);
@ -2767,20 +2767,19 @@ DETONATEB:
//
//---------------------------------------------------------------------------
static int henstand(int i)
static int henstand(DDukeActor *actor)
{
spritetype* s = &sprite[i];
auto t = &hittype[i].temp_data[0];
auto s = &actor->s;
auto t = &actor->temp_data[0];
int sect = s->sectnum;
int j;
if (s->picnum == HENSTAND || s->picnum == HENSTAND + 1)
{
s->lotag--;
if (s->lotag == 0)
{
fi.spawn(i, HEN);
deletesprite(i);
spawn(actor, HEN);
deletesprite(actor);
return 1;
}
}
@ -2788,32 +2787,33 @@ static int henstand(int i)
s->xvel = 0;
if (s->xvel)
{
makeitfall(i);
j = fi.movesprite(i,
makeitfall(actor);
Collision coll;
movesprite_ex(actor,
(sintable[(s->ang + 512) & 2047] * s->xvel) >> 14,
(sintable[s->ang & 2047] * s->xvel) >> 14,
s->zvel, CLIPMASK0);
if (j & 49152)
s->zvel, CLIPMASK0, coll);
if (coll.type)
{
if ((j & 49152) == 32768)
if (coll.type == kHitWall)
{
j &= (MAXWALLS - 1);
int j = coll.index;
int k = getangle(
wall[wall[j].point2].x - wall[j].x,
wall[wall[j].point2].y - wall[j].y);
s->ang = ((k << 1) - s->ang) & 2047;
}
else if ((j & 49152) == 49152)
else if (coll.type == kHitSprite)
{
j &= (MAXSPRITES - 1);
fi.checkhitsprite(i, j);
if (sprite[j].picnum == HEN)
auto hitact = coll.actor;
fi.checkhitsprite(actor->GetIndex(), hitact->GetIndex());
if (hitact->s.picnum == HEN)
{
int ns = fi.spawn(j, HENSTAND);
deletesprite(j);
sprite[ns].xvel = 32;
sprite[ns].lotag = 40;
sprite[ns].ang = s->ang;
auto ns = spawn(hitact, HENSTAND);
deletesprite(hitact);
ns->s.xvel = 32;
ns->s.lotag = 40;
ns->s.ang = s->ang;
}
}
}
@ -2834,18 +2834,18 @@ static int henstand(int i)
if (krand() & 1)
s->picnum = HENSTAND + 1;
if (!s->xvel)
return 2;//deletesprite(i); still needs to run a script but should not do on a deleted object
return 2;//deletesprite(actor); still needs to run a script but should not do on a deleted object
}
if (s->picnum == RRTILE3440 || (s->picnum == RRTILE3440 + 1 && !s->xvel))
{
return 2;//deletesprite(i); still needs to run a script but should not do on a deleted object
return 2;//deletesprite(actor); still needs to run a script but should not do on a deleted object
}
}
else if (sector[s->sectnum].lotag == 900)
{
if (s->picnum == BOWLINGBALL)
ballreturn(i);
deletesprite(i);
ballreturn(actor);
deletesprite(actor);
return 1;
}
return 0;
@ -3023,7 +3023,7 @@ void moveactors_r(void)
case HENSTAND:
case HENSTAND+1:
{
int todo = henstand(i);
int todo = henstand(&hittype[i]);
if (todo == 2) deleteafterexecute = true;
if (todo == 1) continue;
break;

View File

@ -36,25 +36,22 @@ BEGIN_DUKE_NS
short pinsectorresetdown(short sect);
void ballreturn(short spr)
void ballreturn(DDukeActor *ball)
{
int j, i;
StatIterator it(STAT_BOWLING);
while ((i = it.NextIndex()) >= 0)
DukeStatIterator it(STAT_BOWLING);
while (auto act = it.Next())
{
auto si = &sprite[i];
if (si->picnum == RRTILE281 && sprite[spr].sectnum == si->sectnum)
if (act->s.picnum == RRTILE281 && ball->s.sectnum == act->s.sectnum)
{
StatIterator it2(STAT_BOWLING);
while ((j = it2.NextIndex()) >= 0)
DukeStatIterator it2(STAT_BOWLING);
while (auto act2 = it2.Next())
{
auto sj = &sprite[j];
if (sj->picnum == RRTILE282 && si->hitag == sj->hitag)
fi.spawn(j, BOWLINGBALLSPRITE);
if (sj->picnum == RRTILE280 && si->hitag == sj->hitag && sj->lotag == 0)
if (act2->s.picnum == RRTILE282 && act->s.hitag == act2->s.hitag)
spawn(act2, BOWLINGBALLSPRITE);
if (act2->s.picnum == RRTILE280 && act->s.hitag == act2->s.hitag && act2->s.lotag == 0)
{
sj->lotag = 100;
sj->extra++;
act2->s.lotag = 100;
act2->s.extra++;
}
}
}
@ -63,15 +60,12 @@ void ballreturn(short spr)
short pinsectorresetdown(short sect)
{
int vel, j;
j = getanimationgoal(anim_ceilingz, sect);
int j = getanimationgoal(anim_ceilingz, sect);
if (j == -1)
{
j = sector[sect].floorz;
vel = 64;
setanimation(sect, anim_ceilingz, sect, j, vel);
setanimation(sect, anim_ceilingz, sect, j, 64);
return 1;
}
return 0;
@ -79,15 +73,12 @@ short pinsectorresetdown(short sect)
short pinsectorresetup(short sect)
{
int vel, j;
j = getanimationgoal(anim_ceilingz, sect);
int j = getanimationgoal(anim_ceilingz, sect);
if (j == -1)
{
j = sector[nextsectorneighborz(sect, sector[sect].ceilingz, -1, -1)].ceilingz;
vel = 64;
setanimation(sect, anim_ceilingz, sect, j, vel);
setanimation(sect, anim_ceilingz, sect, j, 64);
return 1;
}
return 0;
@ -101,27 +92,27 @@ short checkpins(short sect)
short tag;
pin = 0;
for(i=0;i<10;i++) pins[i] = 0;
for (i = 0; i < 10; i++) pins[i] = 0;
SectIterator it(sect);
while ((i = it.NextIndex()) >= 0)
DukeSectIterator it(sect);
while (auto a2 = it.Next())
{
if (sprite[i].picnum == RRTILE3440)
if (a2->s.picnum == RRTILE3440)
{
pin++;
pins[sprite[i].lotag] = 1;
pins[a2->s.lotag] = 1;
}
if (sprite[i].picnum == RRTILE280)
if (a2->s.picnum == RRTILE280)
{
tag = sprite[i].hitag;
tag = a2->s.hitag;
}
}
if (tag)
{
tag += 2024;
tileCopySection(2024,0,0,128,64,tag,0,0);
for(i=0;i<10;i++)
tileCopySection(2024, 0, 0, 128, 64, tag, 0, 0);
for (i = 0; i < 10; i++)
{
if (pins[i] == 1)
{
@ -168,7 +159,7 @@ short checkpins(short sect)
y = 24;
break;
}
tileCopySection(2023,0,0,8,8,tag,x-4,y-10);
tileCopySection(2023, 0, 0, 8, 8, tag, x - 4, y - 10);
}
}
}
@ -178,39 +169,39 @@ short checkpins(short sect)
void resetpins(short sect)
{
short i, j, tag;
int i, tag;
int x, y;
SectIterator it(sect);
while ((i = it.NextIndex()) >= 0)
DukeSectIterator it(sect);
while (auto a2 = it.Next())
{
if (sprite[i].picnum == 3440)
deletesprite(i);
if (a2->s.picnum == RRTILE3440)
deletesprite(a2);
}
it.Reset(sect);
while ((i = it.NextIndex()) >= 0)
while (auto a2 = it.Next())
{
if (sprite[i].picnum == 283)
if (a2->s.picnum == 283)
{
j = fi.spawn(i,3440);
sprite[j].lotag = sprite[i].lotag;
if (sprite[j].lotag == 3 || sprite[j].lotag == 5)
auto spawned = spawn(a2, RRTILE3440);
spawned->s.lotag = a2->s.lotag;
if (spawned->s.lotag == 3 || spawned->s.lotag == 5)
{
sprite[j].clipdist = (1+(krand()%1))*16+32;
spawned->s.clipdist = (1 + (krand() % 1)) * 16 + 32;
}
else
{
sprite[j].clipdist = (1+(krand()%1))*16+32;
spawned->s.clipdist = (1 + (krand() % 1)) * 16 + 32;
}
sprite[j].ang -= ((krand()&32)-(krand()&64))&2047;
spawned->s.ang -= ((krand() & 32) - (krand() & 64)) & 2047;
}
if (sprite[i].picnum == 280)
tag = sprite[i].hitag;
if (a2->s.picnum == 280)
tag = a2->s.hitag;
}
if (tag)
{
tag += LANEPICS+1;
tileCopySection(LANEPICS+1,0,0,128,64,tag,0,0);
for(i=0;i<10;i++)
tag += LANEPICS + 1;
tileCopySection(LANEPICS + 1, 0, 0, 128, 64, tag, 0, 0);
for (i = 0; i < 10; i++)
{
switch (i)
{
@ -255,7 +246,7 @@ void resetpins(short sect)
y = 24;
break;
}
tileCopySection(LANEPICS,0,0,8,8,tag,x-4,y-10);
tileCopySection(LANEPICS, 0, 0, 8, 8, tag, x - 4, y - 10);
}
}
}
@ -265,13 +256,13 @@ void resetlanepics(void)
int x, y;
short i;
short tag, pic;
for(tag=0;tag<4;tag++)
for (tag = 0; tag < 4; tag++)
{
pic = tag + 1;
if (pic == 0) continue;
pic += LANEPICS+1;
tileCopySection(LANEPICS+1,0,0,128,64, pic,0,0);
for(i=0;i<10;i++)
pic += LANEPICS + 1;
tileCopySection(LANEPICS + 1, 0, 0, 128, 64, pic, 0, 0);
for (i = 0; i < 10; i++)
{
switch (i)
{
@ -316,7 +307,7 @@ void resetlanepics(void)
y = 24;
break;
}
tileCopySection(LANEPICS,0,0,8,8,pic,x-4,y-10);
tileCopySection(LANEPICS, 0, 0, 8, 8, pic, x - 4, y - 10);
}
}
}