hectorgimenez / d2go

Utilities related to Diablo 2 Resurrected, written in Go. Just for fun
MIT License
14 stars 14 forks source link

D2Data and Quest data #9

Closed hectorgimenez closed 8 months ago

hectorgimenez commented 8 months ago

Fetch skill data from https://github.com/blizzhackers/d2data and read game quest status from game memory

iceisfun commented 7 months ago

the quests seem to be wrong (in their order) and flags too.. I had a quick look with a new character and watched the progression of flags changing and some of them are wrong too, however the memory region part works well and the u16 changes as the quest progresses, I did not see the u16 change when talking to npc for final reward.

I think unknown2 was triggered on quest discover?

If I find more time to examine this after other things are done I can post a new issue.

This is all for the leveling bit, I was only testing this for completeness finding useful pointers, the pattern for this is

pattern = "83 c4 20 5f c3 8b 63 ae 58 5c 3f 2a 19 48 8b 05"
offset = (patternaddr + 0x10).readuint32()
ptraddr = baseaddr + patternoffset + 0xc + offset

type QuestStatus struct {
    StatusRewardGranted           bool
    StatusRewardPending           bool
    StatusQuestInitiated          bool
    StatusLeaveTown               bool
    StatusEnterFirstArea          bool
    StatusInProgress1             bool
    StatusInProgress2             bool
    StatusInProgress3             bool
    StatusInProgress4             bool
    StatusInProgress5             bool
    StatusInProgress6             bool
    StatusInProgress7             bool
    StatusUpdateQuestLogCompleted bool
    StatusPrimaryGoalCompleted    bool
    StatusUnknown1                bool
    StatusUnknown2                bool // StatusDiscovered ?
    StatusDiscovered              bool
    States                        []int
}

func DecomposeQuestFlags(questStatusU16 uint16) QuestStatus {
    status := QuestStatus{}

    for i := 0; i < 16; i++ {
        if questStatusU16&(1<<(15-i)) != 0 {
            status.States = append(status.States, i)
            switch i {
            case 0:
                status.StatusRewardGranted = true
            case 1:
                status.StatusRewardPending = true
            case 2:
                status.StatusQuestInitiated = true
            case 3:
                status.StatusLeaveTown = true
            case 4:
                status.StatusEnterFirstArea = true
            case 5:
                status.StatusInProgress1 = true
            case 6:
                status.StatusInProgress2 = true
            case 7:
                status.StatusInProgress3 = true
            case 8:
                status.StatusInProgress4 = true
            case 9:
                status.StatusInProgress5 = true
            case 10:
                status.StatusInProgress6 = true
            case 11:
                status.StatusInProgress7 = true
            case 12:
                status.StatusUpdateQuestLogCompleted = true
            case 13:
                status.StatusPrimaryGoalCompleted = true
            case 14:
                status.StatusUnknown1 = true
            case 15:
                status.StatusUnknown2 = true
            }
        }
    }

    return status
}