2019-11-20 16:21:32 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 sirlemonhead, Nuke.YKT
|
|
|
|
This file is part of PCExhumed.
|
|
|
|
PCExhumed is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-11-22 23:11:37 +00:00
|
|
|
#include "ns.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "engine.h"
|
|
|
|
#include "exhumed.h"
|
2020-08-18 07:52:08 +00:00
|
|
|
#include "aistuff.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "status.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "sequence.h"
|
2021-01-01 22:38:15 +00:00
|
|
|
#include "input.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "sound.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
BEGIN_PS_NS
|
|
|
|
|
2020-11-29 23:18:32 +00:00
|
|
|
FreeListArray<Snake, kMaxSnakes> SnakeList;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
short nPlayerSnake[kMaxPlayers];
|
|
|
|
|
2020-11-29 23:18:32 +00:00
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, Snake& w, Snake* def)
|
|
|
|
{
|
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
{
|
|
|
|
arc("enemy", w.nEnemy)
|
|
|
|
.Array("sprites", w.nSprites, kSnakeSprites)
|
|
|
|
("sc", w.sC)
|
|
|
|
("run", w.nRun)
|
|
|
|
.Array("c", w.c, countof(w.c))
|
|
|
|
("se", w.sE)
|
|
|
|
("player", w.nSnakePlayer)
|
|
|
|
.EndObject();
|
|
|
|
}
|
|
|
|
return arc;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-11-29 23:18:32 +00:00
|
|
|
void SerializeSnake(FSerializer& arc)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2020-11-29 23:18:32 +00:00
|
|
|
arc("snake", SnakeList);
|
|
|
|
arc.Array("playersnake", nPlayerSnake, PlayerCount);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
|
2020-11-29 23:18:32 +00:00
|
|
|
void InitSnakes()
|
|
|
|
{
|
|
|
|
SnakeList.Clear();
|
2019-08-31 07:47:15 +00:00
|
|
|
memset(nPlayerSnake, 0, sizeof(nPlayerSnake));
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
short GrabSnake()
|
|
|
|
{
|
2020-11-29 23:18:32 +00:00
|
|
|
return SnakeList.Get();
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DestroySnake(int nSnake)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nRun = SnakeList[nSnake].nRun;
|
|
|
|
runlist_SubRunRec(nRun);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
for (int i = 0; i < kSnakeSprites; i++)
|
|
|
|
{
|
|
|
|
short nSprite = SnakeList[nSnake].nSprites[i];
|
2021-10-15 21:31:00 +00:00
|
|
|
auto pSprite = &sprite[nSprite];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
runlist_DoSubRunRec(pSprite->lotag - 1);
|
|
|
|
runlist_DoSubRunRec(pSprite->owner);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
mydeletesprite(nSprite);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-11-29 23:18:32 +00:00
|
|
|
SnakeList.Release(nSnake);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (nSnake == nSnakeCam)
|
|
|
|
{
|
|
|
|
nSnakeCam = -1;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ExplodeSnakeSprite(int nSprite, short nPlayer)
|
|
|
|
{
|
2021-10-15 21:31:00 +00:00
|
|
|
auto pSprite = &sprite[nSprite];
|
2019-08-31 07:47:15 +00:00
|
|
|
short nDamage = BulletInfo[kWeaponStaff].nDamage;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-05-13 17:15:53 +00:00
|
|
|
if (PlayerList[nPlayer].nDouble > 0) {
|
2019-08-31 07:47:15 +00:00
|
|
|
nDamage *= 2;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
// take a copy of this, to revert after call to runlist_RadialDamageEnemy()
|
2021-09-06 06:33:02 +00:00
|
|
|
short nOwner = pSprite->owner;
|
|
|
|
pSprite->owner = PlayerList[nPlayer].nSprite;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-02-04 21:45:10 +00:00
|
|
|
runlist_RadialDamageEnemy(nSprite, nDamage, BulletInfo[kWeaponStaff].nRadius);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->owner = nOwner;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
BuildAnim(-1, 23, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 40, 4);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
AddFlash(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 128);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
StopSpriteSound(nSprite);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 16:37:39 +00:00
|
|
|
void BuildSnake(short nPlayer, short zVal)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
zVal -= 1280;
|
|
|
|
|
|
|
|
short nPlayerSprite = PlayerList[nPlayer].nSprite;
|
|
|
|
short nViewSect = nPlayerViewSect[nPlayer];
|
|
|
|
short nPic = seq_GetSeqPicnum(kSeqSnakBody, 0, 0);
|
|
|
|
|
|
|
|
int x = sprite[nPlayerSprite].x;
|
|
|
|
int y = sprite[nPlayerSprite].y;
|
|
|
|
int z = (sprite[nPlayerSprite].z + zVal) - 2560;
|
|
|
|
short nAngle = sprite[nPlayerSprite].ang;
|
|
|
|
|
2019-12-02 16:34:59 +00:00
|
|
|
short hitsect, hitsprite;
|
2019-08-31 07:47:15 +00:00
|
|
|
int hitx, hity, hitz;
|
|
|
|
|
|
|
|
short nSprite;
|
|
|
|
|
|
|
|
vec3_t pos = { x, y, z };
|
|
|
|
hitdata_t hitData;
|
2020-11-14 08:45:08 +00:00
|
|
|
hitscan(&pos, sprite[nPlayerSprite].sectnum, bcos(nAngle), bsin(nAngle), 0, &hitData, CLIPMASK1);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
hitx = hitData.pos.x;
|
|
|
|
hity = hitData.pos.y;
|
|
|
|
hitz = hitData.pos.z;
|
|
|
|
hitsect = hitData.sect;
|
|
|
|
hitsprite = hitData.sprite;
|
|
|
|
|
2021-01-04 12:02:00 +00:00
|
|
|
uint32_t xDiff = abs(hitx - x);
|
|
|
|
uint32_t yDiff = abs(hity - y);
|
2020-06-22 10:24:21 +00:00
|
|
|
|
|
|
|
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff;
|
|
|
|
|
|
|
|
if (sqrtNum > INT_MAX)
|
|
|
|
{
|
2020-09-08 16:48:18 +00:00
|
|
|
DPrintf(DMSG_WARNING, "%s %d: overflow\n", __func__, __LINE__);
|
2020-06-22 10:24:21 +00:00
|
|
|
sqrtNum = INT_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
int nSqrt = ksqrt(sqrtNum);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-11-14 09:19:28 +00:00
|
|
|
if (nSqrt < bsin(512, -4))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
BackUpBullet(&hitx, &hity, nAngle);
|
|
|
|
nSprite = insertsprite(hitsect, 202);
|
2021-10-15 21:31:00 +00:00
|
|
|
auto pSprite = &sprite[nSprite];
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->x = hitx;
|
|
|
|
pSprite->y = hity;
|
|
|
|
pSprite->z = hitz;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
ExplodeSnakeSprite(nSprite, nPlayer);
|
|
|
|
mydeletesprite(nSprite);
|
2021-10-15 16:37:39 +00:00
|
|
|
return;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
short nTarget;
|
|
|
|
|
2019-11-18 19:38:19 +00:00
|
|
|
if (hitsprite >= 0 && sprite[hitsprite].statnum >= 90 && sprite[hitsprite].statnum <= 199) {
|
|
|
|
nTarget = hitsprite;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else {
|
2019-11-18 19:38:19 +00:00
|
|
|
nTarget = sPlayerInput[nPlayer].nTarget;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
short nSnake = GrabSnake();
|
2021-10-15 16:37:39 +00:00
|
|
|
if (nSnake == -1) return;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
// GrabTimeSlot(3);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
short var_24;
|
|
|
|
|
|
|
|
for (int i = 0; i < kSnakeSprites; i++)
|
|
|
|
{
|
|
|
|
nSprite = insertsprite(nViewSect, 202);
|
2021-10-15 21:31:00 +00:00
|
|
|
auto pSprite = &sprite[nSprite];
|
2019-08-31 07:47:15 +00:00
|
|
|
assert(nSprite >= 0 && nSprite < kMaxSprites);
|
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->owner = nPlayerSprite;
|
|
|
|
pSprite->picnum = nPic;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2019-11-18 19:38:19 +00:00
|
|
|
if (i == 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->x = sprite[nPlayerSprite].x;
|
|
|
|
pSprite->y = sprite[nPlayerSprite].y;
|
|
|
|
pSprite->z = sprite[nPlayerSprite].z + zVal;
|
|
|
|
pSprite->xrepeat = 32;
|
|
|
|
pSprite->yrepeat = 32;
|
|
|
|
nViewSect = pSprite->sectnum;
|
2019-08-31 07:47:15 +00:00
|
|
|
var_24 = nSprite;
|
|
|
|
}
|
2019-11-18 19:38:19 +00:00
|
|
|
else
|
|
|
|
{
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->x = sprite[var_24].x;
|
|
|
|
pSprite->y = sprite[var_24].y;
|
|
|
|
pSprite->z = sprite[var_24].z;
|
2021-10-15 21:31:00 +00:00
|
|
|
pSprite->xrepeat = 40 - 3 * i;
|
|
|
|
pSprite->yrepeat = 40 - 3 * i;
|
2019-11-18 19:38:19 +00:00
|
|
|
}
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
pSprite->clipdist = 10;
|
|
|
|
pSprite->cstat = 0;
|
|
|
|
pSprite->shade = -64;
|
|
|
|
pSprite->pal = 0;
|
|
|
|
pSprite->xoffset = 0;
|
|
|
|
pSprite->yoffset = 0;
|
|
|
|
pSprite->ang = sprite[nPlayerSprite].ang;
|
|
|
|
pSprite->xvel = 0;
|
|
|
|
pSprite->yvel = 0;
|
|
|
|
pSprite->zvel = 0;
|
|
|
|
pSprite->hitag = 0;
|
|
|
|
pSprite->extra = -1;
|
|
|
|
pSprite->lotag = runlist_HeadRun() + 1;
|
|
|
|
pSprite->backuppos();
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
SnakeList[nSnake].nSprites[i] = nSprite;
|
|
|
|
|
2021-10-15 16:37:39 +00:00
|
|
|
pSprite->owner = runlist_AddRunRec(pSprite->lotag - 1, ((nSnake << 8) | i), 0x110000);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 16:37:39 +00:00
|
|
|
SnakeList[nSnake].nRun = runlist_AddRunRec(NewRun, nSnake, 0x110000);
|
2019-08-31 07:47:15 +00:00
|
|
|
SnakeList[nSnake].c[1] = 2;
|
|
|
|
SnakeList[nSnake].c[5] = 5;
|
|
|
|
SnakeList[nSnake].c[2] = 4;
|
|
|
|
SnakeList[nSnake].c[3] = 6;
|
|
|
|
SnakeList[nSnake].c[4] = 7;
|
|
|
|
SnakeList[nSnake].c[6] = 6;
|
|
|
|
SnakeList[nSnake].c[7] = 7;
|
|
|
|
SnakeList[nSnake].nEnemy = nTarget;
|
|
|
|
SnakeList[nSnake].sC = 1200;
|
|
|
|
SnakeList[nSnake].sE = 0;
|
2020-11-29 23:18:32 +00:00
|
|
|
SnakeList[nSnake].nSnakePlayer = nPlayer;
|
2019-08-31 07:47:15 +00:00
|
|
|
nPlayerSnake[nPlayer] = nSnake;
|
|
|
|
|
|
|
|
if (bSnakeCam)
|
|
|
|
{
|
|
|
|
if (nSnakeCam < 0) {
|
|
|
|
nSnakeCam = nSnake;
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-09-21 15:47:55 +00:00
|
|
|
D3PlayFX(StaticSound[kSound6], var_24);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int FindSnakeEnemy(short nSnake)
|
|
|
|
{
|
2020-11-29 23:18:32 +00:00
|
|
|
short nPlayer = SnakeList[nSnake].nSnakePlayer;
|
2019-08-31 07:47:15 +00:00
|
|
|
short nPlayerSprite = PlayerList[nPlayer].nSprite;
|
|
|
|
|
|
|
|
short nSprite = SnakeList[nSnake].nSprites[0]; // CHECKME
|
2021-10-15 21:31:00 +00:00
|
|
|
auto pSprite = &sprite[nSprite];
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2021-09-06 06:33:02 +00:00
|
|
|
short nAngle = pSprite->ang;
|
|
|
|
short nSector = pSprite->sectnum;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
int esi = 2048;
|
|
|
|
|
|
|
|
int nEnemy = -1;
|
|
|
|
|
2020-10-15 17:10:51 +00:00
|
|
|
int i;
|
|
|
|
SectIterator it(nSector);
|
|
|
|
while ((i = it.NextIndex()) >= 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2019-11-18 19:38:19 +00:00
|
|
|
if (sprite[i].statnum >= 90 && sprite[i].statnum < 150 && (sprite[i].cstat & 0x101))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2019-11-18 19:38:19 +00:00
|
|
|
if (i != nPlayerSprite && !(sprite[i].cstat & 0x8000))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
int nAngle2 = (nAngle - GetAngleToSprite(nSprite, i)) & kAngleMask;
|
|
|
|
if (nAngle2 < esi)
|
|
|
|
{
|
|
|
|
nEnemy = i;
|
|
|
|
esi = nAngle2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-18 19:38:19 +00:00
|
|
|
if (nEnemy != -1)
|
|
|
|
{
|
|
|
|
SnakeList[nSnake].nEnemy = nEnemy;
|
|
|
|
}
|
|
|
|
else
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
SnakeList[nSnake].nEnemy--;
|
|
|
|
if (SnakeList[nSnake].nEnemy < -25)
|
|
|
|
{
|
|
|
|
nEnemy = nPlayerSprite;
|
|
|
|
SnakeList[nSnake].nEnemy = nPlayerSprite;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nEnemy;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
void AISnake::Tick(RunListEvent* ev)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2021-10-15 21:31:00 +00:00
|
|
|
short nSnake = RunData[ev->nRun].nVal;
|
|
|
|
assert(nSnake >= 0 && nSnake < kMaxSnakes);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
short nSprite = SnakeList[nSnake].nSprites[0];
|
|
|
|
auto pSprite = &sprite[nSprite];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
seq_MoveSequence(nSprite, SeqOffsets[kSeqSnakehed], 0);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
short nEnemySprite = SnakeList[nSnake].nEnemy;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
int nMov;
|
|
|
|
int zVal;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
if (nEnemySprite < 0)
|
|
|
|
{
|
|
|
|
SEARCH_ENEMY:
|
|
|
|
nMov = movesprite(nSprite,
|
|
|
|
600 * bcos(pSprite->ang),
|
|
|
|
600 * bsin(pSprite->ang),
|
|
|
|
bsin(SnakeList[nSnake].sE, -5),
|
|
|
|
0, 0, CLIPMASK1);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
FindSnakeEnemy(nSnake);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
zVal = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!(sprite[nEnemySprite].cstat & 0x101))
|
|
|
|
{
|
|
|
|
SnakeList[nSnake].nEnemy = -1;
|
|
|
|
goto SEARCH_ENEMY;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
zVal = pSprite->z;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
nMov = AngleChase(nSprite, nEnemySprite, 1200, SnakeList[nSnake].sE, 32);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
zVal = pSprite->z - zVal;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
if (nMov)
|
|
|
|
{
|
|
|
|
short nPlayer = SnakeList[nSnake].nSnakePlayer;
|
|
|
|
ExplodeSnakeSprite(SnakeList[nSnake].nSprites[0], nPlayer);
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
nPlayerSnake[nPlayer] = -1;
|
|
|
|
SnakeList[nSnake].nSnakePlayer = -1;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
DestroySnake(nSnake);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
short nAngle = pSprite->ang;
|
|
|
|
int var_30 = -bcos(nAngle, 6);
|
|
|
|
int var_34 = -bsin(nAngle, 6);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
int var_20 = SnakeList[nSnake].sE;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
SnakeList[nSnake].sE = (SnakeList[nSnake].sE + 64) & 0x7FF;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
int var_28 = (nAngle + 512) & kAngleMask;
|
|
|
|
short nSector = pSprite->sectnum;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
int x = pSprite->x;
|
|
|
|
int y = pSprite->y;
|
|
|
|
int z = pSprite->z;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
for (int i = 7; i > 0; i--)
|
|
|
|
{
|
|
|
|
int nSprite2 = SnakeList[nSnake].nSprites[i];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
sprite[nSprite2].ang = nAngle;
|
|
|
|
sprite[nSprite2].x = x;
|
|
|
|
sprite[nSprite2].y = y;
|
|
|
|
sprite[nSprite2].z = z;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
mychangespritesect(nSprite2, nSector);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
int eax = (bsin(var_20) * SnakeList[nSnake].c[i]) >> 9;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
movesprite(nSprite2, var_30 + var_30 * i + eax * bcos(var_28), var_30 + var_34 * i + eax * bsin(var_28),
|
|
|
|
-zVal * (i - 1), 0, 0, CLIPMASK1);
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
var_20 = (var_20 + 128) & kAngleMask;
|
2019-11-18 19:38:19 +00:00
|
|
|
}
|
2021-10-15 21:31:00 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-18 19:38:19 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
void AISnake::Draw(RunListEvent* ev)
|
|
|
|
{
|
|
|
|
short nSnake = RunData[ev->nRun].nVal;
|
|
|
|
short nSprite = ev->nIndex;
|
2019-11-18 19:38:19 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
if ((nSnake & 0xFF) == 0) {
|
|
|
|
seq_PlotSequence(nSprite, SeqOffsets[kSeqSnakehed], 0, 0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
seq_PlotSequence(nSprite, SeqOffsets[kSeqSnakBody], 0, 0);
|
|
|
|
}
|
2019-11-18 19:38:19 +00:00
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
mytsprite[nSprite].owner = -1;
|
|
|
|
}
|
2019-11-18 19:38:19 +00:00
|
|
|
|
|
|
|
|
2021-10-15 21:31:00 +00:00
|
|
|
void FuncSnake(int nObject, int nMessage, int nDamage, int nRun)
|
|
|
|
{
|
|
|
|
AISnake ai;
|
|
|
|
runlist_DispatchEvent(&ai, nObject, nMessage, nDamage, nRun);
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|