-
ThulsaDoom
- Posts: 131
- Joined: Mon Oct 19, 2015 2:46 pm
#1
Post
by ThulsaDoom » Wed Oct 27, 2021 5:11 am
Before I was using this code to check main hand dura, then depending on result, to fo for repair.
Code: Select all
local dura = inventory:getMainHandDurability()
printf("Durability:%s\n", dura);
if ( 99 > dura ) then
__WPL:setWaypointIndex(__WPL:findWaypointTag("repair"));
else
__WPL:setWaypointIndex(__WPL:findWaypointTag("direct"));
end
Now is not working anymore.
The function "inventory:getMainHandDurability()" returns a value that is not correct: -269446252, in the case of a 104 dura in mainhand.
Do I need to call in diferent way the function or is an address problem?
Many thnaks
-
Administrator
- Site Admin
- Posts: 5317
- Joined: Sat Jan 05, 2008 4:21 pm
#2
Post
by Administrator » Wed Oct 27, 2021 4:19 pm
This wasn't a mistake on your end. I've provided an update that should resolve this issue. It isn't always accurate (some items have the durability available on the item struct, while others have a seemingly random value and use a durability of 80 -- exactly what determines which value to use is unknown) but should be good enough.
If you update your scripts, things should be working.
-
ThulsaDoom
- Posts: 131
- Joined: Mon Oct 19, 2015 2:46 pm
#4
Post
by ThulsaDoom » Wed Jun 15, 2022 6:22 am
It seems "inventory:getMainHandDurability()" It does not return a correct value.
Please, cannyou have a look?
Thanks a lot.
-
Administrator
- Site Admin
- Posts: 5317
- Joined: Sat Jan 05, 2008 4:21 pm
#5
Post
by Administrator » Thu Jun 16, 2022 3:34 pm
Could I get some more information? It seems to be having acceptably to me.
My mainhand has a durability of 76/100.
inventory:getMainHandDurability()
returns
76.15
If I had to guess, one thing that could be causing issues for you is that the max durability for items isn't reliably stored with the item itself. In other words, sometimes the "max durability" of an item in the game's memory is actually the durability, and sometimes it is just "0" even though the item does indeed have some max durability; it would need to be read from somewhere else. As a cheat, I've added some pretty dumb logic to cover for those cases and take a best guess at what the max durability of an item should be.
-
ThulsaDoom
- Posts: 131
- Joined: Mon Oct 19, 2015 2:46 pm
#6
Post
by ThulsaDoom » Sun Jun 19, 2022 4:06 am
Before it was getting 0.
Now it's getting a number that seems to be a ratio, the ratio of maximum durability to current durability.
This number is never equal to Durability and varies based on the maximum Durability of the weapon.
For each character and weapon, I have identified the number that the function returns when the durability is negative.
Use the following function to determine if the character's maihand weapon has no durability
Code: Select all
function checkDura()
local dura = inventory:getMainHandDurability()
local nodura = false
repeat myClass=RoMScript("UnitClass('player')"); until myClass
if player.Name=="pj1" then
if ( 94 > dura ) then
nodura = true
end
elseif player.Name=="pj2" then
if myClass=="Rogue" then
if ( 98 > dura ) then
nodura = true
end
end
elseif player.Name=="pj3" then
if myClass=="Rogue" then
if ( 99 > dura ) then
nodura = true
end
elseif myClass=="Kinght" then
nodura = true
end
elseif player.Name=="pj4" then
if myClass=="Druid" then
if ( 88 > dura ) then
nodura = true
end
end
elseif player.Name=="pj5" then
if myClass=="Warden" then
if ( 98 > dura ) then
nodura = true
end
end
end
return nodura
end
So for now the function works fine for me.
Thank you
-
Administrator
- Site Admin
- Posts: 5317
- Joined: Sat Jan 05, 2008 4:21 pm
#7
Post
by Administrator » Sun Jun 19, 2022 6:40 am
Indeed,
getMainHandDurability()
and
getDurability()
actually return the percentage. It's goofy, but it was what I found when I had to pick up maintaining the scripts and didn't want to break compatibility.
It looks like you should be able to get the real (non-percentage) durability with:
Code: Select all
equipment.BagSlot[15]:update()
local dura = equipment.BagSlot[15].Durability
Where `15` is the index for main hand in equipment, `16` for offhand, and `10` for ranged.
-
ThulsaDoom
- Posts: 131
- Joined: Mon Oct 19, 2015 2:46 pm
#8
Post
by ThulsaDoom » Mon Jun 20, 2022 2:53 pm
Tested, worked perfectly, getting the real Durability.
Thank you
Who is online
Users browsing this forum: No registered users and 2 guests