- movefta and ifhitsectors.

This commit is contained in:
Christoph Oelckers 2020-10-22 19:27:59 +02:00
parent 861342a278
commit 7e8be10b04
6 changed files with 60 additions and 63 deletions

View file

@ -705,26 +705,26 @@ void movefta_d(void)
{ {
int x, px, py, sx, sy; int x, px, py, sx, sy;
short p, psect, ssect; short p, psect, ssect;
int i, j; int j;
StatIterator iti(STAT_ZOMBIEACTOR); DukeStatIterator iti(STAT_ZOMBIEACTOR);
while ((i = iti.NextIndex()) >= 0) while (auto act = iti.Next())
{ {
auto s = &sprite[i]; auto s = &act->s;
auto ht = &hittype[i]; p = findplayer(act, &x);
p = findplayer(s, &x);
ssect = psect = s->sectnum; ssect = psect = s->sectnum;
if (sprite[ps[p].i].extra > 0) auto pa = ps[p].GetActor();
if (pa->s.extra > 0)
{ {
if (x < 30000) if (x < 30000)
{ {
ht->timetosleep++; act->timetosleep++;
if (ht->timetosleep >= (x >> 8)) if (act->timetosleep >= (x >> 8))
{ {
if (badguy(s)) if (badguy(act))
{ {
px = ps[p].oposx + 64 - (krand() & 127); px = ps[p].oposx + 64 - (krand() & 127);
py = ps[p].oposy + 64 - (krand() & 127); py = ps[p].oposy + 64 - (krand() & 127);
@ -773,20 +773,20 @@ void movefta_d(void)
s->shade = sector[s->sectnum].ceilingshade; s->shade = sector[s->sectnum].ceilingshade;
else s->shade = sector[s->sectnum].floorshade; else s->shade = sector[s->sectnum].floorshade;
ht->timetosleep = 0; act->timetosleep = 0;
changespritestat(i, STAT_STANDABLE); changespritestat(act, STAT_STANDABLE);
break; break;
default: default:
ht->timetosleep = 0; act->timetosleep = 0;
check_fta_sounds_d(&hittype[i]); check_fta_sounds_d(act);
changespritestat(i, STAT_ACTOR); changespritestat(act, STAT_ACTOR);
break; break;
} }
else ht->timetosleep = 0; else act->timetosleep = 0;
} }
} }
if (badguy(s)) if (badguy(act))
{ {
if (sector[s->sectnum].ceilingstat & 1) if (sector[s->sectnum].ceilingstat & 1)
s->shade = sector[s->sectnum].ceilingshade; s->shade = sector[s->sectnum].ceilingshade;
@ -802,17 +802,15 @@ void movefta_d(void)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
int ifhitsectors_d(int sectnum) DDukeActor* ifhitsectors_d(int sectnum)
{ {
StatIterator it(STAT_MISC); DukeStatIterator it(STAT_MISC);
int i; while (auto a1 = it.Next())
while((i = it.NextIndex()) >= 0)
{ {
auto s = &sprite[i]; if (a1->s.picnum == EXPLOSION2 && sectnum == a1->s.sectnum)
if (s->picnum == EXPLOSION2 && sectnum == s->sectnum) return a1;
return i;
} }
return -1; return nullptr;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View file

@ -522,31 +522,29 @@ void guts_r(DDukeActor* actor, short gtype, short n, short p)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void movefta_r(void) void movefta_r(void)
{ {
int x, px, py, sx, sy; int x, px, py, sx, sy;
short j, p, psect, ssect; short j, p, psect, ssect;
spritetype* s;
DukeStatIterator it(STAT_ZOMBIEACTOR);
StatIterator it(STAT_ZOMBIEACTOR); while(auto act = it.Next())
int i;
while((i = it.NextIndex()) >= 0)
{ {
s = &sprite[i]; auto s = &act->s;
p = findplayer(s, &x); p = findplayer(act, &x);
j = 0; j = 0;
ssect = psect = s->sectnum; ssect = psect = s->sectnum;
if (sprite[ps[p].i].extra > 0) if (ps[p].GetActor()->s.extra > 0)
{ {
if (x < 30000) if (x < 30000)
{ {
hittype[i].timetosleep++; act->timetosleep++;
if (hittype[i].timetosleep >= (x >> 8)) if (act->timetosleep >= (x >> 8))
{ {
if (badguy(s)) if (badguy(act))
{ {
px = ps[p].oposx + 64 - (krand() & 127); px = ps[p].oposx + 64 - (krand() & 127);
py = ps[p].oposy + 64 - (krand() & 127); py = ps[p].oposy + 64 - (krand() & 127);
@ -598,23 +596,23 @@ void movefta_r(void)
s->shade = sector[s->sectnum].ceilingshade; s->shade = sector[s->sectnum].ceilingshade;
else s->shade = sector[s->sectnum].floorshade; else s->shade = sector[s->sectnum].floorshade;
hittype[i].timetosleep = 0; act->timetosleep = 0;
changespritestat(i, STAT_STANDABLE); changespritestat(act, STAT_STANDABLE);
break; break;
default: default:
#if 0 #if 0
// TRANSITIONAL: RedNukem has this here. Needed? // TRANSITIONAL: RedNukem has this here. Needed?
if (actorflag(spriteNum, SFLAG_USEACTIVATOR) && sector[s prite[spriteNum].sectnum].lotag & 16384) break; if (actorflag(spriteNum, SFLAG_USEACTIVATOR) && sector[s prite[spriteNum].sectnum].lotag & 16384) break;
#endif #endif
hittype[i].timetosleep = 0; act->timetosleep = 0;
check_fta_sounds_r(&hittype[i]); check_fta_sounds_r(act);
changespritestat(i, STAT_ACTOR); changespritestat(act, STAT_ACTOR);
break; break;
} }
else hittype[i].timetosleep = 0; else act->timetosleep = 0;
} }
} }
if (/*!j &&*/ badguy(s)) // this is like RedneckGDX. j is uninitialized here, i.e. most likely not 0. if (/*!j &&*/ badguy(act)) // this is like RedneckGDX. j is uninitialized here, i.e. most likely not 0.
{ {
if (sector[s->sectnum].ceilingstat & 1) if (sector[s->sectnum].ceilingstat & 1)
s->shade = sector[s->sectnum].ceilingshade; s->shade = sector[s->sectnum].ceilingshade;
@ -622,11 +620,11 @@ void movefta_r(void)
if (s->picnum != HEN || s->picnum != COW || s->picnum != PIG || s->picnum != DOGRUN || ((isRRRA()) && s->picnum != RABBIT)) if (s->picnum != HEN || s->picnum != COW || s->picnum != PIG || s->picnum != DOGRUN || ((isRRRA()) && s->picnum != RABBIT))
{ {
if (wakeup(i, p)) if (wakeup(act, p))
{ {
hittype[i].timetosleep = 0; act->timetosleep = 0;
check_fta_sounds_r(&hittype[i]); check_fta_sounds_r(act);
changespritestat(i, STAT_ACTOR); changespritestat(act, STAT_ACTOR);
} }
} }
} }
@ -640,16 +638,15 @@ void movefta_r(void)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
int ifhitsectors_r(int sectnum) DDukeActor* ifhitsectors_r(int sectnum)
{ {
StatIterator it(STAT_MISC); DukeStatIterator it(STAT_MISC);
int i; while (auto a1 = it.Next())
while ((i = it.NextIndex()) >= 0)
{ {
if (sprite[i].picnum == EXPLOSION2 || (sprite[i].picnum == EXPLOSION3 && sectnum == sprite[i].sectnum)) if (a1->s.picnum == EXPLOSION2 || (a1->s.picnum == EXPLOSION3 && sectnum == a1->s.sectnum))
return i; return a1;
} }
return -1; return nullptr;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View file

@ -72,8 +72,8 @@ void lotsofpaper_d(DDukeActor* s, short n);
void lotsoffeathers_r(DDukeActor* s, short n); void lotsoffeathers_r(DDukeActor* s, short n);
void guts_d(DDukeActor* s, short gtype, short n, short p); void guts_d(DDukeActor* s, short gtype, short n, short p);
void guts_r(DDukeActor* s, short gtype, short n, short p); void guts_r(DDukeActor* s, short gtype, short n, short p);
int ifhitsectors_d(int sectnum); DDukeActor* ifhitsectors_d(int sectnum);
int ifhitsectors_r(int sectnum); DDukeActor* ifhitsectors_r(int sectnum);
int ifhitbyweapon_r(DDukeActor* sn); int ifhitbyweapon_r(DDukeActor* sn);
int ifhitbyweapon_d(DDukeActor* sn); int ifhitbyweapon_d(DDukeActor* sn);
void fall_d(int g_i, int g_p); void fall_d(int g_i, int g_p);

View file

@ -93,7 +93,7 @@ struct Dispatcher
void (*lotsofmail)(DDukeActor *s, short n); void (*lotsofmail)(DDukeActor *s, short n);
void (*lotsofpaper)(DDukeActor *s, short n); void (*lotsofpaper)(DDukeActor *s, short n);
void (*guts)(DDukeActor* s, short gtype, short n, short p); void (*guts)(DDukeActor* s, short gtype, short n, short p);
int (*ifhitsectors)(int sectnum); DDukeActor* (*ifhitsectors)(int sectnum);
int (*ifhitbyweapon)(DDukeActor* sectnum); int (*ifhitbyweapon)(DDukeActor* sectnum);
void (*fall)(int g_i, int g_p); void (*fall)(int g_i, int g_p);
bool (*spawnweapondebris)(int picnum, int dnum); bool (*spawnweapondebris)(int picnum, int dnum);

View file

@ -108,7 +108,7 @@ void addammo(int weapon, struct player_struct* p, int amount);
int ssp(DDukeActor* i, unsigned int cliptype); //The set sprite function int ssp(DDukeActor* i, unsigned int cliptype); //The set sprite function
void insertspriteq(DDukeActor *i); void insertspriteq(DDukeActor *i);
int wakeup(int sn, int pn); int wakeup(DDukeActor* sn, int pn);
int timedexit(int snum); int timedexit(int snum);

View file

@ -26,6 +26,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
#include "ns.h" #include "ns.h"
#include "duke3d.h" #include "duke3d.h"
#include "dukeactor.h"
BEGIN_DUKE_NS BEGIN_DUKE_NS
@ -39,20 +40,21 @@ int madenoise(int snum)
return 1; return 1;
} }
int wakeup(int i, int snum) int wakeup(DDukeActor* ac, int snum)
{ {
player_struct *p; player_struct *p;
int radius; int radius;
p = &ps[snum]; p = &ps[snum];
auto spr = &ac->s;
if (!p->donoise) if (!p->donoise)
return 0; return 0;
if (sprite[i].pal == 30 || sprite[i].pal == 32 || sprite[i].pal == 33 || (isRRRA() && sprite[i].pal == 8)) if (spr->pal == 30 || spr->pal == 32 || spr->pal == 33 || (isRRRA() && spr->pal == 8))
return 0; return 0;
radius = p->noise_radius; radius = p->noise_radius;
if (p->noise_x - radius < sprite[i].x && p->noise_x + radius > sprite[i].x if (p->noise_x - radius < spr->x && p->noise_x + radius > spr->x
&& p->noise_y - radius < sprite[i].y && p->noise_y + radius > sprite[i].y) && p->noise_y - radius < spr->y && p->noise_y + radius > spr->y)
return 1; return 1;
return 0; return 0;
} }