Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In VerbGui.ash:
- struct Doors {
- ... //Add the following lines to the end
- import static void SetAnimation (bool animate_on, int view_id, int animation_speed, int delay_after);
- import static void AnimateDoor();
- };
- in VerbGui.asc:
- struct VerbsData {
- ... //Add the following lines to the end
- //Sets whether to animate the player before interacting with doors.
- bool door_animate_on = false;
- int door_view_id = 0;
- int door_animation_speed = 4;
- int door_delay_after = 0;
- }
- The following function needs to appear BEFORE static int Doors::AnyClickSpecial in VerbGui.asc:
- static void Doors::AnimateDoor()
- {
- if (verbsData.door_animate_on)
- {
- player.LockView(verbsData.door_view_id);
- player.Animate(player.Loop, verbsData.door_animation_speed);
- Wait(verbsData.door_delay_after);
- player.UnlockView();
- }
- }
- The following function should be added after the AnyClickSpecial function (or could be placed before, probably):
- static void Doors::SetAnimation (bool animate_on, int view_id, int animation_speed, int delay_after)
- {
- verbsData.door_animate_on = animate_on;
- verbsData.door_view_id = view_id;
- verbsData.door_animation_speed = animation_speed;
- verbsData.door_delay_after = delay_after;
- }
- Finally, replace Doors::AnyClickSpecial (the entire function) with:
- // ============================= Door functions ==========================================
- /***********************************************************************
- * 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)
- * This function extends AnyClick with the following parameters:
- *
- * opensound: custom sound to be played, when the door is being opend
- * closesound: custom sound to be played, when the door is being closed
- * key: the id of the inventory item, that can unlock the door, -1 masterkey, -2 if the door cannot be unlocked
- * closevalue: default 0 (closed), but you can also set 2 (locked).
- ***********************************************************************/
- 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) {
- // key = -1: masterkey - even locked doors will be opened
- // key = -2: door can't be unlocked (like rusted)
- AudioChannel *chan;
- int result=1;
- if (Verbs.UsedAction(eGA_Close)) {
- if (Doors.GetDoorState(door_id) == 0 || Doors.GetDoorState(door_id) == 2) Verbs.Unhandled(1);
- else if (Doors.GetDoorState(door_id) == 1 ) {
- if (Verbs.AnyClickMove(x, y, dir)) {
- Doors.AnimateDoor();
- if (closesound != null) chan = closesound.Play();
- // Play default sound
- else if (verbsData.closeDoorSound != null) chan = verbsData.closeDoorSound.Play();
- object[obj].Visible=false;
- Doors.SetDoorState(door_id, closevalue);
- }
- }
- }
- else if (Verbs.UsedAction(eGA_Open)) {
- if (Doors.GetDoorState(door_id) == 0 || (Doors.GetDoorState(door_id) == 2 && key == -1 ) ) {
- if (Verbs.AnyClickMove (x, y, dir))
- {
- Doors.AnimateDoor();
- if (opensound != null) chan = opensound.Play();
- // Play default sound
- else if (verbsData.openDoorSound != null) chan = verbsData.openDoorSound.Play();
- object[obj].Visible=true;
- Doors.SetDoorState(door_id, 1);
- }
- }
- else if (Doors.GetDoorState(door_id) == 1 ) Verbs.Unhandled(1);
- else if (Doors.GetDoorState(door_id) == 2 )
- {
- if (Verbs.AnyClickMove (x, y, dir))
- {
- Doors.AnimateDoor();
- if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringLocked])) player.Say(verbsData.door_strings[eDoorStringLocked]);
- }
- }
- }
- else if (Verbs.UsedAction(eGA_WalkTo)) {
- if (Doors.GetDoorState(door_id) == 1) {
- if ( verbsData.exitDoorDoubleclick && DoubleClick.Event[eMouseLeft] )
- {
- if (Verbs.MovePlayerEx(player.x, player.y, eWalkableAreas) > 0 ) player.EnterRoom(nr_room, nr_x, nr_y, nr_dir);
- result = 2;
- }
- else
- {
- if (Verbs.GoTo(2)){
- player.EnterRoom(nr_room, nr_x, nr_y, nr_dir);
- result = 2;
- }
- }
- }
- else Verbs.AnyClickMove(x, y, dir);
- }
- else if (Verbs.UsedAction (eGA_LookAt) && !String.IsNullOrEmpty(verbsData.door_strings[eDoorStringLookAt]) ) {
- if (Verbs.AnyClickMove (x, y, dir)) player.Say(verbsData.door_strings[eDoorStringLookAt]);
- }
- else if (Verbs.UsedAction(eGA_UseInv) && key >= 0) {
- if (Verbs.AnyClickMove(x, y, dir)) {
- Doors.AnimateDoor();
- if (player.ActiveInventory == inventory[key] ) {
- if (Doors.GetDoorState(door_id) == 1 ) {
- if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringCloseFirst]) ) player.Say(verbsData.door_strings[eDoorStringCloseFirst]);
- }
- else if (Doors.GetDoorState(door_id) == 2 ) {
- if (verbsData.unlockDoorSound != null) chan = verbsData.unlockDoorSound.Play();
- if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringUnlock])) player.Say(verbsData.door_strings[eDoorStringUnlock]);
- Doors.SetDoorState(door_id, closevalue);
- }
- else if (Doors.GetDoorState(door_id) == 0 ) {
- object[obj].Visible=false;
- Doors.SetDoorState(door_id, 2);
- if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringRelock])) player.Say(verbsData.door_strings[eDoorStringRelock]);
- }
- }
- else if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringWrongItem])) player.Say(verbsData.door_strings[eDoorStringWrongItem]);
- }
- }
- else result=0;
- return result;
- // 0 = unhandled
- // 1 = handled
- // 2 = NewRoom
- }
Advertisement
Add Comment
Please, Sign In to add comment