mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-12-27 04:26:29 -05:00
Load monpreset and use that to find monstat entries for NPC's (#477)
* Load monpreset.txt * Get monstat for npc's and their name from strings Using monpreset to grab the key for monstat * Object name tags
This commit is contained in:
parent
b00fa58fc4
commit
3f1fe538e2
28
d2common/d2data/d2datadict/monpreset.go
Normal file
28
d2common/d2data/d2datadict/monpreset.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package d2datadict
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MonPresetRecord struct {
|
||||||
|
Act int
|
||||||
|
Place string
|
||||||
|
}
|
||||||
|
|
||||||
|
var MonPresets []MonPresetRecord
|
||||||
|
|
||||||
|
func LoadMonPresets(file []byte) {
|
||||||
|
dict := d2common.LoadDataDictionary(string(file))
|
||||||
|
numRecords := len(dict.Data)
|
||||||
|
MonPresets = make([]MonPresetRecord, numRecords)
|
||||||
|
for idx := range dict.Data {
|
||||||
|
record := MonPresetRecord{
|
||||||
|
Act: dict.GetNumber("Act", idx),
|
||||||
|
Place: dict.GetString("Place", idx),
|
||||||
|
}
|
||||||
|
MonPresets[idx] = record
|
||||||
|
}
|
||||||
|
log.Printf("Loaded %d MonPreset records", len(MonPresets))
|
||||||
|
}
|
@ -15,6 +15,7 @@ type ObjectLookupRecord struct {
|
|||||||
Act int
|
Act int
|
||||||
Type ObjectType
|
Type ObjectType
|
||||||
Id int
|
Id int
|
||||||
|
Name string
|
||||||
Description string
|
Description string
|
||||||
ObjectsTxtId int
|
ObjectsTxtId int
|
||||||
MonstatsTxtId int
|
MonstatsTxtId int
|
||||||
|
@ -122,6 +122,10 @@ func (ds1 *DS1) loadObjects(br *d2common.StreamReader) {
|
|||||||
newObject.Flags = int(br.GetInt32())
|
newObject.Flags = int(br.GetInt32())
|
||||||
newObject.Lookup = d2datadict.LookupObject(int(ds1.Act), newObject.Type, newObject.Id)
|
newObject.Lookup = d2datadict.LookupObject(int(ds1.Act), newObject.Type, newObject.Id)
|
||||||
|
|
||||||
|
if newObject.Lookup != nil && newObject.Type == 1 {
|
||||||
|
newObject.Lookup.Name = d2datadict.MonPresets[newObject.Id].Place
|
||||||
|
}
|
||||||
|
|
||||||
if newObject.Lookup != nil && newObject.Lookup.ObjectsTxtId != -1 {
|
if newObject.Lookup != nil && newObject.Lookup.ObjectsTxtId != -1 {
|
||||||
newObject.ObjectInfo = d2datadict.Objects[newObject.Lookup.ObjectsTxtId]
|
newObject.ObjectInfo = d2datadict.Objects[newObject.Lookup.ObjectsTxtId]
|
||||||
}
|
}
|
||||||
|
@ -279,6 +279,7 @@ const (
|
|||||||
// --- Enemy Data ---
|
// --- Enemy Data ---
|
||||||
|
|
||||||
MonStats = "/data/global/excel/monstats.txt"
|
MonStats = "/data/global/excel/monstats.txt"
|
||||||
|
MonPreset = "/data/global/excel/monpreset.txt"
|
||||||
SuperUniques = "/data/global/excel/SuperUniques.txt"
|
SuperUniques = "/data/global/excel/SuperUniques.txt"
|
||||||
|
|
||||||
// --- Skill Data ---
|
// --- Skill Data ---
|
||||||
|
@ -13,16 +13,17 @@ import (
|
|||||||
|
|
||||||
type NPC struct {
|
type NPC struct {
|
||||||
mapEntity
|
mapEntity
|
||||||
composite *d2asset.Composite
|
composite *d2asset.Composite
|
||||||
action int
|
action int
|
||||||
HasPaths bool
|
HasPaths bool
|
||||||
Paths []d2common.Path
|
Paths []d2common.Path
|
||||||
path int
|
path int
|
||||||
isDone bool
|
isDone bool
|
||||||
repetitions int
|
repetitions int
|
||||||
direction int
|
direction int
|
||||||
objectLookup *d2datadict.ObjectLookupRecord
|
objectLookup *d2datadict.ObjectLookupRecord
|
||||||
name string
|
monstatRecord *d2datadict.MonStatsRecord
|
||||||
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateNPC(x, y int, object *d2datadict.ObjectLookupRecord, direction int) *NPC {
|
func CreateNPC(x, y int, object *d2datadict.ObjectLookupRecord, direction int) *NPC {
|
||||||
@ -39,25 +40,10 @@ func CreateNPC(x, y int, object *d2datadict.ObjectLookupRecord, direction int) *
|
|||||||
}
|
}
|
||||||
result.SetMode(object.Mode, object.Class, direction)
|
result.SetMode(object.Mode, object.Class, direction)
|
||||||
result.mapEntity.directioner = result.rotate
|
result.mapEntity.directioner = result.rotate
|
||||||
|
result.monstatRecord = d2datadict.MonStats[object.Name]
|
||||||
|
|
||||||
switch object.Act {
|
if result.monstatRecord != nil && result.monstatRecord.IsInteractable {
|
||||||
case 1:
|
result.name = d2common.TranslateString(result.monstatRecord.NameStringTableKey)
|
||||||
switch object.Id {
|
|
||||||
case 0:
|
|
||||||
result.name = "Gheed"
|
|
||||||
case 1:
|
|
||||||
result.name = "Cain"
|
|
||||||
case 2:
|
|
||||||
result.name = "Akara"
|
|
||||||
case 5:
|
|
||||||
result.name = "Kashya"
|
|
||||||
case 7:
|
|
||||||
result.name = "Warriv"
|
|
||||||
case 8:
|
|
||||||
result.name = "Charsi"
|
|
||||||
case 9:
|
|
||||||
result.name = "Andariel"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package d2mapentity
|
package d2mapentity
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2render"
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2render"
|
||||||
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Object represents a composite of animations that can be projected onto the map.
|
// Object represents a composite of animations that can be projected onto the map.
|
||||||
@ -13,6 +16,7 @@ type Object struct {
|
|||||||
composite *d2asset.Composite
|
composite *d2asset.Composite
|
||||||
direction int
|
direction int
|
||||||
highlight bool
|
highlight bool
|
||||||
|
nameLabel d2ui.Label
|
||||||
objectRecord *d2datadict.ObjectRecord
|
objectRecord *d2datadict.ObjectRecord
|
||||||
objectLookup *d2datadict.ObjectLookupRecord
|
objectLookup *d2datadict.ObjectLookupRecord
|
||||||
}
|
}
|
||||||
@ -28,6 +32,7 @@ func CreateObject(x, y int, object *d2datadict.ObjectLookupRecord, palettePath s
|
|||||||
mapEntity: createMapEntity(x, y),
|
mapEntity: createMapEntity(x, y),
|
||||||
composite: composite,
|
composite: composite,
|
||||||
objectLookup: object,
|
objectLookup: object,
|
||||||
|
nameLabel: d2ui.CreateLabel(d2resource.FontFormal11, d2resource.PaletteStatic),
|
||||||
}
|
}
|
||||||
entity.mapEntity.directioner = entity.rotate
|
entity.mapEntity.directioner = entity.rotate
|
||||||
entity.objectRecord = d2datadict.Objects[object.ObjectsTxtId]
|
entity.objectRecord = d2datadict.Objects[object.ObjectsTxtId]
|
||||||
@ -75,6 +80,9 @@ func (ob *Object) Render(target d2render.Surface) {
|
|||||||
ob.offsetY+int(((ob.subcellX+ob.subcellY)*8)-5),
|
ob.offsetY+int(((ob.subcellX+ob.subcellY)*8)-5),
|
||||||
)
|
)
|
||||||
if ob.highlight {
|
if ob.highlight {
|
||||||
|
ob.nameLabel.SetText(d2common.TranslateString(ob.objectRecord.Name))
|
||||||
|
ob.nameLabel.SetPosition(-50, -50)
|
||||||
|
ob.nameLabel.Render(target)
|
||||||
target.PushBrightness(2)
|
target.PushBrightness(2)
|
||||||
defer target.Pop()
|
defer target.Pop()
|
||||||
}
|
}
|
||||||
|
2
main.go
2
main.go
@ -427,11 +427,11 @@ func loadDataDict() error {
|
|||||||
{d2resource.SoundSettings, d2datadict.LoadSounds},
|
{d2resource.SoundSettings, d2datadict.LoadSounds},
|
||||||
{d2resource.AnimationData, d2data.LoadAnimationData},
|
{d2resource.AnimationData, d2data.LoadAnimationData},
|
||||||
{d2resource.MonStats, d2datadict.LoadMonStats},
|
{d2resource.MonStats, d2datadict.LoadMonStats},
|
||||||
|
{d2resource.MonPreset, d2datadict.LoadMonPresets},
|
||||||
{d2resource.MagicPrefix, d2datadict.LoadMagicPrefix},
|
{d2resource.MagicPrefix, d2datadict.LoadMagicPrefix},
|
||||||
{d2resource.MagicSuffix, d2datadict.LoadMagicSuffix},
|
{d2resource.MagicSuffix, d2datadict.LoadMagicSuffix},
|
||||||
{d2resource.ItemStatCost, d2datadict.LoadItemStatCosts},
|
{d2resource.ItemStatCost, d2datadict.LoadItemStatCosts},
|
||||||
{d2resource.CharStats, d2datadict.LoadCharStats},
|
{d2resource.CharStats, d2datadict.LoadCharStats},
|
||||||
{d2resource.MonStats, d2datadict.LoadMonStats},
|
|
||||||
{d2resource.Hireling, d2datadict.LoadHireling},
|
{d2resource.Hireling, d2datadict.LoadHireling},
|
||||||
{d2resource.Experience, d2datadict.LoadExperienceBreakpoints},
|
{d2resource.Experience, d2datadict.LoadExperienceBreakpoints},
|
||||||
{d2resource.Gems, d2datadict.LoadGems},
|
{d2resource.Gems, d2datadict.LoadGems},
|
||||||
|
Loading…
Reference in New Issue
Block a user