LASTEXPRESS: Implement remaining AI logic functions for Francois, Gendarmes and Milos

svn-id: r53682
This commit is contained in:
Julien Templier 2010-10-21 23:40:14 +00:00
parent c35d23aa95
commit b347156e78
5 changed files with 517 additions and 5 deletions

View File

@ -964,7 +964,85 @@ IMPLEMENT_FUNCTION(22, Francois, chapter2Handler)
//////////////////////////////////////////////////////////////////////////
IMPLEMENT_FUNCTION(23, Francois, function23)
error("Francois: callback function 23 not implemented!");
switch (savepoint.action) {
default:
break;
case kActionNone:
if (getEvent(kEventFrancoisShowBeetle) || getEvent(kEventFrancoisShowBeetleD))
if (!getEvent(kEventFrancoisTradeWhistle) && !getEvent(kEventFrancoisTradeWhistleD))
ENTITY_PARAM(0, 1) = 1;
if (ENTITY_PARAM(0, 1) && getEntities()->isPlayerInCar(kCarRedSleeping)) {
setCallback(1);
setup_function15();
break;
}
label_callback_1:
TIME_CHECK_CALLBACK_1(kTime1764000, params->param1, 2, setup_playSound, "Fra2011");
label_callback_2:
TIME_CHECK_CALLBACK(kTime1800000, params->param2, 3, setup_function13);
label_callback_3:
if (!getInventory()->hasItem(kItemWhistle) && getInventory()->get(kItemWhistle)->location != kObjectLocation3) {
TIME_CHECK_CALLBACK_1(kTime1768500, params->param3, 4, setup_function11, kTime1773000);
label_callback_4:
TIME_CHECK_CALLBACK_1(kTime1827000, params->param4, 5, setup_function11, kTime1831500);
}
label_callback_5:
if (getInventory()->get(kItemWhistle)->location != kObjectLocation3) {
// TODO: do we also need to check if the whistle is in the inventory?
break;
}
if (params->param5 != kTimeInvalid) {
UPDATE_PARAM_PROC_TIME(kTimeEnd, !getEntities()->isDistanceBetweenEntities(kEntityFrancois, kEntityPlayer, 2000), params->param5, 75);
setCallback(6);
setup_playSound("Fra2010");
break;
UPDATE_PARAM_PROC_END
}
label_callback_6:
TIME_CHECK_CALLBACK_3(kTime1782000, params->param6, 7, setup_function14, kObjectCompartmentC, kPosition_6470, "c");
label_callback_7:
TIME_CHECK_CALLBACK_3(kTime1813500, params->param7, 8, setup_function14, kObjectCompartmentF, kPosition_4070, "f");
break;
case kActionCallback:
switch (getCallback()) {
default:
break;
case 1:
goto label_callback_1;
case 2:
goto label_callback_2;
case 3:
goto label_callback_3;
case 4:
goto label_callback_4;
case 5:
goto label_callback_5;
case 6:
getProgress().field_9C = 1;
goto label_callback_6;
case 7:
goto label_callback_7;
}
break;
}
}
//////////////////////////////////////////////////////////////////////////

View File

