Skip to content

Commit

Permalink
Merge branch 'update'
Browse files Browse the repository at this point in the history
  • Loading branch information
MillhioreBT committed May 16, 2023
2 parents 450848f + 7ff04be commit bb4370f
Show file tree
Hide file tree
Showing 337 changed files with 8,746 additions and 7,746 deletions.
4 changes: 4 additions & 0 deletions .lua-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
indent_width: 1
continuation_indent_width: 1
use_tab: true
tab_width: 4
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.16)

set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_BUILD_TYPE Release)

# Ensure to pick up the default triplet from the environment if any. This helps
# driving the vcpkg triplet in the same way either when starting vcpkg directly,
Expand Down
74 changes: 37 additions & 37 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
{
"version": 3,
"configurePresets": [
{
"name": "default",
"description": "Generate Ninja project files",
"binaryDir": "${sourceDir}/build"
},
{
"name": "vcpkg",
"inherits": [
"default"
],
"description": "Configure with vcpkg toolchain and generate Ninja project files",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
},
{
"name": "vcpkg",
"configurePreset": "vcpkg"
}
],
"testPresets": [
{
"name": "default",
"configurePreset": "default"
},
{
"name": "vcpkg",
"configurePreset": "vcpkg"
}
]
}
"version": 3,
"configurePresets": [
{
"name": "default",
"description": "Generate Ninja project files",
"binaryDir": "${sourceDir}/build"
},
{
"name": "vcpkg",
"inherits": [
"default"
],
"description": "Configure with vcpkg toolchain and generate Ninja project files",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
},
{
"name": "vcpkg",
"configurePreset": "vcpkg"
}
],
"testPresets": [
{
"name": "default",
"configurePreset": "default"
},
{
"name": "vcpkg",
"configurePreset": "vcpkg"
}
]
}
87 changes: 29 additions & 58 deletions data/actions/lib/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,39 @@ local groundIds = {354, 355} -- pick usable ground
local sandIds = {231, 9059} -- desert sand
local holeId = { -- usable rope holes, for rope spots see global.lua
294, 369, 370, 383, 392, 408, 409, 410, 427, 428, 429, 430, 462, 469, 470, 482,
484, 485, 489, 924, 1369, 3135, 3136, 4835, 4837, 7933, 7938, 8170, 8249, 8250,
8251, 8252, 8254, 8255, 8256, 8276, 8277, 8279, 8281, 8284, 8285, 8286, 8323,
8567, 8585, 8595, 8596, 8972, 9606, 9625
484, 485, 489, 924, 1369, 3135, 3136, 4835, 4837, 7933, 7938, 8170, 8249, 8250,
8251, 8252, 8254, 8255, 8256, 8276, 8277, 8279, 8281, 8284, 8285, 8286, 8323,
8567, 8585, 8595, 8596, 8972, 9606, 9625
}
local holes = {468, 481, 483, 7932} -- holes opened by shovel
local fruits = {2673, 2674, 2675, 2676, 2677, 2678, 2679, 2680, 2681, 2682, 2684, 2685, 5097, 8839, 8840, 8841} -- fruits to make decorated cake with knife
local fruits = {
2673, 2674, 2675, 2676, 2677, 2678, 2679, 2680, 2681, 2682, 2684, 2685, 5097,
8839, 8840, 8841
} -- fruits to make decorated cake with knife

function destroyItem(player, target, toPosition)
if type(target) ~= "userdata" or not target:isItem() then
return false
end
if type(target) ~= "userdata" or not target:isItem() then return false end

if target:hasAttribute(ITEM_ATTRIBUTE_UNIQUEID) or target:hasAttribute(ITEM_ATTRIBUTE_ACTIONID) then
return false
end
if target:hasAttribute(ITEM_ATTRIBUTE_UNIQUEID) or
target:hasAttribute(ITEM_ATTRIBUTE_ACTIONID) then return false end

if toPosition.x == CONTAINER_POSITION then
player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
return true
end

local destroyId = ItemType(target.itemid):getDestroyId()
if destroyId == 0 then
return false
end
if destroyId == 0 then return false end

if math.random(7) == 1 then
local item = Game.createItem(destroyId, 1, toPosition)
if item then
item:decay()
end
if item then item:decay() end

