mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-18 02:16:23 -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
|
||||
Type ObjectType
|
||||
Id int
|
||||
Name string
|
||||
Description string
|
||||
ObjectsTxtId int
|
||||
MonstatsTxtId int
|
||||
|
@ -122,6 +122,10 @@ func (ds1 *DS1) loadObjects(br *d2common.StreamReader) {
|
||||
newObject.Flags = int(br.GetInt32())
|
||||
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 {
|
||||
newObject.ObjectInfo = d2datadict.Objects[newObject.Lookup.ObjectsTxtId]
|
||||
}
|
||||
|
@ -279,6 +279,7 @@ const (
|
||||
// --- Enemy Data ---
|
||||
|
||||
MonStats = "/data/global/excel/monstats.txt"
|
||||
MonPreset = "/data/global/excel/monpreset.txt"
|
||||
SuperUniques = "/data/global/excel/SuperUniques.txt"
|
||||
|
||||
// --- Skill Data ---
|
||||
|
@ -13,16 +13,17 @@ import (
|
||||
|
||||
type NPC struct {
|
||||
mapEntity
|
||||
composite *d2asset.Composite
|
||||
action int
|
||||
HasPaths bool
|
||||
Paths []d2common.Path
|
||||
path int
|
||||
isDone bool
|
||||
repetitions int
|
||||
direction int
|
||||
objectLookup *d2datadict.ObjectLookupRecord
|
||||
name string
|
||||
composite *d2asset.Composite
|
||||
action int
|
||||
HasPaths bool
|
||||
Paths []d2common.Path
|
||||
path int
|
||||
isDone bool
|
||||
repetitions int
|
||||
direction int
|
||||
objectLookup *d2datadict.ObjectLookupRecord
|
||||
monstatRecord *d2datadict.MonStatsRecord
|
||||
name string
|
||||
}
|
||||
|
||||
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.mapEntity.directioner = result.rotate
|
||||
result.monstatRecord = d2datadict.MonStats[object.Name]
|
||||
|
||||
switch object.Act {
|
||||
case 1:
|
||||
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"
|
||||
}
|
||||
if result.monstatRecord != nil && result.monstatRecord.IsInteractable {
|
||||
result.name = d2common.TranslateString(result.monstatRecord.NameStringTableKey)
|
||||
}
|
||||
|
||||
return result
|
||||
|
@ -1,10 +1,13 @@
|
||||
package d2mapentity
|
||||
|
||||
import (
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict"
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
|
||||
"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.
|
||||
@ -13,6 +16,7 @@ type Object struct {
|
||||
composite *d2asset.Composite
|
||||
direction int
|
||||
highlight bool
|
||||
nameLabel d2ui.Label
|
||||
objectRecord *d2datadict.ObjectRecord
|
||||
objectLookup *d2datadict.ObjectLookupRecord
|
||||
}
|
||||
@ -28,6 +32,7 @@ func CreateObject(x, y int, object *d2datadict.ObjectLookupRecord, palettePath s
|
||||
mapEntity: createMapEntity(x, y),
|
||||
composite: composite,
|
||||
objectLookup: object,
|
||||
nameLabel: d2ui.CreateLabel(d2resource.FontFormal11, d2resource.PaletteStatic),
|
||||
}
|
||||
entity.mapEntity.directioner = entity.rotate
|
||||
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),
|
||||
)
|
||||
if ob.highlight {
|
||||
ob.nameLabel.SetText(d2common.TranslateString(ob.objectRecord.Name))
|
||||
ob.nameLabel.SetPosition(-50, -50)
|
||||
ob.nameLabel.Render(target)
|
||||
target.PushBrightness(2)
|
||||
defer target.Pop()
|
||||
}
|
||||
|
2
main.go
2
main.go
@ -427,11 +427,11 @@ func loadDataDict() error {
|
||||
{d2resource.SoundSettings, d2datadict.LoadSounds},
|
||||
{d2resource.AnimationData, d2data.LoadAnimationData},
|
||||
{d2resource.MonStats, d2datadict.LoadMonStats},
|
||||
{d2resource.MonPreset, d2datadict.LoadMonPresets},
|
||||
{d2resource.MagicPrefix, d2datadict.LoadMagicPrefix},
|
||||
{d2resource.MagicSuffix, d2datadict.LoadMagicSuffix},
|
||||
{d2resource.ItemStatCost, d2datadict.LoadItemStatCosts},
|
||||
{d2resource.CharStats, d2datadict.LoadCharStats},
|
||||
{d2resource.MonStats, d2datadict.LoadMonStats},
|
||||
{d2resource.Hireling, d2datadict.LoadHireling},
|
||||
{d2resource.Experience, d2datadict.LoadExperienceBreakpoints},
|
||||
{d2resource.Gems, d2datadict.LoadGems},
|
||||
|
Loading…
Reference in New Issue
Block a user