- getting closer to the end.

This commit is contained in:
Christoph Oelckers 2021-11-14 22:03:46 +01:00
parent 1128d20747
commit 317f13d167
10 changed files with 68 additions and 81 deletions

View file

@ -228,13 +228,10 @@ void aiProcess() {
dragonProcess(plr);
willowProcess(plr);
short i;
WHStatIterator it(PATROL);
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
i = actor->GetSpriteIndex();
Collision moveStat = movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
if (zr_florz > spr.z + (48 << 8)) {
@ -248,7 +245,6 @@ void aiProcess() {
while (auto sectactor = it.Next())
{
SPRITE& tspr = sectactor->s();
int j = sectactor->GetSpriteIndex();
if (tspr.picnum == PATROLPOINT) {
int dx = abs(spr.x - tspr.x); // x distance to sprite
@ -588,14 +584,14 @@ void processfluid(DWHActor* actor, Collision& florHit, boolean fly) {
if (!fly) {
spr.z += tileHeight(spr.picnum) << 5;
trailingsmoke(actor,true);
makemonstersplash(LAVASPLASH, actor->GetSpriteIndex());
makemonstersplash(LAVASPLASH, actor);
}
break;
case TYPEWATER:
if (!fly) {
spr.z += tileHeight(spr.picnum) << 5;
if (krand() % 100 > 60)
makemonstersplash(SPLASHAROO, actor->GetSpriteIndex());
makemonstersplash(SPLASHAROO, actor);
}
break;
}

View file

@ -573,9 +573,8 @@ void gonzoProcess(PLAYER& plr)
}
if (moveStat.type== kHitSprite) { // Bullet hit a sprite
int k = moveStat.actor->GetSpriteIndex();
for (int j = 0; j < 15; j++) {
shards(k, 1);
shards(moveStat.actor, 1);
}
damageactor(plr, moveStat.actor, actor);
}

View file

@ -1010,7 +1010,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
}
}
if (checkweapondist(pHitInfo.hitsprite, plr.x, plr.y, plr.z, plr.selectedgun)) {
if (checkweapondist(hitActor, plr.x, plr.y, plr.z, plr.selectedgun)) {
madeahit = true;
auto& hitspr = hitActor->s();
@ -1646,8 +1646,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
SND_Sound(S_SOCK1 + (krand() % 4));
playsound(S_FREEZEDIE, pHitInfo.hitx, pHitInfo.hity);
for (k = 0; k < 32; k++)
icecubes(pHitInfo.hitsprite, pHitInfo.hitx, pHitInfo.hity, pHitInfo.hitz,
pHitInfo.hitsprite);
icecubes(hitActor, pHitInfo.hitx, pHitInfo.hity, pHitInfo.hitz, pHitInfo.hitsprite);
addscore(&plr, 100);
DeleteActor(hitActor);
}
@ -1847,8 +1846,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
SND_Sound(S_SOCK1 + (krand() % 4));
playsound(S_FREEZEDIE, pHitInfo.hitx, pHitInfo.hity);
for (k = 0; k < 32; k++)
icecubes(pHitInfo.hitsprite, pHitInfo.hitx, pHitInfo.hity, pHitInfo.hitz,
pHitInfo.hitsprite);
icecubes(hitActor, pHitInfo.hitx, pHitInfo.hity, pHitInfo.hitz, pHitInfo.hitsprite);
DeleteActor(hitActor);
}
} // switch frozen
@ -2269,7 +2267,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
}
}
boolean checkweapondist(int i, int x, int y, int z, int guntype) {
boolean checkweapondist(DWHActor* actor, int x, int y, int z, int guntype) {
int length = 1024;
if (guntype != 0) {
@ -2295,9 +2293,11 @@ boolean checkweapondist(int i, int x, int y, int z, int guntype) {
break;
}
}
if (actor == nullptr) return false;
auto& spr = actor->s();
if (i >= 0 && (abs(x - sprite[i].x) + abs(y - sprite[i].y) < length)
&& (abs((z >> 8) - ((sprite[i].z >> 8) - (tileHeight(sprite[i].picnum) >> 1))) <= (length >> 3)))
if ((abs(x - spr.x) + abs(y - spr.y) < length)
&& (abs((z >> 8) - ((spr.z >> 8) - (tileHeight(spr.picnum) >> 1))) <= (length >> 3)))
return true;
else
return false;
@ -2439,7 +2439,7 @@ void swingdaweapon(PLAYER& plr) {
void swingdacrunch(PLAYER& plr, int daweapon) {
auto& pspr = sprite[player->spritenum];
auto& pspr = plr.actor()->s();
switch (daweapon) {
case 0: // fist
spritesound(S_SOCK1 + (krand() % 4), plr.actor());

View file

@ -196,10 +196,10 @@ void makeafire(DWHActor*, int firetype);
void explosion(DWHActor* i, int x, int y, int z, int ownr);
void explosion2(DWHActor* i, int x, int y, int z, int ownr);
void trailingsmoke(DWHActor* actor, boolean ball);
void icecubes(int i, int x, int y, int z, int ownr);
void icecubes(DWHActor* i, int x, int y, int z, int ownr);
boolean damageactor(PLAYER& plr, DWHActor* hitobject, DWHActor* actor);
Collision movesprite(DWHActor*, int dx, int dy, int dz, int ceildist, int flordist, int cliptype);
void trowajavlin(int s);
void trowajavlin(DWHActor* s);
void spawnhornskull(DWHActor* i);
void spawnapentagram(DWHActor* sn);
void processinput(int num);
@ -268,7 +268,7 @@ extern short dragsectorlist[16], dragxdir[16], dragydir[16], dragsectorcnt;
extern int dragx1[16], dragy1[16], dragx2[16], dragy2[16], dragfloorz[16];
void operatesprite(PLAYER& plr, short s);
void operatesprite(PLAYER& plr, DWHActor* s);
void operatesector(PLAYER& plr, int s);
void animatetags(int nPlayer);
void dodelayitems(int tics);
@ -313,7 +313,7 @@ void weaponchange(int snum);
void plrfireweapon(PLAYER& plr);
void weaponsprocess(int snum);
void shootgun(PLAYER& plr, float ang, int guntype);
boolean checkweapondist(int i, int x, int y, int z, int guntype);
boolean checkweapondist(DWHActor* i, int x, int y, int z, int guntype);
void swingdapunch(PLAYER& plr, int daweapon);
void swingdaweapon(PLAYER& plr);
void swingdacrunch(PLAYER& plr, int daweapon);
@ -384,15 +384,15 @@ void dofx();
void thunder();
void thesplash();
void makeasplash(int picnum, PLAYER& plr);
void makemonstersplash(int picnum, int i);
void bats(PLAYER& plr, int k);
void makemonstersplash(int picnum, DWHActor* i);
void bats(PLAYER& plr, DWHActor* k);
void cracks();
void lavadryland();
void warpfxsprite(DWHActor* s);
void resetEffects();
void weaponpowerup(PLAYER& plr);
void makesparks(short i, int type);
void shards(int i, int type);
void shards(DWHActor* i, int type);
// animate
@ -491,14 +491,6 @@ void setupmidi();
extern int attacktheme;
inline int insertsprite(int sectnum, int statnum)
{
int j = ::insertsprite(sectnum, statnum);
if (j != -1)
sprite[j].detail = 0;
return j;
}
void analyzesprites(PLAYER& plr, int dasmoothratio, spritetype* tsprite, int& spritesortcnt);
void precacheTiles();

View file

@ -233,7 +233,10 @@ inline void DeleteActor(DWHActor* actor)
inline DWHActor* InsertActor(int sectnum, int statnum)
{
return &whActors[insertsprite(sectnum, statnum)];
int j = insertsprite(sectnum, statnum);
auto act = &whActors[j];
act->s().detail = 0;
return act;
}
END_WH_NS

View file

@ -409,13 +409,12 @@ void animateobjs(PLAYER& plr) {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
spr.lotag -= TICSPERFRAME;
if (spr.lotag < 0) {
spr.extra--;
spr.lotag = (short) (krand() & 48 + 24);
bats(plr, i);
bats(plr, actor);
if (spr.extra == 0)
ChangeActorStat(actor, 0);
}
@ -444,11 +443,12 @@ void animateobjs(PLAYER& plr) {
}
break;
case 1: // flying in circles
if (spr.lotag < 0) {
{
auto spot = actor->GetOwner(); // was spr.hitag
if (spr.lotag < 0 && spot) {
spr.extra = 2;
spr.lotag = 512;
spr.ang = (short) (((getangle(sprite[spr.hitag].x - spr.x,
sprite[spr.hitag].y - spr.y) & 2047) - 1024) & 2047);
spr.ang = (short) (((getangle(spot->s().x - spr.x, spot->s().y - spr.y) & 2047) - 1024) & 2047);
} else {
spr.z -= TICSPERFRAME << 4;
spr.ang = (short) ((spr.ang + (TICSPERFRAME << 2)) & 2047);
@ -460,6 +460,7 @@ void animateobjs(PLAYER& plr) {
spr.ang = (short) (krand() & 2047);
}
break;
}
case 2: // fly to roof and get deleted
if (spr.lotag < 0) {
if (i == lastbat) {
@ -718,7 +719,7 @@ void animateobjs(PLAYER& plr) {
if (moveStat.type == kHitSector) {
if (spr.sector()->floorpicnum == WATER) {
makemonstersplash(SPLASHAROO, i);
makemonstersplash(SPLASHAROO, actor);
}
switch (spr.picnum) {
case FBARRELFALL:
@ -759,7 +760,7 @@ void animateobjs(PLAYER& plr) {
if (spr.z >= spr.sector()->floorz) {
if (spr.sector()->floorpicnum == WATER
|| spr.sector()->floorpicnum == FLOORMIRROR) {
makemonstersplash(SPLASHAROO, i);
makemonstersplash(SPLASHAROO, actor);
}
SetNewStatus(actor, BROKENVASE);
continue;
@ -924,7 +925,7 @@ void animateobjs(PLAYER& plr) {
spr.z = spr.sector()->floorz;
else {
if (krand() % 100 > 60)
makemonstersplash(SPLASHAROO, i);
makemonstersplash(SPLASHAROO, actor);
}
// if (spr.picnum != THROWPIKE) { //XXX
@ -1049,7 +1050,7 @@ void animateobjs(PLAYER& plr) {
if (spr.sector()->floorpicnum == WATER || spr.sector()->floorpicnum == SLIME
|| spr.sector()->floorpicnum == FLOORMIRROR)
if (krand() % 100 > 60)
makemonstersplash(SPLASHAROO, i);
makemonstersplash(SPLASHAROO, actor);
DeleteActor(actor);
continue;
}
@ -1182,7 +1183,7 @@ void animateobjs(PLAYER& plr) {
spr.z = spr.sector()->floorz;
else {
if (krand() % 100 > 60)
makemonstersplash(SPLASHAROO, i);
makemonstersplash(SPLASHAROO, actor);
}
spr.lotag = -1;
} else {
@ -1492,7 +1493,7 @@ void animateobjs(PLAYER& plr) {
spr.z = spr.sector()->floorz;
else {
if (krand() % 100 > 60) {
makemonstersplash(SPLASHAROO, i);
makemonstersplash(SPLASHAROO, actor);
DeleteActor(actor);
}
}

View file

@ -835,26 +835,27 @@ void makeasplash(int picnum, PLAYER& plr) {
spawned.backuploc();
}
void makemonstersplash(int picnum, int i) {
if (sprite[i].picnum == FISH)
void makemonstersplash(int picnum, DWHActor* actor) {
auto& spr = actor->s();
if (spr.picnum == FISH)
return;
auto spawnedactor = InsertActor(sprite[i].sectnum, MASPLASH);
auto spawnedactor = InsertActor(spr.sectnum, MASPLASH);
auto& spawned = spawnedactor->s();
spawned.x = sprite[i].x;
spawned.y = sprite[i].y;
spawned.z = sector[sprite[i].sectnum].floorz + (tileHeight(picnum) << 8);
spawned.x = spr.x;
spawned.y = spr.y;
spawned.z = sector[spr.sectnum].floorz + (tileHeight(picnum) << 8);
spawned.cstat = 0; // Hitscan does not hit other bullets
spawned.picnum = (short) picnum;
spawned.shade = 0;
if (sector[sprite[i].sectnum].floorpal == 9)
if (sector[spr.sectnum].floorpal == 9)
spawned.pal = 9;
else
spawned.pal = 0;
if (sprite[i].picnum == RAT) {
if (spr.picnum == RAT) {
spawned.xrepeat = 40;
spawned.yrepeat = 40;
} else {
@ -891,8 +892,7 @@ void makemonstersplash(int picnum, int i) {
}
}
void bats(PLAYER& plr, int k) {
auto actor = &whActors[k];
void bats(PLAYER& plr, DWHActor* actor) {
auto& spr = actor->s();
auto spawnedactor = InsertActor(spr.sectnum, FLOCK);
auto& spawned = spawnedactor->s();
@ -909,13 +909,13 @@ void bats(PLAYER& plr, int k) {
spawnedactor->SetOwner(actor);
spawned.clipdist = 16;
spawned.lotag = 128;
spawned.hitag = (short) k; // see: flying in circles
//spawned.hitag = (short) k; // see: flying in circles
spawned.extra = 0;
spawned.backuploc();
SetNewStatus(spawnedactor, FLOCK);
if (sprite[k].extra == 1)
if (spr.extra == 1)
lastbat = spawnedactor->GetSpriteIndex();
}
@ -1134,8 +1134,7 @@ void makesparks(short i, int type) {
spawned.backuploc();
}
void shards(int i, int type) {
auto actor = &whActors[i];
void shards(DWHActor* actor, int type) {
auto& spr = actor->s();
auto spawnedactor = InsertActor(spr.sectnum, SHARDOFGLASS);
auto& spawned = spawnedactor->s();

View file

@ -1505,8 +1505,7 @@ void trailingsmoke(DWHActor* actor, boolean ball) {
spawned.backuploc();
}
void icecubes(int i, int x, int y, int z, int ownr) {
auto actor = &whActors[i];
void icecubes(DWHActor* actor, int x, int y, int z, int ownr) {
auto& spr = actor->s();
auto spawnedactor = InsertActor(spr.sectnum, FX);
auto& spawned = spawnedactor->s();
@ -1699,7 +1698,7 @@ boolean damageactor(PLAYER& plr, DWHActor* hitactor, DWHActor* actor)
// raf because monsters could shatter a guy thats been frozen
if (hitspr.pal == 6) {
for (int k = 0; k < 32; k++)
icecubes(hitactor->GetSpriteIndex(), hitspr.x, hitspr.y, hitspr.z, hitactor->GetSpriteIndex());
icecubes(hitactor, hitspr.x, hitspr.y, hitspr.z, hitactor->GetSpriteIndex());
// EG 26 Oct 2017: Move this here from medusa (anti multi-freeze exploit)
addscore(&plr, 100);
DeleteActor(hitactor);
@ -1793,48 +1792,49 @@ Collision movesprite(DWHActor* actor, int dx, int dy, int dz, int ceildist, int
return Collision(retval);
}
void trowajavlin(int s) {
auto spawnedactor = InsertActor(sprite[s].sectnum, JAVLIN);
void trowajavlin(DWHActor* actor) {
auto& spr = actor->s();
auto spawnedactor = InsertActor(spr.sectnum, JAVLIN);
auto& spawned = spawnedactor->s();
spawned.x = sprite[s].x;
spawned.y = sprite[s].y;
spawned.z = sprite[s].z;// - (40 << 8);
spawned.x = spr.x;
spawned.y = spr.y;
spawned.z = spr.z;// - (40 << 8);
spawned.cstat = 21;
switch (sprite[s].lotag) {
switch (spr.lotag) {
case 91:
spawned.picnum = WALLARROW;
spawned.ang = (short) (((sprite[s].ang + 2048) - 512) & 2047);
spawned.ang = (short) (((spr.ang + 2048) - 512) & 2047);
spawned.xrepeat = 16;
spawned.yrepeat = 48;
spawned.clipdist = 24;
break;
case 92:
spawned.picnum = DART;
spawned.ang = (short) (((sprite[s].ang + 2048) - 512) & 2047);
spawned.ang = (short) (((spr.ang + 2048) - 512) & 2047);
spawned.xrepeat = 64;
spawned.yrepeat = 64;
spawned.clipdist = 16;
break;
case 93:
spawned.picnum = HORIZSPIKEBLADE;
spawned.ang = (short) (((sprite[s].ang + 2048) - 512) & 2047);
spawned.ang = (short) (((spr.ang + 2048) - 512) & 2047);
spawned.xrepeat = 16;
spawned.yrepeat = 48;
spawned.clipdist = 32;
break;
case 94:
spawned.picnum = THROWPIKE;
spawned.ang = (short) (((sprite[s].ang + 2048) - 512) & 2047);
spawned.ang = (short) (((spr.ang + 2048) - 512) & 2047);
spawned.xrepeat = 24;
spawned.yrepeat = 24;
spawned.clipdist = 32;
break;
}
spawned.extra = sprite[s].ang;
spawned.extra = spr.ang;
spawned.shade = -15;
spawned.xvel = (short) ((krand() & 256) - 128);
spawned.yvel = (short) ((krand() & 256) - 128);

View file

@ -278,7 +278,7 @@ void plruse(PLAYER& plr) {
if (sector[i].hitag == spr.hitag)
operatesector(plr, i);
} else
operatesprite(plr, nt.tagactor->GetSpriteIndex());
operatesprite(plr, nt.tagactor);
}
}

View file

@ -24,13 +24,12 @@ short dragsectorlist[16], dragxdir[16], dragydir[16], dragsectorcnt;
int dragx1[16], dragy1[16], dragx2[16], dragy2[16], dragfloorz[16];
void operatesprite(PLAYER& plr, short s) {
auto actor = &whActors[s];
void operatesprite(PLAYER& plr, DWHActor* actor) {
auto& spr = actor->s();
if (spr.picnum == SPAWNFIREBALL)
SetNewStatus(actor, DEVILFIRE);
if (spr.picnum == SPAWNJAVLIN)
trowajavlin(s);
trowajavlin(actor);
switch (spr.picnum) {
case STONEGONZOCHM:
@ -57,7 +56,7 @@ void operatesprite(PLAYER& plr, short s) {
case 2:
spritesound(S_GLASSBREAK1 + (rand() % 3), actor);
for (int j = 0; j < 20; j++) {
shards(s, 2);
shards(actor, 2);
}
DeleteActor(actor);
break;
@ -908,10 +907,9 @@ void animatetags(int nPlayer) {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
if (spr.hitag == plr.Sector()->hitag)
operatesprite(plr, i);
operatesprite(plr, actor);
}
plr.Sector()->lotag = 0;
@ -927,10 +925,9 @@ void animatetags(int nPlayer) {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
if (spr.hitag == plr.Sector()->hitag)
operatesprite(plr, i);
operatesprite(plr, actor);
}
}
}