Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
Feat: adding custom map (containing training room and npcs shop) (#1299)
Browse files Browse the repository at this point in the history
* Feat: adding custom maps

* Fixed Mazarius position

* Add missing npc Zurak

Custom area (event room) added, with trainers, npcs shop and respective loading scripts
Npc/map/attribute loading functions have been moved to 051-functions
Removed npcs shop area from global map and moved to custom map
Custom area npcs are created by entering the teleport that leads to the event room (located in thais temple)

For disable the custom map, is only set in "data/lib/tables/additional_map.lua" to "enabled = false"

All map attribute loading scripts (be it npc/action/unique/item/map) have been moved to startup.lua
The custom map is in the folder world/custom/otservbr-custom.otbm
The custom scripts in the folder data/scripts/custom (without type separation, action/movement/monster etc)
  • Loading branch information
dudantas authored Jun 7, 2020
1 parent 4661158 commit 81826f1
Show file tree
Hide file tree
Showing 17 changed files with 608 additions and 185 deletions.
24 changes: 9 additions & 15 deletions data/globalevents/scripts/others/startup.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
local additionalMap = {
{ description = "map description", file = "data/world/worldchanges/example.otbm", enabled = false}
}

local startupGlobalStorages = {
GlobalStorage.TheAncientTombs.AshmunrahSwitchesGlobalStorage,
GlobalStorage.TheAncientTombs.DiprathSwitchesGlobalStorage,
Expand Down Expand Up @@ -35,19 +31,17 @@ local startupGlobalStorages = {
}

function onStartup()
print(">> Loading additional maps")
for index, value in ipairs(AdditionalMap) do
if value.enabled then
Game.loadMap(value.file)
print("> Loaded " .. (#AdditionalMap) .. " additional map.")
end
end
loadCustomMaps()
print("> Loaded " .. (#CustomMapTable) .. " custom map.")

print(string.format(">> Loaded ".. (#NpcTable) .." npcs and spawned %d monsters.\n>> \z
loadLuaNpcs()
print(string.format("> Loaded ".. (#NpcTable) .." npcs and spawned %d monsters.\n> \z
Loaded %d towns with %d houses in total.", Game.getMonsterCount(), #Game.getTowns(), #Game.getHouses()))
print(">> Loaded " .. (#SignTable) .. " signs in the map.")
print(">> Loaded " .. (#BookTable) .. " books in the map.")
print(">> Loaded action and unique per Lua")

loadLuaMapAttributes()
print("> Loaded " .. (#SignTable) .. " signs in the map.")
print("> Loaded " .. (#BookTable) .. " books in the map.")
print("> Loaded action and unique per Lua")

for i = 1, #startupGlobalStorages do
Game.setStorageValue(startupGlobalStorages[i], 0)
Expand Down
2 changes: 2 additions & 0 deletions data/lib/core/storages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,8 @@ Storage = {
Factions = 50723,
blockMovementStorage = 100000,
PetSummon = 60045,
TrainerRoom = 60046,
NpcSpawn = 60047,
isTraining = 37
}

Expand Down
122 changes: 122 additions & 0 deletions data/lib/miscellaneous/050-functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -500,3 +500,125 @@ function checkWeightAndBackpackRoom(player, itemWeight, message)
end
return true
end

function loadLuaMapAttributes()
print(">> Loading map attributes.")
-- It load actions
for index, value in pairs(ActionTable) do
for i = 1, #value.itemPos do
local tile = Tile(value.itemPos[i])
local item
-- Checks if the position is valid
if tile then
-- Checks that you have no items created
if tile:getItemCountById(value.itemId) == 0 then
-- If not have items created, this create the item
item = Game.createItem(value.itemId, 1, value.itemPos[i])
end
if not item then
item = tile:getItemById(value.itemId)
end
-- If he found the item, add the action id.
if item and value.actionId then
item:setActionId(value.actionId)
end
if value.itemId == false and tile:getTopDownItem() then
tile:getTopDownItem():setActionId(value.actionId)
end
if value.itemId == false and tile:getTopTopItem() then
tile:getTopTopItem():setActionId(value.actionId)
end
-- This function add one action id on an item inside the container
-- It was developed to add action on daily respawn item
if item and value.isDailyAIDContainerItem then
itemAttr = item:addItem(value.containerItem, 1)
itemAttr:setActionId(value.actionId)
end
end
end
end
-- It load uniques
for key, value in pairs(UniqueTable) do
local tile = Tile(value.itemPos)
local item
-- Checks if the position is valid
if tile then
-- Checks that you have no items created
if tile:getItemCountById(value.itemId) == 0 then
-- If not have items created, thisc create the item
item = Game.createItem(value.itemId, 1, value.itemPos)
end
if not item then
item = tile:getItemById(value.itemId)
end
-- If he found the item, add the unique id
if item then
item:setAttribute(ITEM_ATTRIBUTE_UNIQUEID, key)
end
end
end
-- It load signs on map table
for key, value in pairs(SignTable) do
local tile = Tile(value.itemPos)
local item
-- Checks if the position is valid
if tile then
-- Checks that you have no items created
if tile:getItemCountById(value.itemId) == 0 then
-- Create item
item = Game.createItem(value.itemId, 1, value.itemPos)
end
if not item then
item = tile:getItemById(value.itemId)
end
-- If he found the item, add the text
if item then
item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, value.text)
end
end
end
-- It load book on map table
for key, value in pairs(BookTable) do
local tile = Tile(value.itemPos)
local item
-- Checks if the position is valid
if tile then
-- Checks that you have no items created
if tile:getItemCountById(value.itemId) == 0 then
-- Create item
item = Game.createItem(value.itemId, 1, value.itemPos)
end
if not item then
item = tile:getItemById(value.itemId)
end
-- If he found the item, add the text
if item then
item:setAttribute(ITEM_ATTRIBUTE_TEXT, value.text)
end
end
end
end

function loadLuaNpcs()
print(">> Loading NPC's, monsters and houses.")
for i = 1,#NpcTable do
local npc = NpcTable[i]
if npc and npc.name and npc.position then
local spawn = Game.createNpc(npc.name, npc.position)
if spawn then
spawn:setMasterPos(npc.position)
end
end
end
end

function loadCustomMaps()
print(">> Loading custom maps.")
for index, value in ipairs(CustomMapTable) do
if value.enabled then
-- It's load the map
Game.loadMap(value.file)
Game.setStorageValue(Storage.NpcSpawn, -1)
end
end
end
12 changes: 11 additions & 1 deletion data/lib/tables/action_unique.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1085,10 +1085,20 @@ UniqueTable = {
},
[25030] = {
itemId = 3706,
itemPos = Position(33277, 31754, 7),
itemPos = {x = 33277, y = 31754, z = 7},
storage = Storage.TibiaTales.JackFutureQuest.Statue,
value = 1,
setStorage = Storage.TibiaTales.JackFutureQuest.QuestLine,
addItem = 11343
},
-- Custom trainer entrance
[25031] = {
itemId = 8058,
itemPos = {x = 1116, y = 1092, z = 7}
},
-- Custom npcs create
[25032] = {
itemId = false,
itemPos = {x = 32373, y = 32236, z = 7}
}
}
4 changes: 2 additions & 2 deletions data/lib/tables/additional_map.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
AdditionalMap = {
[1] = {file = "data/world/additional/example.otbm", enabled = false}
CustomMapTable = {
[1] = {file = "data/world/custom/otservbr-custom.otbm", enabled = true}
}
79 changes: 50 additions & 29 deletions data/lib/tables/npc_spawn_list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ NpcTable = {
[115] = {name = "ormuhn", position = {x = 33159, y = 32810, z = 5}},
[116] = {name = "mehkesh", position = {x = 33130, y = 32811, z = 5}},
[117] = {name = "fenech", position = {x = 33131, y = 32820, z = 5}},
[118] = {name = "tamoril", position = {x = 31908, y = 33100, z = 5}},
[118] = {name = "tamed_lion", position = {x = 33874, y = 31487, z = 4}},
[119] = {name = "tereban", position = {x = 10191, y = 10085, z = 6}},
[120] = {name = "frosty", position = {x = 33888, y = 31016, z = 6}},
[121] = {name = "siflind", position = {x = 32360, y = 31030, z = 6}},
Expand Down Expand Up @@ -281,12 +281,12 @@ NpcTable = {
[280] = {name = "jack_fate", position = {x = 32286, y = 32891, z = 6}},
[281] = {name = "guide_davina", position = {x = 32275, y = 32894, z = 6}},
[282] = {name = "captain_max", position = {x = 32298, y = 32895, z = 6}},
[283] = {name = "hanna", position = {x = 31885, y = 33060, z = 6}},
[284] = {name = "yasir", position = {x = 31867, y = 33068, z = 6}},
[285] = {name = "lailene", position = {x = 31896, y = 33077, z = 6}},
[286] = {name = "alexander", position = {x = 31862, y = 33084, z = 6}},
[287] = {name = "esrik", position = {x = 31890, y = 33099, z = 6}},
[288] = {name = "rock_in_a_hard_place", position = {x = 31860, y = 33105, z = 6}},
[283] = {name = "saideh", position = {x = 33844, y = 31638, z = 7}},
[284] = {name = "tarun", position = {x = 32976, y = 32715, z = 7}},
[285] = {name = "nomadnpc", position = {x = 31941, y = 31305, z = 6}},
[286] = {name = "kais", position = {x = 32910, y = 32512, z = 8}},
[287] = {name = "pythius_the_rottennpc", position = {x = 32590,y = 31407,z = 15}},
[288] = {name = "iwar", position = {x = 32618,y = 31917,z = 8}},
[289] = {name = "sane_mage", position = {x = 10320, y = 10089, z = 7}},
[290] = {name = "asima", position = {x = 12067, y = 12012, z = 7}},
[291] = {name = "mugluf", position = {x = 12067, y = 12025, z = 7}},
Expand Down Expand Up @@ -344,7 +344,7 @@ NpcTable = {
[343] = {name = "buddel_tyrsung", position = {x = 32332, y = 31227, z = 7}},
[344] = {name = "oliver", position = {x = 32894, y = 31228, z = 7}},
[345] = {name = "zurak", position = {x = 33154, y = 31230, z = 7}},
[346] = {name = "orc_berserker_npc", position = {x = 32777, y = 31237, z = 7}},
[346] = {name = "zurak", position = {x = 33158, y = 31225, z = 7}},
[347] = {name = "dorbin", position = {x = 32783, y = 31236, z = 7}},
[348] = {name = "oiriz", position = {x = 32787, y = 31238, z = 7}},
[349] = {name = "a_grumpy_cyclops", position = {x = 32822, y = 31238, z = 7}},
Expand Down Expand Up @@ -665,13 +665,13 @@ NpcTable = {
[664] = {name = "jason", position = {x = 32157, y = 32939, z = 7}},
[665] = {name = "danlon", position = {x = 32190, y = 32949, z = 7}},
[666] = {name = "meraya", position = {x = 32194, y = 32974, z = 7}},
[667] = {name = "alesar", position = {x = 31856, y = 33056, z = 7}},
[668] = {name = "yaman", position = {x = 31887, y = 33058, z = 7}},
[669] = {name = "nah_bob", position = {x = 31860, y = 33085, z = 7}},
[670] = {name = "guide_kroak", position = {x = 31882, y = 33084, z = 7}},
[671] = {name = "rashid", position = {x = 31887, y = 33101, z = 7}},
[672] = {name = "haroun", position = {x = 31859, y = 33105, z = 7}},
[673] = {name = "mazarius", position = {x = 12124, y = 11999, z = 8}},
[667] = {name = "tanyt", position = {x = 33957, y = 31513, z = 0}},
[668] = {name = "the_empress", position = {x = 33868, y = 31497, z = 3}},
[669] = {name = "the_librarian", position = {x = 33873, y = 31494, z = 5}},
[670] = {name = "yonan", position = {x = 33922, y = 31513, z = 7}},
[671] = {name = "shimun", position = {x = 33758, y = 31494, z = 7}},
[672] = {name = "tefrit", position = {x = 33839, y = 31693, z = 5}},
[673] = {name = "noozer", position = {x = 32502, y = 32338, z = 8}},
[674] = {name = "rebel", position = {x = 33198, y = 31060, z = 8}},
[675] = {name = "lizard_tunnel_guard", position = {x = 33385, y = 31068, z = 8}},
[676] = {name = "lizard_tunnel_guard", position = {x = 33387, y = 31076, z = 8}},
Expand Down Expand Up @@ -725,7 +725,7 @@ NpcTable = {
[724] = {name = "victor", position = {x = 32255, y = 32216, z = 8}},
[725] = {name = "henricus", position = {x = 32316, y = 32267, z = 8}},
[726] = {name = "partos", position = {x = 32323, y = 32280, z = 8}},
[727] = {name = "noozer", position = {x = 32502, y = 32338, z = 8}},
[727] = {name = "mazarius", position = {x = 33277, y = 32390, z = 8}},
[728] = {name = "mazarius", position = {x = 33277, y = 32390, z = 8}},
[729] = {name = "jamesfrancis", position = {x = 31939, y = 32502, z = 8}},
[730] = {name = "gnommander", position = {x = 32248, y = 32604, z = 8}},
Expand Down Expand Up @@ -951,17 +951,38 @@ NpcTable = {
[950] = {name = "ninev", position = {x = 33871, y = 31528, z = 7}},
[951] = {name = "ninos", position = {x = 33904, y = 31498, z = 7}},
[952] = {name = "ramina", position = {x = 33903, y = 31495, z = 7}},
[953] = {name = "tamed_lion", position = {x = 33874, y = 31487, z = 4}},
[954] = {name = "tanyt", position = {x = 33957, y = 31513, z = 0}},
[955] = {name = "the_empress", position = {x = 33868, y = 31497, z = 3}},
[956] = {name = "the_librarian", position = {x = 33873, y = 31494, z = 5}},
[957] = {name = "yonan", position = {x = 33922, y = 31513, z = 7}},
[958] = {name = "shimun", position = {x = 33758, y = 31494, z = 7}},
[959] = {name = "tefrit", position = {x = 33839, y = 31693, z = 5}},
[960] = {name = "saideh", position = {x = 33844, y = 31638, z = 7}},
[961] = {name = "tarun", position = {x = 32976, y = 32715, z = 7}},
[962] = {name = "nomadnpc", position = {x = 31941, y = 31305, z = 6}},
[963] = {name = "kais", position = {x = 32910, y = 32512, z = 8}},
[964] = {name = "pythius_the_rottennpc", position = {x = 32590,y = 31407,z = 15}},
[965] = {name = "iwar", position = {x = 32618,y = 31917,z = 8}}
[953] = {name = "orc_berserker_npc", position = {x = 32777, y = 31237, z = 7}}
}

CustomNpcTable = {
--Custom map (event room)
--Trade island
[1] = {name = "alesar", position = {x = 953, y = 948, z = 7}},
[2] = {name = "yaman", position = {x = 983, y = 951, z = 7}},
[3] = {name = "nah_bob", position = {x = 956, y = 977, z = 7}},
[4] = {name = "guide_kroak", position = {x = 976, y = 977, z = 7}},
[5] = {name = "rashid", position = {x = 984, y = 994, z = 7}},
[6] = {name = "haroun", position = {x = 956, y = 998, z = 7}},
[7] = {name = "hanna", position = {x = 983, y = 951, z = 6}},
[8] = {name = "yasir", position = {x = 963, y = 959, z = 6}},
[9] = {name = "lailene", position = {x = 991, y = 969, z = 6}},
[10] = {name = "alexander", position = {x = 957, y = 976, z = 6}},
[11] = {name = "esrik", position = {x = 985, y = 991, z = 6}},
[12] = {name = "rock_in_a_hard_place", position = {x = 956, y = 997, z = 6}},
[13] = {name = "tamoril", position = {x = 1002, y = 992, z = 5}},
--NPC beach
[14] = {name = "zuma_magehide", position = {x = 1058, y = 1020, z = 7}},
[15] = {name = "runtel_blackspark", position = {x = 1067, y = 1020, z = 7}},
[16] = {name = "rock_in_a_hard_place", position = {x = 993, y = 1034, z = 7}},
[17] = {name = "archery", position = {x = 990, y = 1027, z = 7}},
[18] = {name = "hanna", position = {x = 1003, y = 1019, z = 7}},
[19] = {name = "yasir", position = {x = 984, y = 1029, z = 6}},
[20] = {name = "haroun", position = {x = 988, y = 1024, z = 6}},
[21] = {name = "alesar", position = {x = 996, y = 1024, z = 6}},
[22] = {name = "esrik", position = {x = 1000, y = 1026, z = 6}},
[23] = {name = "yaman", position = {x = 1004, y = 1031, z = 6}},
[24] = {name = "rashid", position = {x = 998, y = 1036, z = 6}},
[25] = {name = "nah_bob", position = {x = 992, y = 1036, z = 6}},
[26] = {name = "cassino", position = {x = 32354, y = 32226, z = 7}},
[27] = {name = "tamoril", position = {x = 1013, y = 1024, z = 5}}
}
5 changes: 5 additions & 0 deletions data/npc/cassino.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Cassino" script="custom/cassino.lua" walkinterval="2000" speed="0">
<health now="100" max="100" />
<look type="331" />
</npc>
Loading

0 comments on commit 81826f1

Please sign in to comment.