|
3 | 3 | use util; |
4 | 4 | use cfgfile; |
5 | 5 |
|
| 6 | +include "include/client"; |
6 | 7 | include ":keys:key"; |
7 | 8 |
|
| 9 | +var doordesc := ReadConfigFile (":doors:itemdesc"); |
| 10 | + |
8 | 11 | // New requried functions..... |
9 | 12 | // Checks to see if the item can be used... |
10 | 13 | function CanUseDoor( byref mobile, byref door ) |
@@ -75,3 +78,80 @@ function IsOccupied( item ) |
75 | 78 |
|
76 | 79 | return ListMobilesNearLocationEX( x, y, item.z, 0, LISTEX_FLAG_HIDDEN+LISTEX_FLAG_NORMAL, item.realm ); |
77 | 80 | endfunction |
| 81 | + |
| 82 | +/////////////////// |
| 83 | +// closes the given door, ignoring locked status |
| 84 | +/////////////////// |
| 85 | + |
| 86 | +function CloseDoor (door) |
| 87 | + if (door.graphic == door.objtype) |
| 88 | + return; |
| 89 | + endif |
| 90 | + |
| 91 | + var xmod := CINT (doordesc[door.objtype].xmod); |
| 92 | + var ymod := CINT (doordesc[door.objtype].ymod); |
| 93 | + |
| 94 | + var newx := door.x - xmod; |
| 95 | + var newy := door.y - ymod; |
| 96 | + if (GetObjProperty (door, "x")) |
| 97 | + newx := GetObjProperty (door, "x"); |
| 98 | + newy := GetObjProperty (door, "y"); |
| 99 | + EraseObjProperty (door, "x"); |
| 100 | + EraseObjProperty (door, "y"); |
| 101 | + endif |
| 102 | + |
| 103 | + var newz := door.z; |
| 104 | + var newr := door.realm; |
| 105 | + if (door.graphic != door.objtype) |
| 106 | + set_critical (1); |
| 107 | + door.movable := 1; |
| 108 | + door.graphic := door.objtype; |
| 109 | + MoveObjectToLocation( door, newx, newy, newz, newr, flags :=MOVEOBJECT_FORCELOCATION ); |
| 110 | + door.movable := 0; |
| 111 | + set_critical (0); |
| 112 | + PlayDoorCloseSound (door); |
| 113 | + endif |
| 114 | +endfunction |
| 115 | + |
| 116 | +/////////////////// |
| 117 | +// plays the sound effect for opening the door |
| 118 | +/////////////////// |
| 119 | + |
| 120 | +function PlayDoorOpenSound (door) |
| 121 | + case (doordesc[door.objtype].doortype) |
| 122 | + "wood": |
| 123 | + PlaySoundEffect (door, SFX_OPEN_WOODEN_DOOR); |
| 124 | + "stone": |
| 125 | + PlaySoundEffect (door, SFX_OPEN_STONE_DOOR); |
| 126 | + "metal": |
| 127 | + PlaySoundEffect (door, SFX_OPEN_METAL_DOOR); |
| 128 | + "sliding": |
| 129 | + PlaySoundEffect (door, SFX_OPEN_SLIDING_DOOR); |
| 130 | + default: |
| 131 | + PlaySoundEffect (door, SFX_OPEN_METAL_DOOR); |
| 132 | + endcase |
| 133 | +endfunction |
| 134 | + |
| 135 | + |
| 136 | + |
| 137 | + |
| 138 | +/////////////////// |
| 139 | +// plays the sound effect for closing the door |
| 140 | +/////////////////// |
| 141 | + |
| 142 | +function PlayDoorCloseSound (door) |
| 143 | + case (doordesc[door.objtype].doortype) |
| 144 | + "wood": |
| 145 | + PlaySoundEffect (door, SFX_CLOSE_WOODEN_DOOR); |
| 146 | + "stone": |
| 147 | + PlaySoundEffect (door, SFX_CLOSE_STONE_DOOR); |
| 148 | + "metal": |
| 149 | + PlaySoundEffect (door, SFX_CLOSE_METAL_DOOR); |
| 150 | + "sliding": |
| 151 | + PlaySoundEffect (door, SFX_CLOSE_SLIDING_DOOR); |
| 152 | + default: |
| 153 | + PlaySoundEffect (door, SFX_CLOSE_METAL_DOOR); |
| 154 | + endcase |
| 155 | +endfunction |
| 156 | + |
| 157 | + |
0 commit comments