@ -95,7 +95,7 @@ IMPLEMENT_FUNCTION_S(5, Gendarmes, arrestPlaysound16)
}
//////////////////////////////////////////////////////////////////////////
IMPLEMENT_FUNCTION_I(6, Gendarmes, arrestCallback, TimeValue)
IMPLEMENT_FUNCTION_I(6, Gendarmes, arrestCallback, uint32)
arrest(savepoint, true, SoundManager::kFlagInvalid, true);
}
@ -111,7 +111,133 @@ IMPLEMENT_FUNCTION_II(8, Gendarmes, arrestUpdateEntity, CarIndex, EntityPosition
//////////////////////////////////////////////////////////////////////////
IMPLEMENT_FUNCTION_IISS(9, Gendarmes, function9, CarIndex, EntityPosition)
error("Gendarmes: callback function 9 not implemented!");
switch (savepoint.action) {
default:
break;
case kActionDefault:
if (params->param2 <= kPosition_3050) {
if (params->param2 != kPosition_3050) {
if (params->param2 == kPosition_2740)
CURRENT_PARAMS(2, 5) = kObjectCompartment8;
} else {
CURRENT_PARAMS(2, 5) = kObjectCompartment7;
CURRENT_PARAMS(2, 6) = true;
}
} else if (params->param2 <= kPosition_4840) {
if (params->param2 != kPosition_4840) {
if (params->param2 == kPosition_4070) {
CURRENT_PARAMS(2, 5) = kObjectCompartment6;
CURRENT_PARAMS(2, 7) = kPosition_4455;
}
} else {
CURRENT_PARAMS(2, 5) = kObjectCompartment5;
CURRENT_PARAMS(2, 6) = true;
CURRENT_PARAMS(2, 7) = kPosition_4455;
}
} else if (params->param2 <= kPosition_6470) {
if (params->param2 != kPosition_6470) {
if (params->param2 == kPosition_5790) {
CURRENT_PARAMS(2, 5) = kObjectCompartment4;
CURRENT_PARAMS(2, 7) = kPosition_6130;
}
} else {
CURRENT_PARAMS(2, 5) = kObjectCompartment3;
CURRENT_PARAMS(2, 6) = true;
CURRENT_PARAMS(2, 7) = kPosition_6130;
}
} else if (params->param2 != kPosition_7500) {
if (params->param2 == kPosition_8200) {
CURRENT_PARAMS(2, 5) = kObjectCompartment1;
CURRENT_PARAMS(2, 6) = true;
CURRENT_PARAMS(2, 7) = kPosition_7850;
}
} else {
CURRENT_PARAMS(2, 5) = kObjectCompartment2;
CURRENT_PARAMS(2, 7) = kPosition_7850;
}
if (params->param1 == kCarBaggageRear)
CURRENT_PARAMS(2, 5) += 31; // Switch to next compartment car
if (CURRENT_PARAMS(2, 6)) {
strcpy((char *)&CURRENT_PARAMS(1, 1), "632A");
strcpy((char *)&CURRENT_PARAMS(1, 4), "632B");
strcpy((char *)&CURRENT_PARAMS(1, 7), "632C");
} else {
strcpy((char *)&CURRENT_PARAMS(1, 1), "632D");
strcpy((char *)&CURRENT_PARAMS(1, 4), "632E");
strcpy((char *)&CURRENT_PARAMS(1, 7), "632F");
}
strcat((char *)&CURRENT_PARAMS(1, 1), (char *)&params->seq1);
strcat((char *)&CURRENT_PARAMS(1, 4), (char *)&params->seq1);
strcat((char *)&CURRENT_PARAMS(1, 7), (char *)&params->seq1);
if ((getEntities()->isInsideCompartment(kEntityPlayer, (CarIndex)params->param1, (EntityPosition)params->param2)
|| getEntities()->isInsideCompartment(kEntityPlayer, (CarIndex)params->param1, (EntityPosition)CURRENT_PARAMS(2, 7))
|| (params->param1 == kCarGreenSleeping && params->param2 == kPosition_8200 && getEntities()->isOutsideAlexeiWindow()))
&& !getEntities()->isInsideCompartment(kEntityPlayer, kCarRedSleeping, kPosition_7850)) {
setCallback(1);
setup_function10((CarIndex)params->param1, (EntityPosition)params->param2, (ObjectIndex)CURRENT_PARAMS(2, 5));
} else {
getEntities()->drawSequenceLeft(kEntityGendarmes, (char *)&CURRENT_PARAMS(1, 1));
getEntities()->enterCompartment(kEntityGendarmes, (ObjectIndex)CURRENT_PARAMS(2, 5));
setCallback(CURRENT_PARAMS(2, 6) ? 2 : 3);
setup_arrestPlaysound(CURRENT_PARAMS(2, 6) ? "POL1044A" : "POL1044B");
}
break;
case kActionCallback:
switch (getCallback()) {
default:
break;
case 1:
CALLBACK_ACTION();
break;
case 2:
case 3:
getEntities()->drawSequenceLeft(kEntityGendarmes, (char *)&CURRENT_PARAMS(1, 4));
if (getEntities()->isNobodyInCompartment((CarIndex)params->param1, (EntityPosition)params->param2) || !strcmp(params->seq2, "NODIALOG")) {
setCallback(4);
setup_arrestCallback(150);
} else {
char *arrestSound = (char *)&CURRENT_PARAMS(2, 2);
strcpy(arrestSound, "POL1045");
strcat(arrestSound, (char *)&params->seq2);
setCallback(5);
setup_arrestPlaysound(arrestSound);
}
break;
case 4:
case 5:
if (!getEntities()->isNobodyInCompartment((CarIndex)params->param1, (EntityPosition)params->param2) && strcmp(params->seq2, "NODIALOG")) {
char *arrestSound = (char *)&CURRENT_PARAMS(2, 2);
strcpy(arrestSound, "POL1043");
strcat(arrestSound, (char *)&params->seq2);
getSound()->playSound(kEntityGendarmes, arrestSound, SoundManager::kFlagInvalid, 30);
}
getData()->location = kLocationInsideCompartment;
setCallback(6);
setup_arrestDraw((char *)&CURRENT_PARAMS(1, 7));
break;
case 6:
getData()->location = kLocationOutsideCompartment;
getEntities()->exitCompartment(kEntityGendarmes, (ObjectIndex)CURRENT_PARAMS(2, 5));
CALLBACK_ACTION();
break;
}
break;
}
}
//////////////////////////////////////////////////////////////////////////