-- Move items outside the container
if target:isContainer() then
for i = target:getSize() - 1, 0, -1 do
local containerItem = target:getItem(i)
if containerItem then
containerItem:moveTo(toPosition)
end
if containerItem then containerItem:moveTo(toPosition) end
end
end

Expand All @@ -58,9 +52,7 @@ end

function onUseMachete(player, item, fromPosition, target, toPosition, isHotkey)
local targetId = target.itemid
if not targetId then
return true
end
if not targetId then return true end

if table.contains(wildGrowth, targetId) then
toPosition:sendMagicEffect(CONST_ME_POFF)
Expand Down Expand Up @@ -98,16 +90,13 @@ function onUsePick(player, item, fromPosition, target, toPosition, isHotkey)
end

local tile = Tile(toPosition)
if not tile then
return false
end
if not tile then return false end

local ground = tile:getGround()
if not ground then
return false
end
if not ground then return false end

if table.contains(groundIds, ground.itemid) and ground.actionid == actionIds.pickHole then
if table.contains(groundIds, ground.itemid) and ground.actionid ==
actionIds.pickHole then
ground:transform(392)
ground:decay()
toPosition:sendMagicEffect(CONST_ME_POFF)
Expand All @@ -130,17 +119,13 @@ end

function onUseRope(player, item, fromPosition, target, toPosition, isHotkey)
local tile = Tile(toPosition)
if not tile then
return false
end
if not tile then return false end

local ground = tile:getGround()

if ground and table.contains(ropeSpots, ground:getId()) then
tile = Tile(toPosition:moveUpstairs())
if not tile then
return false
end
if not tile then return false end

if tile:hasFlag(TILESTATE_PROTECTIONZONE) and player:isPzLocked() then
player:sendCancelMessage(RETURNVALUE_PLAYERISPZLOCKED)
Expand All @@ -154,14 +139,10 @@ function onUseRope(player, item, fromPosition, target, toPosition, isHotkey)
if table.contains(holeId, target.itemid) then
toPosition.z = toPosition.z + 1
tile = Tile(toPosition)
if not tile then
return false
end
if not tile then return false end

local thing = tile:getTopVisibleThing()
if not thing then
return true
end
if not thing then return true end

if thing:isPlayer() then
if Tile(toPosition:moveUpstairs()):queryAdd(thing) ~= RETURNVALUE_NOERROR then
Expand All @@ -181,20 +162,15 @@ end

function onUseShovel(player, item, fromPosition, target, toPosition, isHotkey)
local tile = Tile(toPosition)
if not tile then
return false
end
if not tile then return false end

local ground = tile:getGround()
if not ground then
return false
end
if not ground then return false end

local groundId = ground:getId()
if table.contains(holes, groundId) then
ground:transform(groundId + 1)
ground:decay()

toPosition.z = toPosition.z + 1
tile:relocateTo(toPosition)
player:addAchievementProgress("The Undertaker", 500)
Expand Down Expand Up @@ -222,9 +198,7 @@ function onUseShovel(player, item, fromPosition, target, toPosition, isHotkey)
end

function onUseScythe(player, item, fromPosition, target, toPosition, isHotkey)
if not table.contains({2550, 10513}, item.itemid) then
return false
end
if not table.contains({2550, 10513}, item.itemid) then return false end

if target.itemid == 2739 then -- wheat
target:transform(2737)
Expand All @@ -244,17 +218,14 @@ function onUseScythe(player, item, fromPosition, target, toPosition, isHotkey)
end

function onUseCrowbar(player, item, fromPosition, target, toPosition, isHotkey)
if not table.contains({2416, 10515}, item.itemid) then
return false
end
if not table.contains({2416, 10515}, item.itemid) then return false end

return destroyItem(player, target, toPosition)
end

function onUseKitchenKnife(player, item, fromPosition, target, toPosition, isHotkey)
if not table.contains({2566, 10511, 10515}, item.itemid) then
return false
end
function onUseKitchenKnife(player, item, fromPosition, target, toPosition,
isHotkey)
if not table.contains({2566, 10511, 10515}, item.itemid) then return false end

if table.contains(fruits, target.itemid) and player:removeItem(6278, 1) then
target:remove(1)
Expand Down
9 changes: 4 additions & 5 deletions data/actions/scripts/other/bed_modification_kits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local beds = {
[7904] = {{7811, 7812}, {7813, 7814}}, -- green kit
[7905] = {{7819, 7820}, {7821, 7822}}, -- yellow kit
[7906] = {{7815, 7816}, {7817, 7818}}, -- red kit
[7907] = {{1754, 1755}, {1760, 1761}}, -- removal kit
[7907] = {{1754, 1755}, {1760, 1761}} -- removal kit
}

