Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Improve Temp Enchant handling #27

Merged
merged 6 commits into from
May 28, 2022
Merged

Conversation

insunaa
Copy link
Contributor

@insunaa insunaa commented May 25, 2022

This PR makes temporary enchants update almost properly (buff duration in the aura bar still only updates if some other buff is applied that forces an update).
This PR also allows cancelling temporary enchants (right-clicking the buff to remove the temporary enchant)

Co-authored-by: MaxtorCoder <warsongkiller.s8@gmail.com>
@insunaa
Copy link
Contributor Author

insunaa commented May 25, 2022

Not sure if this should be merged yet, as I haven't figured out why the buff duration doesn't update in the aura bar immediately, instead only after casting another buff...
Maybe this can be faked by sending an opcode both to the client and to the server, the latter one requesting an aura duration update... I'll look into it a bit, but no guarantees, also seems kinda dirty.

Edit: At least the 2.4.3 client automatically updates the time immediately.

I can't find the reason for why it's not updated immediately. I have checked against some data, but all of it says that things are as they should be. I'd appreciate if someone else could also take a look at this :)

Edit: OK, this might just be an Addon issue. Feel free to merge if you have confirmed that it works for you

Edit: It is and isn't an addon issue. The UNIT_AURA event that my addons use to hook into the buff/enchant duration timer isn't fired when casting Windfury Weapon, when it does fire on 2.5.4.

So now I'll need to figure out why UNIT_AURA isn't firing.

image

UNIT_AURA also isn't firing on 2.4.3, so either this is a server issue (we don't update auras when casting temporary enchantments like Windfury Weapon, or it's intended behaviour, and the addons are wrong.

@insunaa insunaa requested a review from MaxtorCoder May 25, 2022 17:11
@insunaa
Copy link
Contributor Author

insunaa commented May 25, 2022

OK, can confirm, the remaining issue (buff time not updating immediately) is serverside and can be solved serverside. This PR is unaffected by that and can be merged now without any reservations from my side

@insunaa
Copy link
Contributor Author

insunaa commented May 26, 2022

Something is still wrong, I'm not actually getting the combat log entries, still. Unfortunately I can't parse the .pkt logs either, so I don't know what's actually being sent which makes this not work.

Edit:
nvm, your packetparser works for me now
image
this is the packet that's sent to the client with the current version

which I'm guessing means that we're not finding the item in the equipped items list

            for (int i = 0; i < 23; i++)
            {
                Log.Print(LogType.Error, $"Entry: {session.GetInventorySlotItem(i).GetEntry()}, ID: {session.GetInventorySlotItem(i)} ");
                if (session.GetInventorySlotItem(i).GetEntry().Equals(enchantment.ItemID))
                {
                    enchantment.ItemGUID = session.GetInventorySlotItem(i).To128(session);
                    break;
                }
            }

always just results in the Entry being 0...

image

it's not like they're empty results, they're just results with no ItemID attached

@insunaa
Copy link
Contributor Author

insunaa commented May 26, 2022

OK, I've been going at this from the wrong direction, I see.
I can't generate an Entry out of the GUID which it's trying to do here.
Instead I have to have to get the Entry by finding the UpdateObject that is stored somewhere but who knows where and then extracting it.

I have literally no idea how to do that. I've tried in many different ways but my C# is lacking in this. At the very least there is no Cache for characters that stores any data even tangentially related to Item IDs. Even the ItemData class doesn't store the Item ID. The only place that stores the Entry is updateData.ObjectData.EntryID = updates[OBJECT_FIELD_ENTRY].Int32Value; which is impossible to get at unfortunately.

Gods I hate C#

Cannot implicitly convert type '(HermesProxy.World.WowGuid128, int OBJECT_FIELD_ENTRY)' to 'System.Collections.Generic.Dictionary<HermesProxy.World.WowGuid128, int>' [HermesProxy]

HOW ELSE AM I SUPPOSED TO CONSTRUCT AN F-ING DICTIONARY IN PLACE THEN?! FFS.

(This is obviously not directed at you fine folks who maintain this repo, but at Microsoft)

Edit:
I tried with

public List<(WowGuid128, int)> InvSlots = new List<(WowGuid128, int)>(23); // equipped gear and bags

and

updateData.ActivePlayerData.InvSlots[i] = (GetGuidValue(updates, PLAYER_FIELD_INV_SLOT_HEAD + i * 2).To128(GetSession().GameState), OBJECT_FIELD_ENTRY);

and

if (activeData.InvSlots[i].Item2.Equals(enchantment.ItemID))
{
    enchantment.ItemGUID = activeData.InvSlots[i].Item1;
    break;
}

Which in my mind should fix this issue, but I always get Index Out Of Bounds exceptions, so actually it does not.

@insunaa
Copy link
Contributor Author

insunaa commented May 26, 2022

StoreObjectUpdate() doesn't seem to extract the correct OBJECT_FIELD_ENTRY
image
This is how the OBJECT_FIELD_ENTRY is supposed to look like, what it actually looks like is 0

@insunaa
Copy link
Contributor Author

insunaa commented May 26, 2022

OK, all issues are resolved. In this state everything works as expected on 2.5.2
Please someone test on 1.14 :)

@insunaa insunaa requested a review from ratkosrb May 26, 2022 18:38
@ratkosrb ratkosrb merged commit 8e66880 into WowLegacyCore:master May 28, 2022
@insunaa insunaa deleted the temp_enchants branch May 28, 2022 06:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants