Skip to content

Commit

Permalink
Merge branch 'main' into pathfinder-multithread
Browse files Browse the repository at this point in the history
  • Loading branch information
mehah authored Oct 29, 2023
2 parents f12d4a4 + 178372b commit c367db8
Show file tree
Hide file tree
Showing 49 changed files with 459 additions and 98 deletions.
2 changes: 1 addition & 1 deletion config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ coreDirectory = "data"
-- Set log level
-- It can be trace, debug, info, warning, error, critical, off (default: info).
-- NOTE: Will only display logs with level higher or equal the one set.
logLevel = "debug"
logLevel = "info"

-- Combat settings
-- NOTE: valid values for worldType are: "pvp", "no-pvp" and "pvp-enforced"
Expand Down
1 change: 1 addition & 0 deletions data-otservbr-global/lib/core/storages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2768,6 +2768,7 @@ Storage = {
GoshnarMegalomaniaAccess = 47220,
GoshnarMegalomaniaKilled = 47222,
QuestReward = 47223,
OutfitReward = 47224,
},
},
U12_60 = { -- update 12.60 - Reserved Storages 47501 - 47600
Expand Down
4 changes: 0 additions & 4 deletions data-otservbr-global/monster/bosses/doctor_marrow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ monster.corpse = 18074
monster.speed = 180
monster.manaCost = 0

monster.events = {
"DoctorMarrowHealth",
}

monster.changeTarget = {
interval = 4000,
chance = 15,
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/monster/bosses/the_first_dragon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ monster.flags = {
}

monster.events = {
"First Dragon Death",
"FirstDragonDeath",
}

monster.light = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ monster.corpse = 35846
monster.speed = 115
monster.manaCost = 0

monster.events = {
"RatmiralBlackwhiskersDeath",
}

monster.changeTarget = {
interval = 4000,
chance = 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ monster.maxHealth = 500000
monster.race = "undead"
monster.corpse = 33889
monster.speed = 165
monster.manaCost = 0

monster.changeTarget = {
interval = 2000,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local mType = Game.createMonsterType("Training Machine")
local monster = {}
monster.description = "Training Machine"

monster.description = "a training machine"
monster.experience = 0
monster.outfit = {
lookType = 1142,
Expand Down
306 changes: 301 additions & 5 deletions data-otservbr-global/npc/imbuement_assistant.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ npcConfig.voices = {
{ text = "Hello adventurer, looking for Imbuement items? Just ask me!" },
}

local playerImbuementData = {}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)

Expand All @@ -55,15 +57,309 @@ end

npcType.onCloseChannel = function(npc, creature)
npcHandler:onCloseChannel(npc, creature)
playerImbuementData[creature:getId()] = nil
end

function addItemsToShoppingBag(npc, player)
local playerId = player:getId()
local playerData = playerImbuementData[playerId]

if playerData then
local moneyRequired = playerData.moneyRequired
local itemList = playerData.itemList
if player:getMoney() + player:getBankBalance() < moneyRequired then
npcHandler:say("Sorry, you don't have enough money", npc, player)
npcHandler:setTopic(player:getId(), 0)
return false, "You don't have enough money."
end

local totalWeight = 0
for _, item in pairs(itemList) do
local itemType = ItemType(item.itemId)
totalWeight = totalWeight + (itemType:getWeight() * item.count)
end

if player:getFreeCapacity() < totalWeight then
return false, "You don't have enough weight."
end

if player:getFreeBackpackSlots() == 0 then
return false, "You don't have enough room."
end

local shoppingBag = player:addItem(2856, 1) -- present box
for _, item in pairs(itemList) do
shoppingBag:addItem(item.itemId, item.count)
end

player:removeMoneyBank(moneyRequired)

return true
end

return false
end

-- Basic
local imbuementPackagesData = {
-- Skill increase packages
["bash"] = {
text = "skill club",
moneyRequired = 6250,
itemList = {
{ itemId = 9657, count = 20 },
{ itemId = 22189, count = 15 },
{ itemId = 10405, count = 10 },
},
},
["blockade"] = {
text = "skill shield",
moneyRequired = 16150,
itemList = {
{ itemId = 9641, count = 20 },
{ itemId = 11703, count = 25 },
{ itemId = 20199, count = 25 },
},
},
["chop"] = {
text = "skill axe",
moneyRequired = 13050,
itemList = {
{ itemId = 10196, count = 20 }, -- orc tooth
{ itemId = 11447, count = 25 }, -- battle stone
{ itemId = 21200, count = 20 }, -- moohtant horn
},
},
["epiphany"] = {
text = "magic level",
moneyRequired = 10650,
itemList = {
{ itemId = 9635, count = 25 }, -- elvish talisman
{ itemId = 11452, count = 15 }, -- broken shamanic staff
{ itemId = 10309, count = 15 }, -- strand of medusa hair
},
},
["precision"] = {
text = "skill distance",
moneyRequired = 6750,
itemList = {
{ itemId = 11464, count = 25 }, -- elven scouting glass
{ itemId = 18994, count = 20 }, -- elven hoof
{ itemId = 10298, count = 10 }, -- metal spike
},
},
["slash"] = {
text = "skill sword",
moneyRequired = 6550,
itemList = {
{ itemId = 9691, count = 25 }, -- lion's mane
{ itemId = 21202, count = 25 }, -- mooh'tah shell
{ itemId = 9654, count = 5 }, -- war crystal
},
},
-- Additional attributes packages
["featherweight"] = {
text = "capacity increase",
moneyRequired = 12250,
itemList = {
{ itemId = 25694, count = 20 }, -- fairy wings
{ itemId = 25702, count = 10 }, -- little bowl of myrrh
{ itemId = 20205, count = 5 }, -- goosebump leather
},
},
["strike"] = {
text = "critical",
moneyRequired = 16700,
itemList = {
{ itemId = 11444, count = 20 }, -- protective charm
{ itemId = 10311, count = 25 }, -- sabretooth
{ itemId = 22728, count = 5 }, -- vexclaw talon
},
},
["swiftness"] = {
text = "speed",
moneyRequired = 5225,
itemList = {
{ itemId = 17458, count = 15 }, -- damselfly wing
{ itemId = 10302, count = 25 }, -- compass
{ itemId = 14081, count = 20 }, -- waspoid wing
},
},
["vampirism"] = {
text = "life leech",
moneyRequired = 10475,
itemList = {
{ itemId = 9685, count = 25 }, -- vampire teeth
{ itemId = 9633, count = 15 }, -- bloody pincers
{ itemId = 9663, count = 5 }, -- piece of dead brain
},
},
["vibrancy"] = {
text = "paralysis removal",
moneyRequired = 15000,
itemList = {
{ itemId = 22053, count = 20 }, -- wereboar hooves
{ itemId = 23507, count = 15 }, -- crystallized anger
{ itemId = 28567, count = 5 }, -- quill
},
},
["void"] = {
text = "mana leech",
moneyRequired = 17400,
itemList = {
{ itemId = 11492, count = 25 }, -- rope belt
{ itemId = 20200, count = 25 }, -- silencer claws
{ itemId = 22730, count = 5 }, -- some grimeleech wings
},
},
-- Elemental damage packages
["electrify"] = {
text = "energy damage",
moneyRequired = 3770,
itemList = {
{ itemId = 18993, count = 25 }, -- rorc feather
{ itemId = 21975, count = 5 }, -- peacock feather fan
{ itemId = 23508, count = 1 }, -- energy vein
},
},
["frost"] = {
text = "ice damage",
moneyRequired = 9750,
itemList = {
{ itemId = 9661, count = 25 }, -- frosty heart
{ itemId = 21801, count = 10 }, -- seacrest hair
{ itemId = 9650, count = 5 }, -- polar bear paw
},
},
["reap"] = {
text = "death damage",
moneyRequired = 3475,
itemList = {
{ itemId = 11484, count = 25 }, -- pile of grave earth
{ itemId = 9647, count = 20 }, -- demonic skeletal hand
{ itemId = 10420, count = 5 }, -- petrified scream
},
},
["scorch"] = {
text = "fire damage",
moneyRequired = 15875,
itemList = {
{ itemId = 9636, count = 25 }, -- fiery heart
{ itemId = 5920, count = 5 }, -- green dragon scale
{ itemId = 5954, count = 5 }, -- demon horn
},
},
["venom"] = {
text = "earth damage",
moneyRequired = 1820,
itemList = {
{ itemId = 9686, count = 25 }, -- swamp grass
{ itemId = 9640, count = 20 }, -- poisonous slime
{ itemId = 21194, count = 2 }, -- slime heart
},
},
-- Elemental protection packages
["cloud fabric"] = {
text = "energy protection",
moneyRequired = 13775,
itemList = {
{ itemId = 9644, count = 20 }, -- wyvern talisman
{ itemId = 14079, count = 15 }, -- crawler head plating
{ itemId = 9665, count = 10 }, -- wyrm scale
},
},
["demon presence"] = {
text = "holy protection",
moneyRequired = 20250,
itemList = {
{ itemId = 9639, count = 25 }, -- cultish robe
{ itemId = 9638, count = 25 }, -- cultish mask
{ itemId = 10304, count = 20 }, -- hellspawn tail
},
},
["dragon hide"] = {
text = "fire protection",
moneyRequired = 10850,
itemList = {
{ itemId = 5877, count = 20 }, -- green dragon leather
{ itemId = 16131, count = 10 }, -- blazing bone
{ itemId = 11658, count = 5 }, -- draken sulphur
},
},
["lich shroud"] = {
text = "death protection",
moneyRequired = 5650,
itemList = {
{ itemId = 11466, count = 25 }, -- flask of embalming fluid
{ itemId = 22007, count = 20 }, -- gloom wolf fur
{ itemId = 9660, count = 5 }, -- mystical hourglass
},
},
["quara scale"] = {
text = "ice protection",
moneyRequired = 3650,
itemList = {
{ itemId = 10295, count = 25 }, -- winter wolf fur
{ itemId = 10307, count = 15 }, -- thick fur
{ itemId = 14012, count = 10 }, -- deepling warts
},
},
["snake skin"] = {
text = "earth protection",
moneyRequired = 12550,
itemList = {
{ itemId = 17823, count = 25 }, -- piece of swampling wood
{ itemId = 9694, count = 20 }, -- snake skin
{ itemId = 11702, count = 10 }, -- brimstone fangs
},
},
}

local function purchaseItems(npc, player, message)
local packageData = imbuementPackagesData[message]
if packageData and npcHandler:getTopic(player:getId()) == 1 then
npcHandler:say("Do you want to buy items for " .. packageData.text .. " imbuement for " .. packageData.moneyRequired .. " gold?", npc, player)
npcHandler:setTopic(player:getId(), 2)
playerImbuementData[player:getId()] = {
moneyRequired = packageData.moneyRequired,
itemList = packageData.itemList,
}
end
end

local function creatureSayCallback(npc, creature, type, message)
local player = Player(creature)
local playerId = player:getId()
if not npcHandler:checkInteraction(npc, creature) then
return false
end

local imbuementPackages = "Available imbuement packages: {bash}, {blockade}, {chop}, {epiphany}, {precision}, {slash}. additional attributes: {featherweight}, {strike}, {swiftness}, {vampirism}, {vibrancy}, {void}. elemental damage: {electrify}, {frost}, {reap}, {scorch}, {venom}. elemental protection: {cloud fabric}, {demon presence}, {dragon hide}, {lich shroud}, {quara scale}, {snake skin}."
if MsgContains(message, "imbuement packages") then
npcHandler:setTopic(playerId, 1)
npcHandler:say(imbuementPackages, npc, creature)
elseif imbuementPackagesData[message] then
purchaseItems(npc, player, message)
elseif MsgContains(message, "yes") and npcHandler:getTopic(playerId) == 2 then
local success, message = addItemsToShoppingBag(npc, player)
if not success then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
npcHandler:setTopic(playerId, 1)
npcHandler:say(imbuementPackages, npc, player)
return
end

playerImbuementData[playerId] = nil
npcHandler:say("You have successfully completed your purchase of the items.", npc, player)
npcHandler:setTopic(playerId, 1)
npcHandler:say(imbuementPackages, npc, creature)
end
end

keywordHandler:addKeyword({ "job" }, StdModule.say, { npcHandler = npcHandler, text = "Currently I have been working selling items for imbuement." })
npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|, say {imbuement packages} or {trade} for buy imbuement items.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "See you later |PLAYERNAME| come back soon.")
npcHandler:setMessage(MESSAGE_FAREWELL, "See you later |PLAYERNAME| come back soon.")

npcHandler:setMessage(MESSAGE_GREET, "Welcome to Imbuement's shop!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Good bye and come again.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye and come again.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true)

Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/npc/the_lootmonger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ npcConfig.description = internalNpcName

npcConfig.health = 100
npcConfig.maxHealth = npcConfig.health
npcConfig.walkInterval = 0
npcConfig.walkInterval = 2000
npcConfig.walkRadius = 2

npcConfig.outfit = {
Expand Down
Loading

0 comments on commit c367db8

Please sign in to comment.