From 19376148b3104a90fb5006127c75c62576daad20 Mon Sep 17 00:00:00 2001 From: elb <51070858+elobo91@users.noreply.github.com> Date: Wed, 2 Oct 2024 18:29:40 -0400 Subject: [PATCH] Added modes to player (#44) * Added States for monsters and corpses Now can properly identify if a corpse is interactable with a skill ( barbarian, necromancer) Also getting states about monsters : Exemple Soul Killer with Conviction aura: State 28 // conviction Also can tell if monster has a state after you used a skill on it Exemple: State 56 Terror ( After using Barbarian skill Howl to fear ) Another Exemple using Grief on Mephistos he now have states : 2 poison 52 Preventheal will be very useful for further development. * Added modes to player Now accessible in koolo using : s.data.PlayerUnit.Mode Those are Modes for player: const Death: 0; const StandingOutsideTown: 1; const Walking: 2; const Running: 3; const GettingHit: 4; const StandingInTown: 5; const WalkingInTown: 6; const Attacking1: 7; const Attacking2: 8; const Blocking: 9; const CastingSkill: 10; const ThrowingItem: 11; const Kicking: 12; const UsingSkill1: 13; const UsingSkill2: 14; const UsingSkill3: 15; const UsingSkill4: 16; const Dead: 17; const SkillActionSequence: 18; const KnockedBack: 19; * update Added alias(const) for player modes can be used like this s.data.PlayerUnit.Mode == mode.StandingInTown --- pkg/data/data.go | 2 ++ pkg/data/mode/player_mode.go | 26 ++++++++++++++++++++++++++ pkg/memory/player.go | 4 ++++ pkg/memory/player_unit.go | 2 ++ 4 files changed, 34 insertions(+) create mode 100644 pkg/data/mode/player_mode.go diff --git a/pkg/data/data.go b/pkg/data/data.go index dcbb68a..8697386 100644 --- a/pkg/data/data.go +++ b/pkg/data/data.go @@ -1,6 +1,7 @@ package data import ( + "github.com/hectorgimenez/d2go/pkg/data/mode" "math" "strings" @@ -161,6 +162,7 @@ type PlayerUnit struct { LeftSkill skill.ID RightSkill skill.ID AvailableWaypoints []area.ID // Is only filled when WP menu is open and only for the specific selected tab + Mode mode.PlayerMode } func (pu PlayerUnit) FindStat(id stat.ID, layer int) (stat.Data, bool) { diff --git a/pkg/data/mode/player_mode.go b/pkg/data/mode/player_mode.go new file mode 100644 index 0000000..7e45451 --- /dev/null +++ b/pkg/data/mode/player_mode.go @@ -0,0 +1,26 @@ +package mode + +type PlayerMode uint32 + +const ( + Death PlayerMode = iota + StandingOutsideTown + Walking + Running + GettingHit + StandingInTown + WalkingInTown + Attacking1 + Attacking2 + Blocking + CastingSkill + ThrowingItem + Kicking + UsingSkill1 + UsingSkill2 + UsingSkill3 + UsingSkill4 + Dead + SkillActionSequence + KnockedBack +) diff --git a/pkg/memory/player.go b/pkg/memory/player.go index 8ba9514..2bbae4b 100644 --- a/pkg/memory/player.go +++ b/pkg/memory/player.go @@ -2,6 +2,7 @@ package memory import ( "encoding/binary" + "github.com/hectorgimenez/d2go/pkg/data/mode" "github.com/hectorgimenez/d2go/pkg/data" "github.com/hectorgimenez/d2go/pkg/data/area" @@ -46,6 +47,7 @@ func (gd *GameReader) GetRawPlayerUnits() RawPlayerUnits { baseStats := gd.getStatsList(statsListExPtr + 0x30) stats := gd.getStatsList(statsListExPtr + 0x88) states := gd.GetStates(statsListExPtr) + playerMode := mode.PlayerMode(gd.Process.ReadUInt(playerUnit+0x0c, Uint32)) rawPlayerUnits = append(rawPlayerUnits, RawPlayerUnit{ UnitID: data.UnitID(unitID), @@ -62,6 +64,7 @@ func (gd *GameReader) GetRawPlayerUnits() RawPlayerUnits { States: states, Stats: stats, BaseStats: baseStats, + Mode: playerMode, }) playerUnit = uintptr(gd.Process.ReadUInt(playerUnit+0x150, Uint64)) } @@ -111,6 +114,7 @@ func (gd *GameReader) GetPlayerUnit(mainPlayerUnit RawPlayerUnit) data.PlayerUni LeftSkill: skill.ID(leftSkillId), RightSkill: skill.ID(rightSkillId), AvailableWaypoints: availableWPs, + Mode: mainPlayerUnit.Mode, } return d diff --git a/pkg/memory/player_unit.go b/pkg/memory/player_unit.go index 1c2b9f4..0e03274 100644 --- a/pkg/memory/player_unit.go +++ b/pkg/memory/player_unit.go @@ -3,6 +3,7 @@ package memory import ( "github.com/hectorgimenez/d2go/pkg/data" "github.com/hectorgimenez/d2go/pkg/data/area" + "github.com/hectorgimenez/d2go/pkg/data/mode" "github.com/hectorgimenez/d2go/pkg/data/stat" "github.com/hectorgimenez/d2go/pkg/data/state" ) @@ -19,6 +20,7 @@ type RawPlayerUnit struct { States state.States Stats stat.Stats BaseStats stat.Stats + Mode mode.PlayerMode } type RawPlayerUnits []RawPlayerUnit