Skip to content

Commit

Permalink
fix: scripts and achievements (#2301)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonyrewind <[email protected]>
  • Loading branch information
elsongabriel and Jonyrewind committed Feb 22, 2024
1 parent f49226c commit 7d90b9a
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 74 deletions.
23 changes: 0 additions & 23 deletions data-canary/scripts/actions/tools/toolgear.lua

This file was deleted.

3 changes: 3 additions & 0 deletions data-otservbr-global/lib/core/storages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2105,6 +2105,9 @@ Storage = {
JumpTimer = 41841,
},
VampireHunter = {},
TheMutatedPumpkin = {
Skinned = 41860,
},
},
U8_4 = { -- update 8.4 - Reserved Storages 41901 - 42145
BloodBrothers = {
Expand Down
4 changes: 4 additions & 0 deletions data-otservbr-global/scripts/actions/other/fishing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,20 @@ function fishing.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local rareChance = math.random(100)
if rareChance == 1 then
player:addItem(7158, 1)
player:addAchievementProgress("Exquisite Taste", 250)
return true
elseif rareChance <= 4 then
player:addItem(3580, 1)
player:addAchievementProgress("Exquisite Taste", 250)
return true
elseif rareChance <= 10 then
player:addItem(7159, 1)
player:addAchievementProgress("Exquisite Taste", 250)
return true
end
end
player:addItem(3578, 1)
player:addAchievementProgress("Here, Fishy Fishy!", 250)
end
return true
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function cultsOfTibiaLevers.onUse(player, item, fromPosition, itemEx, toPosition
Game.createMonster("Wine Cask", Position(33162, 31945, 15))
local leiden = Game.createMonster("Leiden", Position(33162, 31950, 15))
leiden:setHealth(leiden:getHealth() / 2)
kickerPlayerRoomAfferMin(convertTable, frompos, topos, Position(33121, 31951, 15), "You were kicked for exceeding the time limit within the boss room.", "", 60, true, ittable, blockmonsters)
kickerPlayerRoomAfterMin(convertTable, frompos, topos, Position(33121, 31951, 15), "You were kicked for exceeding the time limit within the boss room.", "", 60, true, ittable, blockmonsters)
end
end
if item:getActionId() == 5502 and item:getId() == 8912 then -- The False God
Expand Down Expand Up @@ -241,7 +241,7 @@ function cultsOfTibiaLevers.onUse(player, item, fromPosition, itemEx, toPosition
addEvent(transformMonster, 13 * 15000, 3, 3, "Sphere Of Wrath", {}, {}, 0)
Game.createMonster("The False God", Position(33159, 31914, 15))
-- funçao
kickerPlayerRoomAfferMin(convertTable, frompos, topos, Position(33181, 31894, 15), "You were kicked for exceeding the time limit within the boss room.", "", 60, true, ittable, blockmonsters)
kickerPlayerRoomAfterMin(convertTable, frompos, topos, Position(33181, 31894, 15), "You were kicked for exceeding the time limit within the boss room.", "", 60, true, ittable, blockmonsters)
end
end

Expand Down Expand Up @@ -285,7 +285,7 @@ function cultsOfTibiaLevers.onUse(player, item, fromPosition, itemEx, toPosition
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
end
end
kickerPlayerRoomAfferMin(convertTable, frompos, topos, Position(33091, 31963, 15), "You were kicked for exceeding the time limit within the boss room.", "", 60, true, ittable, blockmonsters)
kickerPlayerRoomAfterMin(convertTable, frompos, topos, Position(33091, 31963, 15), "You were kicked for exceeding the time limit within the boss room.", "", 60, true, ittable, blockmonsters)
Game.createMonster("Pillar of Summoning", Position(33093, 31919, 15))
Game.createMonster("Pillar of Death", Position(33098, 31915, 15))
Game.createMonster("Pillar of Protection", Position(33103, 31919, 15))
Expand Down Expand Up @@ -339,7 +339,7 @@ function cultsOfTibiaLevers.onUse(player, item, fromPosition, itemEx, toPosition
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
end
end
kickerPlayerRoomAfferMin(convertTable, frompos, topos, Position(33109, 31887, 15), "You were kicked for exceeding the time limit within the boss room.", "", 60, true, ittable, blockmonsters)
kickerPlayerRoomAfterMin(convertTable, frompos, topos, Position(33109, 31887, 15), "You were kicked for exceeding the time limit within the boss room.", "", 60, true, ittable, blockmonsters)
Game.createMonster("The Sinister Hermit Dirty", Position(33131, 31925, 15))
ativarGeyser()
end
Expand Down Expand Up @@ -429,7 +429,7 @@ function cultsOfTibiaLevers.onUse(player, item, fromPosition, itemEx, toPosition

Game.createMonster("Containment Machine", Position(33133, 31864, 15)):registerEvent("MachineDeath")
Game.createMonster("The Armored Voidborn", Position(33135, 31859, 15)):registerEvent("MachineDeath")
kickerPlayerRoomAfferMin(convertTable, frompos, topos, Position(33179, 31840, 15), "You were kicked for exceeding the time limit within the boss room.", "", 60, true, ittable, blockmonsters)
kickerPlayerRoomAfterMin(convertTable, frompos, topos, Position(33179, 31840, 15), "You were kicked for exceeding the time limit within the boss room.", "", 60, true, ittable, blockmonsters)
end
end
if item:getActionId() == 5505 then -- Boss da areia
Expand Down Expand Up @@ -485,7 +485,7 @@ function cultsOfTibiaLevers.onUse(player, item, fromPosition, itemEx, toPosition

Game.createMonster("the sandking fake", Position(33099, 31858, 15)):registerEvent("SandkingThink")
Game.setStorageValue("sandking", 1)
kickerPlayerRoomAfferMin(convertTable, frompos, topos, Position(33459, 32269, 10), "You were kicked for exceeding the time limit within the boss room.", "", 60, true, ittable, blockmonsters)
kickerPlayerRoomAfterMin(convertTable, frompos, topos, Position(33459, 32269, 10), "You were kicked for exceeding the time limit within the boss room.", "", 60, true, ittable, blockmonsters)
end
end

Expand Down Expand Up @@ -531,7 +531,7 @@ function cultsOfTibiaLevers.onUse(player, item, fromPosition, itemEx, toPosition
spawnDarkSoul(1, 30)
spawnDarkSoul(2, 30)
spawnStolenSoul(30)
kickerPlayerRoomAfferMin(convertTable, frompos, topos, Position(33072, 31867, 15), "You were kicked for exceeding the time limit within the boss room.", "", 60, true, ittable, blockmonsters)
kickerPlayerRoomAfterMin(convertTable, frompos, topos, Position(33072, 31867, 15), "You were kicked for exceeding the time limit within the boss room.", "", 60, true, ittable, blockmonsters)
end
end
return true
Expand Down
87 changes: 73 additions & 14 deletions data-otservbr-global/scripts/actions/tools/skinning.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---- if you want protected corpses (10 second protection after monster being killed) to be skinned/dusted, delete '--#' in the appropriate lines; be careful, it may cause abuses ----
local CREATURE_SKINNING_CHANCE = 25000 -- 25% probability
local config = {
[5908] = {
Expand Down Expand Up @@ -70,10 +69,28 @@ local config = {
[22742] = { value = CREATURE_SKINNING_CHANCE, newItem = 22186, after = 22744 }, -- after being killed

-- The Mutated Pumpkin
[12816] = { { value = 5000, newItem = 123 }, { value = 10000, newItem = 653 }, { value = 20000, 6491 }, { value = 26764, newItem = 8032 }, { value = 45000, newItem = 3594 }, { value = 60000, newItem = 2977 }, { value = 90000, newItem = 8177, amount = 50 } },
[12816] = {
{ value = 5000, newItem = 8032 }, -- spiderwebs
{ value = 5000, newItem = 8178 }, -- toy spider
{ value = 5000, newItem = 6491 }, -- bat decoration
{ value = 20000, newItem = 6525 }, -- skeleton decoration
{ value = 90000, newItem = 8177, amount = 20 }, -- yummy gummy worm
{ value = 10000, newItem = 6571 }, -- surprise bag (red)
{ value = 10000, newItem = 6570 }, -- surprise bag (blue)
{ value = 50000, newItem = 6574 }, -- bar of chocolate
{ value = 60000, newItem = 2977 }, -- pumpkinhead
{ value = 45000, newItem = 3594 }, -- pumpkin
{ value = 90000, newItem = 3599, amount = 50 }, -- candy cane
{ value = 90000, newItem = 6569, amount = 50 }, -- candy
{ value = 2000, newItem = 6574, amount = 50 }, -- bar of chocolate
},

-- Marble
[10426] = { { value = 10000, newItem = 10429, desc = "This little figurine of Tibiasula was masterfully sculpted by |PLAYERNAME|." }, { value = 26764, newItem = 10428, desc = "This little figurine made by |PLAYERNAME| has some room for improvement." }, { value = 60000, newItem = 10427, desc = "This shoddy work was made by |PLAYERNAME|." } },
[10426] = {
{ value = 10000, newItem = 10429, desc = "This little figurine of Tibiasula was masterfully sculpted by |PLAYERNAME|." },
{ value = 26764, newItem = 10428, desc = "This little figurine made by |PLAYERNAME| has some room for improvement." },
{ value = 60000, newItem = 10427, desc = "This shoddy work was made by |PLAYERNAME|." },
},

-- Ice Cube
[7441] = { value = 22344, newItem = 7442 },
Expand Down Expand Up @@ -101,7 +118,15 @@ local config = {
local skinning = Action()

function skinning.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local topItem = false
local skin = config[item.itemid][target.itemid]
local tile = Tile(toPosition)
if tile then
topItem = tile:getTopDownItem()
if topItem then
skin = config[item.itemid][topItem.itemid]
end
end

if item.itemid == 5908 then
if target:getId() == CONST_FIREWORK_ITEMID_DISASSEMBLE then
Expand Down Expand Up @@ -146,6 +171,22 @@ function skinning.onUse(player, item, fromPosition, target, toPosition, isHotkey
end
end

if target:getId() == 12816 then
if player:getStorageValue(Storage.Quest.U8_2.TheMutatedPumpkin.Skinned) > os.time() then
player:sendCancelMessage("You already used your knife on the corpse.")
return true
end

player:setStorageValue(Storage.Quest.U8_2.TheMutatedPumpkin.Skinned, os.time() + 4 * 60 * 60)
player:say("Happy Halloween!", TALKTYPE_MONSTER_SAY)
player:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS)
player:addAchievement("Mutated Presents")
local reward = math.random(1, #skin)
player:addItem(skin[reward].newItem, skin[reward].amount or 1)
effect = CONST_ME_HITAREA
return true
end

if not skin then
player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
return true
Expand All @@ -167,11 +208,15 @@ function skinning.onUse(player, item, fromPosition, target, toPosition, isHotkey
_skin = skin[i]
if random <= _skin.value then
if target.itemid == 10426 then
target:getPosition():sendMagicEffect(CONST_ME_ICEAREA)
target:getPosition():sendMagicEffect(CONST_ME_HITAREA)
local gobletItem = player:addItem(_skin.newItem, _skin.amount or 1)
if gobletItem then
gobletItem:setDescription(_skin.desc:gsub("|PLAYERNAME|", player:getName()))
end
if _skin.newItem == 10429 then
player:addAchievement("Marblelous")
player:addAchievementProgress("Marble Madness", 5)
end
target:remove()
added = true
else
Expand All @@ -182,41 +227,55 @@ function skinning.onUse(player, item, fromPosition, target, toPosition, isHotkey
end
end

if not added and target.itemid == 12816 then
effect = CONST_ME_POFF
transform = false
elseif not added and target.itemid == 10426 then
effect = CONST_ME_POFF
if not added and target.itemid == 10426 then
effect = CONST_ME_HITAREA
player:say("Your attempt at shaping that marble rock failed miserably.", TALKTYPE_MONSTER_SAY)
transform = false
target:remove()
end
elseif random <= skin.value then
if isInArray({ 7441, 7442, 7444, 7445 }, target.itemid) then
if skin.newItem == 7446 then
player:addAchievement("Ice Sculptor")
player:addAchievementProgress("Cold as Ice", 10)
end
target:transform(skin.newItem, 1)
effect = CONST_ME_HITAREA
return true
else
player:addItem(skin.newItem, skin.amount or 1)
if table.contains({ 5906, 5905 }, skin.newItem) then
player:addAchievementProgress("Ashes to Dust", 500)
else
player:addAchievementProgress("Skin-Deep", 500)
end
local container = Container(item:getParent().uid)
if fromPosition.x == CONTAINER_POSITION and container:getEmptySlots() ~= 0 then
container:addItem(skin.newItem, skin.amount or 1)
else
player:addItem(skin.newItem, skin.amount or 1)
end
end
else
if isInArray({ 7441, 7442, 7444, 7445 }, target.itemid) then
player:say("The attempt of sculpting failed miserably.", TALKTYPE_MONSTER_SAY)
effect = CONST_ME_HITAREA
target:remove()
else
effect = CONST_ME_POFF
effect = CONST_ME_BLOCKHIT
end
end
-- SE BUGAR, PEGAR SCRIPT ANTIGO
toPosition:sendMagicEffect(effect)

if transform then
target:transform(skin.after or target:getType():getDecayId() or target.itemid + 1)
topItem:transform(skin.after or topItem:getType():getDecayId() or topItem.itemid + 1)
else
target:remove()
end

if toPosition.x == CONTAINER_POSITION then
toPosition = player:getPosition()
end
toPosition:sendMagicEffect(effect)

return true
end

Expand Down
15 changes: 0 additions & 15 deletions data-otservbr-global/scripts/actions/tools/toolgear.lua

This file was deleted.

6 changes: 3 additions & 3 deletions data/libs/functions/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ function cleanAreaQuest(frompos, topos, itemtable, blockmonsters)
return true
end

function kickerPlayerRoomAfferMin(playername, fromPosition, toPosition, teleportPos, message, monsterName, minutes, firstCall, itemtable, blockmonsters)
function kickerPlayerRoomAfterMin(playername, fromPosition, toPosition, teleportPos, message, monsterName, minutes, firstCall, itemtable, blockmonsters)
local players = false
if type(playername) == table then
players = true
Expand Down Expand Up @@ -658,15 +658,15 @@ function kickerPlayerRoomAfferMin(playername, fromPosition, toPosition, teleport
end
local min = 60 -- Use the 60 for 1 minute
if firstCall then
addEvent(kickerPlayerRoomAfferMin, 1000, playername, fromPosition, toPosition, teleportPos, message, monsterName, minutes, false, itemtable, blockmonsters)
addEvent(kickerPlayerRoomAfterMin, 1000, playername, fromPosition, toPosition, teleportPos, message, monsterName, minutes, false, itemtable, blockmonsters)
else
local subt = minutes - 1
if monsterName ~= "" then
if minutes > 3 and table.maxn(monster) == 0 then
subt = 2
end
end
addEvent(kickerPlayerRoomAfferMin, min * 1000, playername, fromPosition, toPosition, teleportPos, message, monsterName, subt, false, itemtable, blockmonsters)
addEvent(kickerPlayerRoomAfterMin, min * 1000, playername, fromPosition, toPosition, teleportPos, message, monsterName, subt, false, itemtable, blockmonsters)
end
end

Expand Down
1 change: 1 addition & 0 deletions data/npclib/npc_system/modules.lua
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ if Modules == nil then
player:kv():set("npc-exhaustion", os.time() + 3) -- 3 seconds
player:teleportTo(destination)
playerPosition:sendMagicEffect(CONST_ME_TELEPORT)
player:addAchievementProgress("Ship's Kobold", 1250)

-- What a foolish Quest - Mission 3
if Storage.WhatAFoolish.PieBoxTimer ~= nil then
Expand Down
36 changes: 25 additions & 11 deletions data/scripts/actions/items/usable_outfit_items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,29 @@ local outfitConfig = {
[16257] = { female = 513, male = 512, addon = 2, effect = CONST_ME_GIANTICE, achievement = "Crystal Clear" },

-- makeshift warrior
[27655] = { female = 1043, male = 1042 },
[27657] = { female = 1043, male = 1042, addon = 1, achievement = "Cobbled and Patched" },
[27656] = { female = 1043, male = 1042, addon = 2, achievement = "Cobbled and Patched" },
[27655] = { female = 1043, male = 1042, whiteText = "By using the plan you knock together a makeshift armour out of wooden planks, rusty nails and leather rags." },
[27657] = { female = 1043, male = 1042, addon = 1, achievement = "Cobbled and Patched", whiteText = "You use the wooden planks to knock up a makeshift shield and weapon." },
[27656] = { female = 1043, male = 1042, addon = 2, achievement = "Cobbled and Patched", whiteText = "You use the tinged pot as a makeshift helmet." },

-- hand of the inquisition
[31738] = { female = 1244, male = 1243, addon = 1, effect = CONST_ME_HOLYAREA, achievement = "Inquisition's Arm" },
[31737] = { female = 1244, male = 1243, addon = 2, effect = CONST_ME_HOLYAREA, achievement = "Inquisition's Arm" },

-- poltergeist
[32630] = { female = 1271, male = 1270, addon = 1, effect = CONST_ME_BLUE_GHOST, achievement = "Mainstreet Nightmare" },
[32631] = { female = 1271, male = 1270, addon = 2, effect = CONST_ME_BLUE_GHOST, achievement = "Mainstreet Nightmare" },
[32630] = { female = 1271, male = 1270, addon = 1, effect = CONST_ME_BLUE_GHOST, achievement = "Mainstreet Nightmare", orangeText = "The spooky hood is yours!" },
[32631] = { female = 1271, male = 1270, addon = 2, effect = CONST_ME_BLUE_GHOST, achievement = "Mainstreet Nightmare", orangeText = "You can use the ghost claw now!" },

-- revenant
[34075] = { female = 1323, male = 1322, addon = 1, effect = CONST_ME_HOLYAREA, achievement = "Unleash the Beast", orangeText = "Now the beast is unleashed!" },
[34076] = { female = 1323, male = 1322, addon = 2, effect = CONST_ME_HOLYAREA, achievement = "Unleash the Beast", orangeText = "Wild power flows though your body!" },

-- rascoohan
[35595] = { female = 1372, male = 1371, addon = 1, achievement = "Honorary Rascoohan" },
[35695] = { female = 1372, male = 1371, addon = 2, achievement = "Honorary Rascoohan" },
[35595] = { female = 1372, male = 1371, addon = 1, achievement = "Honorary Rascoohan", orangeText = "You feel a bit more raccoonish." },
[35695] = { female = 1372, male = 1371, addon = 2, achievement = "Honorary Rascoohan", orangeText = "Hmmm, trash cans!!" },

-- fire-fighter
[39544] = { female = 1569, male = 1568, addon = 1, achievement = "Friendly Fire" },
[39545] = { female = 1569, male = 1568, addon = 2, achievement = "Friendly Fire" },
[39544] = { female = 1569, male = 1568, addon = 1, achievement = "Friendly Fire", orangeText = "You feel like fighting a fire!" },
[39545] = { female = 1569, male = 1568, addon = 2, achievement = "Friendly Fire", orangeText = "The flame engulfs you!" },
}

local usableOutfitItems = Action()
Expand All @@ -49,7 +53,12 @@ function usableOutfitItems.onUse(player, item, fromPosition, target, toPosition,

player:addOutfit(outfitInfo.female)
player:addOutfit(outfitInfo.male)
player:getPosition():sendMagicEffect(outfitInfo.effect)
player:getPosition():sendMagicEffect(outfitInfo.effect or CONST_ME_GIFT_WRAPS)
if outfitInfo.orangeText then
player:say(outfitInfo.orangeText, TALKTYPE_MONSTER_SAY)
elseif outfitInfo.whiteText then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, outfitInfo.whiteText)
end
item:remove(1)
return true
end
Expand All @@ -61,7 +70,12 @@ function usableOutfitItems.onUse(player, item, fromPosition, target, toPosition,

player:addOutfitAddon(outfitInfo.female, outfitInfo.addon)
player:addOutfitAddon(outfitInfo.male, outfitInfo.addon)
player:getPosition():sendMagicEffect(outfitInfo.effect)
player:getPosition():sendMagicEffect(outfitInfo.effect or CONST_ME_GIFT_WRAPS)
if outfitInfo.orangeText then
player:say(outfitInfo.orangeText, TALKTYPE_MONSTER_SAY)
elseif outfitInfo.whiteText then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, outfitInfo.whiteText)
end

if player:hasOutfit(looktype, 3) then
player:addAchievement(outfitInfo.achievement)
Expand Down
Loading

0 comments on commit 7d90b9a

Please sign in to comment.