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