Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add sound for open and close doors #1978

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions data-otservbr-global/scripts/actions/door/custom_door.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ function customDoor.onUse(player, item, fromPosition, target, toPosition, isHotk
for index, value in ipairs(CustomDoorTable) do
if value.closedDoor == item.itemid then
item:transform(value.openDoor)
item:getPosition():sendSingleSoundEffect(SOUND_EFFECT_TYPE_ACTION_OPEN_DOOR)
return true
end
end
for index, value in ipairs(CustomDoorTable) do
if value.openDoor == item.itemid then
item:transform(value.closedDoor)
item:getPosition():sendSingleSoundEffect(SOUND_EFFECT_TYPE_ACTION_CLOSE_DOOR)
return true
end
end
Expand Down
6 changes: 6 additions & 0 deletions data-otservbr-global/scripts/actions/door/key_door.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function keyDoor.onUse(player, item, fromPosition, target, toPosition, isHotkey)
for index, value in ipairs(KeyDoorTable) do
if value.closedDoor == item.itemid then
item:transform(value.openDoor)
item:getPosition():sendSingleSoundEffect(SOUND_EFFECT_TYPE_ACTION_OPEN_DOOR)
return true
end
end
Expand All @@ -46,6 +47,7 @@ function keyDoor.onUse(player, item, fromPosition, target, toPosition, isHotkey)
return false
end
item:transform(value.closedDoor)
item:getPosition():sendSingleSoundEffect(SOUND_EFFECT_TYPE_ACTION_CLOSE_DOOR)
return true
end
end
Expand All @@ -60,8 +62,12 @@ function keyDoor.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.actionid == target.actionid then
if value.lockedDoor == target.itemid then
target:transform(value.openDoor)
item:getPosition():sendSingleSoundEffect(SOUND_EFFECT_TYPE_ACTION_OPEN_DOOR)
return true
elseif table.contains({ value.openDoor, value.closedDoor }, target.itemid) then
if value.openDoor == item.itemid then
item:getPosition():sendSingleSoundEffect(SOUND_EFFECT_TYPE_ACTION_CLOSE_DOOR)
end
target:transform(value.lockedDoor)
return true
end
Expand Down
1 change: 1 addition & 0 deletions data-otservbr-global/scripts/actions/door/level_door.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function levelDoor.onUse(player, item, fromPosition, target, toPosition, isHotke
if value.closedDoor == item.itemid then
if item.actionid > 0 and player:getLevel() >= item.actionid - 1000 then
item:transform(value.openDoor)
item:getPosition():sendSingleSoundEffect(SOUND_EFFECT_TYPE_ACTION_OPEN_DOOR)
player:teleportTo(toPosition, true)
return true
else
Expand Down
1 change: 1 addition & 0 deletions data-otservbr-global/scripts/actions/door/quest_door.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function questDoor.onUse(player, item, fromPosition, target, toPosition, isHotke
if value.closedDoor == item.itemid then
if item.actionid > 0 and player:getStorageValue(item.actionid) ~= -1 then
item:transform(value.openDoor)
item:getPosition():sendSingleSoundEffect(SOUND_EFFECT_TYPE_ACTION_OPEN_DOOR)
player:teleportTo(toPosition, true)
return true
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,13 @@ function closingDoor.onStepOut(creature, item, position, fromPosition)
for index, value in ipairs(LevelDoorTable) do
if value.openDoor == item.itemid then
item:transform(value.closedDoor)
item:getPosition():sendSingleSoundEffect(SOUND_EFFECT_TYPE_ACTION_CLOSE_DOOR)
end
end
for index, value in ipairs(QuestDoorTable) do
if value.openDoor == item.itemid then
item:transform(value.closedDoor)
item:getPosition():sendSingleSoundEffect(SOUND_EFFECT_TYPE_ACTION_CLOSE_DOOR)
end
end
return true
Expand Down