Guest User

Untitled

a guest
Feb 14th, 2025
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.93 KB | None | 0 0
  1. In VerbGui.ash:
  2.  
  3. struct Doors {
  4. ... //Add the following lines to the end
  5. import static void SetAnimation (bool animate_on, int view_id, int animation_speed, int delay_after);
  6. import static void AnimateDoor();
  7. };
  8.  
  9. in VerbGui.asc:
  10.  
  11. struct VerbsData {
  12. ... //Add the following lines to the end
  13. //Sets whether to animate the player before interacting with doors.
  14. bool door_animate_on = false;
  15. int door_view_id = 0;
  16. int door_animation_speed = 4;
  17. int door_delay_after = 0;
  18. }
  19.  
  20. The following function needs to appear BEFORE static int Doors::AnyClickSpecial in VerbGui.asc:
  21.  
  22. static void Doors::AnimateDoor()
  23. {
  24. if (verbsData.door_animate_on)
  25. {
  26. player.LockView(verbsData.door_view_id);
  27. player.Animate(player.Loop, verbsData.door_animation_speed);
  28. Wait(verbsData.door_delay_after);
  29. player.UnlockView();
  30. }
  31. }
  32.  
  33. The following function should be added after the AnyClickSpecial function (or could be placed before, probably):
  34.  
  35. static void Doors::SetAnimation (bool animate_on, int view_id, int animation_speed, int delay_after)
  36. {
  37. verbsData.door_animate_on = animate_on;
  38. verbsData.door_view_id = view_id;
  39. verbsData.door_animation_speed = animation_speed;
  40. verbsData.door_delay_after = delay_after;
  41. }
  42.  
  43. Finally, replace Doors::AnyClickSpecial (the entire function) with:
  44.  
  45. // ============================= Door functions ==========================================
  46.  
  47. /***********************************************************************
  48. * AnyClickSpecial(int door_id, int obj, int x, int y, CharacterDirection dir, int nr_room, int nr_x, int nr_y, CharacterDirection nr_dir, AudioClip *opensound, AudioClip *closesound, int key, int closevalue)
  49. * This function extends AnyClick with the following parameters:
  50. *
  51. * opensound: custom sound to be played, when the door is being opend
  52. * closesound: custom sound to be played, when the door is being closed
  53. * key: the id of the inventory item, that can unlock the door, -1 masterkey, -2 if the door cannot be unlocked
  54. * closevalue: default 0 (closed), but you can also set 2 (locked).
  55. ***********************************************************************/
  56. static int Doors::AnyClickSpecial(int door_id, int obj, int x, int y, CharacterDirection dir, int nr_room, int nr_x, int nr_y, CharacterDirection nr_dir, AudioClip *opensound, AudioClip *closesound, int key, int closevalue) {
  57. // key = -1: masterkey - even locked doors will be opened
  58. // key = -2: door can't be unlocked (like rusted)
  59. AudioChannel *chan;
  60. int result=1;
  61.  
  62. if (Verbs.UsedAction(eGA_Close)) {
  63. if (Doors.GetDoorState(door_id) == 0 || Doors.GetDoorState(door_id) == 2) Verbs.Unhandled(1);
  64. else if (Doors.GetDoorState(door_id) == 1 ) {
  65. if (Verbs.AnyClickMove(x, y, dir)) {
  66. Doors.AnimateDoor();
  67. if (closesound != null) chan = closesound.Play();
  68. // Play default sound
  69. else if (verbsData.closeDoorSound != null) chan = verbsData.closeDoorSound.Play();
  70. object[obj].Visible=false;
  71. Doors.SetDoorState(door_id, closevalue);
  72. }
  73. }
  74. }
  75. else if (Verbs.UsedAction(eGA_Open)) {
  76. if (Doors.GetDoorState(door_id) == 0 || (Doors.GetDoorState(door_id) == 2 && key == -1 ) ) {
  77. if (Verbs.AnyClickMove (x, y, dir))
  78. {
  79. Doors.AnimateDoor();
  80. if (opensound != null) chan = opensound.Play();
  81. // Play default sound
  82. else if (verbsData.openDoorSound != null) chan = verbsData.openDoorSound.Play();
  83.  
  84. object[obj].Visible=true;
  85. Doors.SetDoorState(door_id, 1);
  86. }
  87. }
  88. else if (Doors.GetDoorState(door_id) == 1 ) Verbs.Unhandled(1);
  89. else if (Doors.GetDoorState(door_id) == 2 )
  90. {
  91. if (Verbs.AnyClickMove (x, y, dir))
  92. {
  93. Doors.AnimateDoor();
  94. if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringLocked])) player.Say(verbsData.door_strings[eDoorStringLocked]);
  95. }
  96. }
  97. }
  98. else if (Verbs.UsedAction(eGA_WalkTo)) {
  99. if (Doors.GetDoorState(door_id) == 1) {
  100. if ( verbsData.exitDoorDoubleclick && DoubleClick.Event[eMouseLeft] )
  101. {
  102. if (Verbs.MovePlayerEx(player.x, player.y, eWalkableAreas) > 0 ) player.EnterRoom(nr_room, nr_x, nr_y, nr_dir);
  103. result = 2;
  104. }
  105. else
  106. {
  107. if (Verbs.GoTo(2)){
  108. player.EnterRoom(nr_room, nr_x, nr_y, nr_dir);
  109. result = 2;
  110. }
  111.  
  112. }
  113. }
  114. else Verbs.AnyClickMove(x, y, dir);
  115.  
  116. }
  117. else if (Verbs.UsedAction (eGA_LookAt) && !String.IsNullOrEmpty(verbsData.door_strings[eDoorStringLookAt]) ) {
  118. if (Verbs.AnyClickMove (x, y, dir)) player.Say(verbsData.door_strings[eDoorStringLookAt]);
  119. }
  120. else if (Verbs.UsedAction(eGA_UseInv) && key >= 0) {
  121. if (Verbs.AnyClickMove(x, y, dir)) {
  122. Doors.AnimateDoor();
  123. if (player.ActiveInventory == inventory[key] ) {
  124. if (Doors.GetDoorState(door_id) == 1 ) {
  125. if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringCloseFirst]) ) player.Say(verbsData.door_strings[eDoorStringCloseFirst]);
  126. }
  127. else if (Doors.GetDoorState(door_id) == 2 ) {
  128. if (verbsData.unlockDoorSound != null) chan = verbsData.unlockDoorSound.Play();
  129. if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringUnlock])) player.Say(verbsData.door_strings[eDoorStringUnlock]);
  130. Doors.SetDoorState(door_id, closevalue);
  131. }
  132. else if (Doors.GetDoorState(door_id) == 0 ) {
  133. object[obj].Visible=false;
  134. Doors.SetDoorState(door_id, 2);
  135. if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringRelock])) player.Say(verbsData.door_strings[eDoorStringRelock]);
  136. }
  137. }
  138. else if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringWrongItem])) player.Say(verbsData.door_strings[eDoorStringWrongItem]);
  139. }
  140. }
  141. else result=0;
  142.  
  143. return result;
  144. // 0 = unhandled
  145. // 1 = handled
  146. // 2 = NewRoom
  147. }
  148.  
  149.  
Advertisement
Add Comment
Please, Sign In to add comment