Skip to content

Commit

Permalink
Refactoring door system (opentibiabr#995)
Browse files Browse the repository at this point in the history
Refactored doors script, the key tables were transformed into just one and some functions had corrections and improvements.

Thanks for @omarcopires by report and tests

Co-authored-by: Eduardo Dantas <[email protected]>
Co-authored-by: dudztroyer <[email protected]>
  • Loading branch information
dudantas and dudztroyer authored Apr 11, 2020
1 parent 62a979c commit 2547ea9
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 291 deletions.
268 changes: 66 additions & 202 deletions data/lib/tables/door.lua
Original file line number Diff line number Diff line change
@@ -1,209 +1,74 @@
-- Note: The closedDoorUnlocked transform the door closed (only with onUse of the player) to the door locked (with onUse of the key), only need add the id of closedDoor and the lockedDoor.
-- The rest of the variables are self-explanatory, create more variables within the table and add the door ids in their variables.
-- Be careful, do not add quest door inside the level door table or vice versa, this will lock the doors.
-- Be careful, do not add quest door inside the level door table, this will lock the doors.

-- ID of the keys.
keysID = {2086, 2087, 2088, 2089, 2090, 2091, 2092}

-- Keys doors start.
-- Doors locked. This is the doors with the description "It is locked".
keyLockedDoor = {
{ closedDoor = 1209, openDoor = 1211 },
{ closedDoor = 1212, openDoor = 1214 },
{ closedDoor = 1231, openDoor = 1233 },
{ closedDoor = 1234, openDoor = 1236 },
{ closedDoor = 1249, openDoor = 1251 },
{ closedDoor = 1252, openDoor = 1254 },
{ closedDoor = 3535, openDoor = 3537 },
{ closedDoor = 3544, openDoor = 3546 },
{ closedDoor = 4916, openDoor = 4918 },
{ closedDoor = 4913, openDoor = 4915 },
{ closedDoor = 5098, openDoor = 5100 },
{ closedDoor = 5107, openDoor = 5109 },
{ closedDoor = 5116, openDoor = 5118 },
{ closedDoor = 5125, openDoor = 5127 },
{ closedDoor = 5134, openDoor = 5136 },
{ closedDoor = 5137, openDoor = 5139 },
{ closedDoor = 5140, openDoor = 5142 },
{ closedDoor = 5143, openDoor = 5145 },
{ closedDoor = 5278, openDoor = 5280 },
{ closedDoor = 5281, openDoor = 5283 },
{ closedDoor = 5732, openDoor = 5734 },
{ closedDoor = 5735, openDoor = 5737 },
{ closedDoor = 6192, openDoor = 6194 },
{ closedDoor = 6195, openDoor = 6197 },
{ closedDoor = 6249, openDoor = 6251 },
{ closedDoor = 6252, openDoor = 6254 },
{ closedDoor = 6799, openDoor = 6796 },
{ closedDoor = 6801, openDoor = 6798 },
{ closedDoor = 6891, openDoor = 6893 },
{ closedDoor = 6900, openDoor = 6902 },
{ closedDoor = 7033, openDoor = 7035 },
{ closedDoor = 7042, openDoor = 7044 },
{ closedDoor = 8541, openDoor = 8543 },
{ closedDoor = 8544, openDoor = 8546 },
{ closedDoor = 9165, openDoor = 9167 },
{ closedDoor = 9168, openDoor = 9170 },
{ closedDoor = 9267, openDoor = 9269 },
{ closedDoor = 9270, openDoor = 9272 },
{ closedDoor = 10268, openDoor = 10270 },
{ closedDoor = 10271, openDoor = 10273 },
{ closedDoor = 10468, openDoor = 10470 },
{ closedDoor = 10477, openDoor = 10479 },
{ closedDoor = 10775, openDoor = 10777 },
{ closedDoor = 10784, openDoor = 10786 },
{ closedDoor = 12092, openDoor = 12094 },
{ closedDoor = 12099, openDoor = 12101 },
{ closedDoor = 12188, openDoor = 12190 },
{ closedDoor = 12197, openDoor = 12199 },
{ closedDoor = 14633, openDoor = 14635 },
{ closedDoor = 19840, openDoor = 19842 },
{ closedDoor = 19849, openDoor = 19851 },
{ closedDoor = 19980, openDoor = 19982 },
{ closedDoor = 19989, openDoor = 19991 },
{ closedDoor = 20273, openDoor = 20275 },
{ closedDoor = 20282, openDoor = 20284 },
{ closedDoor = 22814, openDoor = 22816 },
{ closedDoor = 22823, openDoor = 22825 },
{ closedDoor = 26541, openDoor = 26545 },
{ closedDoor = 26543, openDoor = 26546 },
{ closedDoor = 33117, openDoor = 32582 },
{ closedDoor = 33119, openDoor = 32583 },
-- The lockedDoor is the doors with the description "It is locked". Use this (with no action) to keep a door permanently isoled.
-- The closedDoor is the doors that are unlocked, when using them open normally.
keyDoor = {
{ lockedDoor = 1209, closedDoor = 1210, openDoor = 1211 },
{ lockedDoor = 1212, closedDoor = 1213, openDoor = 1214 },
{ lockedDoor = 1231, closedDoor = 1232, openDoor = 1233 },
{ lockedDoor = 1234, closedDoor = 1235, openDoor = 1236 },
{ lockedDoor = 1249, closedDoor = 1250, openDoor = 1251 },
{ lockedDoor = 1252, closedDoor = 1253, openDoor = 1254 },
{ lockedDoor = 3535, closedDoor = 3336, openDoor = 3537 },
{ lockedDoor = 3544, closedDoor = 3545, openDoor = 3546 },
{ lockedDoor = 4916, closedDoor = 4917, openDoor = 4918 },
{ lockedDoor = 4913, closedDoor = 4914, openDoor = 4915 },
{ lockedDoor = 5098, closedDoor = 5099, openDoor = 5100 },
{ lockedDoor = 5107, closedDoor = 5108, openDoor = 5109 },
{ lockedDoor = 5116, closedDoor = 5117, openDoor = 5118 },
{ lockedDoor = 5125, closedDoor = 5126, openDoor = 5127 },
{ lockedDoor = 5134, closedDoor = 5135, openDoor = 5136 },
{ lockedDoor = 5137, closedDoor = 5138, openDoor = 5139 },
{ lockedDoor = 5140, closedDoor = 5141, openDoor = 5142 },
{ lockedDoor = 5143, closedDoor = 5144, openDoor = 5145 },
{ lockedDoor = 5278, closedDoor = 5279, openDoor = 5280 },
{ lockedDoor = 5281, closedDoor = 5282, openDoor = 5283 },
{ lockedDoor = 5732, closedDoor = 5733, openDoor = 5734 },
{ lockedDoor = 5735, closedDoor = 5736, openDoor = 5737 },
{ lockedDoor = 6192, closedDoor = 6193, openDoor = 6194 },
{ lockedDoor = 6195, closedDoor = 6196, openDoor = 6197 },
{ lockedDoor = 6249, closedDoor = 6250, openDoor = 6251 },
{ lockedDoor = 6252, closedDoor = 6253, openDoor = 6254 },
{ lockedDoor = 6799, closedDoor = 6795, openDoor = 6796 },
{ lockedDoor = 6801, closedDoor = 6797, openDoor = 6798 },
{ lockedDoor = 6891, closedDoor = 6892, openDoor = 6893 },
{ lockedDoor = 6900, closedDoor = 6901, openDoor = 6902 },
{ lockedDoor = 7033, closedDoor = 7034, openDoor = 7035 },
{ lockedDoor = 7042, closedDoor = 7043, openDoor = 7044 },
{ lockedDoor = 8541, closedDoor = 8542, openDoor = 8543 },
{ lockedDoor = 8544, closedDoor = 8545, openDoor = 8546 },
{ lockedDoor = 9165, closedDoor = 9166, openDoor = 9167 },
{ lockedDoor = 9168, closedDoor = 9169, openDoor = 9170 },
{ lockedDoor = 9267, closedDoor = 9268, openDoor = 9269 },
{ lockedDoor = 9270, closedDoor = 9271, openDoor = 9272 },
{ lockedDoor = 10268, closedDoor = 12269, openDoor = 10270 },
{ lockedDoor = 10271, closedDoor = 10272, openDoor = 10273 },
{ lockedDoor = 10468, closedDoor = 10469, openDoor = 10470 },
{ lockedDoor = 10477, closedDoor = 10478, openDoor = 10479 },
{ lockedDoor = 10775, closedDoor = 10776, openDoor = 10777 },
{ lockedDoor = 10784, closedDoor = 10785, openDoor = 10786 },
{ lockedDoor = 12092, closedDoor = 12093, openDoor = 12094 },
{ lockedDoor = 12099, closedDoor = 12100, openDoor = 12101 },
{ lockedDoor = 12188, closedDoor = 12189, openDoor = 12190 },
{ lockedDoor = 12197, closedDoor = 12198, openDoor = 12199 },
{ lockedDoor = 14633, closedDoor = 14634, openDoor = 14635 },
{ lockedDoor = 19840, closedDoor = 19841, openDoor = 19842 },
{ lockedDoor = 19849, closedDoor = 19850, openDoor = 19851 },
{ lockedDoor = 19980, closedDoor = 19981, openDoor = 19982 },
{ lockedDoor = 19989, closedDoor = 19990, openDoor = 19991 },
{ lockedDoor = 20273, closedDoor = 20274, openDoor = 20275 },
{ lockedDoor = 20282, closedDoor = 20283, openDoor = 20284 },
{ lockedDoor = 22814, closedDoor = 22815, openDoor = 22816 },
{ lockedDoor = 22823, closedDoor = 22824, openDoor = 22825 },
{ lockedDoor = 26541, closedDoor = 26542, openDoor = 26545 },
{ lockedDoor = 26543, closedDoor = 26544, openDoor = 26546 },
{ lockedDoor = 33117, closedDoor = 33118, openDoor = 32582 },
{ lockedDoor = 33119, closedDoor = 33120, openDoor = 32583 },
}

-- This is the commons doors usually used in the keys, are opened just by using.
keyUnlockedDoor = {
{ closedDoor = 1210, openDoor = 1211 },
{ closedDoor = 1213, openDoor = 1214 },
{ closedDoor = 1232, openDoor = 1233 },
{ closedDoor = 1235, openDoor = 1236 },
{ closedDoor = 1250, openDoor = 1251 },
{ closedDoor = 1253, openDoor = 1254 },
{ closedDoor = 3536, openDoor = 3537 },
{ closedDoor = 3545, openDoor = 3546 },
{ closedDoor = 4914, openDoor = 4915 },
{ closedDoor = 4917, openDoor = 4918 },
{ closedDoor = 5099, openDoor = 5100 },
{ closedDoor = 5108, openDoor = 5109 },
{ closedDoor = 5117, openDoor = 5118 },
{ closedDoor = 5126, openDoor = 5127 },
{ closedDoor = 5135, openDoor = 5136 },
{ closedDoor = 5138, openDoor = 5139 },
{ closedDoor = 5141, openDoor = 5142 },
{ closedDoor = 5144, openDoor = 5145 },
{ closedDoor = 5279, openDoor = 5280 },
{ closedDoor = 5282, openDoor = 5283 },
{ closedDoor = 5733, openDoor = 5734 },
{ closedDoor = 5736, openDoor = 5737 },
{ closedDoor = 6193, openDoor = 6194 },
{ closedDoor = 6196, openDoor = 6197 },
{ closedDoor = 6250, openDoor = 6251 },
{ closedDoor = 6253, openDoor = 6254 },
{ closedDoor = 6795, openDoor = 6796 },
{ closedDoor = 6892, openDoor = 6893 },
{ closedDoor = 6894, openDoor = 6895 },
{ closedDoor = 6901, openDoor = 6902 },
{ closedDoor = 6903, openDoor = 6904 },
{ closedDoor = 7034, openDoor = 7035 },
{ closedDoor = 7043, openDoor = 7044 },
{ closedDoor = 8542, openDoor = 8543 },
{ closedDoor = 8545, openDoor = 8546 },
{ closedDoor = 9166, openDoor = 9167 },
{ closedDoor = 9169, openDoor = 9170 },
{ closedDoor = 9268, openDoor = 9269 },
{ closedDoor = 9271, openDoor = 9272 },
{ closedDoor = 10269, openDoor = 10270 },
{ closedDoor = 10272, openDoor = 10273 },
{ closedDoor = 10469, openDoor = 10470 },
{ closedDoor = 10478, openDoor = 10479 },
{ closedDoor = 10776, openDoor = 10777 },
{ closedDoor = 10785, openDoor = 10786 },
{ closedDoor = 12093, openDoor = 12094 },
{ closedDoor = 12100, openDoor = 12101 },
{ closedDoor = 12189, openDoor = 12190 },
{ closedDoor = 12198, openDoor = 12199 },
{ closedDoor = 14634, openDoor = 14635 },
{ closedDoor = 19841, openDoor = 19842 },
{ closedDoor = 19850, openDoor = 19851 },
{ closedDoor = 19981, openDoor = 19982 },
{ closedDoor = 19990, openDoor = 19991 },
{ closedDoor = 20274, openDoor = 20275 },
{ closedDoor = 20283, openDoor = 20284 },
{ closedDoor = 22815, openDoor = 22816 },
{ closedDoor = 22824, openDoor = 22825 },
{ closedDoor = 26542, openDoor = 26545 },
{ closedDoor = 26544, openDoor = 26546 },
{ closedDoor = 33118, openDoor = 32582 },
{ closedDoor = 33120, openDoor = 32583 },
}

-- Add the common closed key door here and in the second variable the door locked with the key.
-- This allows that when using the closed door with the key, it becomes the locked door.
fromClosedToLockedDoor = {
{ keyDoorClosed = 1210, keyDoorLocked = 1209 },
{ keyDoorClosed = 1213, keyDoorLocked = 1212 },
{ keyDoorClosed = 1232, keyDoorLocked = 1231 },
{ keyDoorClosed = 1235, keyDoorLocked = 1234 },
{ keyDoorClosed = 1250, keyDoorLocked = 1249 },
{ keyDoorClosed = 1253, keyDoorLocked = 1252 },
{ keyDoorClosed = 3536, keyDoorLocked = 3535 },
{ keyDoorClosed = 3545, keyDoorLocked = 3544 },
{ keyDoorClosed = 4914, keyDoorLocked = 4913 },
{ keyDoorClosed = 4917, keyDoorLocked = 4916 },
{ keyDoorClosed = 5099, keyDoorLocked = 5098 },
{ keyDoorClosed = 5108, keyDoorLocked = 5107 },
{ keyDoorClosed = 5117, keyDoorLocked = 5116 },
{ keyDoorClosed = 5126, keyDoorLocked = 5125 },
{ keyDoorClosed = 5135, keyDoorLocked = 5134 },
{ keyDoorClosed = 5141, keyDoorLocked = 5140 },
{ keyDoorClosed = 5144, keyDoorLocked = 5143 },
{ keyDoorClosed = 5279, keyDoorLocked = 5278 },
{ keyDoorClosed = 5282, keyDoorLocked = 5281 },
{ keyDoorClosed = 5733, keyDoorLocked = 5732 },
{ keyDoorClosed = 5736, keyDoorLocked = 5735 },
{ keyDoorClosed = 6193, keyDoorLocked = 6192 },
{ keyDoorClosed = 6196, keyDoorLocked = 6195 },
{ keyDoorClosed = 6250, keyDoorLocked = 6249 },
{ keyDoorClosed = 6253, keyDoorLocked = 6252 },
{ keyDoorClosed = 6795, keyDoorLocked = 6799 },
{ keyDoorClosed = 6797, keyDoorLocked = 6801 },
{ keyDoorClosed = 6892, keyDoorLocked = 6891 },
{ keyDoorClosed = 6901, keyDoorLocked = 6900 },
{ keyDoorClosed = 7034, keyDoorLocked = 7033 },
{ keyDoorClosed = 7043, keyDoorLocked = 7042 },
{ keyDoorClosed = 8542, keyDoorLocked = 8541 },
{ keyDoorClosed = 8545, keyDoorLocked = 8544 },
{ keyDoorClosed = 9166, keyDoorLocked = 9165 },
{ keyDoorClosed = 9169, keyDoorLocked = 9168 },
{ keyDoorClosed = 9268, keyDoorLocked = 9267 },
{ keyDoorClosed = 9271, keyDoorLocked = 9270 },
{ keyDoorClosed = 10269, keyDoorLocked = 10268 },
{ keyDoorClosed = 10272, keyDoorLocked = 10271 },
{ keyDoorClosed = 10469, keyDoorLocked = 10468 },
{ keyDoorClosed = 10478, keyDoorLocked = 10477 },
{ keyDoorClosed = 10776, keyDoorLocked = 10775 },
{ keyDoorClosed = 10785, keyDoorLocked = 10784 },
{ keyDoorClosed = 12093, keyDoorLocked = 12092 },
{ keyDoorClosed = 12100, keyDoorLocked = 12099 },
{ keyDoorClosed = 12189, keyDoorLocked = 12188 },
{ keyDoorClosed = 12198, keyDoorLocked = 12197 },
{ keyDoorClosed = 14634, keyDoorLocked = 14633 },
{ keyDoorClosed = 14641, keyDoorLocked = 14640 },
{ keyDoorClosed = 19841, keyDoorLocked = 19840 },
{ keyDoorClosed = 19850, keyDoorLocked = 19849 },
{ keyDoorClosed = 19981, keyDoorLocked = 19980 },
{ keyDoorClosed = 19990, keyDoorLocked = 19989 },
{ keyDoorClosed = 20274, keyDoorLocked = 20273 },
{ keyDoorClosed = 20283, keyDoorLocked = 20282 },
{ keyDoorClosed = 22815, keyDoorLocked = 22814 },
{ keyDoorClosed = 22824, keyDoorLocked = 22823 },
{ keyDoorClosed = 26542, keyDoorLocked = 26541 },
{ keyDoorClosed = 26544, keyDoorLocked = 26543 },
{ keyDoorClosed = 33118, keyDoorLocked = 33117 },
{ keyDoorClosed = 33120, keyDoorLocked = 33119 },
}
-- Keys doors end.


-- These are the common doors, the ones that just open and close without any special requirements.
customDoor = {
{ closedDoor = 1219, openDoor = 1220 },
Expand All @@ -228,7 +93,6 @@ customDoor = {
{ closedDoor = 6200, openDoor = 6201 },
{ closedDoor = 6255, openDoor = 6256 },
{ closedDoor = 6257, openDoor = 6258 },
{ closedDoor = 6797, openDoor = 6798 },
{ closedDoor = 7036, openDoor = 7037 },
{ closedDoor = 7045, openDoor = 7046 },
{ closedDoor = 7054, openDoor = 7055 },
Expand Down
Loading

0 comments on commit 2547ea9

Please sign in to comment.