Skip to content
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

[Enhancement] Rework of the imbuement system and conversion to c++ #164

Merged
merged 111 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
7c64a1b
Fix sonar warning
Costallat Oct 18, 2021
be647c4
Fix sonar warning
Costallat Oct 18, 2021
b738348
Use switch to load items.xml
beats-dh Oct 21, 2021
482f8d1
[Decouple] Parses item attributes in its own file
dudantas Oct 22, 2021
1e62986
Fix sonar
dudantas Oct 22, 2021
70ae8ac
Refactor for items parse attributes
dudantas Oct 22, 2021
93b8afd
Add imbuement slot on look
dudantas Oct 22, 2021
3185aa6
Indent
dudantas Oct 22, 2021
6250852
Indent
dudantas Oct 22, 2021
b988d65
Indent
dudantas Oct 22, 2021
b0cfeae
Fix nil value
dudantas Oct 26, 2021
dcca785
Fix sonar code smell
dudantas Oct 26, 2021
14a7dd6
Fix sonar bug
dudantas Oct 26, 2021
cfce5e7
Fix somes problems and sonar check
dudantas Oct 26, 2021
201a25d
Try to fix sonar check
dudantas Oct 26, 2021
56668b9
Fix show imbuement on look
dudantas Oct 26, 2021
d5c8089
Try to fix check
dudantas Oct 27, 2021
f85bc18
Try to fix check
dudantas Oct 27, 2021
6efbc06
Merge branch 'Use-switch-to-load-items.xml' of https://github.com/Bea…
dudantas Oct 27, 2021
c0ea414
Fix typo
dudantas Oct 27, 2021
f1d7f23
Try to fix sonar
dudantas Oct 27, 2021
9519ede
Refactor field item parse and fix fields attributes on items.xml
dudantas Oct 27, 2021
e18801d
Merge branch 'master' into pr/140
dudantas Oct 27, 2021
3e506e5
Try to fix sonar check
dudantas Oct 27, 2021
b10ecf3
Merge branch 'master' into Use-switch-to-load-items.xml
dudantas Oct 27, 2021
bd74e62
Try fix sonar check
dudantas Oct 27, 2021
e4e818a
Fix sonar check (use std::tuple for parseFieldConditions
dudantas Oct 27, 2021
0c9a453
Fix sonar check
dudantas Oct 27, 2021
943c33f
Merge branch 'master' into Use-switch-to-load-items.xml
dudantas Oct 27, 2021
005b4ff
Fix sonar check (remove "for" from the "if" scope)
dudantas Oct 27, 2021
c3ff19b
Fix imbuement, fix somes functions, fix combat and others fixes
dudantas Oct 27, 2021
6f8ffea
Update analysis-sonarcloud.yml
dudantas Oct 27, 2021
0e7fb2c
Fix onTargetCombat
dudantas Oct 27, 2021
e85be0d
Fix sonar check
dudantas Oct 27, 2021
6b73160
Fix on target combat and experience stage (#152)
dudantas Oct 27, 2021
dc198c9
Merge branch 'master' into fix-imbuement-window
dudantas Oct 27, 2021
a18c4a1
Merge branch 'master' into fix-imbuement-window
dudantas Oct 27, 2021
eb98937
Fix Player:onLook
dudantas Oct 30, 2021
2be9b1b
Merge branch 'master' into rework-imbuement-system
dudantas Oct 30, 2021
1fc4199
imbuements implemented in item.xml
Glatharth Nov 1, 2021
6f1f83d
Init of convert of imbuement system to c++
dudantas Nov 4, 2021
fd52a19
Add "onApplyImbuement", "getImbuement/setImbuement" and rework "check…
dudantas Nov 21, 2021
3516c76
Fix reviews from @lgrossi
dudantas Nov 23, 2021
ece543e
Add clear imbuement and modified the name of some functions/variables
dudantas Nov 23, 2021
ae9f8e0
Merge branch 'master' into rework-imbuement-system
dudantas Nov 23, 2021
9c2f3b6
Update analysis-sonarcloud.yml
dudantas Nov 23, 2021
f067d91
Merge branch 'master' into rework-imbuement-system
dudantas Nov 23, 2021
22ef2a8
Fix compilation error and remove unused codes
dudantas Nov 23, 2021
c572cd6
Add ItemParse::parseImbuement to ItemParse::initParse
dudantas Nov 23, 2021
8433da1
Attempt
lgrossi Nov 23, 2021
7d14c0a
Fix int size
dudantas Nov 23, 2021
ba6d579
Fix compilation errors
dudantas Nov 23, 2021
458b41c
Fix compilation errors
dudantas Nov 23, 2021
5a9cce9
more things
lgrossi Nov 23, 2021
ac70a64
Update player.cpp
lgrossi Nov 23, 2021
b64c656
Fix somes things
dudantas Nov 24, 2021
a687253
Fix function logic
dudantas Nov 24, 2021
8d86f40
Remove codes from lua imbuement
dudantas Nov 24, 2021
3337326
Fix checkImbuements and equipImbuement item
dudantas Nov 24, 2021
a84c0c6
Fix item decaying on backpack and remove ReleaseItem and erase imbued…
dudantas Nov 24, 2021
23ce2d5
Fix player name logs and add check for not imbue equiped item
dudantas Nov 24, 2021
e0338f5
Add log for getTopParent and getParent functions and fix check for no…
dudantas Nov 24, 2021
25371b4
Fix somes things
dudantas Nov 24, 2021
f23c0de
Remove unused function
dudantas Nov 24, 2021
d68fdaf
Update src/game/game.cpp
dudantas Nov 24, 2021
2868f7b
Update src/game/game.cpp
dudantas Nov 24, 2021
e014456
more adjusts
lgrossi Nov 24, 2021
8aed7f8
Fix reviews, add more imbuable items, fix sonar checks and others fixes
dudantas Nov 24, 2021
ff7718d
Remove unused things
dudantas Nov 24, 2021
fd5628f
More things
dudantas Nov 25, 2021
0a6bd16
Fix duration
dudantas Nov 25, 2021
f8f09c0
Fix checkImbuements function
dudantas Nov 25, 2021
e7540cb
Fix
dudantas Nov 25, 2021
eaa57bc
minor update
lgrossi Nov 26, 2021
b4089b5
Fix compilation errors
dudantas Nov 26, 2021
d884926
Remove ReleaseItem and add protectionzone check
dudantas Nov 26, 2021
e3b8467
Rework on Game::checkImbuements and added imbuing equiped item
dudantas Nov 26, 2021
0443a8d
Simplify imbument check logic
lgrossi Nov 27, 2021
4a3f07d
small refactor in logout function
lgrossi Nov 27, 2021
cc87788
Fix compilation errors
dudantas Nov 27, 2021
c6183ee
fix
lgrossi Nov 27, 2021
7fd1cac
Fix imbuement decrease time
dudantas Nov 27, 2021
f3cf7f4
Merge branch 'master' into rework-imbuement-system
dudantas Dec 1, 2021
f6435b6
Add closeImbuementWindow to luascript interface and others things
dudantas Dec 3, 2021
504ff0d
Remove item param from closeImbuementWindow
dudantas Dec 3, 2021
c122a52
Fix for not apply same imbuement to various slots
dudantas Dec 4, 2021
1feda5a
Fix sonar check and others somes things
dudantas Dec 5, 2021
1e15570
Fix compilation error
dudantas Dec 5, 2021
f73cfdd
Add members to private
dudantas Dec 5, 2021
920fd02
Add check for imbuement time not decay on protection zone
dudantas Dec 5, 2021
c469d1b
Add missing imbuement item
dudantas Dec 5, 2021
c83ec3e
Fix name from imbuementList to imbuementMap
dudantas Dec 5, 2021
2a84337
Add code for elemental imbuement damage
dudantas Dec 5, 2021
179495f
Add applyImbuementElementalDamage
dudantas Dec 5, 2021
7292099
Fix pointer logic
dudantas Dec 5, 2021
e8a2d9f
Add getImbuement method for lua item functions
dudantas Dec 5, 2021
61c17e1
Fix check reviews
dudantas Dec 5, 2021
a50733b
Fix typo
dudantas Dec 6, 2021
f02a423
Fix linux compilation error
dudantas Dec 6, 2021
7013188
Fix codes
dudantas Dec 7, 2021
a3d5f59
Some fixes
dudantas Dec 7, 2021
c352731
Merge branch 'master' into rework-imbuement-system
dudantas Dec 8, 2021
7b17af0
Fix somes bugs in the imbuement
dudantas Dec 9, 2021
b78ec5b
Remove wrong weapon
dudantas Dec 9, 2021
97425aa
small improvements
lgrossi Dec 12, 2021
0eff2bb
Fix compilation errors
dudantas Dec 12, 2021
162f167
Fix compilation error
dudantas Dec 12, 2021
7680cc3
Fix crash in Game::checkImbuements
dudantas Dec 15, 2021
0203913
Merge branch 'master' into rework-imbuement-system
dudantas Dec 15, 2021
f333904
Add missing imbued items
dudantas Dec 15, 2021
238a759
Somes fixes
dudantas Dec 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ saveIntervalType = "hour"
togleSaveIntervalCleanMap = true
saveIntervalTime = 1

-- Imbuement
togleImbuementShrineStorage = false

-- 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
146 changes: 73 additions & 73 deletions data/XML/imbuements.xml

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions data/events/events.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
<event class="Player" method="onRequestQuestLog" enabled="1" />
<event class="Player" method="onRequestQuestLine" enabled="1" />
<event class="Player" method="onStorageUpdate" enabled="1" />
<!-- Imbuement System -->
<event class="Player" method="canBeAppliedImbuement" enabled="1" />
<event class="Player" method="onApplyImbuement" enabled="1" />
<event class="Player" method="clearImbuement" enabled="1" />
<event class="Player" method="onCombat" enabled="1" />

<event class="Creature" method="onDrainHealth" enabled="1" />
Expand Down
177 changes: 1 addition & 176 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,7 @@ end
function Player:onLook(thing, position, distance)
local description = "You see "
description = description .. thing:getDescription(distance)
if thing:isItem() then
local itemType = thing:getType()
if (itemType and itemType:getImbuingSlots() > 0) then
local imbuingSlots = "Imbuements: ("
for slot = 0, itemType:getImbuingSlots() - 1 do
if slot > 0 then
imbuingSlots = string.format("%s, ", imbuingSlots)
end
local duration = thing:getImbuementDuration(slot)
if duration > 0 then
local imbue = thing:getImbuement(slot)
imbuingSlots = string.format("%s%s %s %s",
imbuingSlots, imbue:getBase().name, imbue:getName(), getTime(duration))
else
imbuingSlots = string.format("%sEmpty Slot", imbuingSlots)
end
end
imbuingSlots = string.format("%s).", imbuingSlots)
description = string.gsub(description, "It weighs", imbuingSlots.. "\nIt weighs")
end
elseif thing:isMonster() then
if thing:isMonster() then
description = description .. thing:getDescription(distance)
local master = thing:getMaster()
if master and table.contains(FAMILIARSNAME, thing:getName():lower()) then
Expand Down Expand Up @@ -346,158 +326,3 @@ function Player:onChangeZone(zone)
end
return false
end

function Player:canBeAppliedImbuement(imbuement, item)
local categories = {}
local slots = ItemType(item:getId()):getImbuingSlots()
if slots > 0 then
for slot = 0, slots - 1 do
local duration = item:getImbuementDuration(slot)
if duration > 0 then
local imbuementlot = item:getImbuement(slot)
local categoryId = imbuementlot:getCategory().id
table.insert(categories, categoryId)
end
end
end

if table.contains(categories, imbuement:getCategory().id) then
return false
end

if imbuement:isPremium() and self:getPremiumDays() < 1 then
return false
end

if self:getStorageValue(Storage.Imbuement) > 0 then
imbuable = true
else
imbuable = false
end

if not self:canImbueItem(imbuement, item) then
return false
end

return true
end

function Player:onApplyImbuement(imbuement, item, slot, protectionCharm)
for slot = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
local slotItem = self:getSlotItem(slot)
if slotItem and slotItem == item then
self:sendImbuementResult(MESSAGEDIALOG_IMBUEMENT_ROLL_FAILED, "You can't imbue a equipped item.")
self:closeImbuementWindow()
return true
end
end

for _, pid in pairs(imbuement:getItems()) do
if (self:getItemCount(pid.itemid) + self:getStashItemCount(pid.itemid)) < pid.count then
self:sendImbuementResult(MESSAGEDIALOG_IMBUEMENT_ROLL_FAILED, "You don't have all necessary items.")
return false
end
end

if item:getImbuementDuration(slot) > 0 then
self:sendImbuementResult(MESSAGEDIALOG_IMBUEMENT_ERROR, "An error ocurred, please reopen imbuement window.")
return false
end

local base = imbuement:getBase()
local price = base.price + (protectionCharm and base.protection or 0)

local chance = protectionCharm and 100 or base.percent
if math.random(100) > chance then -- failed attempt
self:sendImbuementResult(MESSAGEDIALOG_IMBUEMENT_ROLL_FAILED, "Oh no!\n\nThe imbuement has failed. You have lost the astral sources and gold you needed for the imbuement.\n\nNext time use a protection charm to better your chances.")
-- Removing items
for _, pid in pairs(imbuement:getItems()) do
self:removeItem(pid.itemid, pid.count)
end
-- Removing money
self:removeMoneyBank(price)
-- Refreshing shrine window
local nitem = Item(item.uid)
self:sendImbuementPanel(nitem)
return false
end

-- Removing items
for _, pid in pairs(imbuement:getItems()) do
local invertoryItemCount = self:getItemCount(pid.itemid)
if invertoryItemCount >= pid.count then
if not(self:removeItem(pid.itemid, pid.count)) then
self:sendImbuementResult(MESSAGEDIALOG_IMBUEMENT_ERROR, "An error ocurred, please reopen imbuement window.")
return false
end
else
local mathItemCount = pid.count
if invertoryItemCount > 0 and self:removeItem(pid.itemid, invertoryItemCount) then
mathItemCount = mathItemCount - invertoryItemCount
end

if not(self:removeStashItem(pid.itemid, mathItemCount)) then
self:sendImbuementResult(MESSAGEDIALOG_IMBUEMENT_ERROR, "An error ocurred, please reopen imbuement window.")
return false
end
end
end

if not self:removeMoneyBank(price) then
self:sendImbuementResult(MESSAGEDIALOG_IMBUEMENT_ROLL_FAILED, "You don't have enough money " ..price.. " gps.")
return false
end

if not item:addImbuement(slot, imbuement:getId()) then
self:sendImbuementResult(MESSAGEDIALOG_IMBUEMENT_ROLL_FAILED, "Item failed to apply imbuement.")
return false
end

-- Update item
local imbueItem = Item(item.uid)
self:sendImbuementPanel(imbueItem)
return true
end

function Player:clearImbuement(item, slot)
local slots = ItemType(item:getId()):getImbuingSlots()
if slots < slot then
self:sendImbuementResult(MESSAGEDIALOG_CLEARING_CHARM_ERROR, "Sorry, not possible.")
return false
end

if item:getTopParent() ~= self or item:getParent() == self then
self:sendImbuementResult(MESSAGEDIALOG_CLEARING_CHARM_ERROR,
"An error occurred while applying the clearing charm to the item.")
return false
end

-- slot is not used
local info = item:getImbuementDuration(slot)
if info == 0 then
self:sendImbuementResult(MESSAGEDIALOG_CLEARING_CHARM_ERROR,
"An error occurred while applying the clearing charm to the item.")
return false
end

local imbuement = item:getImbuement(slot)
if not self:removeMoneyBank(imbuement:getBase().removecust) then
self:sendImbuementResult(MESSAGEDIALOG_CLEARING_CHARM_ERROR,
"You don't have enough money " ..imbuement:getBase().removecust.. " gps.")
return false
end

if not item:cleanImbuement(slot) then
self:sendImbuementResult(MESSAGEDIALOG_CLEARING_CHARM_ERROR,
"An error occurred while applying the clearing charm to the item.")
return false
end

-- Update item
local nitem = Item(item.uid)
self:sendImbuementResult(MESSAGEDIALOG_CLEARING_CHARM_SUCCESS,
"Congratulations! You have successfully applied the clearing charm to your item.");
self:sendImbuementPanel(nitem)

return true
end