| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | ///////////////////////////////////////////////////////////////////// |
| 20 | // D.A.L.L.A.S. Generated Level Script - DLL Source File |
| 21 | // |
| 22 | // Filename: HalfPipe5.cpp |
| 23 | // Version: 3 |
| 24 | ///////////////////////////////////////////////////////////////////// |
| 25 | #include <stdio.h> |
| 26 | #include <stdlib.h> |
| 27 | #include <string.h> |
| 28 | #include <ctype.h> |
| 29 | #include "osiris_import.h" |
| 30 | #include "osiris_common.h" |
| 31 | #include "DallasFuncs.cpp" |
| 32 | |
| 33 | #include "module.h" |
| 34 | |
| 35 | #ifdef __cplusplus |
| 36 | extern "C" { |
| 37 | #endif |
| 38 | DLLEXPORT char STDCALL InitializeDLL(tOSIRISModuleInit *func_list); |
| 39 | DLLEXPORT void STDCALL ShutdownDLL(void); |
| 40 | DLLEXPORT int STDCALL GetGOScriptID(const char *name, uint8_t is_door); |
| 41 | DLLEXPORT void STDCALLPTR CreateInstance(int id); |
| 42 | DLLEXPORT void STDCALL DestroyInstance(int id, void *ptr); |
| 43 | DLLEXPORT int16_t STDCALL CallInstanceEvent(int id, void *ptr, int event, tOSIRISEventInfo *data); |
| 44 | DLLEXPORT int STDCALL GetTriggerScriptID(int trigger_room, int trigger_face); |
| 45 | DLLEXPORT int STDCALL GetCOScriptList(int **list, int **id_list); |
| 46 | DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state); |
| 47 | #ifdef __cplusplus |
| 48 | } |
| 49 | #endif |
| 50 | |
| 51 | // ================= |
| 52 | // Script ID Numbers |
| 53 | // ================= |
| 54 | #define ID_LEVEL_0000 0x000 |
| 55 | |
| 56 | #define ID_TRIGGER_0003 0x001 |
| 57 | #define ID_TRIGGER_0002 0x002 |
| 58 | #define ID_TRIGGER_0001 0x003 |
| 59 | #define ID_TRIGGER_0000 0x004 |
| 60 | |
| 61 | // ======================== |
| 62 | // Script Class Definitions |
| 63 | // ======================== |
| 64 | |
| 65 | class BaseScript { |
| 66 | public: |
| 67 | BaseScript(); |
| 68 | ~BaseScript(); |
| 69 | virtual int16_t CallEvent(int event, tOSIRISEventInfo *data); |
| 70 | }; |
| 71 | |
| 72 | class LevelScript_0000 : public BaseScript { |
| 73 | public: |
| 74 | int16_t CallEvent(int event, tOSIRISEventInfo *data); |
| 75 | }; |
| 76 | |
| 77 | class TriggerScript_0003 : public BaseScript { |
| 78 | public: |
| 79 | int16_t CallEvent(int event, tOSIRISEventInfo *data); |
| 80 | }; |
| 81 | |
| 82 | class TriggerScript_0002 : public BaseScript { |
| 83 | public: |
| 84 | int16_t CallEvent(int event, tOSIRISEventInfo *data); |
| 85 | }; |
| 86 | |
| 87 | class TriggerScript_0001 : public BaseScript { |
| 88 | public: |
| 89 | int16_t CallEvent(int event, tOSIRISEventInfo *data); |
| 90 | }; |
| 91 | |
| 92 | class TriggerScript_0000 : public BaseScript { |
| 93 | public: |
| 94 | int16_t CallEvent(int event, tOSIRISEventInfo *data); |
| 95 | }; |
| 96 | |
| 97 | // ====================== |
| 98 | // Global Action Counters |
| 99 | // ====================== |
| 100 | |
| 101 | #define MAX_ACTION_CTR_VALUE 100000 |
| 102 | |
| 103 | int ScriptActionCtr_000 = 0; |
| 104 | int ScriptActionCtr_004 = 0; |
| 105 | int ScriptActionCtr_003 = 0; |
| 106 | int ScriptActionCtr_002 = 0; |
| 107 | int ScriptActionCtr_001 = 0; |
| 108 | |
| 109 | // ======================================== |
| 110 | // Function to Clear Global Action Counters |
| 111 | // ======================================== |
| 112 | void ClearGlobalActionCtrs(void) { |
| 113 | ScriptActionCtr_000 = 0; |
| 114 | ScriptActionCtr_004 = 0; |
| 115 | ScriptActionCtr_003 = 0; |
| 116 | ScriptActionCtr_002 = 0; |
| 117 | ScriptActionCtr_001 = 0; |
| 118 | } |
| 119 | |
| 120 | // ======================================== |
| 121 | // Function to Save Global Action Counters |
| 122 | // ======================================== |
| 123 | void SaveGlobalActionCtrs(void *file_ptr) { |
| 124 | File_WriteInt(ScriptActionCtr_000, file_ptr); |
| 125 | File_WriteInt(ScriptActionCtr_004, file_ptr); |
| 126 | File_WriteInt(ScriptActionCtr_003, file_ptr); |
| 127 | File_WriteInt(ScriptActionCtr_002, file_ptr); |
| 128 | File_WriteInt(ScriptActionCtr_001, file_ptr); |
| 129 | } |
| 130 | |
| 131 | // =========================================== |
| 132 | // Function to Restore Global Action Counters |
| 133 | // =========================================== |
| 134 | void RestoreGlobalActionCtrs(void *file_ptr) { |
| 135 | ScriptActionCtr_000 = File_ReadInt(file_ptr); |
| 136 | ScriptActionCtr_004 = File_ReadInt(file_ptr); |
| 137 | ScriptActionCtr_003 = File_ReadInt(file_ptr); |
| 138 | ScriptActionCtr_002 = File_ReadInt(file_ptr); |
| 139 | ScriptActionCtr_001 = File_ReadInt(file_ptr); |
| 140 | } |
| 141 | |
| 142 | // =============================================================== |
| 143 | // Start of Custom Script Block - DO NOT EDIT ANYTHING BEFORE THIS |
| 144 | // =============================================================== |
| 145 | /**{CUSTOM_SCRIPT_BLOCK_START}** DO NOT EDIT! **/ |
| 146 | |
| 147 | // Enter your custom script code here |
| 148 | |
| 149 | /**{CUSTOM_SCRIPT_BLOCK_END}**** DO NOT EDIT! **/ |
| 150 | // ============================================================ |
| 151 | // End of Custom Script Block - DO NOT EDIT ANYTHING AFTER THIS |
| 152 | // ============================================================ |
| 153 | |
| 154 | // ================= |
| 155 | // Message File Data |
| 156 | // ================= |
| 157 | |
| 158 | #define MAX_SCRIPT_MESSAGES 256 |
| 159 | #define MAX_MSG_FILEBUF_LEN 1024 |
| 160 | #define NO_MESSAGE_STRING "*Message Not Found*" |
| 161 | #define INV_MSGNAME_STRING "*Message Name Invalid*" |
| 162 | #define WHITESPACE_CHARS " \t\r\n" |
| 163 | |
| 164 | // Structure for storing a script message |
| 165 | struct tScriptMessage { |
| 166 | char *name; // the name of the message |
| 167 | char *message; // the actual message text |
| 168 | }; |
| 169 | |
| 170 | // Global storage for level script messages |
| 171 | tScriptMessage *message_list[MAX_SCRIPT_MESSAGES]; |
| 172 | int num_messages; |
| 173 | |
| 174 | // ====================== |
| 175 | // Message File Functions |
| 176 | // ====================== |
| 177 | |
| 178 | // Initializes the Message List |
| 179 | void InitMessageList(void) { |
| 180 | for (int j = 0; j < MAX_SCRIPT_MESSAGES; j++) |
| 181 | message_list[j] = NULL; |
| 182 | num_messages = 0; |
| 183 | } |
| 184 | |
| 185 | // Clear the Message List |
| 186 | void ClearMessageList(void) { |
| 187 | for (int j = 0; j < num_messages; j++) { |
| 188 | free(message_list[j]->name); |
| 189 | free(message_list[j]->message); |
| 190 | free(message_list[j]); |
| 191 | message_list[j] = NULL; |
| 192 | } |
| 193 | num_messages = 0; |
| 194 | } |
| 195 | |
| 196 | // Adds a message to the list |
| 197 | int AddMessageToList(char *name, char *msg) { |
| 198 | int pos; |
| 199 | |
| 200 | // Make sure there is room in the list |
| 201 | if (num_messages >= MAX_SCRIPT_MESSAGES) |
| 202 | return false; |
| 203 | |
| 204 | // Allocate memory for this message entry |
| 205 | pos = num_messages; |
| 206 | message_list[pos] = (tScriptMessage *)malloc(sizeof(tScriptMessage)); |
| 207 | if (message_list[pos] == NULL) |
| 208 | return false; |
| 209 | |
| 210 | // Allocate memory for the message name |
| 211 | message_list[pos]->name = (char *)malloc(strlen(name) + 1); |
| 212 | if (message_list[pos]->name == NULL) { |
| 213 | free(message_list[pos]); |
| 214 | return false; |
| 215 | } |
| 216 | strcpy(message_list[pos]->name, name); |
| 217 | |
| 218 | // Allocate memory for the message name |
| 219 | message_list[pos]->message = (char *)malloc(strlen(msg) + 1); |
| 220 | if (message_list[pos]->message == NULL) { |
| 221 | free(message_list[pos]->name); |
| 222 | free(message_list[pos]); |
| 223 | return false; |
| 224 | } |
| 225 | strcpy(message_list[pos]->message, msg); |
| 226 | num_messages++; |
| 227 | |
| 228 | return true; |
| 229 | } |
| 230 | |
| 231 | // Removes any whitespace padding from the end of a string |
| 232 | void RemoveTrailingWhitespace(char *s) { |
| 233 | int last_char_pos; |
| 234 | |
| 235 | last_char_pos = strlen(s) - 1; |
| 236 | while (last_char_pos >= 0 && isspace(s[last_char_pos])) { |
| 237 | s[last_char_pos] = '\0'; |
| 238 | last_char_pos--; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | // Returns a pointer to the first non-whitespace char in given string |
| 243 | char *SkipInitialWhitespace(char *s) { |
| 244 | while ((*s) != '\0' && isspace(*s)) |
| 245 | s++; |
| 246 | |
| 247 | return (s); |
| 248 | } |
| 249 | |
| 250 | // Read in the Messages |
| 251 | int ReadMessageFile(const char *filename) { |
| 252 | void *infile; |
| 253 | char filebuffer[MAX_MSG_FILEBUF_LEN + 1]; |
| 254 | char *line, *msg_start; |
| 255 | int line_num; |
| 256 | bool next_msgid_found; |
| 257 | |
| 258 | // Try to open the file for loading |
| 259 | infile = File_Open(filename, "rt"); |
| 260 | if (!infile) |
| 261 | return false; |
| 262 | |
| 263 | line_num = 0; |
| 264 | next_msgid_found = true; |
| 265 | |
| 266 | // Clear the message list |
| 267 | ClearMessageList(); |
| 268 | |
| 269 | // Read in and parse each line of the file |
| 270 | while (!File_eof(infile)) { |
| 271 | |
| 272 | // Clear the buffer |
| 273 | strcpy(filebuffer, ""); |
| 274 | |
| 275 | // Read in a line from the file |
| 276 | File_ReadString(filebuffer, MAX_MSG_FILEBUF_LEN, infile); |
| 277 | line_num++; |
| 278 | |
| 279 | // Remove whitespace padding at start and end of line |
| 280 | RemoveTrailingWhitespace(filebuffer); |
| 281 | line = SkipInitialWhitespace(filebuffer); |
| 282 | |
| 283 | // If line is a comment, or empty, discard it |
| 284 | if (strlen(line) == 0 || strncmp(line, "//", 2) == 0) |
| 285 | continue; |
| 286 | |
| 287 | if (!next_msgid_found) { // Parse out the last message ID number |
| 288 | |
| 289 | // Grab the first keyword, make sure it's valid |
| 290 | line = strtok(line, WHITESPACE_CHARS); |
| 291 | if (line == NULL) |
| 292 | continue; |
| 293 | |
| 294 | // Grab the second keyword, and assign it as the next message ID |
| 295 | line = strtok(NULL, WHITESPACE_CHARS); |
| 296 | if (line == NULL) |
| 297 | continue; |
| 298 | |
| 299 | next_msgid_found = true; |
| 300 | } else { // Parse line as a message line |
| 301 | |
| 302 | // Find the start of message, and mark it |
| 303 | msg_start = strchr(line, '='); |
| 304 | if (msg_start == NULL) |
| 305 | continue; |
| 306 | msg_start[0] = '\0'; |
| 307 | msg_start++; |
| 308 | |
| 309 | // Add the message to the list |
| 310 | AddMessageToList(line, msg_start); |
| 311 | } |
| 312 | } |
| 313 | File_Close(infile); |
| 314 | |
| 315 | return true; |
| 316 | } |
| 317 | |
| 318 | // Find a message |
| 319 | const char *GetMessage(const char *name) { |
| 320 | // Make sure given name is valid |
| 321 | if (name == NULL) |
| 322 | return INV_MSGNAME_STRING; |
| 323 | |
| 324 | // Search message list for name |
| 325 | for (int j = 0; j < num_messages; j++) |
| 326 | if (strcmp(message_list[j]->name, name) == 0) |
| 327 | return (message_list[j]->message); |
| 328 | |
| 329 | // Couldn't find it |
| 330 | return NO_MESSAGE_STRING; |
| 331 | } |
| 332 | |
| 333 | //====================== |
| 334 | // Name List Arrays |
| 335 | //====================== |
| 336 | |
| 337 | #define NUM_DOOR_NAMES 0 |
| 338 | const char **Door_names = NULL; |
| 339 | int *Door_handles = NULL; |
| 340 | |
| 341 | #define NUM_OBJECT_NAMES 0 |
| 342 | const char **Object_names = NULL; |
| 343 | int *Object_handles = NULL; |
| 344 | |
| 345 | #define NUM_ROOM_NAMES 4 |
| 346 | const char *Room_names[NUM_ROOM_NAMES] = {"BlueIn", "BlueOut", "RedOut", "RedIn"}; |
| 347 | int Room_indexes[NUM_ROOM_NAMES]; |
| 348 | |
| 349 | #define NUM_TRIGGER_NAMES 4 |
| 350 | const char *Trigger_names[NUM_TRIGGER_NAMES] = {"BlueOut", "BlueIn", "RedOut", "RedIn"}; |
| 351 | int Trigger_indexes[NUM_TRIGGER_NAMES]; |
| 352 | int Trigger_faces[NUM_TRIGGER_NAMES]; |
| 353 | int Trigger_rooms[NUM_TRIGGER_NAMES]; |
| 354 | |
| 355 | #define NUM_SOUND_NAMES 1 |
| 356 | const char *Sound_names[NUM_SOUND_NAMES] = {"LevSecAccelRelease"}; |
| 357 | int Sound_indexes[NUM_SOUND_NAMES]; |
| 358 | |
| 359 | #define NUM_TEXTURE_NAMES 0 |
| 360 | const char **Texture_names = NULL; |
| 361 | int *Texture_indexes = NULL; |
| 362 | |
| 363 | #define NUM_PATH_NAMES 0 |
| 364 | const char **Path_names = NULL; |
| 365 | int *Path_indexes = NULL; |
| 366 | |
| 367 | #define NUM_MATCEN_NAMES 0 |
| 368 | const char **Matcen_names = NULL; |
| 369 | int *Matcen_indexes = NULL; |
| 370 | |
| 371 | #define NUM_GOAL_NAMES 0 |
| 372 | const char **Goal_names = NULL; |
| 373 | int *Goal_indexes = NULL; |
| 374 | |
| 375 | #define NUM_MESSAGE_NAMES 0 |
| 376 | const char **Message_names = NULL; |
| 377 | const char **Message_strings = NULL; |
| 378 | |
| 379 | // =============== |
| 380 | // InitializeDLL() |
| 381 | // =============== |
| 382 | char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) { |
| 383 | osicommon_Initialize((tOSIRISModuleInit *)func_list); |
| 384 | if (func_list->game_checksum != CHECKSUM) { |
| 385 | mprintf(0, "Game-Checksum FAIL!!! (%ul!=%ul)\n", func_list->game_checksum, CHECKSUM); |
| 386 | mprintf(0, "RECOMPILE YOUR SCRIPTS!!!\n"); |
| 387 | return 0; |
| 388 | } |
| 389 | |
| 390 | ClearGlobalActionCtrs(); |
| 391 | dfInit(); |
| 392 | InitMessageList(); |
| 393 | |
| 394 | // Build the filename of the message file |
| 395 | char filename[_MAX_PATH + 32]; |
| 396 | int lang_type; |
| 397 | if (func_list->script_identifier != NULL) { |
| 398 | _splitpath(func_list->script_identifier, NULL, NULL, filename, NULL); |
| 399 | lang_type = Game_GetLanguage(); |
| 400 | if (lang_type == LANGUAGE_FRENCH) |
| 401 | strcat(filename, "_FRN"); |
| 402 | else if (lang_type == LANGUAGE_GERMAN) |
| 403 | strcat(filename, "_GER"); |
| 404 | else if (lang_type == LANGUAGE_ITALIAN) |
| 405 | strcat(filename, "_ITN"); |
| 406 | else if (lang_type == LANGUAGE_SPANISH) |
| 407 | strcat(filename, "_SPN"); |
| 408 | strcat(filename, ".msg"); |
| 409 | } else { |
| 410 | strcpy(filename, "HalfPipe5.msg"); |
| 411 | lang_type = LANGUAGE_ENGLISH; |
| 412 | } |
| 413 | if (!ReadMessageFile(filename)) { |
| 414 | mprintf(0, "ERROR: Could not load message file - %s\n", filename); |
| 415 | } |
| 416 | |
| 417 | int j; |
| 418 | |
| 419 | // Do Door Index lookups |
| 420 | for (j = 0; j < NUM_DOOR_NAMES; j++) |
| 421 | Door_handles[j] = Scrpt_FindDoorName(Door_names[j]); |
| 422 | |
| 423 | // Do Object Index lookups |
| 424 | for (j = 0; j < NUM_OBJECT_NAMES; j++) |
| 425 | Object_handles[j] = Scrpt_FindObjectName(Object_names[j]); |
| 426 | |
| 427 | // Do Room Index lookups |
| 428 | for (j = 0; j < NUM_ROOM_NAMES; j++) |
| 429 | Room_indexes[j] = Scrpt_FindRoomName(Room_names[j]); |
| 430 | |
| 431 | // Do Trigger Index lookups |
| 432 | for (j = 0; j < NUM_TRIGGER_NAMES; j++) { |
| 433 | Trigger_indexes[j] = Scrpt_FindTriggerName(Trigger_names[j]); |
| 434 | Trigger_faces[j] = Scrpt_GetTriggerFace(Trigger_indexes[j]); |
| 435 | Trigger_rooms[j] = Scrpt_GetTriggerRoom(Trigger_indexes[j]); |
| 436 | } |
| 437 | |
| 438 | // Do Sound Index lookups |
| 439 | for (j = 0; j < NUM_SOUND_NAMES; j++) |
| 440 | Sound_indexes[j] = Scrpt_FindSoundName(Sound_names[j]); |
| 441 | |
| 442 | // Do Texture Index lookups |
| 443 | for (j = 0; j < NUM_TEXTURE_NAMES; j++) |
| 444 | Texture_indexes[j] = Scrpt_FindTextureName(Texture_names[j]); |
| 445 | |
| 446 | // Do Path Index lookups |
| 447 | for (j = 0; j < NUM_PATH_NAMES; j++) |
| 448 | Path_indexes[j] = Scrpt_FindPathName(Path_names[j]); |
| 449 | |
| 450 | // Do Matcen Index lookups |
| 451 | for (j = 0; j < NUM_MATCEN_NAMES; j++) |
| 452 | Matcen_indexes[j] = Scrpt_FindMatcenName(Matcen_names[j]); |
| 453 | |
| 454 | // Do Goal Index lookups |
| 455 | for (j = 0; j < NUM_GOAL_NAMES; j++) |
| 456 | Goal_indexes[j] = Scrpt_FindLevelGoalName(Goal_names[j]); |
| 457 | |
| 458 | // Do Message Name lookups |
| 459 | for (j = 0; j < NUM_MESSAGE_NAMES; j++) |
| 460 | Message_strings[j] = GetMessage(Message_names[j]); |
| 461 | |
| 462 | return 1; |
| 463 | } |
| 464 | |
| 465 | // ============= |
| 466 | // ShutdownDLL() |
| 467 | // ============= |
| 468 | void STDCALL ShutdownDLL(void) { ClearMessageList(); } |
| 469 | |
| 470 | // =============== |
| 471 | // GetGOScriptID() |
| 472 | // =============== |
| 473 | int STDCALL GetGOScriptID(const char *name, uint8_t isdoor) { return -1; } |
| 474 | |
| 475 | // ================ |
| 476 | // CreateInstance() |
| 477 | // ================ |
| 478 | void STDCALLPTR CreateInstance(int id) { |
| 479 | switch (id) { |
| 480 | case ID_LEVEL_0000: |
| 481 | return new LevelScript_0000; |
| 482 | break; |
| 483 | case ID_TRIGGER_0003: |
| 484 | return new TriggerScript_0003; |
| 485 | break; |
| 486 | case ID_TRIGGER_0002: |
| 487 | return new TriggerScript_0002; |
| 488 | break; |
| 489 | case ID_TRIGGER_0001: |
| 490 | return new TriggerScript_0001; |
| 491 | break; |
| 492 | case ID_TRIGGER_0000: |
| 493 | return new TriggerScript_0000; |
| 494 | break; |
| 495 | default: |
| 496 | mprintf(0, "SCRIPT: Illegal ID (%d)\n", id); |
| 497 | break; |
| 498 | } |
| 499 | return NULL; |
| 500 | } |
| 501 | |
| 502 | // ================= |
| 503 | // DestroyInstance() |
| 504 | // ================= |
| 505 | void STDCALL DestroyInstance(int id, void *ptr) { |
| 506 | switch (id) { |
| 507 | case ID_LEVEL_0000: |
| 508 | delete ((LevelScript_0000 *)ptr); |
| 509 | break; |
| 510 | case ID_TRIGGER_0003: |
| 511 | delete ((TriggerScript_0003 *)ptr); |
| 512 | break; |
| 513 | case ID_TRIGGER_0002: |
| 514 | delete ((TriggerScript_0002 *)ptr); |
| 515 | break; |
| 516 | case ID_TRIGGER_0001: |
| 517 | delete ((TriggerScript_0001 *)ptr); |
| 518 | break; |
| 519 | case ID_TRIGGER_0000: |
| 520 | delete ((TriggerScript_0000 *)ptr); |
| 521 | break; |
| 522 | default: |
| 523 | mprintf(0, "SCRIPT: Illegal ID (%d)\n", id); |
| 524 | break; |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | // =================== |
| 529 | // CallInstanceEvent() |
| 530 | // =================== |
| 531 | int16_t STDCALL CallInstanceEvent(int id, void *ptr, int event, tOSIRISEventInfo *data) { |
| 532 | switch (id) { |
| 533 | case ID_LEVEL_0000: |
| 534 | case ID_TRIGGER_0003: |
| 535 | case ID_TRIGGER_0002: |
| 536 | case ID_TRIGGER_0001: |
| 537 | case ID_TRIGGER_0000: |
| 538 | return ((BaseScript *)ptr)->CallEvent(event, data); |
| 539 | break; |
| 540 | default: |
| 541 | mprintf(0, "SCRIPT: Illegal ID (%d)\n", id); |
| 542 | break; |
| 543 | } |
| 544 | return CONTINUE_CHAIN | CONTINUE_DEFAULT; |
| 545 | } |
| 546 | |
| 547 | // ================== |
| 548 | // SaveRestoreState() |
| 549 | // ================== |
| 550 | int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state) { return 0; } |
| 551 | |
| 552 | // ==================== |
| 553 | // GetTriggerScriptID() |
| 554 | // ==================== |
| 555 | int STDCALL GetTriggerScriptID(int trigger_room, int trigger_face) { |
| 556 | if (trigger_room == Trigger_rooms[0] && trigger_face == Trigger_faces[0]) |
| 557 | return ID_TRIGGER_0003; |
| 558 | |
| 559 | if (trigger_room == Trigger_rooms[1] && trigger_face == Trigger_faces[1]) |
| 560 | return ID_TRIGGER_0002; |
| 561 | |
| 562 | if (trigger_room == Trigger_rooms[2] && trigger_face == Trigger_faces[2]) |
| 563 | return ID_TRIGGER_0001; |
| 564 | |
| 565 | if (trigger_room == Trigger_rooms[3] && trigger_face == Trigger_faces[3]) |
| 566 | return ID_TRIGGER_0000; |
| 567 | |
| 568 | return -1; |
| 569 | } |
| 570 | |
| 571 | // ================= |
| 572 | // GetCOScriptList() |
| 573 | // ================= |
| 574 | int STDCALL GetCOScriptList(int **list, int **id_list) { |
| 575 | static int *cust_handle_list = NULL; |
| 576 | static int *cust_id_list = NULL; |
| 577 | |
| 578 | *list = cust_handle_list; |
| 579 | *id_list = cust_id_list; |
| 580 | |
| 581 | return 0; |
| 582 | } |
| 583 | |
| 584 | //======================= |
| 585 | // Script Implementation |
| 586 | //======================= |
| 587 | |
| 588 | BaseScript::BaseScript() {} |
| 589 | |
| 590 | BaseScript::~BaseScript() {} |
| 591 | |
| 592 | int16_t BaseScript::CallEvent(int event, tOSIRISEventInfo *data) { |
| 593 | mprintf(0, "BaseScript::CallEvent()\n"); |
| 594 | return CONTINUE_CHAIN | CONTINUE_DEFAULT; |
| 595 | } |
| 596 | |
| 597 | int16_t LevelScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { |
| 598 | switch (event) { |
| 599 | case EVT_SAVESTATE: { |
| 600 | tOSIRISEVTSAVESTATE *event_data = &data->evt_savestate; |
| 601 | |
| 602 | SaveGlobalActionCtrs(event_data->fileptr); |
| 603 | dfSave(event_data->fileptr); |
| 604 | } break; |
| 605 | case EVT_RESTORESTATE: { |
| 606 | tOSIRISEVTRESTORESTATE *event_data = &data->evt_restorestate; |
| 607 | |
| 608 | RestoreGlobalActionCtrs(event_data->fileptr); |
| 609 | dfRestore(event_data->fileptr); |
| 610 | } break; |
| 611 | case EVT_LEVELSTART: { |
| 612 | tOSIRISEVTLEVELSTART *event_data = &data->evt_levelstart; |
| 613 | |
| 614 | ClearGlobalActionCtrs(); |
| 615 | dfInit(); |
| 616 | |
| 617 | // Script 000: WindStart |
| 618 | if (1) { |
| 619 | aRoomSetWind(Room_indexes[0], 0.000000f, 0.000000f, -20.000000f, 1.500000f); |
| 620 | aRoomSetWind(Room_indexes[1], 0.000000f, 0.000000f, 20.000000f, 1.500000f); |
| 621 | aRoomSetWind(Room_indexes[2], 0.000000f, 0.000000f, -20.000000f, 1.500000f); |
| 622 | aRoomSetWind(Room_indexes[3], 0.000000f, 0.000000f, 20.000000f, 1.500000f); |
| 623 | |
| 624 | // Increment the script action counter |
| 625 | if (ScriptActionCtr_000 < MAX_ACTION_CTR_VALUE) |
| 626 | ScriptActionCtr_000++; |
| 627 | } |
| 628 | } break; |
| 629 | } |
| 630 | return CONTINUE_CHAIN | CONTINUE_DEFAULT; |
| 631 | } |
| 632 | |
| 633 | int16_t TriggerScript_0003::CallEvent(int event, tOSIRISEventInfo *data) { |
| 634 | switch (event) { |
| 635 | case EVT_COLLIDE: { |
| 636 | tOSIRISEVTCOLLIDE *event_data = &data->evt_collide; |
| 637 | |
| 638 | // Script 004: BlueOut |
| 639 | if (1) { |
| 640 | aMiscShakeArea(event_data->it_handle, 50.000000f, 40.000000f); |
| 641 | aSoundPlayObject(Sound_indexes[0], event_data->it_handle, 1.000000f); |
| 642 | |
| 643 | // Increment the script action counter |
| 644 | if (ScriptActionCtr_004 < MAX_ACTION_CTR_VALUE) |
| 645 | ScriptActionCtr_004++; |
| 646 | } |
| 647 | } break; |
| 648 | } |
| 649 | return CONTINUE_CHAIN | CONTINUE_DEFAULT; |
| 650 | } |
| 651 | |
| 652 | int16_t TriggerScript_0002::CallEvent(int event, tOSIRISEventInfo *data) { |
| 653 | switch (event) { |
| 654 | case EVT_COLLIDE: { |
| 655 | tOSIRISEVTCOLLIDE *event_data = &data->evt_collide; |
| 656 | |
| 657 | // Script 003: BlueIn |
| 658 | if (1) { |
| 659 | aMiscShakeArea(event_data->it_handle, 50.000000f, 40.000000f); |
| 660 | aSoundPlayObject(Sound_indexes[0], event_data->it_handle, 1.000000f); |
| 661 | |
| 662 | // Increment the script action counter |
| 663 | if (ScriptActionCtr_003 < MAX_ACTION_CTR_VALUE) |
| 664 | ScriptActionCtr_003++; |
| 665 | } |
| 666 | } break; |
| 667 | } |
| 668 | return CONTINUE_CHAIN | CONTINUE_DEFAULT; |
| 669 | } |
| 670 | |
| 671 | int16_t TriggerScript_0001::CallEvent(int event, tOSIRISEventInfo *data) { |
| 672 | switch (event) { |
| 673 | case EVT_COLLIDE: { |
| 674 | tOSIRISEVTCOLLIDE *event_data = &data->evt_collide; |
| 675 | |
| 676 | // Script 002: RedOut |
| 677 | if (1) { |
| 678 | aMiscShakeArea(event_data->it_handle, 50.000000f, 40.000000f); |
| 679 | aSoundPlayObject(Sound_indexes[0], event_data->it_handle, 1.000000f); |
| 680 | |
| 681 | // Increment the script action counter |
| 682 | if (ScriptActionCtr_002 < MAX_ACTION_CTR_VALUE) |
| 683 | ScriptActionCtr_002++; |
| 684 | } |
| 685 | } break; |
| 686 | } |
| 687 | return CONTINUE_CHAIN | CONTINUE_DEFAULT; |
| 688 | } |
| 689 | |
| 690 | int16_t TriggerScript_0000::CallEvent(int event, tOSIRISEventInfo *data) { |
| 691 | switch (event) { |
| 692 | case EVT_COLLIDE: { |
| 693 | tOSIRISEVTCOLLIDE *event_data = &data->evt_collide; |
| 694 | |
| 695 | // Script 001: RedIn |
| 696 | if (1) { |
| 697 | aMiscShakeArea(event_data->it_handle, 50.000000f, 40.000000f); |
| 698 | aSoundPlayObject(Sound_indexes[0], event_data->it_handle, 1.000000f); |
| 699 | |
| 700 | // Increment the script action counter |
| 701 | if (ScriptActionCtr_001 < MAX_ACTION_CTR_VALUE) |
| 702 | ScriptActionCtr_001++; |
| 703 | } |
| 704 | } break; |
| 705 | } |
| 706 | return CONTINUE_CHAIN | CONTINUE_DEFAULT; |
| 707 | } |
| 708 | |
| 709 | /********************************************************* |
| 710 | Script Save Block: DO NOT TOUCH ANYTHING IN THIS BLOCK!!! |
| 711 | ********************************************************** |
| 712 | $$SCRIPT_BLOCK_START |
| 713 | |
| 714 | VERSION 3 |
| 715 | NEXT_ID 5 |
| 716 | |
| 717 | // UserType value blocks |
| 718 | $$UTYPE_VALS_START UserVar |
| 719 | $$UTYPE_VALS_END |
| 720 | |
| 721 | $$UTYPE_VALS_START UserFlag |
| 722 | $$UTYPE_VALS_END |
| 723 | |
| 724 | $$UTYPE_VALS_START SpewHandle |
| 725 | $$UTYPE_VALS_END |
| 726 | |
| 727 | $$UTYPE_VALS_START TimerID |
| 728 | $$UTYPE_VALS_END |
| 729 | |
| 730 | $$UTYPE_VALS_START SavedObjectSlot |
| 731 | $$UTYPE_VALS_END |
| 732 | |
| 733 | $$UTYPE_VALS_START GoalID |
| 734 | $$UTYPE_VALS_END |
| 735 | |
| 736 | |
| 737 | // Name Lists |
| 738 | $$DOOR_LIST_START |
| 739 | $$DOOR_LIST_END |
| 740 | |
| 741 | $$OBJECT_LIST_START |
| 742 | $$OBJECT_LIST_END |
| 743 | |
| 744 | $$ROOM_LIST_START |
| 745 | BlueIn |
| 746 | BlueOut |
| 747 | RedOut |
| 748 | RedIn |
| 749 | $$ROOM_LIST_END |
| 750 | |
| 751 | $$TRIGGER_LIST_START |
| 752 | BlueOut |
| 753 | BlueIn |
| 754 | RedOut |
| 755 | RedIn |
| 756 | $$TRIGGER_LIST_END |
| 757 | |
| 758 | $$SOUND_LIST_START |
| 759 | LevSecAccelRelease |
| 760 | $$SOUND_LIST_END |
| 761 | |
| 762 | $$TEXTURE_LIST_START |
| 763 | $$TEXTURE_LIST_END |
| 764 | |
| 765 | $$SPECNAME_LIST_START |
| 766 | $$SPECNAME_LIST_END |
| 767 | |
| 768 | $$PATH_LIST_START |
| 769 | $$PATH_LIST_END |
| 770 | |
| 771 | $$MATCEN_LIST_START |
| 772 | $$MATCEN_LIST_END |
| 773 | |
| 774 | $$GOAL_LIST_START |
| 775 | $$GOAL_LIST_END |
| 776 | |
| 777 | $$STRM_AUDIO_LIST_START |
| 778 | $$STRM_AUDIO_LIST_END |
| 779 | |
| 780 | |
| 781 | // Script Tree Dump |
| 782 | 00:0:WindStart |
| 783 | $$CHILD_BLOCK_START |
| 784 | 01:2:0 |
| 785 | 02:6 |
| 786 | 03:0 |
| 787 | $$CHILD_BLOCK_START |
| 788 | 05:0 |
| 789 | $$CHILD_BLOCK_END |
| 790 | 04:0:0:0 |
| 791 | $$CHILD_BLOCK_START |
| 792 | 08:aRoomSetWind |
| 793 | $$CHILD_BLOCK_START |
| 794 | 10:2:0:Room |
| 795 | 10:6:0.000000:X |
| 796 | 10:6:0.000000:Y |
| 797 | 10:6:-20.000000:Z |
| 798 | 10:6:1.500000:Speed |
| 799 | $$CHILD_BLOCK_END |
| 800 | 08:aRoomSetWind |
| 801 | $$CHILD_BLOCK_START |
| 802 | 10:2:1:Room |
| 803 | 10:6:0.000000:X |
| 804 | 10:6:0.000000:Y |
| 805 | 10:6:20.000000:Z |
| 806 | 10:6:1.500000:Speed |
| 807 | $$CHILD_BLOCK_END |
| 808 | 08:aRoomSetWind |
| 809 | $$CHILD_BLOCK_START |
| 810 | 10:2:2:Room |
| 811 | 10:6:0.000000:X |
| 812 | 10:6:0.000000:Y |
| 813 | 10:6:-20.000000:Z |
| 814 | 10:6:1.500000:Speed |
| 815 | $$CHILD_BLOCK_END |
| 816 | 08:aRoomSetWind |
| 817 | $$CHILD_BLOCK_START |
| 818 | 10:2:3:Room |
| 819 | 10:6:0.000000:X |
| 820 | 10:6:0.000000:Y |
| 821 | 10:6:20.000000:Z |
| 822 | 10:6:1.500000:Speed |
| 823 | $$CHILD_BLOCK_END |
| 824 | $$CHILD_BLOCK_END |
| 825 | $$CHILD_BLOCK_END |
| 826 | 00:4:BlueOut |
| 827 | $$CHILD_BLOCK_START |
| 828 | 01:0:0 |
| 829 | 02:1 |
| 830 | 03:0 |
| 831 | $$CHILD_BLOCK_START |
| 832 | 05:0 |
| 833 | $$CHILD_BLOCK_END |
| 834 | 04:0:0:0 |
| 835 | $$CHILD_BLOCK_START |
| 836 | 08:aMiscShakeArea |
| 837 | $$CHILD_BLOCK_START |
| 838 | 10:1:1:-1:Object |
| 839 | 10:6:50.000000:Amount |
| 840 | 10:6:40.000000:Dist |
| 841 | $$CHILD_BLOCK_END |
| 842 | 08:aSoundPlayObject |
| 843 | $$CHILD_BLOCK_START |
| 844 | 10:12:0:Sound |
| 845 | 10:1:1:-1:Object |
| 846 | 10:9:1.000000:Volume |
| 847 | $$CHILD_BLOCK_END |
| 848 | 08:DO NOTHING |
| 849 | $$CHILD_BLOCK_END |
| 850 | $$CHILD_BLOCK_END |
| 851 | 00:3:BlueIn |
| 852 | $$CHILD_BLOCK_START |
| 853 | 01:0:1 |
| 854 | 02:1 |
| 855 | 03:0 |
| 856 | $$CHILD_BLOCK_START |
| 857 | 05:0 |
| 858 | $$CHILD_BLOCK_END |
| 859 | 04:0:0:0 |
| 860 | $$CHILD_BLOCK_START |
| 861 | 08:aMiscShakeArea |
| 862 | $$CHILD_BLOCK_START |
| 863 | 10:1:1:-1:Object |
| 864 | 10:6:50.000000:Amount |
| 865 | 10:6:40.000000:Dist |
| 866 | $$CHILD_BLOCK_END |
| 867 | 08:aSoundPlayObject |
| 868 | $$CHILD_BLOCK_START |
| 869 | 10:12:0:Sound |
| 870 | 10:1:1:-1:Object |
| 871 | 10:9:1.000000:Volume |
| 872 | $$CHILD_BLOCK_END |
| 873 | 08:DO NOTHING |
| 874 | $$CHILD_BLOCK_END |
| 875 | $$CHILD_BLOCK_END |
| 876 | 00:2:RedOut |
| 877 | $$CHILD_BLOCK_START |
| 878 | 01:0:2 |
| 879 | 02:1 |
| 880 | 03:0 |
| 881 | $$CHILD_BLOCK_START |
| 882 | 05:0 |
| 883 | $$CHILD_BLOCK_END |
| 884 | 04:0:0:0 |
| 885 | $$CHILD_BLOCK_START |
| 886 | 08:aMiscShakeArea |
| 887 | $$CHILD_BLOCK_START |
| 888 | 10:1:1:-1:Object |
| 889 | 10:6:50.000000:Amount |
| 890 | 10:6:40.000000:Dist |
| 891 | $$CHILD_BLOCK_END |
| 892 | 08:aSoundPlayObject |
| 893 | $$CHILD_BLOCK_START |
| 894 | 10:12:0:Sound |
| 895 | 10:1:1:-1:Object |
| 896 | 10:9:1.000000:Volume |
| 897 | $$CHILD_BLOCK_END |
| 898 | 08:DO NOTHING |
| 899 | $$CHILD_BLOCK_END |
| 900 | $$CHILD_BLOCK_END |
| 901 | 00:1:RedIn |
| 902 | $$CHILD_BLOCK_START |
| 903 | 01:0:3 |
| 904 | 02:1 |
| 905 | 03:0 |
| 906 | $$CHILD_BLOCK_START |
| 907 | 05:0 |
| 908 | $$CHILD_BLOCK_END |
| 909 | 04:0:0:0 |
| 910 | $$CHILD_BLOCK_START |
| 911 | 08:aMiscShakeArea |
| 912 | $$CHILD_BLOCK_START |
| 913 | 10:1:1:-1:Object |
| 914 | 10:6:50.000000:Amount |
| 915 | 10:6:40.000000:Dist |
| 916 | $$CHILD_BLOCK_END |
| 917 | 08:aSoundPlayObject |
| 918 | $$CHILD_BLOCK_START |
| 919 | 10:12:0:Sound |
| 920 | 10:1:1:-1:Object |
| 921 | 10:9:1.000000:Volume |
| 922 | $$CHILD_BLOCK_END |
| 923 | 08:DO NOTHING |
| 924 | $$CHILD_BLOCK_END |
| 925 | $$CHILD_BLOCK_END |
| 926 | |
| 927 | $$SCRIPT_BLOCK_END |
| 928 | *********************************************************/ |