View File

@ -53,7 +53,7 @@ public:
DECLARE_FUNCTION_1(arrestDraw, const char *sequence)
DECLARE_FUNCTION_1(arrestPlaysound, const char *soundName)
DECLARE_FUNCTION_1(arrestPlaysound16, const char *soundName)
DECLARE_FUNCTION_1(arrestCallback, TimeValue timeValue)
DECLARE_FUNCTION_1(arrestCallback, uint32 timeValue)
/**
* Saves the game

View File

@ -29,6 +29,7 @@
#include "lastexpress/game/action.h"
#include "lastexpress/game/entities.h"
#include "lastexpress/game/fight.h"
#include "lastexpress/game/inventory.h"
#include "lastexpress/game/logic.h"
#include "lastexpress/game/object.h"
@ -408,7 +409,310 @@ IMPLEMENT_FUNCTION(13, Milos, function13)
//////////////////////////////////////////////////////////////////////////
IMPLEMENT_FUNCTION(14, Milos, function14)
error("Milos: callback function 14 not implemented!");
switch (savepoint.action) {
default:
break;
case kActionNone:
if (getProgress().field_14 == 29 || getProgress().field_14 == 3) {
if (params->param2) {
setCallback(1);
setup_enterExitCompartment("609Ca", kObjectCompartment1);
} else {
getEntities()->exitCompartment(kEntityMilos, kObjectCompartment1, true);
getObjects()->update(kObjectCompartment1, kEntityPlayer, kObjectLocationNone, kCursorHandKnock, kCursorHand);
CALLBACK_ACTION();
}
break;
}
if (params->param1) {
// TODO replace with UPDATE_PARAM_PROC (without the kTimeInvalid part)
if (!CURRENT_PARAMS(1, 1))
CURRENT_PARAMS(1, 1) = getState()->timeTicks + 45;
if (CURRENT_PARAMS(1, 1) < getState()->timeTicks) {
if (getObjects()->get(kObjectCompartment1).location == kObjectLocation1) {
UPDATE_PARAM(CURRENT_PARAMS(1, 2), getState()->timeTicks, 75);
getObjects()->update(kObjectCompartment1, kEntityMilos, getObjects()->get(kObjectCompartment1).location, kCursorNormal, kCursorNormal);
++params->param5;
switch (params->param5) {
default:
getObjects()->update(kObjectCompartment1, kEntityMilos, getObjects()->get(kObjectCompartment1).location, params->param3 < 1 ? kCursorTalk : kCursorNormal, kCursorHand);
CURRENT_PARAMS(1, 2) = 0;
break;
case 1:
setCallback(6);
setup_playSound("LIB013");
break;
case 2:
setCallback(8);
setup_playSound("LIB012");
break;
case 3:
setCallback(10);
setup_playSound("LIB012");
break;
case 4:
++params->param7;
if (params->param7 < 3) {
params->param5 = 1;
getObjects()->update(kObjectCompartment1, kEntityMilos, getObjects()->get(kObjectCompartment1).location, params->param3 < 1 ? kCursorTalk : kCursorNormal, kCursorHand);
CURRENT_PARAMS(1, 2) = 0;
break;
}
getObjects()->update(kObjectCompartment1, kEntityPlayer, getObjects()->get(kObjectCompartment1).location, kCursorHandKnock, kCursorHand);
CALLBACK_ACTION();
break;
}
} else {
if (getProgress().eventCorpseMovedFromFloor && getProgress().jacket != kJacketBlood) {
params->param6 = (getObjects()->get(kObjectCompartment1).location2 == kObjectLocation1) ? kEventMilosTylerCompartmentBedVisit : kEventMilosTylerCompartmentVisit;
setCallback(3);
setup_savegame(kSavegameTypeEvent, kEventMilosTylerCompartmentVisit);
} else {
getObjects()->update(kObjectOutsideTylerCompartment, kEntityPlayer, kObjectLocationNone, kCursorKeepValue, kCursorKeepValue);
setCallback(2);
setup_savegame(kSavegameTypeEvent, kEventMilosCorpseFloor);
}
}
}
break;
}
// TODO replace with UPDATE_PARAM_PROC (without the kTimeInvalid part)
if (!CURRENT_PARAMS(1, 3))
CURRENT_PARAMS(1, 3) = getState()->timeTicks + 75;
if (CURRENT_PARAMS(1, 3) < getState()->timeTicks) {
if (!params->param4) {
setCallback(12);
setup_playSound("MIL1030C");
break;
}
label_callback_12:
UPDATE_PARAM(CURRENT_PARAMS(1, 4), getState()->timeTicks, 75);
getEntities()->exitCompartment(kEntityMilos, kObjectCompartment1, true);
if (getProgress().eventCorpseMovedFromFloor) {
setCallback(13);
setup_enterExitCompartment("609Ba", kObjectCompartment1);
break;
}
if (getEntities()->isInsideTrainCar(kEntityPlayer, kCarGreenSleeping)) {
setCallback(14);
setup_enterExitCompartment2("609Ba", kObjectCompartment1);
break;
}
getScenes()->loadSceneFromPosition(kCarNone, 1);
getObjects()->update(kObjectOutsideTylerCompartment, kEntityPlayer, kObjectLocationNone, kCursorKeepValue, kCursorKeepValue);
setCallback(15);
setup_savegame(kSavegameTypeEvent, kEventMilosCorpseFloor);
}
break;
case kActionKnock:
if (params->param2) {
getObjects()->update(kObjectCompartment1, kEntityMilos, kObjectLocationNone, kCursorNormal, kCursorNormal);
setCallback(20);
setup_playSound("LIB012");
} else if (!params->param3) {
getObjects()->update(kObjectCompartment1, kEntityMilos, getObjects()->get(kObjectCompartment1).location, kCursorNormal, kCursorNormal);
setCallback(22);
setup_playSound16("MIL1032");
}
break;
case kActionOpenDoor:
if (getProgress().eventCorpseMovedFromFloor && getProgress().jacket != kJacketBlood) {
if (params->param2) {
getEntityData(kEntityPlayer)->location = kLocationInsideCompartment;
params->param6 = (getObjects()->get(kObjectCompartment1).location2 == kObjectLocation1) ? kEventMilosTylerCompartmentBed : kEventMilosTylerCompartment;
} else {
params->param6 = (getObjects()->get(kObjectCompartment1).location2 == kObjectLocation1) ? kEventMilosTylerCompartmentBedVisit : kEventMilosTylerCompartmentVisit;
}
setCallback(17);
setup_savegame(kSavegameTypeEvent, kEventMilosTylerCompartmentVisit);
} else {
getObjects()->update(kObjectOutsideTylerCompartment, kEntityPlayer, kObjectLocationNone, kCursorKeepValue, kCursorKeepValue);
setCallback(16);
setup_savegame(kSavegameTypeEvent, kEventMilosCorpseFloor);
}
break;
case kActionDefault:
if (getEntities()->isInsideCompartment(kEntityPlayer, kCarGreenSleeping, kPosition_8200)
|| getEntities()->isInsideCompartment(kEntityPlayer, kCarGreenSleeping, kPosition_7850)
|| getEntities()->isOutsideAlexeiWindow()) {
getObjects()->update(kObjectCompartment1, kEntityMilos, getObjects()->get(kObjectCompartment1).location, kCursorNormal, kCursorNormal);
if (getEntities()->isOutsideAlexeiWindow())
getScenes()->loadSceneFromPosition(kCarGreenSleeping, 49);
getSound()->playSound(kEntityPlayer, "LIB012");
getObjects()->update(kObjectCompartment1, kEntityMilos, getObjects()->get(kObjectCompartment1).location, kCursorTalk, kCursorHand);
params->param1 = 1;
} else {
getEntities()->drawSequenceLeft(kEntityMilos, "609Aa");
getEntities()->enterCompartment(kEntityMilos, kObjectCompartment1, true);
}
break;
case kActionCallback:
switch (getCallback()) {
default:
break;
case 1:
getData()->location = kLocationOutsideCompartment;
getObjects()->update(kObjectCompartment1, kEntityPlayer, kObjectLocationNone, kCursorHandKnock, kCursorHand);
CALLBACK_ACTION();
break;
case 2:
getSound()->playSound(kEntityPlayer, "LIB014");
getAction()->playAnimation(kEventMilosCorpseFloor);
getLogic()->gameOver(kSavegameTypeIndex, 1, getProgress().eventCorpseMovedFromFloor ? kSceneGameOverBloodJacket : kSceneGameOverPolice1, true);
break;
case 3:
getObjects()->update(kObjectCompartment1, kEntityPlayer, kObjectLocationNone, kCursorHandKnock, kCursorHand);
getObjects()->update(kObjectOutsideTylerCompartment, kEntityPlayer, kObjectLocationNone, kCursorKeepValue, kCursorKeepValue);
getSound()->playSound(kEntityPlayer, "LIB014");
getAction()->playAnimation((EventIndex)params->param6);
setCallback(4);
setup_savegame(kSavegameTypeTime, kTimeNone);
break;
case 4:
case 18:
params->param8 = getFight()->setup(kFightMilos);
if (params->param8) {
getLogic()->gameOver(kSavegameTypeIndex, 0, kSceneNone, params->param8 == Fight::kFightEndLost);
} else {
getState()->time += 1800;
getProgress().field_CC = 1;
setCallback(getCallback() == 4 ? 5 : 19);
setup_savegame(kSavegameTypeEvent, kEventMilosTylerCompartmentDefeat);
}
break;
case 5:
case 19:
getAction()->playAnimation(kEventMilosTylerCompartmentDefeat);
getSound()->playSound(kEntityPlayer, "LIB015");
getScenes()->loadScene(kScene41);
getData()->location = kLocationOutsideCompartment;
CALLBACK_ACTION();
break;
case 6:
setCallback(7);
setup_playSound16("MIL1031C");
break;
case 7:
case 9:
case 11:
getObjects()->update(kObjectCompartment1, kEntityMilos, getObjects()->get(kObjectCompartment1).location, params->param3 < 1 ? kCursorTalk : kCursorNormal, kCursorHand);
CURRENT_PARAMS(1, 2) = 0;
break;
case 8:
setCallback(9);
setup_playSound16("MIL1031A");
break;
case 10:
setCallback(11);
setup_playSound16("MIL1031B");
break;
case 12:
params->param4 = 1;
goto label_callback_12;
case 13:
params->param2 = 1;
getEntities()->clearSequences(kEntityMilos);
getData()->location = kLocationInsideCompartment;
getObjects()->update(kObjectCompartment1, kEntityMilos, kObjectLocationNone, kCursorHandKnock, kCursorHand);
break;
case 14:
getObjects()->update(kObjectOutsideTylerCompartment, kEntityPlayer, kObjectLocationNone, kCursorKeepValue, kCursorKeepValue);
setCallback(15);
setup_savegame(kSavegameTypeEvent, kEventMilosCorpseFloor);
break;
case 15:
getAction()->playAnimation(kEventMilosCorpseFloor);
getLogic()->gameOver(kSavegameTypeIndex, 1, kSceneGameOverPolice1, true);
break;
case 16:
getSound()->playSound(kEntityPlayer, getObjects()->get(kObjectCompartment1).location == kObjectLocation1 ? "LIB032" : "LIB014");
getAction()->playAnimation(kEventMilosCorpseFloor);
getLogic()->gameOver(kSavegameTypeIndex, 1, getProgress().eventCorpseMovedFromFloor ? kSceneGameOverBloodJacket : kSceneGameOverPolice1, true);
break;
case 17:
getSound()->playSound(kEntityPlayer, getObjects()->get(kObjectCompartment1).location == kObjectLocation1 ? "LIB032" : "LIB014");
getObjects()->update(kObjectCompartment1, kEntityPlayer, kObjectLocationNone, kCursorHandKnock, kCursorHand);
getObjects()->update(kObjectOutsideTylerCompartment, kEntityPlayer, kObjectLocationNone, kCursorKeepValue, kCursorKeepValue);
getAction()->playAnimation((EventIndex)params->param6);
setCallback(18);
setup_savegame(kSavegameTypeTime, kTimeNone);
break;
case 20:
setCallback(21);
setup_playSound("MIL1117A");
break;
case 21:
getObjects()->update(kObjectCompartment1, kEntityMilos, kObjectLocationNone, kCursorHandKnock, kCursorHand);
break;
case 22:
params->param3 = 1;
getObjects()->update(kObjectCompartment1, kEntityMilos, getObjects()->get(kObjectCompartment1).location, kCursorNormal, kCursorHand);
break;
}
break;
}
}
//////////////////////////////////////////////////////////////////////////

View File

@ -125,6 +125,7 @@ enum TimeValue {
kTime1759500 = 1759500,
kTime1755000 = 1755000,
kTime1764000 = 1764000,
kTime1768500 = 1768500,
kTime1773000 = 1773000,
kTime1777500 = 1777500,
kTime1782000 = 1782000,
@ -135,10 +136,13 @@ enum TimeValue {
kTime1806300 = 1806300,
kTime1809000 = 1809000,
kTimeCityAugsburg = 1809900,
kTime1813500 = 1813500,
kTime1818000 = 1818000,
kTime1818900 = 1818900,
kTime1820700 = 1820700,
kTime1822500 = 1822500,
kTime1827000 = 1827000,
kTime1831500 = 1831500,
kTime1836000 = 1836000,
kTime1845000 = 1845000,
kTime1849500 = 1849500,