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

View file

@ -36,25 +36,22 @@ BEGIN_DUKE_NS
short pinsectorresetdown(short sect); short pinsectorresetdown(short sect);
void ballreturn(short spr) void ballreturn(DDukeActor *ball)
{ {
int j, i; DukeStatIterator it(STAT_BOWLING);
StatIterator it(STAT_BOWLING); while (auto act = it.Next())
while ((i = it.NextIndex()) >= 0)
{ {
auto si = &sprite[i]; if (act->s.picnum == RRTILE281 && ball->s.sectnum == act->s.sectnum)
if (si->picnum == RRTILE281 && sprite[spr].sectnum == si->sectnum)
{ {
StatIterator it2(STAT_BOWLING); DukeStatIterator it2(STAT_BOWLING);
while ((j = it2.NextIndex()) >= 0) while (auto act2 = it2.Next())
{ {
auto sj = &sprite[j]; if (act2->s.picnum == RRTILE282 && act->s.hitag == act2->s.hitag)
if (sj->picnum == RRTILE282 && si->hitag == sj->hitag) spawn(act2, BOWLINGBALLSPRITE);
fi.spawn(j, BOWLINGBALLSPRITE); if (act2->s.picnum == RRTILE280 && act->s.hitag == act2->s.hitag && act2->s.lotag == 0)
if (sj->picnum == RRTILE280 && si->hitag == sj->hitag && sj->lotag == 0)
{ {
sj->lotag = 100; act2->s.lotag = 100;
sj->extra++; act2->s.extra++;
} }
} }
} }
@ -63,15 +60,12 @@ void ballreturn(short spr)
short pinsectorresetdown(short sect) short pinsectorresetdown(short sect)
{ {
int vel, j; int j = getanimationgoal(anim_ceilingz, sect);
j = getanimationgoal(anim_ceilingz, sect);
if (j == -1) if (j == -1)
{ {
j = sector[sect].floorz; j = sector[sect].floorz;
vel = 64; setanimation(sect, anim_ceilingz, sect, j, 64);
setanimation(sect, anim_ceilingz, sect, j, vel);
return 1; return 1;
} }
return 0; return 0;
@ -79,15 +73,12 @@ short pinsectorresetdown(short sect)
short pinsectorresetup(short sect) short pinsectorresetup(short sect)
{ {
int vel, j; int j = getanimationgoal(anim_ceilingz, sect);
j = getanimationgoal(anim_ceilingz, sect);
if (j == -1) if (j == -1)
{ {
j = sector[nextsectorneighborz(sect, sector[sect].ceilingz, -1, -1)].ceilingz; j = sector[nextsectorneighborz(sect, sector[sect].ceilingz, -1, -1)].ceilingz;
vel = 64; setanimation(sect, anim_ceilingz, sect, j, 64);
setanimation(sect, anim_ceilingz, sect, j, vel);
return 1; return 1;
} }
return 0; return 0;
@ -99,76 +90,76 @@ short checkpins(short sect)
int x, y; int x, y;
short pins[10]; short pins[10];
short tag; short tag;
pin = 0;
for(i=0;i<10;i++) pins[i] = 0;
SectIterator it(sect); pin = 0;
while ((i = it.NextIndex()) >= 0) for (i = 0; i < 10; i++) pins[i] = 0;
DukeSectIterator it(sect);
while (auto a2 = it.Next())
{ {
if (sprite[i].picnum == RRTILE3440) if (a2->s.picnum == RRTILE3440)
{ {
pin++; 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) if (tag)
{ {
tag += 2024; tag += 2024;
tileCopySection(2024,0,0,128,64,tag,0,0); tileCopySection(2024, 0, 0, 128, 64, tag, 0, 0);
for(i=0;i<10;i++) for (i = 0; i < 10; i++)
{ {
if (pins[i] == 1) if (pins[i] == 1)
{ {
switch (i) switch (i)
{ {
case 0: case 0:
x = 64; x = 64;
y = 48; y = 48;
break; break;
case 1: case 1:
x = 56; x = 56;
y = 40; y = 40;
break; break;
case 2: case 2:
x = 72; x = 72;
y = 40; y = 40;
break; break;
case 3: case 3:
x = 48; x = 48;
y = 32; y = 32;
break; break;
case 4: case 4:
x = 64; x = 64;
y = 32; y = 32;
break; break;
case 5: case 5:
x = 80; x = 80;
y = 32; y = 32;
break; break;
case 6: case 6:
x = 40; x = 40;
y = 24; y = 24;
break; break;
case 7: case 7:
x = 56; x = 56;
y = 24; y = 24;
break; break;
case 8: case 8:
x = 72; x = 72;
y = 24; y = 24;
break; break;
case 9: case 9:
x = 88; x = 88;
y = 24; y = 24;
break; break;
} }
tileCopySection(2023,0,0,8,8,tag,x-4,y-10); tileCopySection(2023, 0, 0, 8, 8, tag, x - 4, y - 10);
} }
} }
} }
@ -178,84 +169,84 @@ short checkpins(short sect)
void resetpins(short sect) void resetpins(short sect)
{ {
short i, j, tag; int i, tag;
int x, y; int x, y;
SectIterator it(sect); DukeSectIterator it(sect);
while ((i = it.NextIndex()) >= 0) while (auto a2 = it.Next())
{ {
if (sprite[i].picnum == 3440) if (a2->s.picnum == RRTILE3440)
deletesprite(i); deletesprite(a2);
} }
it.Reset(sect); 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); auto spawned = spawn(a2, RRTILE3440);
sprite[j].lotag = sprite[i].lotag; spawned->s.lotag = a2->s.lotag;
if (sprite[j].lotag == 3 || sprite[j].lotag == 5) 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 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) if (a2->s.picnum == 280)
tag = sprite[i].hitag; tag = a2->s.hitag;
} }
if (tag) if (tag)
{ {
tag += LANEPICS+1; tag += LANEPICS + 1;
tileCopySection(LANEPICS+1,0,0,128,64,tag,0,0); tileCopySection(LANEPICS + 1, 0, 0, 128, 64, tag, 0, 0);
for(i=0;i<10;i++) for (i = 0; i < 10; i++)
{ {
switch (i) switch (i)
{ {
case 0: case 0:
x = 64; x = 64;
y = 48; y = 48;
break; break;
case 1: case 1:
x = 56; x = 56;
y = 40; y = 40;
break; break;
case 2: case 2:
x = 72; x = 72;
y = 40; y = 40;
break; break;
case 3: case 3:
x = 48; x = 48;
y = 32; y = 32;
break; break;
case 4: case 4:
x = 64; x = 64;
y = 32; y = 32;
break; break;
case 5: case 5:
x = 80; x = 80;
y = 32; y = 32;
break; break;
case 6: case 6:
x = 40; x = 40;
y = 24; y = 24;
break; break;
case 7: case 7:
x = 56; x = 56;
y = 24; y = 24;
break; break;
case 8: case 8:
x = 72; x = 72;
y = 24; y = 24;
break; break;
case 9: case 9:
x = 88; x = 88;
y = 24; y = 24;
break; break;
} }
tileCopySection(LANEPICS,0,0,8,8,tag,x-4,y-10); tileCopySection(LANEPICS, 0, 0, 8, 8, tag, x - 4, y - 10);
} }
} }
} }
@ -265,58 +256,58 @@ void resetlanepics(void)
int x, y; int x, y;
short i; short i;
short tag, pic; short tag, pic;
for(tag=0;tag<4;tag++) for (tag = 0; tag < 4; tag++)
{ {
pic = tag + 1; pic = tag + 1;
if (pic == 0) continue; if (pic == 0) continue;
pic += LANEPICS+1; pic += LANEPICS + 1;
tileCopySection(LANEPICS+1,0,0,128,64, pic,0,0); tileCopySection(LANEPICS + 1, 0, 0, 128, 64, pic, 0, 0);
for(i=0;i<10;i++) for (i = 0; i < 10; i++)
{ {
switch (i) switch (i)
{ {
case 0: case 0:
x = 64; x = 64;
y = 48; y = 48;
break; break;
case 1: case 1:
x = 56; x = 56;
y = 40; y = 40;
break; break;
case 2: case 2:
x = 72; x = 72;
y = 40; y = 40;
break; break;
case 3: case 3:
x = 48; x = 48;
y = 32; y = 32;
break; break;
case 4: case 4:
x = 64; x = 64;
y = 32; y = 32;
break; break;
case 5: case 5:
x = 80; x = 80;
y = 32; y = 32;
break; break;
case 6: case 6:
x = 40; x = 40;
y = 24; y = 24;
break; break;
case 7: case 7:
x = 56; x = 56;
y = 24; y = 24;
break; break;
case 8: case 8:
x = 72; x = 72;
y = 24; y = 24;
break; break;
case 9: case 9:
x = 88; x = 88;
y = 24; y = 24;
break; break;
} }
tileCopySection(LANEPICS,0,0,8,8,pic,x-4,y-10); tileCopySection(LANEPICS, 0, 0, 8, 8, pic, x - 4, y - 10);
} }
} }
} }