Refactored energy bubbles function names; Removed LanguageScript.cpp from the project; Working on ID_CROCODILE_GOD;

This commit is contained in:
MontyTRC89 2021-08-20 06:00:34 +02:00
parent 2e1ac44c08
commit 4991da66f6
10 changed files with 720 additions and 704 deletions

View file

@ -38,14 +38,14 @@ enum ZoneType
ZONE_HUMAN_LONGJUMP_AND_MONKEY,
};
struct OBJECT_Bones
struct OBJECT_BONES
{
short bone0;
short bone1;
short bone2;
short bone3;
OBJECT_Bones()
OBJECT_BONES()
{
this->bone0 = 0;
this->bone1 = 0;
@ -53,7 +53,7 @@ struct OBJECT_Bones
this->bone3 = 0;
}
OBJECT_Bones(short all)
OBJECT_BONES(short all)
{
this->bone0 = all;
this->bone1 = all;
@ -61,7 +61,7 @@ struct OBJECT_Bones
this->bone3 = all;
}
OBJECT_Bones(short angleY, short angleX)
OBJECT_BONES(short angleY, short angleX)
{
this->bone0 = angleY;
this->bone1 = angleX;
@ -69,7 +69,7 @@ struct OBJECT_Bones
this->bone3 = angleX;
}
OBJECT_Bones(short angleY, short angleX, bool total)
OBJECT_BONES(short angleY, short angleX, bool total)
{
this->bone0 = angleY;
this->bone1 = angleX;

View file

@ -11,8 +11,10 @@
#include "lara.h"
#include "tr4_mutant.h"
void BubblesEffect1(short fxNum, short xVel, short yVel, short zVel)
namespace ten::entities::all
{
void TriggerSethMissileFlame(short fxNum, short xVel, short yVel, short zVel)
{
FX_INFO* fx = &EffectList[fxNum];
int dx = LaraItem->pos.xPos - fx->pos.xPos;
@ -31,7 +33,7 @@ void BubblesEffect1(short fxNum, short xVel, short yVel, short zVel)
spark->dG = spark->dB + 64;
spark->fadeToBlack = 8;
spark->colFadeSpeed = (GetRandomControl() & 3) + 4;
spark->transType = COLADD;
spark->transType = TransTypeEnum::COLADD;
spark->life = spark->sLife = (GetRandomControl() & 3) + 16;
spark->y = 0;
spark->x = (GetRandomControl() & 0xF) - 8;
@ -64,10 +66,10 @@ void BubblesEffect1(short fxNum, short xVel, short yVel, short zVel)
spark->sSize = spark->size = (GetRandomControl() & 7) + 64;
spark->dSize = spark->size / 32;
}
}
}
void BubblesEffect2(short fxNum, short xVel, short yVel, short zVel)
{
void TriggerHarpyFlameFlame(short fxNum, short xVel, short yVel, short zVel)
{
FX_INFO* fx = &EffectList[fxNum];
int dx = LaraItem->pos.xPos - fx->pos.xPos;
@ -111,10 +113,10 @@ void BubblesEffect2(short fxNum, short xVel, short yVel, short zVel)
spark->sSize = spark->size = (GetRandomControl() & 7) + 64;
spark->dSize = spark->size / 32;
}
}
}
void BubblesEffect4(short fxNum, short xVel, short yVel, short zVel)
{
void TriggerDemigodMissileFlame(short fxNum, short xVel, short yVel, short zVel)
{
FX_INFO* fx = &EffectList[fxNum];
int dx = LaraItem->pos.xPos - fx->pos.xPos;
@ -171,10 +173,10 @@ void BubblesEffect4(short fxNum, short xVel, short yVel, short zVel)
spark->sSize = spark->size = (GetRandomControl() & 7) + 64;
spark->dSize = spark->size / 32;
}
}
}
void BubblesShatterFunction(FX_INFO* fx, int param1, int param2)
{
void BubblesShatterFunction(FX_INFO* fx, int param1, int param2)
{
ShatterItem.yRot = fx->pos.yRot;
ShatterItem.meshp = &g_Level.Meshes[fx->frameNumber];
ShatterItem.sphere.x = fx->pos.xPos;
@ -183,10 +185,10 @@ void BubblesShatterFunction(FX_INFO* fx, int param1, int param2)
ShatterItem.bit = 0;
ShatterItem.flags = fx->flag2 & 0x400;
ShatterObject(&ShatterItem, 0, param2, fx->roomNumber, param1);
}
}
void BubblesControl(short fxNum)
{
void ControlEnemyMissile(short fxNum)
{
FX_INFO* fx = &EffectList[fxNum];
short angles[2];
@ -400,7 +402,7 @@ void BubblesControl(short fxNum)
}
else
{
TriggerShockwave( &fx->pos, 24, 88, 48, 64, 128, 0, 16, (((~g_Level.Rooms[fx->roomNumber].flags) / 16) & 2) * 65536, 0);
TriggerShockwave(&fx->pos, 24, 88, 48, 64, 128, 0, 16, (((~g_Level.Rooms[fx->roomNumber].flags) / 16) & 2) * 65536, 0);
}
}
else
@ -418,20 +420,21 @@ void BubblesControl(short fxNum)
{
default:
case 1:
BubblesEffect1(fxNum, 32 * dx, 32 * dy, 32 * dz);
TriggerSethMissileFlame(fxNum, 32 * dx, 32 * dy, 32 * dz);
break;
case 2:
BubblesEffect2(fxNum, 16 * dx, 16 * dy, 16 * dz);
TriggerHarpyFlameFlame(fxNum, 16 * dx, 16 * dy, 16 * dz);
break;
case 3:
case 4:
case 5:
BubblesEffect4(fxNum, 16 * dx, 16 * dy, 16 * dz);
TriggerDemigodMissileFlame(fxNum, 16 * dx, 16 * dy, 16 * dz);
break;
case 6:
TriggerMutantRocketEffects(fxNum, 16 * dx, 16 * dy, 16 * dz);
ten::entities::tr4::TriggerCrocgodMissileFlame(fxNum, 16 * dx, 16 * dy, 16 * dz);
break;
}
}
}
}
}

