mirror of
https://github.com/ZDoom/Raze.git
synced 2024-12-02 00:53:16 +00:00
- replaced the iterators in aiProcess.
Copy/Paste work.
This commit is contained in:
parent
ee53d1003a
commit
3caf334ed5
2 changed files with 93 additions and 56 deletions
|
@ -86,11 +86,11 @@ void initAI()
|
||||||
}
|
}
|
||||||
|
|
||||||
void aiInit() {
|
void aiInit() {
|
||||||
for (short i = 0; i < MAXSPRITES; i++) {
|
WHLinearSpriteIterator it;
|
||||||
if (sprite[i].statnum >= MAXSTATUS)
|
while (auto actor = it.Next())
|
||||||
continue;
|
{
|
||||||
|
SPRITE& spr = actor->s();
|
||||||
SPRITE& spr = sprite[i];
|
int i = actor->GetSpriteIndex();
|
||||||
int pic = spr.picnum;
|
int pic = spr.picnum;
|
||||||
switch (spr.picnum) {
|
switch (spr.picnum) {
|
||||||
default:
|
default:
|
||||||
|
@ -229,12 +229,13 @@ void aiProcess() {
|
||||||
dragonProcess(plr);
|
dragonProcess(plr);
|
||||||
willowProcess(plr);
|
willowProcess(plr);
|
||||||
|
|
||||||
short i, nextsprite;
|
short i;
|
||||||
|
|
||||||
for (i = headspritestat[PATROL]; i >= 0; i = nextsprite) {
|
WHStatIterator it(PATROL);
|
||||||
nextsprite = nextspritestat[i];
|
while (auto actor = it.Next())
|
||||||
|
{
|
||||||
SPRITE& spr = sprite[i];
|
SPRITE& spr = actor->s();
|
||||||
|
i = actor->GetSpriteIndex();
|
||||||
short movestat = (short)movesprite((short)i, (bcos(spr.ang) * TICSPERFRAME) << 3,
|
short movestat = (short)movesprite((short)i, (bcos(spr.ang) * TICSPERFRAME) << 3,
|
||||||
(bsin(spr.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
|
(bsin(spr.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
|
||||||
if (zr_florz > spr.z + (48 << 8)) {
|
if (zr_florz > spr.z + (48 << 8)) {
|
||||||
|
@ -273,32 +274,41 @@ void aiProcess() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = headspritestat[CHASE]; i >= 0; i = nextsprite) {
|
it.Reset(CHASE);
|
||||||
nextsprite = nextspritestat[i];
|
while (auto actor = it.Next())
|
||||||
SPRITE& spr = sprite[i];
|
{
|
||||||
|
SPRITE& spr = actor->s();
|
||||||
|
i = actor->GetSpriteIndex();
|
||||||
|
|
||||||
if (enemy[spr.detail].chase != nullptr)
|
if (enemy[spr.detail].chase != nullptr)
|
||||||
enemy[spr.detail].chase(plr, i);
|
enemy[spr.detail].chase(plr, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = headspritestat[RESURECT]; i >= 0; i = nextsprite) {
|
it.Reset(RESURECT);
|
||||||
nextsprite = nextspritestat[i];
|
while (auto actor = it.Next())
|
||||||
SPRITE& spr = sprite[i];
|
{
|
||||||
|
SPRITE& spr = actor->s();
|
||||||
|
i = actor->GetSpriteIndex();
|
||||||
if (enemy[spr.detail].resurect != nullptr) {
|
if (enemy[spr.detail].resurect != nullptr) {
|
||||||
enemy[spr.detail].resurect(plr, i);
|
enemy[spr.detail].resurect(plr, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = headspritestat[FINDME]; i >= 0; i = nextsprite) {
|
it.Reset(FINDME);
|
||||||
nextsprite = nextspritestat[i];
|
while (auto actor = it.Next())
|
||||||
SPRITE& spr = sprite[i];
|
{
|
||||||
|
SPRITE& spr = actor->s();
|
||||||
|
i = actor->GetSpriteIndex();
|
||||||
|
|
||||||
if (enemy[spr.detail].search != nullptr)
|
if (enemy[spr.detail].search != nullptr)
|
||||||
enemy[spr.detail].search(plr, i);
|
enemy[spr.detail].search(plr, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = headspritestat[NUKED]; i >= 0; i = nextsprite) {
|
it.Reset(NUKED);
|
||||||
nextsprite = nextspritestat[i];
|
while (auto actor = it.Next())
|
||||||
SPRITE& spr = sprite[i];
|
{
|
||||||
|
SPRITE& spr = actor->s();
|
||||||
|
i = actor->GetSpriteIndex();
|
||||||
|
|
||||||
if (spr.picnum == ZFIRE) {
|
if (spr.picnum == ZFIRE) {
|
||||||
spr.lotag -= TICSPERFRAME;
|
spr.lotag -= TICSPERFRAME;
|
||||||
|
@ -311,32 +321,41 @@ void aiProcess() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = headspritestat[FROZEN]; i >= 0; i = nextsprite) {
|
it.Reset(FROZEN);
|
||||||
nextsprite = nextspritestat[i];
|
while (auto actor = it.Next())
|
||||||
SPRITE& spr = sprite[i];
|
{
|
||||||
|
SPRITE& spr = actor->s();
|
||||||
|
i = actor->GetSpriteIndex();
|
||||||
|
|
||||||
if (enemy[spr.detail].frozen != nullptr)
|
if (enemy[spr.detail].frozen != nullptr)
|
||||||
enemy[spr.detail].frozen(plr, i);
|
enemy[spr.detail].frozen(plr, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = headspritestat[PAIN]; i >= 0; i = nextsprite) {
|
it.Reset(PAIN);
|
||||||
nextsprite = nextspritestat[i];
|
while (auto actor = it.Next())
|
||||||
SPRITE& spr = sprite[i];
|
{
|
||||||
|
SPRITE& spr = actor->s();
|
||||||
|
i = actor->GetSpriteIndex();
|
||||||
|
|
||||||
if (enemy[spr.detail].pain != nullptr)
|
if (enemy[spr.detail].pain != nullptr)
|
||||||
enemy[spr.detail].pain(plr, i);
|
enemy[spr.detail].pain(plr, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = headspritestat[FACE]; i >= 0; i = nextsprite) {
|
it.Reset(FACE);
|
||||||
nextsprite = nextspritestat[i];
|
while (auto actor = it.Next())
|
||||||
SPRITE& spr = sprite[i];
|
{
|
||||||
|
SPRITE& spr = actor->s();
|
||||||
|
i = actor->GetSpriteIndex();
|
||||||
|
|
||||||
if (enemy[spr.detail].face != nullptr)
|
if (enemy[spr.detail].face != nullptr)
|
||||||
enemy[spr.detail].face(plr, i);
|
enemy[spr.detail].face(plr, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = headspritestat[ATTACK]; i >= 0; i = nextsprite) {
|
it.Reset(ATTACK);
|
||||||
nextsprite = nextspritestat[i];
|
while (auto actor = it.Next())
|
||||||
SPRITE& spr = sprite[i];
|
{
|
||||||
|
SPRITE& spr = actor->s();
|
||||||
|
i = actor->GetSpriteIndex();
|
||||||
|
|
||||||
if (isWh2() && attacktheme == 0) {
|
if (isWh2() && attacktheme == 0) {
|
||||||
attacktheme = 1;
|
attacktheme = 1;
|
||||||
|
@ -347,48 +366,62 @@ void aiProcess() {
|
||||||
enemy[spr.detail].attack(plr, i);
|
enemy[spr.detail].attack(plr, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = headspritestat[FLEE]; i >= 0; i = nextsprite) {
|
it.Reset(FLEE);
|
||||||
nextsprite = nextspritestat[i];
|
while (auto actor = it.Next())
|
||||||
SPRITE& spr = sprite[i];
|
{
|
||||||
|
SPRITE& spr = actor->s();
|
||||||
|
i = actor->GetSpriteIndex();
|
||||||
|
|
||||||
if (enemy[spr.detail].flee != nullptr)
|
if (enemy[spr.detail].flee != nullptr)
|
||||||
enemy[spr.detail].flee(plr, i);
|
enemy[spr.detail].flee(plr, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = headspritestat[CAST]; i >= 0; i = nextsprite) {
|
it.Reset(CAST);
|
||||||
nextsprite = nextspritestat[i];
|
while (auto actor = it.Next())
|
||||||
SPRITE& spr = sprite[i];
|
{
|
||||||
|
SPRITE& spr = actor->s();
|
||||||
|
i = actor->GetSpriteIndex();
|
||||||
|
|
||||||
if (enemy[spr.detail].cast != nullptr)
|
if (enemy[spr.detail].cast != nullptr)
|
||||||
enemy[spr.detail].cast(plr, i);
|
enemy[spr.detail].cast(plr, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = headspritestat[DIE]; i >= 0; i = nextsprite) {
|
it.Reset(DIE);
|
||||||
nextsprite = nextspritestat[i];
|
while (auto actor = it.Next())
|
||||||
SPRITE& spr = sprite[i];
|
{
|
||||||
|
SPRITE& spr = actor->s();
|
||||||
|
i = actor->GetSpriteIndex();
|
||||||
|
|
||||||
if (enemy[spr.detail].die != nullptr)
|
if (enemy[spr.detail].die != nullptr)
|
||||||
enemy[spr.detail].die(plr, i);
|
enemy[spr.detail].die(plr, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = headspritestat[SKIRMISH]; i >= 0; i = nextsprite) {
|
it.Reset(SKIRMISH);
|
||||||
nextsprite = nextspritestat[i];
|
while (auto actor = it.Next())
|
||||||
SPRITE& spr = sprite[i];
|
{
|
||||||
|
SPRITE& spr = actor->s();
|
||||||
|
i = actor->GetSpriteIndex();
|
||||||
|
|
||||||
if (enemy[spr.detail].skirmish != nullptr)
|
if (enemy[spr.detail].skirmish != nullptr)
|
||||||
enemy[spr.detail].skirmish(plr, i);
|
enemy[spr.detail].skirmish(plr, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = headspritestat[STAND]; i >= 0; i = nextsprite) {
|
it.Reset(STAND);
|
||||||
nextsprite = nextspritestat[i];
|
while (auto actor = it.Next())
|
||||||
SPRITE& spr = sprite[i];
|
{
|
||||||
|
SPRITE& spr = actor->s();
|
||||||
|
i = actor->GetSpriteIndex();
|
||||||
|
|
||||||
if (enemy[spr.detail].stand != nullptr)
|
if (enemy[spr.detail].stand != nullptr)
|
||||||
enemy[spr.detail].stand(plr, i);
|
enemy[spr.detail].stand(plr, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = headspritestat[CHILL]; i >= 0; i = nextsprite) {
|
it.Reset(CHILL);
|
||||||
nextsprite = nextspritestat[i];
|
while (auto actor = it.Next())
|
||||||
SPRITE& spr = sprite[i];
|
{
|
||||||
|
SPRITE& spr = actor->s();
|
||||||
|
i = actor->GetSpriteIndex();
|
||||||
|
|
||||||
switch (spr.detail) {
|
switch (spr.detail) {
|
||||||
case GOBLINTYPE:
|
case GOBLINTYPE:
|
||||||
goblinChill(plr, i);
|
goblinChill(plr, i);
|
||||||
|
@ -399,9 +432,11 @@ void aiProcess() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = headspritestat[DEAD]; i >= 0; i = nextsprite) {
|
it.Reset(DEAD);
|
||||||
nextsprite = nextspritestat[i];
|
while (auto actor = it.Next())
|
||||||
SPRITE& spr = sprite[i];
|
{
|
||||||
|
SPRITE& spr = actor->s();
|
||||||
|
i = actor->GetSpriteIndex();
|
||||||
|
|
||||||
getzrange(spr.x, spr.y, spr.z - 1, spr.sectnum, (spr.clipdist) << 2, CLIPMASK0);
|
getzrange(spr.x, spr.y, spr.z - 1, spr.sectnum, (spr.clipdist) << 2, CLIPMASK0);
|
||||||
switch (checkfluid(i, zr_florhit)) {
|
switch (checkfluid(i, zr_florhit)) {
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
BEGIN_WH_NS
|
BEGIN_WH_NS
|
||||||
|
|
||||||
|
DWHActor whActors[MAXSPRITES];
|
||||||
|
|
||||||
// Placeholders that will go away.
|
// Placeholders that will go away.
|
||||||
int attacktheme;
|
int attacktheme;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue