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

Commit

Permalink
Loyalty system by Petardako (#106)
Browse files Browse the repository at this point in the history
* Update player.lua
* Update creaturescripts.xml
* Create loyalty.lua
* Update loyalty.lua
* Update player.lua
* Update player.lua
* Update global.lua
* Update player.lua
* Update player.lua
* Update player.lua
* Update init.lua
  • Loading branch information
Olimpotibia authored and omarcopires committed Jun 3, 2019
1 parent f80acef commit ee5e37b
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 3 deletions.
2 changes: 2 additions & 0 deletions data/creaturescripts/creaturescripts.xml
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
<!-- loyalty Points -->
<event type="login" name="loyalty" script="loyalty.lua"/>

<!-- The Masters Voice Quest-->
<event type="death" name="Servant_Death" script="mastervoice/servant_death.lua"/>
Expand Down
18 changes: 18 additions & 0 deletions data/creaturescripts/scripts/loyalty.lua
@@ -0,0 +1,18 @@
local loyalty_condition = Condition(CONDITION_ATTRIBUTES)
loyalty_condition:setParameter(CONDITION_PARAM_TICKS, -1)
loyalty_condition:setParameter(CONDITION_PARAM_SUBID, 10)
loyalty_condition:setParameter(CONDITION_PARAM_SKILL_MELEEPERCENT, 115)

local parameters = {
CONDITION_PARAM_STAT_MAGICPOINTSPERCENT, CONDITION_PARAM_SKILL_MELEEPERCENT, CONDITION_PARAM_SKILL_FISTPERCENT,
CONDITION_PARAM_SKILL_DISTANCEPERCENT, CONDITION_PARAM_SKILL_SHIELDPERCENT, CONDITION_PARAM_SKILL_FISHINGPERCENT
}

function onLogin(player)
local attr_value = 100 + math.floor(player:getLoyalty() / 360) * 0.05
for key, attr_key in pairs(parameters) do
loyalty_condition:setParameter(attr_key, attr_value)
end
player:addCondition(loyalty_condition)
return true
end
10 changes: 9 additions & 1 deletion data/events/scripts/player.lua
Expand Up @@ -143,6 +143,14 @@ function Player:onLook(thing, position, distance)
description = description..' (Master: ' .. master:getName() .. '). It will disappear in ' .. getTimeinWords(master:getStorageValue(Storage.PetSummon) - os.time())
end
end
if thing:isPlayer() then
local loyalty = LOYALTY_STORAGE[thing.uid]
for key = 1, #LOYALTY_TITLES do
if loyalty >= LOYALTY_TITLES[key][1] then
description = description .. (thing:getSex() == 0 and " She" or " He") .. " is a " .. LOYALTY_TITLES[key][2] .. " of ' .. configManager.getString(configKeys.SERVER_NAME) .. '."
break
end
end
end

if self:getGroup():getAccess() then
Expand Down Expand Up @@ -1138,4 +1146,4 @@ end

function Player:onStorageUpdate(key, value, oldValue, currentFrameTime)
self:updateStorage(key, value, oldValue, currentFrameTime)
end
end
5 changes: 4 additions & 1 deletion data/global.lua
Expand Up @@ -9,6 +9,9 @@ STORAGEVALUE_ASSISTS = 30000
STORAGEVALUE_DEATHS = 30001
STORAGEVALUE_KILLS = 30002

LOYALTY_STORAGE = LOYALTY_STORAGE or {}
LOYALTY_TITLES = {{3600, "King"}, {3240, "Sage"}, {2880, "Guardian"}, {2520, "Keeper"}, {2160, "Warrior"}, {1800, "Squire"}, {1440, "Warden"},
{1080, "Steward"}, {720, "Sentinel"}, {360, "Scout"}}


ropeSpots = {384, 418, 8278, 8592, 13189, 14435, 14436, 15635, 19518, 26019, 24621, 24622, 24623, 24624}
Expand Down Expand Up @@ -371,4 +374,4 @@ end
--[[function getLootRandom()
math.randomseed(os.mtime())
return math.random(0, MAX_LOOTCHANCE) / configManager.getNumber(configKeys.RATE_LOOT)
end]]
end]]
9 changes: 9 additions & 0 deletions data/lib/core/player.lua
Expand Up @@ -2,6 +2,15 @@ function Player.allowMovement(self, allow)
return self:setStorageValue(STORAGE.blockMovementStorage, allow and -1 or 1)
end

function Player.getLoyalty(self)
local resultId, loyalty = db.storeQuery('SELECT `premdays` FROM `accounts` WHERE `id` = ' .. self:getAccountId()), 0
if resultId ~= false then
loyalty = result.getNumber(resultId, "premdays")
result.free(resultId)
end
return loyalty
end

function Player.checkGnomeRank(self)
local points = self:getStorageValue(Storage.BigfootBurden.Rank)
local questProgress = self:getStorageValue(Storage.BigfootBurden.QuestLine)
Expand Down
3 changes: 2 additions & 1 deletion data/modules/scripts/gamestore/init.lua
Expand Up @@ -964,6 +964,7 @@ end

function GameStore.processPremiumPurchase(player, offerId)
player:addPremiumDays(offerId)
--player:addLoyaltyPoints(offerId)
end

function GameStore.processStackablePurchase(player, offerId, offerCount, offerName)
Expand Down Expand Up @@ -1227,4 +1228,4 @@ function Player.toggleSex(self)
playerOutfit.lookType = 136
end
self:setOutfit(playerOutfit)
end
end

0 comments on commit ee5e37b

Please sign in to comment.