Skip to content

Commit

Permalink
[Bug] rework in subactions from gamestore (#701)
Browse files Browse the repository at this point in the history
Some subactions were repeated, which meant that the purchase of some offers did not work properly.
Catalogued the subactions of each offer, and added to enum, to avoid repetitions.
  • Loading branch information
dudantas authored Dec 19, 2022
1 parent 20656e2 commit 29fd13b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 32 deletions.
30 changes: 15 additions & 15 deletions data/modules/scripts/gamestore/gamestore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ GameStore.Categories = {
icons = { "All_PvE_Blessings.png" },
name = "All Regular Blessings",
price = 130,
id = 11,
id = GameStore.SubActions.BLESSING_ALL_PVE,
count = 1,
description = "<i>Reduces your character's chance to lose any items as well as the amount of your character's experience and skill loss upon death:</i>\n\n&#8226; 1 blessing = 8.00% less Skill / XP loss, 30% equipment protection\n&#8226; 2 blessing = 16.00% less Skill / XP loss, 55% equipment protection\n&#8226; 3 blessing = 24.00% less Skill / XP loss, 75% equipment protection\n&#8226; 4 blessing = 32.00% less Skill / XP loss, 90% equipment protection\n&#8226; 5 blessing = 40.00% less Skill / XP loss, 100% equipment protection\n&#8226; 6 blessing = 48.00% less Skill / XP loss, 100% equipment protection\n&#8226; 7 blessing = 56.00% less Skill / XP loss, 100% equipment protection\n\n{character} \n{limit|5} \n{info} added directly to the Record of Blessings \n{info} characters with a red or black skull will always lose all equipment upon death",
type = GameStore.OfferTypes.OFFER_TYPE_ALLBLESSINGS,
Expand All @@ -87,7 +87,7 @@ GameStore.Categories = {
icons = { "All_PvE_Blessings.png" },
name = "All Regular Blessings",
price = 650,
id = 12,
id = GameStore.SubActions.BLESSING_ALL_PVP,
count = 5,
description = "<i>Reduces your character's chance to lose any items as well as the amount of your character's experience and skill loss upon death:</i>\n\n&#8226; 1 blessing = 8.00% less Skill / XP loss, 30% equipment protection\n&#8226; 2 blessing = 16.00% less Skill / XP loss, 55% equipment protection\n&#8226; 3 blessing = 24.00% less Skill / XP loss, 75% equipment protection\n&#8226; 4 blessing = 32.00% less Skill / XP loss, 90% equipment protection\n&#8226; 5 blessing = 40.00% less Skill / XP loss, 100% equipment protection\n&#8226; 6 blessing = 48.00% less Skill / XP loss, 100% equipment protection\n&#8226; 7 blessing = 56.00% less Skill / XP loss, 100% equipment protection\n\n{character} \n{limit|5} \n{info} added directly to the Record of Blessings \n{info} characters with a red or black skull will always lose all equipment upon death",
type = GameStore.OfferTypes.OFFER_TYPE_ALLBLESSINGS,
Expand All @@ -98,7 +98,7 @@ GameStore.Categories = {
price = 8,
blessid = 1,
count = 1,
id = 3,
id = GameStore.SubActions.BLESSING_TWIST,
description = "<i>Protects your character's regular blessings or an Amulet of Loss if you are unfortunate enough to die in a PvP fight.</i>\n\n{character}\n{limit|5}\n{info} added directly to the Record of Blessings\n{info} does not work for characters with a red or black skull",
type = GameStore.OfferTypes.OFFER_TYPE_BLESSINGS,
},
Expand All @@ -117,7 +117,7 @@ GameStore.Categories = {
price = 15,
blessid = 2,
count = 1,
id = 4,
id = GameStore.SubActions.BLESSING_SOLITUDE,
description = "<i>Reduces your character's chance to lose any items as well as the amount of your character's experience and skill loss upon death:</i>\n\n&#8226; 1 blessing = 8.00% less Skill / XP loss, 30% equipment protection\n&#8226; 2 blessing = 16.00% less Skill / XP loss, 55% equipment protection\n&#8226; 3 blessing = 24.00% less Skill / XP loss, 75% equipment protection\n&#8226; 4 blessing = 32.00% less Skill / XP loss, 90% equipment protection\n&#8226; 5 blessing = 40.00% less Skill / XP loss, 100% equipment protection\n&#8226; 6 blessing = 48.00% less Skill / XP loss, 100% equipment protection\n&#8226; 7 blessing = 56.00% less Skill / XP loss, 100% equipment protection\n\n{character} \n{limit|5} \n{info} added directly to the Record of Blessings \n{info} characters with a red or black skull will always lose all equipment upon death",
type = GameStore.OfferTypes.OFFER_TYPE_BLESSINGS,
},
Expand All @@ -127,7 +127,7 @@ GameStore.Categories = {
price = 20,
blessid = 3,
count = 1,
id = 5,
id = GameStore.SubActions.BLESSING_PHOENIX,
description = "<i>Reduces your character's chance to lose any items as well as the amount of your character's experience and skill loss upon death:</i>\n\n&#8226; 1 blessing = 8.00% less Skill / XP loss, 30% equipment protection\n&#8226; 2 blessing = 16.00% less Skill / XP loss, 55% equipment protection\n&#8226; 3 blessing = 24.00% less Skill / XP loss, 75% equipment protection\n&#8226; 4 blessing = 32.00% less Skill / XP loss, 90% equipment protection\n&#8226; 5 blessing = 40.00% less Skill / XP loss, 100% equipment protection\n&#8226; 6 blessing = 48.00% less Skill / XP loss, 100% equipment protection\n&#8226; 7 blessing = 56.00% less Skill / XP loss, 100% equipment protection\n\n{character} \n{limit|5} \n{info} added directly to the Record of Blessings \n{info} characters with a red or black skull will always lose all equipment upon death",
type = GameStore.OfferTypes.OFFER_TYPE_BLESSINGS,
},
Expand All @@ -137,7 +137,7 @@ GameStore.Categories = {
price = 15,
blessid = 4,
count = 1,
id = 6,
id = GameStore.SubActions.BLESSING_SUNS,
description = "<i>Reduces your character's chance to lose any items as well as the amount of your character's experience and skill loss upon death:</i>\n\n&#8226; 1 blessing = 8.00% less Skill / XP loss, 30% equipment protection\n&#8226; 2 blessing = 16.00% less Skill / XP loss, 55% equipment protection\n&#8226; 3 blessing = 24.00% less Skill / XP loss, 75% equipment protection\n&#8226; 4 blessing = 32.00% less Skill / XP loss, 90% equipment protection\n&#8226; 5 blessing = 40.00% less Skill / XP loss, 100% equipment protection\n&#8226; 6 blessing = 48.00% less Skill / XP loss, 100% equipment protection\n&#8226; 7 blessing = 56.00% less Skill / XP loss, 100% equipment protection\n\n{character} \n{limit|5} \n{info} added directly to the Record of Blessings \n{info} characters with a red or black skull will always lose all equipment upon death",
type = GameStore.OfferTypes.OFFER_TYPE_BLESSINGS,
},
Expand All @@ -147,7 +147,7 @@ GameStore.Categories = {
price = 15,
blessid = 5,
count = 1,
id = 7,
id = GameStore.SubActions.BLESSING_SPIRITUAL,
description = "<i>Reduces your character's chance to lose any items as well as the amount of your character's experience and skill loss upon death:</i>\n\n&#8226; 1 blessing = 8.00% less Skill / XP loss, 30% equipment protection\n&#8226; 2 blessing = 16.00% less Skill / XP loss, 55% equipment protection\n&#8226; 3 blessing = 24.00% less Skill / XP loss, 75% equipment protection\n&#8226; 4 blessing = 32.00% less Skill / XP loss, 90% equipment protection\n&#8226; 5 blessing = 40.00% less Skill / XP loss, 100% equipment protection\n&#8226; 6 blessing = 48.00% less Skill / XP loss, 100% equipment protection\n&#8226; 7 blessing = 56.00% less Skill / XP loss, 100% equipment protection\n\n{character} \n{limit|5} \n{info} added directly to the Record of Blessings \n{info} characters with a red or black skull will always lose all equipment upon death",
type = GameStore.OfferTypes.OFFER_TYPE_BLESSINGS,
},
Expand All @@ -157,7 +157,7 @@ GameStore.Categories = {
price = 15,
blessid = 6,
count = 1,
id = 8,
id = GameStore.SubActions.BLESSING_EMBRACE,
description = "<i>Reduces your character's chance to lose any items as well as the amount of your character's experience and skill loss upon death:</i>\n\n&#8226; 1 blessing = 8.00% less Skill / XP loss, 30% equipment protection\n&#8226; 2 blessing = 16.00% less Skill / XP loss, 55% equipment protection\n&#8226; 3 blessing = 24.00% less Skill / XP loss, 75% equipment protection\n&#8226; 4 blessing = 32.00% less Skill / XP loss, 90% equipment protection\n&#8226; 5 blessing = 40.00% less Skill / XP loss, 100% equipment protection\n&#8226; 6 blessing = 48.00% less Skill / XP loss, 100% equipment protection\n&#8226; 7 blessing = 56.00% less Skill / XP loss, 100% equipment protection\n\n{character} \n{limit|5} \n{info} added directly to the Record of Blessings \n{info} characters with a red or black skull will always lose all equipment upon death",
type = GameStore.OfferTypes.OFFER_TYPE_BLESSINGS,
},
Expand All @@ -167,7 +167,7 @@ GameStore.Categories = {
price = 25,
blessid = 7,
count = 1,
id = 9,
id = GameStore.SubActions.BLESSING_HEART,
description = "<i>Reduces your character's chance to lose any items as well as the amount of your character's experience and skill loss upon death:</i>\n\n&#8226; 1 blessing = 8.00% less Skill / XP loss, 30% equipment protection\n&#8226; 2 blessing = 16.00% less Skill / XP loss, 55% equipment protection\n&#8226; 3 blessing = 24.00% less Skill / XP loss, 75% equipment protection\n&#8226; 4 blessing = 32.00% less Skill / XP loss, 90% equipment protection\n&#8226; 5 blessing = 40.00% less Skill / XP loss, 100% equipment protection\n&#8226; 6 blessing = 48.00% less Skill / XP loss, 100% equipment protection\n&#8226; 7 blessing = 56.00% less Skill / XP loss, 100% equipment protection\n\n{character} \n{limit|5} \n{info} added directly to the Record of Blessings \n{info} characters with a red or black skull will always lose all equipment upon death",
type = GameStore.OfferTypes.OFFER_TYPE_BLESSINGS,
},
Expand All @@ -177,7 +177,7 @@ GameStore.Categories = {
price = 25,
blessid = 8,
count = 1,
id = 10,
id = GameStore.SubActions.BLESSING_BLOOD,
description = "<i>Reduces your character's chance to lose any items as well as the amount of your character's experience and skill loss upon death:</i>\n\n&#8226; 1 blessing = 8.00% less Skill / XP loss, 30% equipment protection\n&#8226; 2 blessing = 16.00% less Skill / XP loss, 55% equipment protection\n&#8226; 3 blessing = 24.00% less Skill / XP loss, 75% equipment protection\n&#8226; 4 blessing = 32.00% less Skill / XP loss, 90% equipment protection\n&#8226; 5 blessing = 40.00% less Skill / XP loss, 100% equipment protection\n&#8226; 6 blessing = 48.00% less Skill / XP loss, 100% equipment protection\n&#8226; 7 blessing = 56.00% less Skill / XP loss, 100% equipment protection\n\n{character} \n{limit|5} \n{info} added directly to the Record of Blessings \n{info} characters with a red or black skull will always lose all equipment upon death",
type = GameStore.OfferTypes.OFFER_TYPE_BLESSINGS,
},
Expand Down Expand Up @@ -4164,7 +4164,7 @@ GameStore.Categories = {
icons = {"Prey_Bonus_Reroll.png"},
name = "Prey Wildcard",
price = 50,
id = 1,
id = GameStore.SubActions.PREY_WILDCARD,
count = 5,
description = "<i>Use Prey Wildcards to reroll the bonus of an active prey, to lock your active prey or to select a prey of your choice.</i>\n\n{character}\n{info} added directly to Prey dialog\n{info} maximum amount that can be owned by character: 50",
type = GameStore.OfferTypes.OFFER_TYPE_PREYBONUS
Expand All @@ -4173,7 +4173,7 @@ GameStore.Categories = {
icons = {"Instant_Reward_Access.png"},
name = "Instant Reward Access",
price = 100,
id = 2,
id = GameStore.SubActions.INSTANT_REWARD,
count = 1,
description = "<i>No matter where you are in Tibia, claim your daily reward on the spot!</i>\n\n{character}\n{info} added to your reward wall\n{info} maximum amount that can be owned by character: 90",
type = GameStore.OfferTypes.OFFER_TYPE_INSTANT_REWARD_ACCESS
Expand All @@ -4182,23 +4182,23 @@ GameStore.Categories = {
icons = {"Charm_Expansion_Offer.png"},
name = "Charm Expansion",
price = 450,
id = 3,
id = GameStore.SubActions.CHARM_EXPANSION,
description = "<i>Assign as many of your unlocked Charms as you like and get a 25% discount whenever you are removing a Charm from a creature!</i>\n\n{character}\n{once}",
type = GameStore.OfferTypes.OFFER_TYPE_CHARMS
},
{
icons = {"Permanent_Prey_Slot.png"},
name = "Permanent Prey Slot",
price = 900,
id = 4,
id = GameStore.SubActions.PREY_THIRDSLOT_REDIRECT,
description = "<i>Get an additional prey slot to activate additional prey!</i>\n\n{character}\n{info} maximum amount that can be owned by character: 3\n{info} added directly to Prey dialog",
type = GameStore.OfferTypes.OFFER_TYPE_PREYSLOT
},
{
icons = {"Permanent_Hunting_Task_Slot.png"},
name = "Permanent Hunting Task Slot",
price = 900,
id = 5,
id = GameStore.SubActions.TASKHUNTING_THIRDSLOT,
description = "<i>Get an additional hunting tasks slot to activate additional hunting task!</i>\n\n{character}\n{info} maximum amount that can be owned by character: 3\n{info} added directly to Hunting Task dialog",
type = GameStore.OfferTypes.OFFER_TYPE_HUNTINGSLOT
},
Expand Down
41 changes: 24 additions & 17 deletions data/modules/scripts/gamestore/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,22 @@ GameStore.OfferTypes = {
}

GameStore.SubActions = {
PREY_THIRDSLOT = 0,
TASKHUNTING_THIRDSLOT = 14
PREY_THIRDSLOT_REAL = 0,
PREY_WILDCARD = 1,
INSTANT_REWARD = 2,
BLESSING_TWIST = 3,
BLESSING_SOLITUDE = 4,
BLESSING_PHOENIX = 5,
BLESSING_SUNS = 6,
BLESSING_SPIRITUAL = 7,
BLESSING_EMBRACE = 8,
BLESSING_HEART = 9,
BLESSING_BLOOD = 10,
BLESSING_ALL_PVE = 11,
BLESSING_ALL_PVP = 12,
CHARM_EXPANSION = 13,
TASKHUNTING_THIRDSLOT = 14,
PREY_THIRDSLOT_REDIRECT = 15
}

GameStore.ActionType = {
Expand Down Expand Up @@ -288,7 +302,6 @@ function parseRequestStoreOffers(playerId, msg)
end

local actionType = msg:getByte()

if actionType == GameStore.ActionType.OPEN_CATEGORY then
local categoryName = msg:getString()
local category = GameStore.getCategoryByName(categoryName)
Expand Down Expand Up @@ -316,25 +329,19 @@ function parseRequestStoreOffers(playerId, msg)
elseif actionType == GameStore.ActionType.OPEN_USEFUL_THINGS then
local subAction = msg:getByte()
local offerId = subAction
local category = GameStore.getCategoryByName("Useful Things")

-- Third prey slot offerId
-- We can't use offerId 0
-- Subaction 0 is offer from "unlock permanently" of prey window button, offerId 4 is the id of the gamestore.lua third slot
if subAction == GameStore.SubActions.PREY_THIRDSLOT then
offerId = 4
-- Subaction 14 is offer from "unlock permanently" of task hunting window button, offerId 5 is the id of the gamestore.lua third slot
elseif subAction == GameStore.SubActions.TASKHUNTING_THIRDSLOT then
offerId = 5
local category = nil
if subAction >= GameStore.SubActions.BLESSING_TWIST and subAction <= GameStore.SubActions.BLESSING_ALL_PVP then
category = GameStore.getCategoryByName("Blessings")
else
category = GameStore.getCategoryByName("Useful Things")
end
-- Enable this for look sub action offer button
-- Example of subaction is the button for redirect to the store on clicking "unlock permanently" on prey window
--Spdlog.info("SubAction ".. subAction)

if subAction == GameStore.SubActions.PREY_THIRDSLOT_REAL then
offerId = GameStore.SubActions.PREY_THIRDSLOT_REDIRECT
end
if category then
addPlayerEvent(sendShowStoreOffers, 50, playerId, category, offerId)
end

elseif actionType == GameStore.ActionType.OPEN_OFFER then
local offerId = msg:getU32()
local category = GameStore.getCategoryByOffer(offerId)
Expand Down

0 comments on commit 29fd13b

Please sign in to comment.