M4: RIDDLE: In progress room 504 daemon

This commit is contained in:
Paul Gilbert 2024-09-11 22:25:41 -07:00
parent fd2090b627
commit 3c2a58f89c
4 changed files with 740 additions and 5 deletions

View File

@ -341,6 +341,12 @@ void kernel_examine_inventory_object(const char *picName, RGB8 *pal, int steps,
pauseEngines();
}
void kernel_examine_inventory_object(const char *picName, int steps, int delay,
int32 x, int32 y, int32 triggerNum, const char *digiName, int32 digiTrigger) {
kernel_examine_inventory_object(picName, _G(master_palette), steps, delay,
x, y, triggerNum, digiName, digiTrigger);
}
void kernel_unexamine_inventory_object(RGB8 *pal, int steps, int delay) {
if (!_GP(seriesAnim8) || _GP(seriesHash) < 0)
return;

View File

@ -121,6 +121,8 @@ void DAC_tint_range(const RGB8 *tintColor, int32 percent, int32 firstPalEntry, i
void kernel_examine_inventory_object(const char *picName, RGB8 *pal,
int steps, int delay, int32 x, int32 y, int32 trigger,
const char *digiName, int32 digiTrigger);
void kernel_examine_inventory_object(const char *picName, int steps, int delay,
int32 x, int32 y, int32 triggerNum, const char *digiName = nullptr, int32 digiTrigger = -1);
void kernel_unexamine_inventory_object(RGB8 *pal, int steps, int delay);
void remap_buffer_with_luminance_map(Buffer *src, int32 x1, int32 y1, int32 x2, int32 y2);

View File

@ -23,12 +23,19 @@
#include "m4/graphics/gr_series.h"
#include "m4/riddle/vars.h"
#include "m4/gui/gui_vmng.h"
#include "m4/adv_r/other.h"
#include "m4/m4.h"
namespace M4 {
namespace Riddle {
namespace Rooms {
static const int16 NORMAL_DIRS[] = { 200, -1 };
static const char *NORMAL_NAMES[] = { "menendez walker 3" };
static const int16 SHADOW_DIRS[] = { 210, -1 };
static const char *SHADOW_NAMES[] = { "menendez walker shadow 3" };
void Room504::init() {
_trigger1 = -1;
@ -100,6 +107,711 @@ void Room504::init() {
}
void Room504::daemon() {
switch (_G(kernel).trigger) {
case 501:
player_update_info();
if (_G(player_info).x <= 550) {
_volume = 127;
} else if (_G(player_info).x <= 978) {
_volume = (float)_G(player_info).x * -0.119158878 + 193.0373832;
} else if (_G(player_info).x > 978 && _G(player_info).x <= 1919) {
_volume = (float)_G(player_info).x * -0.040648246 + 116.2539851;
}
digi_change_panning(3, _volume);
kernel_timing_trigger(60, 501);
break;
case 502:
_val2 = 1;
_convState1 = 1;
_trigger2 = -1;
_trigger3 = -1;
_mzDigs = series_load("504 MZ DIGS");
_mzStandsTalks = series_load("504 MZ STANDS TALKS");
_mzMachine = TriggerMachineByHash(1, 1, 0, 0, 0, 0, 0, 0, 100, 0xb00, 0,
triggerMachineByHashCallbackNegative, "Emilio Menendez Machine");
kernel_timing_trigger(1, 503);
break;
case 503:
if (_trigger2 != -1 && _convState1 == 2 && _val2 == 2) {
kernel_trigger_dispatchx(_trigger2);
_trigger2 = -1;
}
if (_trigger3 != -1 && _convState1 == 1 && _val2 == 1) {
kernel_trigger_dispatchx(_trigger3);
_trigger3 = -1;
}
if (_trigger3 != -1 && _convState1 == 5 && _val2 == 5) {
kernel_trigger_dispatchx(_trigger3);
_trigger3 = -1;
}
if (_trigger3 != -1 && _convState1 == 9 && _val2 == 9) {
kernel_trigger_dispatchx(_trigger3);
_trigger3 = -1;
}
if (_trigger3 != -1 && _convState1 == 15 && _val2 == 15) {
kernel_trigger_dispatchx(_trigger3);
_trigger3 = -1;
}
kernel_timing_trigger(1, 504);
break;
case 504:
// TODO
switch (_val2) {
case 1:
break;
}
break;
case 508:
_G(kernel).trigger_mode = KT_PARSE;
conv_load("con504a", 10, 10, 747);
_val3 = inv_player_has("PERUVIAN INTI") ? 1 : 0;
conv_export_pointer_curr(&_val3, 0);
conv_play();
break;
case 509:
_convState1 = 2;
_trigger2 = kernel_trigger_create(510);
break;
case 510:
_convState1 = 1;
_convState2 = 9;
if (!_G(flags)[V040]) {
_G(flags)[V040] = 1;
setMiscItems();
}
break;
case 513:
_convState2 = 1;
_convState1 = 2;
_trigger2 = kernel_trigger_create(514);
break;
case 514:
_convState2 = 5;
_trigger4 = kernel_trigger_create(515);
break;
case 516:
_convState2 = 5;
_convState1 = 6;
break;
case 520:
_convState2 = 1;
sendWSMessage_10000(1, _mzMachine, _mzSeries1, 21, 29, 503,
_mzStandsTalks, 11, 11, 4);
_convState1 = 2;
_val2 = 2;
_trigger2 = kernel_trigger_create(521);
break;
case 523:
_convState2 = 1;
_convState1 = 16;
break;
case 524:
_trigger1 = kernel_trigger_create(525);
break;
case 529:
_convState2 = 3;
digi_play("504R16", 1, 255, 530);
break;
case 530:
_convState2 = 1;
sendWSMessage_10000(1, _mzMachine, _mzSeries2, 60, 61, -1,
_mzSeries2, 60, 62, 4);
digi_play("504Z17", 1, 255, 531);
break;
case 533:
_shovel = series_place_sprite("504shov", 0, 0, 0, 100, 0xf00);
_trigger4 = kernel_trigger_create(534);
break;
case 534:
digi_unload("504_S07");
ws_walk_load_walker_series(NORMAL_DIRS, NORMAL_NAMES);
ws_walk_load_shadow_series(SHADOW_DIRS, SHADOW_NAMES);
terminateMachineAndNull(_mzMachine);
series_unload(_mzSeries2);
digi_unload("504_S02D");
_menendez = triggerMachineByHash_3000(8, 16, NORMAL_DIRS, SHADOW_DIRS,
1005, 155, 9, triggerMachineByHashCallback3000, "Emilio Menendez Walker");
sendWSMessage_10000(_menendez, -_G(game_buff_ptr)->x1 - 30,
155, 9, 536, 1);
kernel_timing_trigger(150, 535);
break;
case 535:
case 539:
_convState2 = 13;
break;
case 536:
_convState2 = 10;
digi_play("504R17", 1, 255, 537);
break;
case 537:
_convState2 = 13;
digi_play("504Z18", 1, 255, 538);
break;
case 540:
_convState2 = 10;
digi_play("504R18A", 1, 255, 541);
break;
case 541:
kernel_timing_trigger(5, 542);
break;
case 542:
_convState2 = 11;
_trigger4 = kernel_trigger_create(543);
break;
case 543:
kernel_timing_trigger(5, 544);
break;
case 544:
_convState2 = 7;
_trigger4 = kernel_trigger_create(545);
break;
case 545:
sendWSMessage_60000(_menendez);
kernel_timing_trigger(5, 745);
_G(flags)[V141] = 1;
setMiscItems();
_convState2 = 9;
break;
case 549:
_convState2 = 3;
digi_play("504R51", 1, 255, 550);
break;
case 550:
_convState2 = 1;
_convState1 = 2;
_trigger2 = kernel_trigger_create(551);
break;
case 551:
_convState2 = 5;
_trigger4 = kernel_trigger_create(552);
break;
case 552:
_convState2 = 6;
digi_play("504R13", 1, 255, 553);
break;
case 554:
_convState1 = 2;
_trigger2 = kernel_trigger_create(555);
break;
case 555:
_convState2 = 1;
digi_play("504Z12", 1, 255, 556);
break;
case 556:
_convState1 = 1;
_trigger1 = kernel_trigger_create(557);
break;
case 557:
_convState2 = 9;
break;
case 558:
player_set_commands_allowed(false);
digi_preload("504_S05");
_flag1 = false;
_ripStep = series_stream("RIP STEP UP TO R PLATFORM", 5, 0, 560);
series_stream_break_on_frame(_ripStep, 1, 559);
break;
case 559:
case 571:
case 715:
case 735:
ws_hide_walker();
break;
case 560:
series_stream("504 SHUFFLE TO ROPE", 5, 0, 561);
break;
case 561:
terminateMachineAndNull(_rope);
_ripStep = series_stream("504 RIP CROSS R TO L", 5, 0, 562);
series_stream_break_on_frame(_ripStep, 103, 563);
break;
case 562:
series_stream("504 RIP R TO L FINISH CROSS", 5, 0, 564);
break;
case 563:
digi_play("504_S05", 1);
break;
case 564:
_rope = series_place_sprite("ROPE SPRITE", 0, 0, 0, 100, 0xe00);
series_stream("RIP STEP DOWN ON LEFT", 5, 0, 565);
break;
case 565:
ws_unhide_walker();
ws_demand_location(170, 145, 1);
_flag1 = false;
kernel_timing_trigger(5, 566);
break;
case 567:
player_update_info();
digi_preload("COM125");
_ripWipe = series_load("504WIPE");
_ripley = TriggerMachineByHash(1, 1, 0, 0, 0, 0, 0, 0, 100,
_G(player_info).depth, 0, triggerMachineByHashCallbackNegative,
"Rip Delta Machine State");
sendWSMessage_10000(1, _ripley, _ripWipe, 1, 6, 568,
_ripWipe, 6, 6, 0);
break;
case 570:
player_set_commands_allowed(false);
digi_preload("504_S05");
_ripStep = series_stream("RIP STEP UP ON LEFT", 5, 0, 572);
series_stream_break_on_frame(_ripStep, 1, 571);
break;
case 572:
_ripStep = series_stream("504 RIP L TO R CROSS", 5, 0, 574);
series_stream_break_on_frame(_ripStep, 45, 573);
terminateMachineAndNull(_rope);
break;
case 573:
digi_play("504_S05", 1);
break;
case 574:
series_stream("504 RIP L TO R FINISH CROSS", 5, 0, 575);
break;
case 575:
_rope = series_place_sprite("ROPE SPRITE", 0, 0, 0, 100, 0xe00);
series_stream("504 SHUFFLE FROM ROPE", 5, 0, 576);
break;
case 576:
_ripStep = series_stream("RIP STEP OFF R PLATFORM", 5, 0, 578);
series_stream_break_on_frame(_ripStep, 27, 577);
break;
case 577:
digi_play("COM125", 1);
break;
case 581:
_vineMachine2 = TriggerMachineByHash(1, 1, 0, 0, 0, 0, 0, 0, 100, 0xe00, 0,
triggerMachineByHashCallbackNegative, "Rope Falling to the Ground");
sendWSMessage_10000(1, _vineMachine2, _vineTie, 1, 6, 582, _vineTie, 6, 6, 0);
break;
case 582:
switch (_val1) {
case 1:
inv_move_object("ROPE", 504);
break;
case 2:
inv_move_object("GREEN VINE", 504);
break;
case 3:
inv_move_object("BROWN VINE", 504);
break;
case 4:
inv_move_object("VINES", 4);
break;
default:
break;
}
setVines();
sendWSMessage_120000(583);
break;
case 583:
sendWSMessage_150000(584);
terminateMachineAndNull(_vineMachine2);
break;
case 588:
sendWSMessage_120000(589);
break;
case 592:
sendWSMessage_120000(593);
break;
case 606:
terminateMachineAndNull(_vineMachine2);
sendWSMessage_120000(607);
break;
case 607:
switch (_val1) {
case 1:
inv_give_to_player("ROPE");
kernel_examine_inventory_object("PING ROPE",
5, 1, 449, 90, 608);
break;
case 2:
inv_give_to_player("GREEN VINE");
kernel_examine_inventory_object("PING GREEN VINE",
5, 1, 449, 90, 608);
break;
case 3:
inv_give_to_player("BROWN VINE");
kernel_examine_inventory_object("PING BROWN VINE",
5, 1, 449, 90, 608);
break;
case 4:
inv_give_to_player("VINES");
kernel_examine_inventory_object("PING VINES",
5, 1, 449, 90, 608);
break;
default:
break;
}
break;
case 633:
switch (_val1) {
case 1:
_G(flags)[V154] = 0;
inv_move_object("ROPE", 504);
break;
case 2:
_G(flags)[V152] = 0;
inv_move_object("GREEN VINE", 504);
break;
case 3:
_G(flags)[V153] = 0;
inv_move_object("BROWN VINE", 504);
break;
case 4:
_G(flags)[V171] = 0;
inv_move_object("VINES", 504);
break;
default:
break;
}
setVines();
terminateMachineAndNull(_vineMachine2);
sendWSMessage_120000(634);
break;
case 634:
sendWSMessage_150000(635);
terminateMachineAndNull(_vineMachine2);
break;
case 641:
_vineTie = series_load("504 R VINE TIE BEFORE THROW");
_vine = TriggerMachineByHash(1, 1, 0, 0, 0, 0, 0, 0, 100, 0xe00, 0,
triggerMachineByHashCallbackNegative, "Vine Unrolling as Tied");
sendWSMessage_10000(1, _vine, _vineTie, 1, 6, 642, _vineTie, 6, 6, 0);
break;
case 657:
_convState2 = 5;
_trigger4 = kernel_trigger_create(658);
break;
case 658:
_convState2 = 6;
digi_play(conv_sound_to_play(), 1, 255, 549);
break;
case 659:
_convState2 = 5;
_convState1 = 5;
_trigger3 = kernel_trigger_create(659);
break;
case 660:
_convState2 = 1;
_convState1 = 2;
_trigger2 = kernel_trigger_create(661);
break;
case 661:
_convState1 = 9;
_trigger3 = kernel_trigger_create(662);
break;
case 662:
_trigger1 = kernel_trigger_create(663);
break;
case 663:
inv_give_to_player("SHRUNKEN HEAD");
_convState2 = 4;
_trigger4 = kernel_trigger_create(664);
break;
case 664:
kernel_examine_inventory_object("PING SHRUNKEN HEAD",
5, 1, 136, 120, 665);
break;
case 665:
_convState1 = 2;
_convState2 = 1;
_trigger2 = kernel_trigger_create(666);
break;
case 666:
_trigger1 = kernel_trigger_create(667);
break;
case 667:
case 674:
conv_resume();
break;
case 669:
_convState1 = 15;
_trigger3 = kernel_trigger_create(670);
break;
case 670:
_convState2 = 8;
_trigger4 = kernel_trigger_create(671);
break;
case 671:
digi_play(conv_sound_to_play(), 1, 255, 672);
break;
case 672:
_convState1 = 2;
_convState2 = 1;
_trigger1 = kernel_trigger_create(673);
break;
case 673:
_trigger2 = kernel_trigger_create(674);
break;
case 696:
switch (_val1) {
case 1:
inv_give_to_player("ROPE");
kernel_examine_inventory_object("PING ROPE",
5, 1, 105, 60, 697);
break;
case 2:
inv_give_to_player("GREEN VINE");
kernel_examine_inventory_object("PING GREEN VINE",
5, 1, 105, 60, 697);
break;
case 3:
inv_give_to_player("BROWN VINE");
kernel_examine_inventory_object("PING BROWN VINE",
5, 1, 105, 60, 697);
break;
case 4:
inv_give_to_player("VINES");
kernel_examine_inventory_object("PING VINES",
5, 1, 105, 60, 697);
break;
default:
break;
}
break;
case 703:
switch (_val1) {
case 1:
inv_give_to_player("ROPE");
kernel_examine_inventory_object("PING ROPE",
5, 1, 105, 60, 704);
break;
case 2:
inv_give_to_player("GREEN VINE");
kernel_examine_inventory_object("PING GREEN VINE",
5, 1, 105, 60, 704);
break;
case 3:
inv_give_to_player("BROWN VINE");
kernel_examine_inventory_object("PING BROWN VINE",
5, 1, 105, 60, 704);
break;
case 4:
inv_give_to_player("VINES");
kernel_examine_inventory_object("PING VINES",
5, 1, 105, 60, 704);
break;
default:
break;
}
break;
case 707:
player_set_commands_allowed(false);
digi_play("504R45", 1, 255, 708);
break;
case 714:
player_set_commands_allowed(false);
digi_preload("504_S09");
digi_preload("504_S03");
digi_preload("504_S05");
_ripStep = series_stream("RIP STEP UP ON LEFT", 5, 0, 716);
series_stream_break_on_frame(_ripStep, 1, 715);
ws_hide_walker();
break;
case 716:
_ripStep = series_stream("504 RIP L TO R CROSS", 5, 0, 718);
series_stream_break_on_frame(_ripStep, 45, 717);
terminateMachineAndNull(_rope);
break;
case 717:
digi_play("504_S05", 1);
break;
case 718:
digi_play("504_S09", 1, 255, 719);
_ripStep = series_stream("504 RIP L TO R FALLS", 5, 0, -1);
series_stream_break_on_frame(_ripStep, 27, 721);
break;
case 720:
digi_play("504_S03", 1);
break;
case 722:
pal_fade_init(21, 255, 0, 30, 723);
interface_hide();
break;
case 723:
case 744:
other_save_game_for_resurrection();
_G(game).setRoom(413);
break;
case 725:
player_set_commands_allowed(false);
digi_play("504R45", 1, 255, 726);
break;
case 734:
player_set_commands_allowed(false);
digi_preload("504_s09");
digi_preload("504_s03");
digi_preload("504_s05");
_flag1 = false;
_ripStep = series_stream("RIP STEP UP TO R PLATFORM", 5, 0, 736);
series_stream_break_on_frame(_ripStep, 1, 735);
break;
case 736:
series_stream("504 SHUFFLE TO ROPE", 5, 0, 737);
break;
case 737:
terminateMachineAndNull(_rope);
_ripStep = series_stream("504 RIP CROSS R TO L", 5, 0, 739);
series_stream_break_on_frame(_ripStep, 103, 738);
break;
case 738:
digi_play("504_S05", 1);
break;
case 739:
digi_play("504_S09", 1, 255, 740);
_ripStep = series_stream("504 RIP R TO L FALL", 5, 0, -1);
series_stream_break_on_frame(_ripStep, 25, 742);
break;
case 741:
digi_play("504_S03", 1);
break;
case 743:
pal_fade_init(21, 255, 0, 30, 744);
interface_hide();
break;
case 748:
_G(game).setRoom(501);
inv_move_object("ROPE", 504);
break;
case 751:
digi_play("504R44", 1, 255, 752);
break;
case 755:
player_set_commands_allowed(false);
digi_play("504R45", 1, 255, 756);
break;
case 756:
player_set_commands_allowed(false);
ws_walk(546, 143, nullptr, 757, 11);
break;
// TODO: Various switch cases
default:
break;
}
}
void Room504::pre_parser() {
@ -217,7 +929,7 @@ void Room504::parser() {
break;
case 3:
_convState2 = 1;
_convState = 2;
_convState1 = 2;
_trigger2 = kernel_trigger_create(4);
break;
case 4:
@ -1409,7 +2121,7 @@ void Room504::conv504a() {
if (_G(kernel).trigger == 1) {
if (who <= 0)
_convState = 2;
_convState1 = 2;
else if (who == 1)
_convState2 = 1;
@ -1417,12 +2129,12 @@ void Room504::conv504a() {
} else {
if (who <= 0) {
if (node == 8 && entry == 3) {
_convState = 10;
_convState1 = 10;
} else if (node == 19 && entry == 2) {
_G(kernel).trigger_mode = KT_DAEMON;
kernel_timing_trigger(1, 669);
} else {
_convState = 4;
_convState1 = 4;
if (sound)
digi_play(sound, 1, 255, 1);

View File

@ -35,11 +35,17 @@ private:
int _upSteps = 0;
int _downSteps = 0;
int _volume = 0;
int _convState = 0;
int _convState1 = 0;
int _convState2 = 0;
int _ripSketching = 0;
int _ripLowReach = 0;
int _ripMedReach = 0;
int _ripWipe = 0;
int _mzDigs = 0;
int _mzStandsTalks = 0;
int _mzSeries1 = 0;
int _mzSeries2 = 0;
int _vineTie = 0;
machine *_vines1 = nullptr;
machine *_vines2 = nullptr;
@ -51,6 +57,11 @@ private:
machine *_shovel = nullptr;
machine *_driftwood = nullptr;
machine *_pole = nullptr;
machine *_mzMachine = nullptr;
machine *_menendez = nullptr;
machine *_vineMachine2 = nullptr;
machine *_ripStep = nullptr;
machine *_vine = nullptr;
bool _flag1 = false;
bool _flag2 = false;
bool _flag3 = false;
@ -58,7 +69,11 @@ private:
int _trigger1 = 0;
int _trigger2 = 0;
int _trigger3 = 0;
int _trigger4 = 0;
int _val1 = 0;
int _val2 = 0;
int32 _val3 = 0;
void setVines();
void freeVines();