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

Commit

Permalink
Fix free quest logic (#407)
Browse files Browse the repository at this point in the history
Free quest always ran when logging in.
Added tags in config.lua to add new quests
  • Loading branch information
dudantas authored Feb 7, 2022
1 parent e96951d commit 5a722dc
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
9 changes: 8 additions & 1 deletion config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ onlyPremiumAccount = false
-- Customs
weatherRain = false
thunderEffect = false
freeQuests = false
allConsoleLog = false
-- NOTE: saveIntervalTime in hours
saveInterval = false
Expand All @@ -81,6 +80,14 @@ maxAllowedOnADummy = 1
-- Imbuement
togleImbuementShrineStorage = false

-- Free quests
-- Add quest access to player when logging in
-- NOTE: Only quests that are in the "freequests.lua" script table will work
-- toggleFreeQuest = enable/disable the system
-- freeQuestStage = if you add more quests to the table, change this value to run freeQuest again
toggleFreeQuest = false
freeQuestStage = 1

-- Deaths
-- NOTE: Leave deathLosePercent as -1 if you want to use the default
-- death penalty formula. For the old formula, set it to 10. For
Expand Down
6 changes: 2 additions & 4 deletions data/scripts/creaturescripts/customs/freequests.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local upperLimit = 1 -- change upperLimit to a higher one after adding a new quest to questTable

local questTable = {
{storage = Storage.BigfootBurden.QuestLine, storageValue = 2},
{storage = Storage.BigfootBurden.QuestLine, storageValue = 4},
Expand Down Expand Up @@ -326,8 +324,8 @@ end
local freeQuests = CreatureEvent("FreeQuests")

function freeQuests.onLogin(player)
if configManager.getBoolean(configKeys.FREE_QUESTS) and
player:getStorageValue(Storage.FreeQuests) == upperLimit then
if not configManager.getBoolean(configKeys.TOGGLE_FREE_QUEST) or
player:getStorageValue(Storage.FreeQuests) == configManager.getNumber(configKeys.FREE_QUEST_STAGE) then
return true
end

Expand Down
11 changes: 2 additions & 9 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,11 @@ bool ConfigManager::load()
boolean[STOREMODULES] = getGlobalBoolean(L, "gamestoreByModules", true);
boolean[ONLY_INVITED_CAN_MOVE_HOUSE_ITEMS] = getGlobalBoolean(L, "onlyInvitedCanMoveHouseItems", true);
boolean[ONLY_PREMIUM_ACCOUNT] = getGlobalBoolean(L, "onlyPremiumAccount", false);

boolean[WEATHER_RAIN] = getGlobalBoolean(L, "weatherRain", false);
boolean[WEATHER_THUNDER] = getGlobalBoolean(L, "thunderEffect", false);
boolean[ALL_CONSOLE_LOG] = getGlobalBoolean(L, "allConsoleLog", false);

boolean[SORT_LOOT_BY_CHANCE] = getGlobalBoolean(L, "sortLootByChance", false);

boolean[FREE_QUESTS] = getGlobalBoolean(L, "freeQuests", false);
boolean[TOGGLE_FREE_QUEST] = getGlobalBoolean(L, "toggleFreeQuest", false);
boolean[SAVE_INTERVAL] = getGlobalBoolean(L, "saveInterval", false);
boolean[SAVE_INTERVAL_CLEAN_MAP] = getGlobalBoolean(L, "saveIntervalCleanMap", false);
boolean[STAMINA_TRAINER] = getGlobalBoolean(L, "staminaTrainer", false);
Expand Down Expand Up @@ -236,32 +233,28 @@ bool ConfigManager::load()
integer[BLACK_SKULL_DURATION] = getGlobalNumber(L, "blackSkullDuration", 45);
integer[ORANGE_SKULL_DURATION] = getGlobalNumber(L, "orangeSkullDuration", 7);
integer[SERVER_SAVE_NOTIFY_DURATION] = getGlobalNumber(L, "serverSaveNotifyDuration", 5);

integer[SAVE_INTERVAL_TIME] = getGlobalNumber(L, "saveIntervalTime", 1);
integer[STAMINA_ORANGE_DELAY] = getGlobalNumber(L, "staminaOrangeDelay", 1);
integer[STAMINA_GREEN_DELAY] = getGlobalNumber(L, "staminaGreenDelay", 5);
integer[STAMINA_PZ_GAIN] = getGlobalNumber(L, "staminaPzGain", 1);
integer[STAMINA_TRAINER_DELAY] = getGlobalNumber(L, "staminaTrainerDelay", 5);
integer[STAMINA_TRAINER_GAIN] = getGlobalNumber(L, "staminaTrainerGain", 1);
integer[MAX_ALLOWED_ON_A_DUMMY] = getGlobalNumber(L, "maxAllowedOnADummy", 1);

integer[PARTY_LIST_MAX_DISTANCE] = getGlobalNumber(L, "partyListMaxDistance", 0);

integer[PUSH_DELAY] = getGlobalNumber(L, "pushDelay", 1000);
integer[PUSH_DISTANCE_DELAY] = getGlobalNumber(L, "pushDistanceDelay", 1500);
integer[FREE_QUEST_STAGE] = getGlobalNumber(L, "freeQuestStage", 1);

floating[RATE_HEALTH_REGEN] = getGlobalFloat(L, "rateHealthRegen", 1.0);
floating[RATE_HEALTH_REGEN_SPEED] = getGlobalFloat(L, "rateHealthRegenSpeed", 1.0);
floating[RATE_MANA_REGEN] = getGlobalFloat(L, "rateManaRegen", 1.0);
floating[RATE_MANA_REGEN_SPEED] = getGlobalFloat(L, "rateManaRegenSpeed", 1.0);
floating[RATE_SOUL_REGEN] = getGlobalFloat(L, "rateSoulRegen", 1.0);
floating[RATE_SOUL_REGEN_SPEED] = getGlobalFloat(L, "rateSoulRegenSpeed", 1.0);

floating[RATE_SPELL_COOLDOWN] = getGlobalFloat(L, "rateSpellCooldown", 1.0);
floating[RATE_ATTACK_SPEED] = getGlobalFloat(L, "rateAttackSpeed", 1.0);
floating[RATE_OFFLINE_TRAINING_SPEED] = getGlobalFloat(L, "rateOfflineTrainingSpeed", 1.0);
floating[RATE_EXERCISE_TRAINING_SPEED] = getGlobalFloat(L, "rateExerciseTrainingSpeed", 1.0);

floating[RATE_MONSTER_HEALTH] = getGlobalFloat(L, "rateMonsterHealth", 1.0);
floating[RATE_MONSTER_ATTACK] = getGlobalFloat(L, "rateMonsterAttack", 1.0);
floating[RATE_MONSTER_DEFENSE] = getGlobalFloat(L, "rateMonsterDefense", 1.0);
Expand Down
7 changes: 4 additions & 3 deletions src/config/configmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ConfigManager
ONLY_INVITED_CAN_MOVE_HOUSE_ITEMS,
WEATHER_RAIN,
WEATHER_THUNDER,
FREE_QUESTS,
TOGGLE_FREE_QUEST,
ONLY_PREMIUM_ACCOUNT,
MAP_CUSTOM_ENABLED,
ALL_CONSOLE_LOG,
Expand Down Expand Up @@ -95,7 +95,7 @@ class ConfigManager
MAP_CUSTOM_FILE,
MAP_CUSTOM_SPAWN,
MAP_CUSTOM_AUTHOR,
DISCORD_WEBHOOK_URL,
DISCORD_WEBHOOK_URL,

LAST_STRING_CONFIG /* this must be the last one */
};
Expand Down Expand Up @@ -148,13 +148,14 @@ class ConfigManager
PUSH_DISTANCE_DELAY,
STASH_ITEMS,
PARTY_LIST_MAX_DISTANCE,
SAVE_INTERVAL_TIME,
SAVE_INTERVAL_TIME,
STAMINA_ORANGE_DELAY,
STAMINA_GREEN_DELAY,
STAMINA_TRAINER_DELAY,
STAMINA_PZ_GAIN,
STAMINA_TRAINER_GAIN,
MAX_ALLOWED_ON_A_DUMMY,
FREE_QUEST_STAGE,

LAST_INTEGER_CONFIG /* this must be the last one */
};
Expand Down
3 changes: 2 additions & 1 deletion src/lua/scripts/luascript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2127,7 +2127,8 @@ void LuaScriptInterface::registerFunctions()
registerEnumIn("configKeys", ConfigManager::STOREMODULES)
registerEnumIn("configKeys", ConfigManager::WEATHER_RAIN)
registerEnumIn("configKeys", ConfigManager::WEATHER_THUNDER)
registerEnumIn("configKeys", ConfigManager::FREE_QUESTS)
registerEnumIn("configKeys", ConfigManager::TOGGLE_FREE_QUEST)
registerEnumIn("configKeys", ConfigManager::FREE_QUEST_STAGE)
registerEnumIn("configKeys", ConfigManager::ALL_CONSOLE_LOG)
registerEnumIn("configKeys", ConfigManager::SAVE_INTERVAL)
registerEnumIn("configKeys", ConfigManager::SAVE_INTERVAL_CLEAN_MAP)
Expand Down

0 comments on commit 5a722dc

Please sign in to comment.