Guest User

GlobalScript.asc

a guest
Feb 17th, 2014
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.60 KB | None | 0 0
  1. // main global script file
  2.  
  3. // Globals from GUIscript
  4. import int ActionLabelColorHighlighted;
  5. import char key_l_yes, key_u_yes, key_l_no, key_u_no;
  6. import int action_l_keycode[A_COUNT_];
  7. import int action_u_keycode[A_COUNT_];
  8. import int GStopsaveitem;
  9. import int listBoxGap;
  10. import int lang;
  11. import InventoryItem*ItemGiven;
  12.  
  13. // Door IDs in use are:
  14. ///////////////////////////////////////////////
  15. // ID 20 - Sample Door in Room 1
  16. ///////////////////////////////////////////////
  17.  
  18. // =======================================================================================
  19. function game_start() {
  20.  
  21. String tr_lang;
  22. // --- translate GUI action buttons ---
  23. tr_lang = GetTranslation("GUI_LANGUAGE");
  24. tr_lang = tr_lang.LowerCase();
  25.  
  26. if (tr_lang == "de") {
  27. lang = eLangDE;
  28. }
  29. else if (tr_lang =="es") {
  30. lang = eLangES;
  31. }
  32. else if (tr_lang =="fr") {
  33. lang = eLangFR;
  34. }
  35. else if (tr_lang =="en") {
  36. lang = eLangEN;
  37. }
  38. else if (tr_lang =="it") {
  39. lang = eLangIT;
  40. }
  41. AdjustLanguage();
  42.  
  43. // --- initialize game settings ---
  44. SetDefaultAction(eMA_WalkTo);
  45. set_double_click_speed(GetGameSpeed()/4);
  46.  
  47. // --- set the pixel gap for listbox items according to the screen res
  48. if (System.ScreenWidth<640) listBoxGap = 2;
  49. else listBoxGap = 4;
  50. }
  51.  
  52. function on_mouse_click(MouseButton button) {
  53. }
  54.  
  55. function repeatedly_execute() {
  56. }
  57.  
  58. function on_key_press(eKeyCode keycode) {
  59. // called when a key is pressed. keycode holds the key's ASCII code
  60.  
  61. // --- PAUSE-GUI ---
  62. if (keycode == eKeySpace)
  63. {
  64. // SPACEBAR
  65. if (!IsGamePaused()) {
  66. PauseGame();
  67. AdjustGUIText();
  68. gPaused.Visible=true;
  69. }
  70. else {
  71. gPaused.Visible=false;
  72. UnPauseGame();
  73. SetAction(eMA_Default);
  74. ActionLine.TextColor=ActionLabelColorHighlighted;
  75. CheckDefaultAction();
  76. UpdateActionBar();
  77. }
  78. }
  79. // --- RESTART-GUI ---
  80. else if (gRestart.Visible) {
  81.  
  82. // if exit gui is on
  83. if (keycode==key_u_no || keycode == key_l_no) gRestart.Visible=false; // if N is pressed continue
  84. if (keycode==key_u_yes || keycode == key_l_yes) RestartGame(); // if Y is pressed restart game
  85. }
  86. // --- QUITGAME-GUI ---
  87. if (gConfirmexit.Visible) {
  88. // if exit gui is on
  89. if (keycode==key_u_no || keycode==key_l_no) gConfirmexit.Visible=false; // if N is pressed continue
  90. if (keycode==key_u_yes || keycode==key_l_yes) QuitGame(0); // if Y is pressed quit game
  91. }
  92. if (IsGamePaused()) keycode = 0; // game paused, so don't react to keypresses
  93.  
  94. // Translate GUIs on keypress
  95. if (keycode == eKeyF5 || keycode == eKeyF6 || keycode == eKeyF8 || keycode == eKeyCtrlC) AdjustGUIText();
  96.  
  97. //
  98. if (keycode == eKeyF5) gOptions.Visible=true; // F5 - OPTIONS
  99. if (keycode == eKeyF8) gRestart.Visible=true; // F8 - RESTART
  100. if (keycode == eKeyCtrlC) gConfirmexit.Visible=true; // Ctrl-C - QUIT
  101. if (keycode == eKeyF12) SaveScreenShot("scrnshot.pcx"); // F12
  102. if (keycode == eKeyCtrlS) Debug (0, 0); // Ctrl-S, give all inventory
  103. if (keycode == eKeyCtrlV) Debug (1, 0); // Ctrl-V, version
  104. if (keycode == eKeyCtrlA) Debug (2, 0); // Ctrl-A, show walkable areas
  105. if (keycode == eKeyCtrlX) Debug (3, 0); // Ctrl-X, teleport to room
  106. // --- triggering actions by the keys:---
  107. int act_i=0;
  108. while (act_i<A_COUNT_) {
  109. if (keycode == action_l_keycode[act_i] || keycode==action_u_keycode[act_i]) {
  110. SetAction(act_i);
  111. act_i=A_COUNT_;
  112. }
  113. else {
  114. act_i++;
  115. }
  116. }
  117. }
  118.  
  119. function on_event(EventType event, int data) {
  120. if (event==eEventLeaveRoom)
  121. if (event==eEventRestoreGame) {
  122. AdjustLanguage();
  123. }
  124. if (event==eEventEnterRoomBeforeFadein || event==eEventRestoreGame)
  125. player.PlaceOnWalkableArea();
  126. }
  127.  
  128.  
  129. ////////////////////////////////////////////////////////////////////////////////////
  130. // GUI handling
  131. ////////////////////////////////////////////////////////////////////////////////////
  132.  
  133. function Action_Click(GUIControl *control, MouseButton button) {
  134. Action tempbutton = getButtonAction(control.ID);
  135. SetAction(tempbutton);
  136. }
  137.  
  138. function btnMainOpt_OnClick(GUIControl *control, MouseButton button)
  139. {
  140. AdjustGUIText();
  141. gOptions.Visible=true;
  142. }
  143.  
  144. function ScrollInv_Click(GUIControl *control, MouseButton button) {
  145. if (control==InvUp) MainInv.ScrollUp();
  146. else MainInv.ScrollDown();
  147. }
  148.  
  149. function Options_Click(GUIControl *control, MouseButton button) {
  150. if (control==OptionsSave) {
  151. //save game
  152. gOptions.Visible=false;
  153. GetLucasSavegameListBox(SaveListBox);
  154. gSave.Visible=true;
  155. }
  156. if (control==OptionsLoad) {
  157. //load game
  158. gOptions.Visible=false;
  159. GetLucasSavegameListBox(RestoreListBox);
  160. RestoreListBox.TopItem=0;
  161. gRestore.Visible=true;
  162. }
  163. if (control==OptionsPlay) {
  164. // continue playing
  165. gOptions.Visible=false;
  166. }
  167. if (control==OptionsQuit) {
  168. // exit??
  169. gOptions.Visible=false;
  170. gConfirmexit.Visible=true;
  171. }
  172. }
  173.  
  174. function OptionsRestart_OnClick(GUIControl *control, MouseButton button)
  175. {
  176. gOptions.Visible=false;
  177. gRestart.Visible=true;
  178. }
  179.  
  180. function OptionsDefault_OnClick(GUIControl *control, MouseButton button)
  181. {
  182. OptionsSldMusic.Value = 80;
  183. OptionsSldSound.Value = 90;
  184. OptionsSldSpeed.Value = 40;
  185. #ifver 3.2
  186. Game.SetAudioTypeVolume(eAudioTypeMusic, OptionsSldMusic.Value, eVolExistingAndFuture);
  187. Game.SetAudioTypeVolume(eAudioTypeSound, OptionsSldSound.Value, eVolExistingAndFuture);
  188. Game.SetAudioTypeVolume(eAudioTypeAmbientSound, OptionsSldSound.Value, eVolExistingAndFuture);
  189. #endif
  190.  
  191. #ifnver 3.2
  192. SetSoundVolume(OptionsSldSound.Value);
  193. SetMusicVolume(OptionsSldMusic.Value);
  194. #endif
  195. SetGameSpeed(OptionsSldSpeed.Value);
  196. }
  197.  
  198. function OptionsSldMusic_OnChange(GUIControl *control)
  199. {
  200. #ifver 3.2
  201. Game.SetAudioTypeVolume(eAudioTypeMusic, OptionsSldMusic.Value, eVolExistingAndFuture);
  202. #endif
  203. #ifnver 3.2
  204. SetMusicVolume(OptionsSldMusic.Value);
  205. #endif
  206.  
  207. }
  208. function OptionsSldSound_OnChange(GUIControl *control)
  209. {
  210. #ifver 3.2
  211. Game.SetAudioTypeVolume(eAudioTypeSound, OptionsSldSound.Value, eVolExistingAndFuture);
  212. Game.SetAudioTypeVolume(eAudioTypeAmbientSound, OptionsSldSound.Value, eVolExistingAndFuture);
  213. #endif
  214. #ifnver 3.2
  215. SetSoundVolume(OptionsSldSound.Value);
  216. #endif
  217.  
  218. }
  219.  
  220.  
  221. function OptionsSldSpeed_OnChange(GUIControl *control)
  222. {
  223. SetGameSpeed(OptionsSldSpeed.Value);
  224. }
  225.  
  226. function Restore_Click(GUIControl *control, MouseButton button) {
  227. if (control==RestoreCancel) gRestore.Visible=false;
  228. if (control==RestoreScrollUp) {
  229. if (GStopsaveitem < 5) GStopsaveitem = 0;
  230. else GStopsaveitem -= 5;
  231. RestoreListBox.TopItem=GStopsaveitem;
  232. }
  233. if (control==RestoreScrollDown) {
  234. if (GStopsaveitem < 90) {
  235. GStopsaveitem += 5;
  236. RestoreListBox.TopItem=GStopsaveitem;
  237. }
  238. }
  239. }
  240.  
  241. function RestoreListBox_Click(GUIControl *control) {
  242. int index = RestoreListBox.SelectedIndex;
  243. String buffer=Game.GetSaveSlotDescription(index+100);
  244. if (buffer!=null) {
  245. gRestore.Visible=false;
  246. RestoreGameSlot(index + 100);
  247. }
  248. }
  249.  
  250. function Save_Click(GUIControl *control, MouseButton button) {
  251. int index = SaveListBox.SelectedIndex;
  252. String buffer;
  253. if (control==SaveCancel) {
  254. gSave.Visible=false;
  255. gSavetextbox.Visible=false;
  256. }
  257. if (control==SaveOK && index >= 0) {
  258. buffer=SaveTextBox.Text;
  259. gSave.Visible=false;
  260. gSavetextbox.Visible=false;
  261. SaveGameSlot (index + 100, buffer);
  262. }
  263. if (control==SaveScrollUp) {
  264. gSavetextbox.Visible=false;
  265. SaveListBox.SelectedIndex=-1;
  266. if (GStopsaveitem < 5) GStopsaveitem = 0;
  267. else GStopsaveitem -= 5;
  268. SaveListBox.TopItem=GStopsaveitem;
  269. }
  270. if (control==SaveScrollDown && GStopsaveitem < 90) {
  271. gSavetextbox.Visible=false;
  272. SaveListBox.SelectedIndex=-1;
  273. GStopsaveitem += 5;
  274. SaveListBox.TopItem=GStopsaveitem;
  275. }
  276. }
  277.  
  278. function SaveListBox_Click(GUIControl *control) {
  279. int saveBox_ypos;
  280. int saveBox_xpos;
  281. int index = SaveListBox.SelectedIndex;
  282.  
  283. String buffer=String.Format("%d.", index+1);
  284. SaveLabel.Text=buffer;
  285. buffer=Game.GetSaveSlotDescription(index+100);
  286. if (buffer==null) buffer="";
  287. SaveTextBox.Text=buffer;
  288.  
  289. saveBox_ypos = gSave.Y + SaveListBox.Y + ((index - GStopsaveitem) * (GetTextHeight(SaveLabel.Text, SaveLabel.Font, SaveLabel.Width)+listBoxGap));
  290. saveBox_xpos = GetTextWidth(SaveLabel.Text, SaveLabel.Font);
  291. SaveTextBox.SetPosition(saveBox_xpos, 0);
  292.  
  293. gSavetextbox.SetPosition(gSave.X + SaveListBox.X, saveBox_ypos);
  294. gSavetextbox.Visible=true;
  295. }
  296.  
  297. function SaveTextBox_Click(GUIControl *control) {
  298. if (mouse.IsButtonDown(eMouseRight)) gSavetextbox.Visible=false;
  299. }
  300.  
  301.  
  302. function dialog_request(int param) {
  303. }
  304.  
  305. //////////////////////////////////////////////////////////////////////////
  306. ///////////////////Custom FUNCTIONS//////////////////////////////////
  307. //////////////////////////////////////////////////////////////////////////
  308.  
  309. /* Character, Object, Hotspot full blown SAMPLE
  310. function cChar_AnyClick() {
  311.  
  312. // TALK TO (characters only)
  313. if (UsedAction(eGA_TalkTo)) {
  314. Unhandled();
  315. }
  316. // LOOK AT
  317. else if(UsedAction(eGA_LookAt)) {
  318. Unhandled();
  319. }
  320. // OPEN
  321. else if(UsedAction(eGA_Open)) {
  322. Unhandled();
  323. }
  324. // CLOSE
  325. else if(UsedAction(eGA_Close)) {
  326. Unhandled();
  327. }
  328. // USE
  329. else if(UsedAction(eGA_Use)) {
  330. Unhandled();
  331. }
  332. // Push
  333. else if(UsedAction(eGA_Push)) {
  334. Unhandled();
  335. }
  336. // Pull
  337. else if(UsedAction(eGA_Pull)) {
  338. Unhandled();
  339. }
  340. // PICKUP
  341. else if(UsedAction(eGA_PickUp)) {
  342. Unhandled();
  343. }
  344. // GIVE TO (characters only)
  345. else if(UsedAction(eGA_GiveTo)) {
  346. Unhandled();
  347. }
  348. //USE INV
  349. else if(UsedAction(eGA_UseInv)) {
  350. Unhandled();
  351. }
  352. else Unhandled();
  353. }
  354. */
  355.  
  356. /* Inventory SAMPLE
  357. // LOOK AT
  358. else if(UsedAction(eGA_LookAt)) {
  359. Unhandled();
  360. }
  361. // USE
  362. else if(UsedAction(eGA_Use)) {
  363. Unhandled();
  364. }
  365. // Push
  366. else if(UsedAction(eGA_Push)) {
  367. Unhandled();
  368. }
  369. // Pull
  370. else if(UsedAction(eGA_Pull)) {
  371. Unhandled();
  372. }
  373. //USE INV
  374. else if(UsedAction(eGA_UseInv)) {
  375. Unhandled();
  376. }
  377. else Unhandled();
  378.  
  379. */
  380.  
  381. function iBook_AnyClick()
  382. {
  383. if (UsedAction(eGA_LookAt)) {
  384. dBook.Start();
  385. }
  386. }
  387.  
  388. function iSheet_AnyClick()
  389. {
  390. if (UsedAction(eGA_LookAt)) {
  391. cRachel.Say("It's my bedsheet.");
  392. }
  393. if (UsedAction(eGA_UseInv)) {
  394. if (cRachel.ActiveInventory == iPants) {
  395. cRachel.AddInventory(iSPTT);
  396. cRachel.LoseInventory(iSheet);
  397. cRachel.LoseInventory(iPants);
  398. cRachel.Say("I tied my sheet and pants together. It looks like a rope now.");
  399. }
  400. if (cRachel.ActiveInventory == iShirt) {
  401. cRachel.AddInventory(iSSTT);
  402. cRachel.LoseInventory(iSheet);
  403. cRachel.LoseInventory(iShirt);
  404. cRachel.Say("It tied my sheet and shirt together. It looks like a rope now.");
  405. }
  406. if (cRachel.ActiveInventory == iShPTT) {
  407. cRachel.AddInventory(iSTTL);
  408. cRachel.LoseInventory(iSheet);
  409. cRachel.LoseInventory(iShPTT);
  410. cRachel.Say("I tied my sheet to the shirt and pants making an even longer clothing rope.");
  411. }
  412. }
  413. }
  414.  
  415. function iPants_AnyClick()
  416. {
  417. Display("iPants_AnyClick");
  418. if (UsedAction(eGA_LookAt)) {
  419. cRachel.Say("It's my pants.");
  420. }
  421. if (UsedAction(eGA_UseInv)) {
  422. if (cRachel.ActiveInventory == iSheet) {
  423. cRachel.AddInventory(iSPTT);
  424. cRachel.LoseInventory(iSheet);
  425. cRachel.LoseInventory(iPants);
  426. cRachel.Say("I tied my sheet and pants together. It looks like a rope now.");
  427. }
  428. if (cRachel.ActiveInventory == iShirt) {
  429. cRachel.AddInventory(iShPTT);
  430. cRachel.LoseInventory(iShirt);
  431. cRachel.LoseInventory(iPants);
  432. cRachel.Say("I tied my shirt and pants together. It looks like a rope now.");
  433. }
  434. if (cRachel.ActiveInventory == iSSTT) {
  435. cRachel.AddInventory(iSTTL);
  436. cRachel.LoseInventory(iPants);
  437. cRachel.LoseInventory(iSSTT);
  438. cRachel.Say("I tied my pants to the sheet and shirt making an even longer clothing rope.");
  439. }
  440. }
  441. }
  442.  
  443. function iShirt_AnyClick()
  444. {
  445. if (UsedAction(eGA_LookAt)) {
  446. cRachel.Say("It's my smilely face shirt");
  447. }
  448. if (UsedAction(eGA_UseInv)) {
  449. if (cRachel.ActiveInventory == iSheet) {
  450. cRachel.AddInventory(iSSTT);
  451. cRachel.LoseInventory(iSheet);
  452. cRachel.LoseInventory(iShirt);
  453. cRachel.Say("It tied my sheet and shirt together. It looks like a rope now.");
  454. }
  455. if (cRachel.ActiveInventory == iPants) {
  456. cRachel.AddInventory(iShPTT);
  457. cRachel.LoseInventory(iShirt);
  458. cRachel.LoseInventory(iPants);
  459. cRachel.Say("I tied my shirt and pants together. It looks like a rope now.");
  460. }
  461. if (cRachel.ActiveInventory == iSPTT) {
  462. cRachel.AddInventory(iSTTL);
  463. cRachel.LoseInventory(iShirt);
  464. cRachel.LoseInventory(iSPTT);
  465. cRachel.Say("I tied my shirt to the sheet and pants making an even longer clothing rope.");
  466. }
  467. }
  468. }
  469.  
  470. function iSock_AnyClick()
  471. {
  472. if (UsedAction(eGA_LookAt)) {
  473. cRachel.Say("It's my annoyingly pink giant sock.");
  474. }
  475. }
  476.  
  477. function iSPTT_AnyClick()
  478. {
  479. if (UsedAction(eGA_LookAt)) {
  480. cRachel.Say("I tied my sheet and pants together. It looks like a rope now.");
  481. }
  482. if (UsedAction(eGA_UseInv)) {
  483. if (cRachel.ActiveInventory == iShirt) {
  484. cRachel.AddInventory(iSTTL);
  485. cRachel.LoseInventory(iShirt);
  486. cRachel.LoseInventory(iSPTT);
  487. cRachel.Say("I tied my shirt to the sheet and pants making an even longer clothing rope.");
  488. }
  489. }
  490. }
  491.  
  492. function iSSTT_AnyClick()
  493. {
  494. if (UsedAction(eGA_LookAt)) {
  495. cRachel.Say("I tied my sheet and shirt together. It looks like a rope now.");
  496. }
  497. if (UsedAction(eGA_UseInv)) {
  498. if (cRachel.ActiveInventory == iPants) {
  499. cRachel.AddInventory(iSTTL);
  500. cRachel.LoseInventory(iPants);
  501. cRachel.LoseInventory(iSSTT);
  502. cRachel.Say("I tied my pants to the sheet and shirt making an even longer clothing rope.");
  503. }
  504. }
  505. }
  506.  
  507. function iShPTT_AnyClick()
  508. {
  509. if (UsedAction(eGA_LookAt)) {
  510. cRachel.Say("I tied my shirt and pants together. It looks like a rope now.");
  511. }
  512. if (UsedAction(eGA_UseInv)) {
  513. if (cRachel.ActiveInventory == iSheet) {
  514. cRachel.AddInventory(iSTTL);
  515. cRachel.LoseInventory(iSheet);
  516. cRachel.LoseInventory(iShPTT);
  517. cRachel.Say("I tied my sheet to the shirt and pants making an even longer clothing rope.");
  518. }
  519. }
  520. }
  521.  
  522. function iSTTL_AnyClick()
  523. {
  524. if(UsedAction(eGA_LookAt)) {
  525. cRachel.Say("I tied a bunch of laundry into a long rope.");
  526. }
  527. }
Advertisement
Add Comment
Please, Sign In to add comment