-
Notifications
You must be signed in to change notification settings - Fork 1.1k
blessings updated #4479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
reyaleman
wants to merge
6
commits into
otland:master
Choose a base branch
from
reyaleman:blessings-updated
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
blessings updated #4479
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,41 @@ | ||
| function onUpdateDatabase() | ||
| return false | ||
| print("> Updating database to version 36 (blessings update)") | ||
|
|
||
| -- skip BLESSING_ADVENTURERS_BLESSING & BLESSING_TWIST_OF_FATE | ||
| -- start at 10003001 + BLESSING_WISDOM_OF_SOLITUDE (2) | ||
| local storageRange = 10003003 | ||
|
|
||
| local resultId = db.storeQuery("SELECT `id`, `blessings` FROM `players`") | ||
| if resultId then | ||
| local rows = {} | ||
| repeat | ||
| local blessings = result.getNumber(resultId, "blessings") | ||
| local playerId = result.getNumber(resultId, "id") | ||
| for id = 0, 4 do | ||
| if bit.band(blessings, 2 ^ id) ~= 0 then | ||
| rows[#rows + 1] = "(" .. playerId .. ", " .. (storageRange + id) .. ", 1)" | ||
| end | ||
| end | ||
| until not result.next(resultId) | ||
| result.free(resultId) | ||
|
|
||
| local stmt = "INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES " | ||
| if #rows > 0 then | ||
| db.query(stmt .. table.concat(rows, ",")) | ||
| end | ||
| end | ||
|
|
||
| db.query([[ | ||
| CREATE TABLE IF NOT EXISTS `blessings_history` ( | ||
| `id` int unsigned NOT NULL AUTO_INCREMENT, | ||
| `player_id` int NOT NULL, | ||
| `type` tinyint NOT NULL DEFAULT '0', | ||
| `event` varchar(255) NOT NULL, | ||
| `created_at` bigint unsigned NOT NULL, | ||
| PRIMARY KEY (`id`), | ||
| FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE | ||
| ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; | ||
| ]]) | ||
| db.query("ALTER TABLE `players` DROP COLUMN `blessings`") | ||
| return true | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| function onUpdateDatabase() | ||
| return false | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| local ec = EventCallback | ||
|
|
||
| ec.onUpdateStorage = function(player, key, value, oldValue, isLogin) | ||
| if isLogin then | ||
| return | ||
| end | ||
|
|
||
| local storageBlessing = 10003001 | ||
| if key >= (storageBlessing + BLESSING_FIRST) and key <= (storageBlessing + BLESSING_LAST) then | ||
| player:sendBlessings() | ||
| end | ||
| end | ||
|
|
||
| ec:register() | ||
|
|
||
|
|
||
| local function sendBlessingsWindow(player) | ||
| local msg = NetworkMessage() | ||
| msg:addByte(0x9B) | ||
|
|
||
| msg:addByte(BLESSING_LAST + 1) | ||
| for blessingId = BLESSING_FIRST, BLESSING_LAST, 1 do | ||
| msg:addU16(2 ^ blessingId) | ||
| msg:addByte(player:getBlessing(blessingId)) | ||
| msg:addByte(0) -- charges bought from store | ||
| end | ||
|
|
||
| local isPromoted = player:isPromoted() | ||
| msg:addByte(isPromoted and 0x01 or 0x00) | ||
| msg:addByte(30) -- fixed value | ||
|
|
||
| local percentReduction = 0 | ||
| if isPromoted then | ||
| percentReduction = percentReduction + 30 | ||
| end | ||
|
|
||
| local blessings = player:getBlessings(true) | ||
| percentReduction = percentReduction + (#blessings * 8) | ||
|
|
||
| msg:addByte(percentReduction) -- exp/skill min loss pvp death | ||
| msg:addByte(percentReduction + 9) -- exp/skill max loss pvp death | ||
| msg:addByte(percentReduction) -- exp/skill loss pve death | ||
|
|
||
| local equipmentLoss = {100, 70, 45, 25, 10, 0, 0, 0} | ||
| local equipmentPercent = equipmentLoss[#blessings + 1] | ||
|
|
||
| local isBlackOrRedSkull = (player:getSkull() == SKULL_RED or player:getSkull() == SKULL_BLACK) | ||
|
|
||
| if isBlackOrRedSkull then | ||
| equipmentPercent = 100 | ||
| end | ||
|
|
||
| msg:addByte(equipmentPercent) -- loss container death pvp & 10% for pve (100pvp => 10pve) | ||
| msg:addByte(equipmentPercent) -- loss equipment death pvp & 10% for pve (100pvp => 10pve) | ||
|
|
||
| msg:addByte(isBlackOrRedSkull and 0x01 or 0x00) | ||
|
|
||
| local amulet = player:getSlotItem(CONST_SLOT_NECKLACE) | ||
| if amulet and amulet:getId() == ITEM_AMULETOFLOSS then | ||
| msg:addByte(0x01) | ||
| else | ||
| msg:addByte(0x00) | ||
| end | ||
|
|
||
| local history = player:getBlessingsHistory() | ||
| msg:addByte(#history) | ||
| for _, entry in ipairs(history) do | ||
| msg:addU32(entry.ts) | ||
| msg:addByte(entry.type) | ||
| msg:addString(entry.event) | ||
| end | ||
|
|
||
| msg:sendToPlayer(player) | ||
| msg:delete() | ||
|
|
||
| return true | ||
| end | ||
|
|
||
| local handler = PacketHandler(0xCF) | ||
|
|
||
| function handler.onReceive(player, msg) | ||
| sendBlessingsWindow(player) | ||
| end | ||
|
|
||
| handler:register() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.