Added cobra

This commit is contained in:
MontyTRC89 2018-09-17 12:09:23 +02:00
parent e219cb26b4
commit 166bc52e0a
7 changed files with 142 additions and 30 deletions

Binary file not shown.

View file

@ -37,14 +37,14 @@ typedef enum object_types {
ID_SWAT, ID_SWAT,
ID_MOTORBIKE, // TR4 ID_MOTORBIKE, // TR4
ID_SWAT_PLUS, ID_SWAT_PLUS,
ID_LARA_JEEP_ANIMS, // TR4 ID_LARA_JEEP_ANIMS, // TR4 - OK
ID_BLUE_GUARD, ID_BLUE_GUARD,
ID_LARA_MOTORBIKE_ANIMS, // TR4 ID_LARA_MOTORBIKE_ANIMS, // TR4 - OK
ID_TWOGUN, ID_TWOGUN,
ID_SKELETON, // TR4 - Working on ID_SKELETON, // TR4 - Working on
ID_DOG, ID_DOG,
ID_CROCODILE, // TR4 ID_CROCODILE, // TR4
ID_CROW, ID_CROW_TR5,
ID_MUMMY, // TR4 - OK ID_MUMMY, // TR4 - OK
ID_LARSON, ID_LARSON,
ID_SMALL_SCORPION, // TR4 - OK ID_SMALL_SCORPION, // TR4 - OK
@ -304,9 +304,9 @@ typedef enum object_types {
ID_CLOSED_DOOR1, ID_CLOSED_DOOR1,
ID_SCUBA_DIVER, // TR3 - 26 ID_SCUBA_DIVER, // TR3 - 26
ID_CLOSED_DOOR2, ID_CLOSED_DOOR2,
ID_CROW_TR3, // TR3 - 27 ID_CROW, // TR3 - 27
ID_CLOSED_DOOR3, ID_CLOSED_DOOR3,
ID_TIGER, // TR3 - 28 ID_TIGER, // TR3 - OK
ID_CLOSED_DOOR4, ID_CLOSED_DOOR4,
ID_EAGLE, // TR3 - 29 ID_EAGLE, // TR3 - 29
ID_CLOSED_DOOR5, ID_CLOSED_DOOR5,

View file

@ -15,6 +15,7 @@ BITE_INFO batBiteInfo = { 0, 16, 45, 4 };
BITE_INFO barracudaBite = { 2, -60, 121, 7 }; BITE_INFO barracudaBite = { 2, -60, 121, 7 };
BITE_INFO sharkBite = { 17, -22, 344, 12 }; BITE_INFO sharkBite = { 17, -22, 344, 12 };
BITE_INFO tigerBite = { 19, -13, 3, 26 }; BITE_INFO tigerBite = { 19, -13, 3, 26 };
BITE_INFO cobraBite = { 0, 0, 0, 13 };
void __cdecl InitialiseWildBoar(__int16 itemNum) void __cdecl InitialiseWildBoar(__int16 itemNum)
{ {
@ -822,4 +823,110 @@ void __cdecl TigerControl(__int16 itemNum)
CreatureTilt(item, tilt); CreatureTilt(item, tilt);
CreatureJoint(item, 0, head); CreatureJoint(item, 0, head);
CreatureAnimation(itemNum, angle, tilt); CreatureAnimation(itemNum, angle, tilt);
}
void __cdecl InitialiseCobra(__int16 itemNum)
{
InitialiseCreature(itemNum);
ITEM_INFO* item = &Items[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;
item->hitPoints = Objects[item->objectNumber].hitPoints;
}
void __cdecl CobraControl(__int16 itemNum)
{
if (!CreatureActive(itemNum))
return;
__int16 head = 0;
__int16 angle = 0;
__int16 tilt = 0;
ITEM_INFO* item = &Items[itemNum];
CREATURE_INFO* creature = (CREATURE_INFO *)item->data;
if (item->hitPoints <= 0 && item->hitPoints != -16384)
{
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, 0);
} }

View file

@ -76,3 +76,8 @@ void __cdecl KillerStatueControl(__int16 item_number);
void __cdecl SpringBoardControl(__int16 item_number); void __cdecl SpringBoardControl(__int16 item_number);
void __cdecl TigerControl(__int16 itemNum); void __cdecl TigerControl(__int16 itemNum);
void __cdecl InitialiseCobra(__int16 itemNum);
void __cdecl CobraControl(__int16 itemNum);

View file

@ -5,13 +5,13 @@ GameScript::GameScript()
m_lua.open_libraries(sol::lib::base); m_lua.open_libraries(sol::lib::base);
m_lua.new_usertype<GameScriptSettings>("GameScriptSettings", m_lua.new_usertype<GameScriptSettings>("GameScriptSettings",
"screenWidth", &GameScriptSettings::ScreenWidth, "screenwidth", &GameScriptSettings::ScreenWidth,
"screenHeight", &GameScriptSettings::ScreenHeight, "screenheight", &GameScriptSettings::ScreenHeight,
"windowTitle", &GameScriptSettings::WindowTitle, "windowtitle", &GameScriptSettings::WindowTitle,
"enableDynamicShadows", &GameScriptSettings::EnableDynamicShadows, "enabledynamicshadows", &GameScriptSettings::EnableDynamicShadows,
"windowed", &GameScriptSettings::Windowed, "windowed", &GameScriptSettings::Windowed,
"enableWaterCaustics", &GameScriptSettings::EnableWaterCaustics, "enablewatercaustics", &GameScriptSettings::EnableWaterCaustics,
"drawingDistance", &GameScriptSettings::DrawingDistance "drawingdistance", &GameScriptSettings::DrawingDistance
); );
m_lua.new_usertype<GameScriptSkyLayer>("SkyLayer", m_lua.new_usertype<GameScriptSkyLayer>("SkyLayer",

View file

@ -3,10 +3,10 @@
-- Place in this LUA script all the engine settings for your game -- Place in this LUA script all the engine settings for your game
-- WARNING: bad values could make your game unplayable, please follow with attention the reference guide -- WARNING: bad values could make your game unplayable, please follow with attention the reference guide
Gameflow.settings.screenWidth = 800; Gameflow.settings.screenwidth = 800;
Gameflow.settings.screenHeight = 600; Gameflow.settings.screenheight = 600;
Gameflow.settings.windowTitle = "TR5Main Alpha"; Gameflow.settings.windowiitle = "TR5Main Alpha";
Gameflow.settings.enableDynamicShadows = true; Gameflow.settings.enabledynamicshadows = true;
Gameflow.settings.enableWaterCaustics = true; Gameflow.settings.enablewatercaustics = true;
Gameflow.settings.windowed = true; Gameflow.settings.windowed = true;
Gameflow.settings.drawingDistance = 102400; Gameflow.settings.drawingdistance = 102400;

View file

@ -301,25 +301,15 @@ void __cdecl NewObjects()
Bones[obj->boneIndex + 21 * 4] |= ROT_Y; Bones[obj->boneIndex + 21 * 4] |= ROT_Y;
} }
/*
obj = &Objects[ID_SPIKEY_WALL];
if (obj->loaded)
{
obj->control = ControlSpikeWall;
obj->collision = ObjectCollision;
obj->savePosition = true;
obj->saveFlags = true;
}
obj = &Objects[ID_COBRA]; obj = &Objects[ID_COBRA];
if (obj->loaded) if (obj->loaded)
{ {
obj->initialise = InitialiseCobra; obj->initialise = InitialiseCobra;
obj->control = CobraControl; obj->control = CobraControl;
obj->collision = CreatureCollision; obj->collision = CreatureCollision;
obj->shadowSize = UNIT_SHADOW / 2; obj->shadowSize = 128;
obj->hitPoints = COBRA_hitPoints; obj->hitPoints = 8;
obj->radius = COBRA_RADIUS; obj->radius = 102;
obj->intelligent = true; obj->intelligent = true;
obj->nonLot = true; obj->nonLot = true;
obj->savePosition = true; obj->savePosition = true;
@ -331,6 +321,16 @@ void __cdecl NewObjects()
Bones[obj->boneIndex + 6 * 4] |= ROT_Y; Bones[obj->boneIndex + 6 * 4] |= ROT_Y;
} }
/*
obj = &Objects[ID_SPIKEY_WALL];
if (obj->loaded)
{
obj->control = ControlSpikeWall;
obj->collision = ObjectCollision;
obj->savePosition = true;
obj->saveFlags = true;
}
obj = &Objects[ID_TREX]; obj = &Objects[ID_TREX];
if (obj->loaded) if (obj->loaded)
{ {