View file

@ -1,3 +1,6 @@
#pragma once
void BubblesControl(short fxNum);
namespace ten::entities::all
{
void ControlEnemyMissile(short fxNum);
}

View file

@ -104,7 +104,7 @@ void CrocodileControl(short itemNumber)
OBJECT_INFO* obj;
CREATURE_INFO* crocodile;
AI_INFO info;
OBJECT_Bones boneRot;
OBJECT_BONES boneRot;
short angle;
short boneAngle;

View file

@ -10,30 +10,10 @@
#include "objectslist.h"
#include "trmath.h"
enum MUTANT_STATE
{
MUTANT_EMPTY,
MUTANT_APPEAR,
MUTANT_IDLE,
MUTANT_SHOOT,
MUTANT_LOCUST1,
MUTANT_LOCUST2,
};
enum class MissileRotationType
{
M_FRONT,
M_LEFT,
M_RIGHT
};
constexpr auto MUTANT_ANIM_APPEAR = 0;
constexpr auto MUTANT_SHOOT_RANGE = SQUARE(SECTOR(10));
constexpr auto MUTANT_LOCUST1_RANGE = SQUARE(SECTOR(15));
constexpr auto MUTANT_LOCUST2_RANGE = SQUARE(SECTOR(30));
static void TriggerMutantRocket(PHD_3DPOS* src, short roomNumber, short counter)
namespace ten::entities::tr4
{
void TriggerCrocgodMissile(PHD_3DPOS* src, short roomNumber, short counter)
{
FX_INFO* fx;
short fxNumber = NO_ITEM;
@ -54,10 +34,10 @@ static void TriggerMutantRocket(PHD_3DPOS* src, short roomNumber, short counter)
fx->speed = (GetRandomControl() & 0x1F) + 96;
fx->flag1 = 6;
}
}
}
void TriggerMutantRocketEffects(short fxNumber, short xVel, short yVel, short zVel)
{
void TriggerCrocgodMissileFlame(short fxNumber, short xVel, short yVel, short zVel)
{
FX_INFO* fx;
SPARKS* sptr;
BYTE color, life, size;
@ -79,7 +59,7 @@ void TriggerMutantRocketEffects(short fxNumber, short xVel, short yVel, short zV
sptr->dG = color / 2;
sptr->fadeToBlack = 8;
sptr->colFadeSpeed = (GetRandomControl() & 3) + 8;
sptr->transType = COLADD;
sptr->transType = TransTypeEnum::COLADD;
sptr->dynamic = -1;
life = (GetRandomControl() & 7) + 32;
sptr->life = life;
@ -108,10 +88,10 @@ void TriggerMutantRocketEffects(short fxNumber, short xVel, short yVel, short zV
sptr->size = size;
sptr->sSize = size;
sptr->dSize = size / 4;
}
}
static void ShootFireball(PHD_3DPOS* src, MissileRotationType rotation, short roomNumber, int timer)
{
static void ShootFireball(PHD_3DPOS* src, MissileRotationType rotation, short roomNumber, int timer)
{
switch (rotation)
{
case MissileRotationType::M_LEFT:
@ -122,11 +102,11 @@ static void ShootFireball(PHD_3DPOS* src, MissileRotationType rotation, short ro
break;
}
TriggerMutantRocket(src, roomNumber, timer);
}
TriggerCrocgodMissile(src, roomNumber, timer);
}
static bool ShootFrame(ITEM_INFO* item)
{
static bool ShootFrame(ITEM_INFO* item)
{
short frameNumber = (item->frameNumber - g_Level.Anims[item->objectNumber].frameBase);
if (frameNumber == 45
//|| frameNumber == 50
@ -138,10 +118,10 @@ static bool ShootFrame(ITEM_INFO* item)
return true;
else
return false;
}
}
static void RotateHeadToTarget(ITEM_INFO* item, CREATURE_INFO* creature, int joint, short& headAngle)
{
static void RotateHeadToTarget(ITEM_INFO* item, CREATURE_INFO* creature, int joint, short& headAngle)
{
if (creature->enemy == nullptr)
{
headAngle = item->pos.yRot;
@ -157,10 +137,10 @@ static void RotateHeadToTarget(ITEM_INFO* item, CREATURE_INFO* creature, int joi
x = enemy->pos.xPos - pos.x;
z = enemy->pos.zPos - pos.z;
headAngle = (short)(phd_atan(z, x) - item->pos.yRot) / 2;
}
}
static void GetTargetPosition(ITEM_INFO* item, PHD_3DPOS* target)
{
static void GetTargetPosition(ITEM_INFO* item, PHD_3DPOS* target)
{
PHD_VECTOR start, end;
short angles[2];
start.x = 0;
@ -178,10 +158,10 @@ static void GetTargetPosition(ITEM_INFO* item, PHD_3DPOS* target)
target->yRot = angles[0];
target->xRot = angles[1];
target->zRot = 0;
}
}
enum CARDINAL_POINT
{
enum CARDINAL_POINT
{
C_NORTH = 0,
C_NORTH_EAST = 45,
C_EAST = 90,
@ -190,10 +170,10 @@ enum CARDINAL_POINT
C_SOUTH_WEST = 225,
C_WEST = 270,
C_WEST_NORTH = 315
};
};
static void MoveItemFront(ITEM_INFO* item, int distance)
{
static void MoveItemFront(ITEM_INFO* item, int distance)
{
short degree = short(TO_DEGREES(item->pos.yRot));
switch (degree)
{
@ -210,10 +190,10 @@ static void MoveItemFront(ITEM_INFO* item, int distance)
item->pos.xPos -= distance;
break;
}
}
}
static void MoveItemBack(ITEM_INFO* item, int distance)
{
static void MoveItemBack(ITEM_INFO* item, int distance)
{
short degree = short(TO_DEGREES(item->pos.yRot));
switch (degree)
{
@ -230,38 +210,38 @@ static void MoveItemBack(ITEM_INFO* item, int distance)
item->pos.xPos += distance;
break;
}
}
}
static void MutantAIFix(ITEM_INFO* item, AI_INFO* info)
{
static void MutantAIFix(ITEM_INFO* item, AI_INFO* info)
{
MoveItemFront(item, SECTOR(2));
item->pos.yPos -= CLICK(3);
CreatureAIInfo(item, info);
item->pos.yPos += CLICK(3);
MoveItemBack(item, SECTOR(2));
}
}
void InitialiseMutant(short itemNumber)
{
void InitialiseCrocgod(short itemNumber)
{
ITEM_INFO* item;
InitialiseCreature(itemNumber);
item = &g_Level.Items[itemNumber];
item->animNumber = Objects[item->objectNumber].animIndex + MUTANT_ANIM_APPEAR;
item->frameNumber = g_Level.Anims[item->animNumber].frameBase;
item->currentAnimState = MUTANT_APPEAR;
item->goalAnimState = MUTANT_APPEAR;
}
item->currentAnimState = STATE_MUTANT_APPEAR;
item->goalAnimState = STATE_MUTANT_APPEAR;
}
void MutantControl(short itemNumber)
{
void CrocgodControl(short itemNumber)
{
if (!CreatureActive(itemNumber))
return;
ITEM_INFO* item;
CREATURE_INFO* mutant;
AI_INFO info;
OBJECT_Bones mutant_joint;
OBJECT_BONES mutant_joint;
short frameNumber;
short headY;
short angle;
@ -287,19 +267,20 @@ void MutantControl(short itemNumber)
switch (item->currentAnimState)
{
case MUTANT_IDLE:
case STATE_MUTANT_IDLE:
if (info.ahead)
{
int random = GetRandomControl() & 31;
if ((random > 0 && random < 10) && info.distance <= MUTANT_SHOOT_RANGE)
item->goalAnimState = MUTANT_SHOOT;
item->goalAnimState = STATE_MUTANT_SHOOT;
else if ((random > 10 && random < 20) && info.distance <= MUTANT_LOCUST1_RANGE)
item->goalAnimState = MUTANT_LOCUST1;
item->goalAnimState = STATE_MUTANT_LOCUST1;
else if ((random > 20 && random < 30) && info.distance <= MUTANT_LOCUST2_RANGE)
item->goalAnimState = MUTANT_LOCUST2;
item->goalAnimState = STATE_MUTANT_LOCUST2;
}
break;
case MUTANT_SHOOT:
case STATE_MUTANT_SHOOT:
frameNumber = (item->frameNumber - g_Level.Anims[item->objectNumber].frameBase);
if (frameNumber >= 94 && frameNumber <= 96)
{
@ -321,12 +302,14 @@ void MutantControl(short itemNumber)
}
}
break;
case MUTANT_LOCUST1:
case STATE_MUTANT_LOCUST1:
frameNumber = (item->frameNumber - g_Level.Anims[item->objectNumber].frameBase);
if (frameNumber >= 60 && frameNumber <= 120)
ten::entities::tr4::SpawnLocust(item);
break;
case MUTANT_LOCUST2:
case STATE_MUTANT_LOCUST2:
if (ShootFrame(item))
{
PHD_3DPOS src;
@ -336,15 +319,15 @@ void MutantControl(short itemNumber)
break;
}
if (item->currentAnimState != MUTANT_LOCUST1)
mutant_joint = OBJECT_Bones(headY, info.xAngle, true);
if (item->currentAnimState != STATE_MUTANT_LOCUST1)
mutant_joint = OBJECT_BONES(headY, info.xAngle, true);
else
mutant_joint = OBJECT_Bones(0);
mutant_joint = OBJECT_BONES(0);
CreatureJoint(item, 0, mutant_joint.bone0);
CreatureJoint(item, 1, mutant_joint.bone1);
CreatureJoint(item, 2, mutant_joint.bone2);
CreatureJoint(item, 3, mutant_joint.bone3);
CreatureAnimation(itemNumber, angle, 0);
}
}

View file

@ -1,5 +1,33 @@
#pragma once
void InitialiseMutant(short itemNumber);
void MutantControl(short itemNumber);
void TriggerMutantRocketEffects(short fxNumber, short xVel, short yVel, short zVel);
#include "framework.h"
#include "trmath.h"
namespace ten::entities::tr4
{
enum MUTANT_STATE
{
STATE_MUTANT_EMPTY,
STATE_MUTANT_APPEAR,
STATE_MUTANT_IDLE,
STATE_MUTANT_SHOOT,
STATE_MUTANT_LOCUST1,
STATE_MUTANT_LOCUST2,
};
enum class MissileRotationType
{
M_FRONT,
M_LEFT,
M_RIGHT
};
constexpr auto MUTANT_ANIM_APPEAR = 0;
constexpr auto MUTANT_SHOOT_RANGE = SQUARE(SECTOR(10));
constexpr auto MUTANT_LOCUST1_RANGE = SQUARE(SECTOR(15));
constexpr auto MUTANT_LOCUST2_RANGE = SQUARE(SECTOR(30));
void InitialiseCrocgod(short itemNumber);
void CrocgodControl(short itemNumber);
void TriggerCrocgodMissileFlame(short fxNumber, short xVel, short yVel, short zVel);
}

View file

@ -664,8 +664,8 @@ static void StartBaddy(OBJECT_INFO* obj)
obj = &Objects[ID_CROCODILE_GOD];
if (obj->loaded)
{
obj->initialise = InitialiseMutant;
obj->control = MutantControl;
obj->initialise = ten::entities::tr4::InitialiseCrocgod;
obj->control = ten::entities::tr4::CrocgodControl;
obj->collision = CreatureCollision;
obj->shadowSize = UNIT_SHADOW / 2;
obj->hitPoints = NOT_TARGETABLE;

View file

@ -1241,7 +1241,7 @@ static void StartShatter(OBJECT_INFO *obj)
static void StartProjectiles(OBJECT_INFO *obj)
{
InitProjectile(obj, BubblesControl, ID_ENERGY_BUBBLES, true);
InitProjectile(obj, ten::entities::all::ControlEnemyMissile, ID_ENERGY_BUBBLES, true);
InitProjectile(obj, MissileControl, ID_BUBBLES, true);
InitProjectile(obj, MissileControl, ID_IMP_ROCK, true);
InitProjectile(obj, TorpedoControl, ID_TORPEDO);

View file

@ -110,7 +110,7 @@ enum GAME_OBJECT_ID : short
ID_DOBERMAN,
ID_HAMMERHEAD, // TR4 - OK
ID_CROCODILE_GOD, // TR4 Citadel Gate Mutant
ID_LOCUSTS_EMITTER,
ID_LOCUSTS_EMITTER, // TR4 - OK
/* Humans */
ID_SCUBA_HARPOON = 150,

View file

@ -711,7 +711,6 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\"</Command>
<ClCompile Include="Scripting\GameScriptSinkInfo.cpp" />
<ClCompile Include="Scripting\GameScriptSkyLayer.cpp" />
<ClCompile Include="Scripting\GameScriptSoundSourceInfo.cpp" />
<ClCompile Include="Scripting\LanguageScript.cpp" />
<ClCompile Include="Objects\TR4\Entity\tr4_demigod.cpp" />
<ClCompile Include="Objects\TR4\Entity\tr4_guide.cpp" />
<ClCompile Include="Objects\TR4\Entity\tr4_jeanyves.cpp" />