mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-01 01:08:01 +03:00
108 lines
2.4 KiB
C++
108 lines
2.4 KiB
C++
![]() |
#include "../newobjects.h"
|
||
|
#include "../../Game/Box.h"
|
||
|
#include "../../Game/effects.h"
|
||
|
|
||
|
BITE_INFO cobraBite = { 0, 0, 0, 13 };
|
||
|
|
||
|
void InitialiseCobra(short itemNum)
|
||
|
{
|
||
|
ITEM_INFO* item = &Items[itemNum];
|
||
|
InitialiseCreature(itemNum);
|
||
|
item->animNumber = Objects[item->objectNumber].animIndex + 2;
|
||
|
item->frameNumber = Anims[item->animNumber].frameBase + 45;
|
||
|
item->currentAnimState = item->goalAnimState = 3;
|
||
|
item->itemFlags[2] = item->hitStatus;
|
||
|
}
|
||
|
|
||
|
void CobraControl(short itemNum)
|
||
|
{
|
||
|
if (!CreatureActive(itemNum))
|
||
|
return;
|
||
|
|
||
|
ITEM_INFO* item = &Items[itemNum];
|
||
|
CREATURE_INFO* creature = (CREATURE_INFO*)item->data;
|
||
|
short head = 0;
|
||
|
short angle = 0;
|
||
|
short tilt = 0;
|
||
|
|
||
|
if (item->hitPoints <= 0)
|
||
|
{
|
||
|
if (item->currentAnimState != 4)
|
||
|
{
|
||
|
item->animNumber = Objects[item->objectNumber].animIndex + 4;
|
||
|
item->frameNumber = Anims[item->animNumber].frameBase;
|
||
|
item->currentAnimState = 4;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AI_INFO info;
|
||
|
CreatureAIInfo(item, &info);
|
||
|
|
||
|
info.angle += 0xC00;
|
||
|
|
||
|
GetCreatureMood(item, &info, 1);
|
||
|
CreatureMood(item, &info, 1);
|
||
|
|
||
|
creature->target.x = LaraItem->pos.xPos;
|
||
|
creature->target.z = LaraItem->pos.zPos;
|
||
|
angle = CreatureTurn(item, creature->maximumTurn);
|
||
|
|
||
|
if (info.ahead)
|
||
|
head = info.angle;
|
||
|
|
||
|
if (abs(info.angle) < ANGLE(10))
|
||
|
item->pos.yRot += info.angle;
|
||
|
else if (info.angle < 0)
|
||
|
item->pos.yRot -= ANGLE(10);
|
||
|
else
|
||
|
item->pos.yRot += ANGLE(10);
|
||
|
|
||
|
switch (item->currentAnimState)
|
||
|
{
|
||
|
case 1:
|
||
|
creature->flags = 0;
|
||
|
if (info.distance > SQUARE(2560))
|
||
|
item->goalAnimState = 3;
|
||
|
else if ((LaraItem->hitPoints > 0) && ((info.ahead && info.distance < SQUARE(1024)) || item->hitStatus || (LaraItem->speed > 15)))
|
||
|
item->goalAnimState = 2;
|
||
|
break;
|
||
|
|
||
|
case 3:
|
||
|
creature->flags = 0;
|
||
|
if (item->hitPoints != -16384)
|
||
|
{
|
||
|
item->itemFlags[2] = item->hitPoints;
|
||
|
item->hitPoints = -16384;
|
||
|
}
|
||
|
if (info.distance < SQUARE(1536) && LaraItem->hitPoints > 0)
|
||
|
{
|
||
|
item->goalAnimState = 0;
|
||
|
item->hitPoints = item->itemFlags[2];
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case 2:
|
||
|
if (creature->flags != 1 && (item->touchBits & 0x2000))
|
||
|
{
|
||
|
creature->flags = 1;
|
||
|
LaraItem->hitPoints -= 80;
|
||
|
LaraItem->hitStatus = true;
|
||
|
Lara.poisoned = 0x100;
|
||
|
|
||
|
CreatureEffect(item, &cobraBite, DoBloodSplat);
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case 0:
|
||
|
item->hitPoints = item->itemFlags[2];
|
||
|
break;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
CreatureTilt(item, tilt);
|
||
|
CreatureJoint(item, 0, head >> 1);
|
||
|
CreatureJoint(item, 1, head >> 1);
|
||
|
CreatureAnimation(itemNum, angle, tilt);
|
||
|
}
|