TombEngine/TR5Main/Objects/TR4/Entity/tr4_smallscorpion.cpp

187 lines
4.1 KiB
C++
Raw Normal View History

#include "framework.h"
#include "tr4_smallscorpion.h"
2021-09-19 23:41:26 +03:00
#include "control/box.h"
#include "items.h"
#include "effects\effects.h"
#include "setup.h"
#include "level.h"
#include "lara.h"
#include "itemdata/creature_info.h"
2021-09-19 23:41:26 +03:00
#include "control/control.h"
2021-09-24 07:53:42 +02:00
#include "item.h"
2021-09-25 11:27:47 +02:00
BITE_INFO smallScorpionBiteInfo1 = { 0, 0, 0, 0 };
BITE_INFO smallScorpionBiteInfo2 = { 0, 0, 0, 23 };
enum SMALL_SCORPION_STATES {
SMALL_SCORPION_STOP = 1,
SMALL_SCORPION_WALK = 2,
SMALL_SCORPION_RUN = 3,
SMALL_SCORPION_ATTACK1 = 4,
SMALL_SCORPION_ATTACK2 = 5,
SMALL_SCORPION_DEATH1 = 6,
SMALL_SCORPION_DEATH2 = 7
};
void InitialiseSmallScorpion(short itemNumber)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
ClearItem(itemNumber);
item->animNumber = Objects[ID_SMALL_SCORPION].animIndex + 2;
item->frameNumber = g_Level.Anims[item->animNumber].frameBase;
item->goalAnimState = SMALL_SCORPION_STOP;
item->currentAnimState = SMALL_SCORPION_STOP;
}
void SmallScorpionControl(short itemNumber)
{
short angle = 0;
short head = 0;
short neck = 0;
short tilt = 0;
short joint0 = 0;
short joint1 = 0;
short joint2 = 0;
short joint3 = 0;
if (!CreatureActive(itemNumber))
return;
ITEM_INFO* item = &g_Level.Items[itemNumber];
CREATURE_INFO* creature = (CREATURE_INFO*)item->data;
if (item->hitPoints <= 0)
{
item->hitPoints = 0;
if (item->currentAnimState != SMALL_SCORPION_DEATH1 && item->currentAnimState != SMALL_SCORPION_DEATH2)
{
item->animNumber = Objects[ID_SMALL_SCORPION].animIndex + 5;
item->frameNumber = g_Level.Anims[item->animNumber].frameBase;
item->currentAnimState = SMALL_SCORPION_DEATH1;
}
}
else
{
int dx = LaraItem->pos.xPos - item->pos.xPos;
int dz = LaraItem->pos.zPos - item->pos.zPos;
int laraDistance = dx * dx + dz * dz;
if (item->aiBits & GUARD)
GetAITarget(creature);
else
creature->enemy = LaraItem;
AI_INFO info;
CreatureAIInfo(item, &info);
GetCreatureMood(item, &info, VIOLENT);
CreatureMood(item, &info, VIOLENT);
angle = CreatureTurn(item, creature->maximumTurn);
switch (item->currentAnimState)
{
case SMALL_SCORPION_STOP:
creature->maximumTurn = 0;
creature->flags = 0;
if (info.distance > SQUARE(341))
{
item->goalAnimState = SMALL_SCORPION_WALK;
}
else if (info.bite)
{
creature->maximumTurn = ANGLE(6);
if (GetRandomControl() & 1)
{
item->goalAnimState = SMALL_SCORPION_ATTACK1;
}
else
{
item->goalAnimState = SMALL_SCORPION_ATTACK2;
}
}
else if (!info.ahead)
{
item->goalAnimState = SMALL_SCORPION_RUN;
}
break;
case SMALL_SCORPION_WALK:
creature->maximumTurn = ANGLE(6);
if (info.distance >= SQUARE(341))
{
if (info.distance > SQUARE(213))
{
item->goalAnimState = SMALL_SCORPION_RUN;
}
}
else
{
item->goalAnimState = SMALL_SCORPION_STOP;
}
break;
case SMALL_SCORPION_RUN:
creature->maximumTurn = ANGLE(8);
if (info.distance < SQUARE(341))
{
item->goalAnimState = SMALL_SCORPION_STOP;
}
break;
case SMALL_SCORPION_ATTACK1:
case SMALL_SCORPION_ATTACK2:
creature->maximumTurn = 0;
if (abs(info.angle) >= ANGLE(6))
{
if (info.angle >= 0)
{
item->pos.yRot += ANGLE(6);
}
else
{
item->pos.yRot -= ANGLE(6);
}
}
else
{
item->pos.yRot += info.angle;
}
if (!creature->flags)
{
if (item->touchBits & 0x1B00100)
{
if (item->frameNumber > g_Level.Anims[item->animNumber].frameBase + 20 &&
item->frameNumber < g_Level.Anims[item->animNumber].frameBase + 32)
{
2021-08-02 12:07:54 +03:00
Lara.poisoned += 512;
LaraItem->hitPoints -= 20;
LaraItem->hitStatus = true;
BITE_INFO* biteInfo;
short rot;
if (item->currentAnimState == SMALL_SCORPION_ATTACK1)
{
rot = item->pos.yRot + -ANGLE(180);
biteInfo = &smallScorpionBiteInfo1;
}
else
{
rot = item->pos.yRot + -ANGLE(180);
biteInfo = &smallScorpionBiteInfo2;
}
CreatureEffect2(item, biteInfo, 3, rot, DoBloodSplat);
creature->flags = 1;
}
}
}
break;
}
}
CreatureAnimation(itemNumber, angle, 0);
Merge branch 'master' into item_data # Conflicts: # TR5Main/Game/Lara/lara.cpp # TR5Main/Game/Lara/lara_collide.cpp # TR5Main/Game/Lara/lara_monkey.cpp # TR5Main/Game/Lara/lara_struct.h # TR5Main/Game/Lara/lara_tests.cpp # TR5Main/Game/collide.h # TR5Main/Game/control.h # TR5Main/Game/effect.h # TR5Main/Game/effect2.cpp # TR5Main/Game/flipeffect.cpp # TR5Main/Game/floordata.h # TR5Main/Game/hair.cpp # TR5Main/Game/health.cpp # TR5Main/Game/items.cpp # TR5Main/Game/newinv2.cpp # TR5Main/Game/spotcam.cpp # TR5Main/Objects/Effects/tr4_bubbles.cpp # TR5Main/Objects/TR1/Entity/tr1_ape.cpp # TR5Main/Objects/TR1/Entity/tr1_bigrat.cpp # TR5Main/Objects/TR1/Entity/tr1_doppelganger.cpp # TR5Main/Objects/TR2/Entity/tr2_birdmonster.cpp # TR5Main/Objects/TR2/Entity/tr2_shark.cpp # TR5Main/Objects/TR2/Entity/tr2_spider.cpp # TR5Main/Objects/TR2/Entity/tr2_yeti.cpp # TR5Main/Objects/TR3/Entity/tr3_fishemitter.cpp # TR5Main/Objects/TR3/Entity/tr3_flamethrower.cpp # TR5Main/Objects/TR3/Entity/tr3_monkey.cpp # TR5Main/Objects/TR3/Entity/tr3_raptor.cpp # TR5Main/Objects/TR3/Entity/tr3_scuba.cpp # TR5Main/Objects/TR3/Entity/tr3_trex.cpp # TR5Main/Objects/TR3/Vehicles/kayak.cpp # TR5Main/Objects/TR3/Vehicles/minecart.cpp # TR5Main/Objects/TR4/Entity/tr4_bat.cpp # TR5Main/Objects/TR4/Entity/tr4_big_beetle.cpp # TR5Main/Objects/TR4/Entity/tr4_bigscorpion.cpp # TR5Main/Objects/TR4/Entity/tr4_demigod.cpp # TR5Main/Objects/TR4/Entity/tr4_dog.cpp # TR5Main/Objects/TR4/Entity/tr4_hammerhead.cpp # TR5Main/Objects/TR4/Entity/tr4_harpy.cpp # TR5Main/Objects/TR4/Entity/tr4_mutant.cpp # TR5Main/Objects/TR4/Entity/tr4_smallscorpion.cpp # TR5Main/Objects/TR4/Entity/tr4_troops.cpp # TR5Main/Objects/TR4/Entity/tr4_wildboar.cpp # TR5Main/Objects/TR4/Trap/tr4_joby_spikes.cpp # TR5Main/Objects/TR4/Vehicles/motorbike.cpp # TR5Main/Objects/TR5/Entity/tr5_doberman.cpp # TR5Main/Objects/TR5/Entity/tr5_imp.cpp # TR5Main/Objects/TR5/Entity/tr5_larson.cpp # TR5Main/Objects/TR5/Entity/tr5_lion.cpp # TR5Main/Objects/TR5/Entity/tr5_reaper.cpp # TR5Main/Objects/TR5/Object/tr5_pushableblock.cpp # TR5Main/Objects/TR5/Object/tr5_rollingball.cpp # TR5Main/Objects/TR5/Trap/tr5_fallingceiling.cpp # TR5Main/Renderer/Renderer11Draw2D.cpp # TR5Main/Specific/input.cpp # TR5Main/Specific/level.cpp # TR5Main/TombEngine.vcxproj.filters
2021-08-31 17:37:15 +02:00
}