local function internalBedTransform(item, targetItem, toPosition, itemArray)
Expand All @@ -22,13 +22,12 @@ function onUse(player, item, fromPosition, target, toPosition, isHotkey)
end

local tile = Tile(toPosition)
if not tile or not tile:getHouse() then
return false
end
if not tile or not tile:getHouse() then return false end

local targetItemId = target:getId()
if targetItemId == newBed[1][1] or targetItemId == newBed[2][1] then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You already have this bed modification.")
player:sendTextMessage(MESSAGE_STATUS_SMALL,
"You already have this bed modification.")
return true
end

Expand Down
73 changes: 57 additions & 16 deletions data/actions/scripts/other/construction_kits.lua
Original file line number Diff line number Diff line change
@@ -1,33 +1,74 @@
local constructionKits = {
[3901] = 1666, [3902] = 1670, [3903] = 1652, [3904] = 1674, [3905] = 1658,
[3906] = 3813, [3907] = 3817, [3908] = 1619, [3909] = 12799, [3910] = 2105,
[3911] = 1614, [3912] = 3806, [3913] = 3807, [3914] = 3809, [3915] = 1716,
[3916] = 1724, [3917] = 1732, [3918] = 1775, [3919] = 1774, [3920] = 1750,
[3921] = 3832, [3922] = 2095, [3923] = 2098, [3924] = 2064, [3925] = 2582,
[3926] = 2117, [3927] = 1728, [3928] = 1442, [3929] = 1446, [3930] = 1447,
[3931] = 2034, [3932] = 2604, [3933] = 2080, [3934] = 2084, [3935] = 3821,
[3936] = 3811, [3937] = 2101, [3938] = 3812, [5086] = 5046, [5087] = 5055,
[5088] = 5056, [6114] = 6111, [6115] = 6109, [6372] = 6356, [6373] = 6371,
[8692] = 8688, [9974] = 9975, [11126] = 11127, [11133] = 11129, [11124] = 11125,
[3901] = 1666,
[3902] = 1670,
[3903] = 1652,
[3904] = 1674,
[3905] = 1658,
[3906] = 3813,
[3907] = 3817,
[3908] = 1619,
[3909] = 12799,
[3910] = 2105,
[3911] = 1614,
[3912] = 3806,
[3913] = 3807,
[3914] = 3809,
[3915] = 1716,
[3916] = 1724,
[3917] = 1732,
[3918] = 1775,
[3919] = 1774,
[3920] = 1750,
[3921] = 3832,
[3922] = 2095,
[3923] = 2098,
[3924] = 2064,
[3925] = 2582,
[3926] = 2117,
[3927] = 1728,
[3928] = 1442,
[3929] = 1446,
[3930] = 1447,
[3931] = 2034,
[3932] = 2604,
[3933] = 2080,
[3934] = 2084,
[3935] = 3821,
[3936] = 3811,
[3937] = 2101,
[3938] = 3812,
[5086] = 5046,
[5087] = 5055,
[5088] = 5056,
[6114] = 6111,
[6115] = 6109,
[6372] = 6356,
[6373] = 6371,
[8692] = 8688,
[9974] = 9975,
[11126] = 11127,
[11133] = 11129,
[11124] = 11125,
[11205] = 11203
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local kit = constructionKits[item.itemid]
if not kit then
return false
end
if not kit then return false end

local tile = Tile(item:getPosition())
if tile and tile:getHouse() then
if fromPosition.x ~= CONTAINER_POSITION or item:getParent():getId() == ITEM_BROWSEFIELD then
if fromPosition.x ~= CONTAINER_POSITION or item:getParent():getId() ==
ITEM_BROWSEFIELD then
item:transform(kit)
fromPosition:sendMagicEffect(CONST_ME_POFF)
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, "Put the construction kit on the floor first.")
player:sendTextMessage(MESSAGE_STATUS_SMALL,
"Put the construction kit on the floor first.")
end
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You may construct this only inside a house.")
player:sendTextMessage(MESSAGE_STATUS_SMALL,
"You may construct this only inside a house.")
end
return true
end
Loading

0 comments on commit bb4370f

Please sign in to comment.