diff options
author | Evgeny Grechnikov | 2018-08-25 15:11:24 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2018-08-26 12:09:43 +0200 |
commit | f771fa40ad474d78d32ce5bff67afc937547e5de (patch) | |
tree | 483ee750c81169142fc58a68e87d5a321a4a96f3 /engines/lastexpress/entities/kronos.cpp | |
parent | f3cb1fcd84d7ca1dd25b7adb4b54f08c535008ac (diff) | |
download | scummvm-rg350-f771fa40ad474d78d32ce5bff67afc937547e5de.tar.gz scummvm-rg350-f771fa40ad474d78d32ce5bff67afc937547e5de.tar.bz2 scummvm-rg350-f771fa40ad474d78d32ce5bff67afc937547e5de.zip |
LASTEXPRESS: multiple fixes in NPC logic
Checked the logic against the original game
(to be precise, DOS English version from GOG, although I think
AI logic has no significant differences with other versions).
Fixed a *lot* of errors with varying visibility for the user.
Also, save+exit+load sometimes resulted in memory corruption like
((EntityParametersSSII*)(new EntityParametersIIII))->param8 = 0;
load operation did not restore the correct type of NPC logic context,
the default one was used (which also has the smallest sizeof).
Should be fixed now. Save+load is still unusable because it locks
everybody waiting for kActionEndSound (the sound state is not restored),
but, at least, it should not corrupt the memory. Hopefully.
Diffstat (limited to 'engines/lastexpress/entities/kronos.cpp')
-rw-r--r-- | engines/lastexpress/entities/kronos.cpp | 63 |
1 files changed, 48 insertions, 15 deletions
diff --git a/engines/lastexpress/entities/kronos.cpp b/engines/lastexpress/entities/kronos.cpp index 61c164115b..60be35e8fa 100644 --- a/engines/lastexpress/entities/kronos.cpp +++ b/engines/lastexpress/entities/kronos.cpp @@ -63,11 +63,11 @@ static const struct { Kronos::Kronos(LastExpressEngine *engine) : Entity(engine, kEntityKronos) { ADD_CALLBACK_FUNCTION(Kronos, reset); - ADD_CALLBACK_FUNCTION(Kronos, savegame); - ADD_CALLBACK_FUNCTION(Kronos, updateEntity); - ADD_CALLBACK_FUNCTION(Kronos, playSound); - ADD_CALLBACK_FUNCTION(Kronos, updateFromTime); - ADD_CALLBACK_FUNCTION(Kronos, updateFromTicks); + ADD_CALLBACK_FUNCTION_II(Kronos, savegame); + ADD_CALLBACK_FUNCTION_II(Kronos, updateEntity); + ADD_CALLBACK_FUNCTION_S(Kronos, playSound); + ADD_CALLBACK_FUNCTION_I(Kronos, updateFromTime); + ADD_CALLBACK_FUNCTION_I(Kronos, updateFromTicks); ADD_CALLBACK_FUNCTION(Kronos, chapter1); ADD_CALLBACK_FUNCTION(Kronos, chapter1Handler); ADD_CALLBACK_FUNCTION(Kronos, greetCath); @@ -147,7 +147,16 @@ IMPLEMENT_FUNCTION(8, Kronos, chapter1Handler) break; case kActionNone: - Entity::timeCheck(kTime1489500, params->param2, WRAP_SETUP_FUNCTION(Kronos, setup_function11)); + if (Entity::timeCheck(kTime1489500, params->param2, WRAP_SETUP_FUNCTION(Kronos, setup_function11))) + break; + + if (params->param1 && getEntities()->isInsideTrainCar(kEntityPlayer, kCarKronos)) { + if (Entity::updateParameter(params->param3, getState()->timeTicks, 150)) { + setup_greetCath(); + break; + } + } + break; case kAction171849314: @@ -260,7 +269,7 @@ IMPLEMENT_FUNCTION(14, Kronos, chapter3Handler) break; case kActionNone: - if (getState()->time > kTime1993500 && !params->param1 && !params->param2 && !params->param3) + if (getState()->time > kTime1993500 && params->param1 && params->param2 && params->param3) setup_function15(); break; @@ -301,7 +310,7 @@ IMPLEMENT_FUNCTION(15, Kronos, function15) if (params->param3 != kTimeInvalid && getState()->time > kTime2002500) { if (getState()->time <= kTime2052000) { - if (!getEntities()->isInSalon(kEntityPlayer) || getEntities()->isInSalon(kEntityPlayer) || !params->param3) + if (!getEntities()->isInSalon(kEntityPlayer) || getEntities()->isInSalon(kEntityBoutarel) || !params->param3) params->param3 = (uint)getState()->time + 900; if (params->param3 >= getState()->time) @@ -381,7 +390,7 @@ IMPLEMENT_FUNCTION(17, Kronos, returnCompartment) getData()->car = kCarRedSleeping; setCallback(1); - setup_updateEntity(kCarGreenSleeping, kPosition_9270); + setup_updateEntity(kCarKronos, kPosition_9270); break; case kActionCallback: @@ -435,6 +444,19 @@ IMPLEMENT_FUNCTION(19, Kronos, startConcert) break; case kActionNone: + if (getState()->time > kTime2115000 && !params->param1) { + params->param1 = 1; + getSound()->playSound(kEntityKronos, "1917.lnk"); + setup_duringConcert(); + break; + } + + if (getEntities()->isInKronosSanctum(kEntityPlayer)) { + setCallback(1); + setup_savegame(kSavegameTypeEvent, kEventKahinaPunchSuite4); + break; + } + break; case kActionDefault: @@ -442,6 +464,14 @@ IMPLEMENT_FUNCTION(19, Kronos, startConcert) break; case kActionDrawScene: + if (getEntities()->isInsideTrainCar(kEntityPlayer, kCarKronos) + && !getEntities()->isInKronosSanctum(kEntityPlayer) + && !getInventory()->hasItem(kItemFirebird) + && !getEvent(kEventConcertStart)) { + getEntities()->drawSequenceLeft(kEntityKronos, "201a"); + setCallback(2); + setup_savegame(kSavegameTypeEvent, kEventConcertStart); + } break; case kActionCallback: @@ -479,6 +509,7 @@ IMPLEMENT_FUNCTION(20, Kronos, duringConcert) break; case kActionNone: + // TODO: should *2 really be there? should it be /2? params->param5 = getSoundQueue()->getEntryTime(kEntityKronos)* 2; if (params->param6 < ARRAYSIZE(concertData) && params->param5 > concertData[params->param6].time) { @@ -734,12 +765,14 @@ IMPLEMENT_FUNCTION(22, Kronos, awaitingCath) break; case kActionNone: - if (getProgress().field_44) { - setCallback(5); - setup_savegame(kSavegameTypeEvent, kEventKahinaPunchBaggageCarEntrance); - } else { - setCallback(6); - setup_savegame(kSavegameTypeEvent, kEventKahinaWrongDoor); + if (getEntities()->isInKronosSanctum(kEntityPlayer)) { + if (getProgress().field_44) { + setCallback(5); + setup_savegame(kSavegameTypeEvent, kEventKahinaPunchBaggageCarEntrance); + } else { + setCallback(6); + setup_savegame(kSavegameTypeEvent, kEventKahinaWrongDoor); + } } break; |