- spawninitdefault.

This commit is contained in:
Christoph Oelckers 2020-11-02 18:58:23 +01:00
parent 4d4cb2da9b
commit 618c739318
4 changed files with 40 additions and 35 deletions

View file

@ -186,7 +186,7 @@ void checkplayerhurt_r(struct player_struct* p, const Collision& coll);
void addspritetodelete(int spnum=0);
void checkavailinven(struct player_struct* p);
int initspriteforspawn(int j, int pn, const std::initializer_list<int> &excludes);
void spawninitdefault(int j, int i);
void spawninitdefault(DDukeActor* actj, DDukeActor* act);
void spawntransporter(int j, int i, bool beam);
int spawnbloodpoolpart1(int j, int i);
void initfootprint(int j, int i);

View file

@ -228,19 +228,18 @@ int initspriteforspawn(int j, int pn, const std::initializer_list<int> &excludes
//
//---------------------------------------------------------------------------
void spawninitdefault(int j, int i)
void spawninitdefault(DDukeActor* actj, DDukeActor *act)
{
auto act = &hittype[i];
auto sp = &act->s;
auto sect = sp->sectnum;
if (actorinfo[sp->picnum].scriptaddress)
{
if (j == -1 && sp->lotag > ud.player_skill)
if (actj == nullptr && sp->lotag > ud.player_skill)
{
// make it go away...
sp->xrepeat = sp->yrepeat = 0;
changespritestat(i, STAT_MISC);
changespritestat(act, STAT_MISC);
return;
}
@ -253,11 +252,11 @@ void spawninitdefault(int j, int i)
if (ud.monsters_off == 1)
{
sp->xrepeat = sp->yrepeat = 0;
changespritestat(i, STAT_MISC);
changespritestat(act, STAT_MISC);
return;
}
makeitfall(i);
makeitfall(act);
if (actorflag(act, SFLAG_BADGUYSTAYPUT))
act->actorstayput = sp->sectnum;
@ -266,25 +265,25 @@ void spawninitdefault(int j, int i)
ps[myconnectindex].max_actors_killed++;
sp->clipdist = 80;
if (j >= 0)
if (actj)
{
if (sprite[j].picnum == RESPAWN)
act->tempang = sp->pal = sprite[j].pal;
changespritestat(i, STAT_ACTOR);
if (actj->s.picnum == RESPAWN)
act->tempang = sp->pal = actj->s.pal;
changespritestat(act, STAT_ACTOR);
}
else changespritestat(i, STAT_ZOMBIEACTOR);
else changespritestat(act, STAT_ZOMBIEACTOR);
}
else
{
sp->clipdist = 40;
sp->owner = i;
changespritestat(i, STAT_ACTOR);
act->SetOwner(act);
changespritestat(act, STAT_ACTOR);
}
act->timetosleep = 0;
if (j >= 0)
sp->ang = sprite[j].ang;
if (actj)
sp->ang = actj->s.ang;
}
}
@ -298,15 +297,16 @@ void spawntransporter(int j, int i, bool beam)
{
if (j == -1) return;
auto sp = &sprite[i];
auto spj = &sprite[j];
if (beam)
{
sp->xrepeat = 31;
sp->yrepeat = 1;
sp->z = sector[sprite[j].sectnum].floorz - (40 << 8);
sp->z = sector[spj->sectnum].floorz - (40 << 8);
}
else
{
if (sprite[j].statnum == 4)
if (spj->statnum == 4)
{
sp->xrepeat = 8;
sp->yrepeat = 8;
@ -315,14 +315,14 @@ void spawntransporter(int j, int i, bool beam)
{
sp->xrepeat = 48;
sp->yrepeat = 64;
if (sprite[j].statnum == 10 || badguy(&sprite[j]))
if (spj->statnum == 10 || badguy(spj))
sp->z -= (32 << 8);
}
}
sp->shade = -127;
sp->cstat = 128 | 2;
sp->ang = sprite[j].ang;
sp->ang = spj->ang;
sp->xvel = 128;
changespritestat(i, STAT_MISC);
@ -961,15 +961,16 @@ void spawneffector(int i)
for (j = 0; j < MAXSPRITES; j++)
{
if (sprite[j].statnum < MAXSTATUS)
if (sprite[j].picnum == SECTOREFFECTOR &&
sprite[j].lotag == 1 &&
sprite[j].hitag == sp->hitag)
auto spr = &sprite[j];
if (spr->statnum < MAXSTATUS)
if (spr->picnum == SECTOREFFECTOR &&
spr->lotag == 1 &&
spr->hitag == sp->hitag)
{
if (sp->ang == 512)
{
sp->x = sprite[j].x;
sp->y = sprite[j].y;
sp->x = spr->x;
sp->y = spr->y;
}
break;
}

View file

@ -48,9 +48,11 @@ int spawn_d(int j, int pn)
int i = initspriteforspawn(j, pn, { CRACK1, CRACK2, CRACK3, CRACK4, SPEAKER, LETTER, DUCK, TARGET, TRIPBOMB, VIEWSCREEN, VIEWSCREEN2 });
if (!(i & 0x1000000)) return i;
i &= 0xffffff;
auto sp = &sprite[i];
auto spj = &sprite[j];
auto t = hittype[i].temp_data;
auto act = &hittype[i];
auto sp = &act->s;
auto actj = &hittype[j];
auto spj = &actj->s;
auto t = act->temp_data;
int sect = sp->sectnum;
@ -146,7 +148,7 @@ int spawn_d(int j, int pn)
switch(sp->picnum)
{
default:
spawninitdefault(j, i);
spawninitdefault(actj, act);
break;
case FOF:
sp->xrepeat = sp->yrepeat = 0;

View file

@ -43,16 +43,18 @@ int spawn_r(int j, int pn)
int i = initspriteforspawn(j, pn, { CRACK1, CRACK2, CRACK3, CRACK4 });
if (!(i & 0x1000000)) return i;
i &= 0xffffff;
auto sp = &sprite[i];
auto spj = &sprite[j];
auto t = hittype[i].temp_data;
auto act = &hittype[i];
auto sp = &act->s;
auto actj = j <0? nullptr : &hittype[j];
auto spj = j < 0? nullptr : &actj->s;
auto t = act->temp_data;
int sect = sp->sectnum;
switch(sp->picnum)
{
default:
default_case:
spawninitdefault(j, i);
spawninitdefault(actj, act);
break;
case RRTILE280:
case RRTILE281:
@ -1051,10 +1053,10 @@ int spawn_r(int j, int pn)
hittype[i].timetosleep = 0;
check_fta_sounds_r(&hittype[i]);
changespritestat(i,1);
sp->shade = spj->shade;
}
else changespritestat(i,2);
sp->shade = spj->shade;
}
break;