[Scummvm-git-logs] scummvm master -> 8304887bf790903872271f20ca9ad7563b99029c
mgerhardy
noreply at scummvm.org
Wed Aug 14 16:02:31 UTC 2024
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
2ea91eae31 TWINE: LBA2: implemented a few more opcodes
8304887bf7 TWINE: fixed different values for max life points in lba1 and lba2
Commit: 2ea91eae31d9a07937cc3f0a2b0cd3350f986945
https://github.com/scummvm/scummvm/commit/2ea91eae31d9a07937cc3f0a2b0cd3350f986945
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-08-14T17:51:23+02:00
Commit Message:
TWINE: LBA2: implemented a few more opcodes
Changed paths:
engines/twine/scene/actor.h
engines/twine/script/script_life_v2.cpp
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index 0b751dfb6f9..53b393312ae 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -135,6 +135,7 @@ struct BonusParameter {
uint16 unused : 7;
};
+// TODO: this is 255 for lba2
#define kActorMaxLife 50
/**
diff --git a/engines/twine/script/script_life_v2.cpp b/engines/twine/script/script_life_v2.cpp
index fee9c3e3452..4ec2512b2f9 100644
--- a/engines/twine/script/script_life_v2.cpp
+++ b/engines/twine/script/script_life_v2.cpp
@@ -24,6 +24,7 @@
#include "twine/audio/music.h"
#include "twine/movies.h"
#include "twine/menu/interface.h"
+#include "twine/scene/animations.h"
#include "twine/parser/anim3ds.h"
#include "twine/renderer/redraw.h"
#include "twine/renderer/renderer.h"
@@ -734,7 +735,19 @@ int32 ScriptLifeV2::lSET_ARMOR_OBJ(TwinEEngine *engine, LifeScriptContext &ctx)
}
int32 ScriptLifeV2::lADD_LIFE_POINT_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
- return -1;
+ const uint8 num = ctx.stream.readByte();
+ const uint8 life = ctx.stream.readByte();
+ ActorStruct *actor = engine->_scene->getActor(num);
+ if (actor->_workFlags.bIsDead) {
+ actor->_workFlags.bIsDead = false;
+ engine->_actor->initBody(BodyType::btNormal, num);
+ engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeRepeat, AnimationTypes::kStanding, num);
+ }
+ actor->_lifePoint += life;
+ if (actor->_lifePoint > kActorMaxLife) {
+ actor->_lifePoint = kActorMaxLife;
+ }
+ return 0;
}
int32 ScriptLifeV2::lSTATE_INVENTORY(TwinEEngine *engine, LifeScriptContext &ctx) {
@@ -774,7 +787,16 @@ int32 ScriptLifeV2::lEND_SWITCH(TwinEEngine *engine, LifeScriptContext &ctx) {
}
int32 ScriptLifeV2::lSET_HIT_ZONE(TwinEEngine *engine, LifeScriptContext &ctx) {
- return -1;
+ const uint8 num = ctx.stream.readByte();
+ const uint8 info1 = ctx.stream.readByte();
+ debugC(3, kDebugLevels::kDebugScripts, "LIFE::lSET_HIT_ZONE(%i, %i)", (int)num, (int)info1);
+ for (int n = 0; n < engine->_scene->_sceneNumZones; n++) {
+ ZoneStruct &zone = engine->_scene->_sceneZones[n];
+ if (zone.type == ZoneType::kHit && zone.num == num) {
+ zone.infoData.generic.info1 = info1;
+ }
+ }
+ return 0;
}
int32 ScriptLifeV2::lSAVE_COMPORTEMENT(TwinEEngine *engine, LifeScriptContext &ctx) {
@@ -790,22 +812,38 @@ int32 ScriptLifeV2::lRESTORE_COMPORTEMENT(TwinEEngine *engine, LifeScriptContext
}
int32 ScriptLifeV2::lSAMPLE(TwinEEngine *engine, LifeScriptContext &ctx) {
+ const int16 sample = ctx.stream.readSint16LE();
+ debugC(3, kDebugLevels::kDebugScripts, "LIFE::lSAMPLE(%i)", (int)sample);
+ // TODO: HQ_3D_MixSample(sample, 0x1000, 0, 1, ctx.actor->posObj());
return -1;
}
int32 ScriptLifeV2::lSAMPLE_RND(TwinEEngine *engine, LifeScriptContext &ctx) {
+ const int16 sample = ctx.stream.readSint16LE();
+ debugC(3, kDebugLevels::kDebugScripts, "LIFE::lSAMPLE_RND(%i)", (int)sample);
+ // TODO: HQ_3D_MixSample(sample, 0x800, 0x1000, 1, ctx.actor->posObj());
return -1;
}
int32 ScriptLifeV2::lSAMPLE_ALWAYS(TwinEEngine *engine, LifeScriptContext &ctx) {
+ const int16 sample = ctx.stream.readSint16LE();
+ debugC(3, kDebugLevels::kDebugScripts, "LIFE::lSAMPLE_ALWAYS(%i)", (int)sample);
+ // TODO:
return -1;
}
int32 ScriptLifeV2::lSAMPLE_STOP(TwinEEngine *engine, LifeScriptContext &ctx) {
+ const int16 sample = ctx.stream.readSint16LE();
+ debugC(3, kDebugLevels::kDebugScripts, "LIFE::lSAMPLE_STOP(%i)", (int)sample);
+ // TODO:
return -1;
}
int32 ScriptLifeV2::lREPEAT_SAMPLE(TwinEEngine *engine, LifeScriptContext &ctx) {
+ const int16 sample = ctx.stream.readSint16LE();
+ uint8 repeat = ctx.stream.readByte();
+ debugC(3, kDebugLevels::kDebugScripts, "LIFE::lREPEAT_SAMPLE(%i, %i)", (int)sample, (int)repeat);
+ // TODO: HQ_3D_MixSample(sample, 0x1000, 0, repeat, ctx.actor->posObj());
return -1;
}
@@ -833,6 +871,7 @@ int32 ScriptLifeV2::lSET_FLAG_GAME(TwinEEngine *engine, LifeScriptContext &ctx)
int32 ScriptLifeV2::lADD_VAR_GAME(TwinEEngine *engine, LifeScriptContext &ctx) {
const uint8 num = ctx.stream.readByte();
const int16 val = ctx.stream.readSint16LE();
+ debugC(3, kDebugLevels::kDebugScripts, "LIFE::lADD_VAR_GAME(%i, %i)", (int)num, (int)val);
int16 currentVal = engine->_gameState->hasGameFlag(num);
if ((int)currentVal + (int)val < 32767) {
currentVal += val;
@@ -854,6 +893,7 @@ int32 ScriptLifeV2::lADD_VAR_GAME(TwinEEngine *engine, LifeScriptContext &ctx) {
int32 ScriptLifeV2::lSUB_VAR_GAME(TwinEEngine *engine, LifeScriptContext &ctx) {
const uint8 num = ctx.stream.readByte();
const int16 val = ctx.stream.readSint16LE();
+ debugC(3, kDebugLevels::kDebugScripts, "LIFE::lADD_VAR_GAME(%i, %i)", (int)num, (int)val);
int16 currentVal = engine->_gameState->hasGameFlag(num);
if ((int)currentVal - (int)val > -32768) {
currentVal -= val;
@@ -915,7 +955,7 @@ int32 ScriptLifeV2::lINVERSE_BETA(TwinEEngine *engine, LifeScriptContext &ctx) {
ctx.actor->_beta = ClampAngle(ctx.actor->_beta + LBAAngles::ANGLE_180);
if (ctx.actor->_controlMode == ControlMode::kWagon) {
-#if 0
+#if 0 // TODO:
ctx.actor->Info1 = 1; // reinit speed wagon
// to be clean
Commit: 8304887bf790903872271f20ca9ad7563b99029c
https://github.com/scummvm/scummvm/commit/8304887bf790903872271f20ca9ad7563b99029c
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-08-14T18:01:03+02:00
Commit Message:
TWINE: fixed different values for max life points in lba1 and lba2
Changed paths:
engines/twine/scene/actor.cpp
engines/twine/scene/actor.h
engines/twine/scene/gamestate.cpp
engines/twine/script/script_life.cpp
engines/twine/script/script_life_v2.cpp
engines/twine/twine.cpp
engines/twine/twine.h
diff --git a/engines/twine/scene/actor.cpp b/engines/twine/scene/actor.cpp
index 61d28fd8d91..3ffe5ebb1b8 100644
--- a/engines/twine/scene/actor.cpp
+++ b/engines/twine/scene/actor.cpp
@@ -358,7 +358,7 @@ void Actor::startInitObj(int16 actorIdx) {
void Actor::initObject(int16 actorIdx) {
ActorStruct *actor = _engine->_scene->getActor(actorIdx);
- *actor = ActorStruct();
+ *actor = ActorStruct(_engine->getMaxLife());
actor->_actorIdx = actorIdx;
actor->_pos = IVec3(0, SIZE_BRICK_Y, 0);
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index 53b393312ae..06eac3f380e 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -135,9 +135,6 @@ struct BonusParameter {
uint16 unused : 7;
};
-// TODO: this is 255 for lba2
-#define kActorMaxLife 50
-
/**
* Actors structure
*
@@ -147,10 +144,12 @@ class ActorStruct { // T_OBJET
private:
ShapeType _col = ShapeType::kNone; // collision
bool _brickCausesDamage = false;
+ int32 _maxLife;
EntityData _entityData;
public:
+ ActorStruct(int maxLife = 0) : _lifePoint(maxLife), _maxLife(maxLife) {}
StaticFlagsStruct _staticFlags; // Flags
DynamicFlagsStruct _workFlags; // WorkFlags
@@ -207,7 +206,7 @@ public:
int32 _bonusAmount = 0;
int32 _talkColor = COLOR_BLACK;
int32 _armor = 1;
- int32 _lifePoint = kActorMaxLife;
+ int32 _lifePoint = 0;
/** Process actor coordinate Nxw, Nyw, Nzw */
IVec3 _processActor;
@@ -264,8 +263,8 @@ inline void ActorStruct::addLife(int32 val) {
inline void ActorStruct::setLife(int32 val) {
_lifePoint = val;
- if (_lifePoint > kActorMaxLife) {
- _lifePoint = kActorMaxLife;
+ if (_lifePoint > _maxLife) {
+ _lifePoint = _maxLife;
}
}
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index a0bb4f32597..80575c78f9b 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -98,7 +98,7 @@ void GameState::initHeroVars() {
_usingSabre = false;
_engine->_scene->_sceneHero->_genBody = BodyType::btNormal;
- _engine->_scene->_sceneHero->setLife(kActorMaxLife);
+ _engine->_scene->_sceneHero->setLife(_engine->getMaxLife());
_engine->_scene->_sceneHero->_talkColor = COLOR_BRIGHT_BLUE;
}
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index c2fccd6dbff..d6ea2dd02ff 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -1717,7 +1717,7 @@ int32 ScriptLife::lSAY_MESSAGE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx)
*/
int32 ScriptLife::lFULL_POINT(TwinEEngine *engine, LifeScriptContext &ctx) {
debugC(3, kDebugLevels::kDebugScripts, "LIFE::FULL_POINT()");
- engine->_scene->_sceneHero->setLife(kActorMaxLife);
+ engine->_scene->_sceneHero->setLife(engine->getMaxLife());
engine->_gameState->setMaxMagicPoints();
return 0;
}
@@ -1959,8 +1959,9 @@ int32 ScriptLife::lTHE_END(TwinEEngine *engine, LifeScriptContext &ctx) {
debugC(3, kDebugLevels::kDebugScripts, "LIFE::THE_END()");
engine->_sceneLoopState = SceneLoopState::Finished;
engine->_gameState->setLeafs(0);
- engine->_scene->_sceneHero->setLife(kActorMaxLife);
+ engine->_scene->_sceneHero->setLife(engine->getMaxLife());
engine->_gameState->setMagicPoints(80);
+ // TODO: lba2 has a different ending
engine->_scene->_currentSceneIdx = LBA1SceneId::Polar_Island_Final_Battle;
engine->_actor->_heroBehaviour = engine->_actor->_previousHeroBehaviour;
engine->_scene->_newHeroPos.x = -1;
diff --git a/engines/twine/script/script_life_v2.cpp b/engines/twine/script/script_life_v2.cpp
index 4ec2512b2f9..f3cf484f7b5 100644
--- a/engines/twine/script/script_life_v2.cpp
+++ b/engines/twine/script/script_life_v2.cpp
@@ -743,10 +743,7 @@ int32 ScriptLifeV2::lADD_LIFE_POINT_OBJ(TwinEEngine *engine, LifeScriptContext &
engine->_actor->initBody(BodyType::btNormal, num);
engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeRepeat, AnimationTypes::kStanding, num);
}
- actor->_lifePoint += life;
- if (actor->_lifePoint > kActorMaxLife) {
- actor->_lifePoint = kActorMaxLife;
- }
+ actor->setLife(actor->_lifePoint + life);
return 0;
}
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 3196ecf4be7..a3aeba01bb4 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -793,7 +793,7 @@ void TwinEEngine::processInventoryAction() {
debug("penguin angle: %i", penguin->_beta);
if (_collision->checkValidObjPos(_scene->_mecaPenguinIdx)) {
- penguin->setLife(kActorMaxLife);
+ penguin->setLife(getMaxLife());
penguin->_genBody = BodyType::btNone;
_actor->initBody(BodyType::btNormal, _scene->_mecaPenguinIdx);
penguin->_workFlags.bIsDead = 0;
@@ -810,9 +810,9 @@ void TwinEEngine::processInventoryAction() {
break;
}
case kiCloverLeaf:
- if (_scene->_sceneHero->_lifePoint < kActorMaxLife) {
+ if (_scene->_sceneHero->_lifePoint < getMaxLife()) {
if (_gameState->_inventoryNumLeafs > 0) {
- _scene->_sceneHero->setLife(kActorMaxLife);
+ _scene->_sceneHero->setLife(getMaxLife());
_gameState->setMagicPoints(_gameState->_magicLevelIdx * 20);
_gameState->addLeafs(-1);
_redraw->addOverlay(OverlayType::koInventoryItem, InventoryItems::kiCloverLeaf, 0, 0, 0, OverlayPosType::koNormal, 3);
@@ -1108,7 +1108,7 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
_scene->_heroPositionType = ScenePositionType::kReborn;
- _scene->_sceneHero->setLife(kActorMaxLife);
+ _scene->_sceneHero->setLife(getMaxLife());
_redraw->_firstTime = true;
_screens->_fadePalette = true;
_gameState->addLeafs(-1);
@@ -1119,7 +1119,7 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
_gameState->setMaxMagicPoints();
_actor->_heroBehaviour = _actor->_previousHeroBehaviour;
actor->_beta = _actor->_previousHeroAngle;
- actor->setLife(kActorMaxLife);
+ actor->setLife(getMaxLife());
if (_scene->_previousSceneIdx != _scene->_currentSceneIdx) {
_scene->_newHeroPos.x = -1;
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index e72788e04ab..0d30dd0cf34 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -275,6 +275,10 @@ public:
return maxLocations;
}
+ inline int getMaxLife() const {
+ return isLBA1() ? 50 : 255;
+ }
+
bool unlockAchievement(const Common::String &id);
Actor *_actor;
More information about the Scummvm-git-logs
mailing list