Some more character investigations
This commit is contained in:
@@ -102,5 +102,21 @@ func (m *Map) SpritesForCell(x, y, z int) ([]*Sprite, error) {
|
||||
sprites = append(sprites, sprite)
|
||||
}
|
||||
|
||||
// FIXME: this just marks character positions with sprite 19 for now.
|
||||
specialsObj, err := m.assets.Object("specials")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
chrSpr, err := specialsObj.Sprite(19)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, chr := range m.raw.Characters {
|
||||
if chr.XPos == x && chr.YPos == y && z == 1 { // FIXME: sort out ZPos
|
||||
sprites = append(sprites, chrSpr)
|
||||
}
|
||||
}
|
||||
|
||||
return sprites, nil
|
||||
}
|
||||
|
@@ -67,8 +67,9 @@ type GameMap struct {
|
||||
TrailerUnknown3 int `struc:"uint16"`
|
||||
TrailerUnknown4 int `struc:"uint32"`
|
||||
|
||||
NumThingies int `struc:"uint32"`
|
||||
Padding1 []byte `struc:"[20]byte"`
|
||||
NumThingies int `struc:"byte"`
|
||||
TrailerUnknown5 []byte `struc:"[3]byte"`
|
||||
Padding1 []byte `struc:"[20]byte"`
|
||||
|
||||
// FIXME: The rest is trash until Character & Thingy are worked out
|
||||
|
||||
@@ -79,7 +80,7 @@ type GameMap struct {
|
||||
Briefing string `struc:"[2048]byte"`
|
||||
|
||||
// Maybe? each contains either 0 or 1? Hard to say
|
||||
TrailerUnknown5 []byte `struc:"[85]byte"`
|
||||
TrailerUnknown6 []byte `struc:"[85]byte"`
|
||||
}
|
||||
|
||||
type Cell struct {
|
||||
@@ -98,7 +99,29 @@ type Cell struct {
|
||||
}
|
||||
|
||||
type Character struct {
|
||||
Unknown1 int `struc:"uint32"`
|
||||
Unknown1 []byte `struc:"[179]byte"`
|
||||
Name string `struc:"[80]byte"`
|
||||
|
||||
// Attributes guessed by matching up numbers. Starts at 0x103
|
||||
WeaponSkill int `struc:"byte"`
|
||||
BallisticSkill int `struc:"byte"`
|
||||
Unknown2 byte `struc:"byte"`
|
||||
Leadership int `struc:"byte"`
|
||||
Toughness int `struc:"byte"`
|
||||
Strength int `struc:"byte"`
|
||||
ActionPoints int `struc:"byte"`
|
||||
Unknown3 byte `struc:"byte"`
|
||||
Unknown4 byte `struc:"byte"`
|
||||
Health int `struc:"byte"`
|
||||
|
||||
Unknown5 []byte `struc:"[91]byte"`
|
||||
Armor int `struc:"byte"`
|
||||
Unknown6 []byte `struc:"[84]byte"`
|
||||
YPos int `struc:"byte"` // These are actually much more complicated
|
||||
XPos int `struc:"byte"`
|
||||
Unknown7 []byte `struc:"[317]byte"`
|
||||
SquadNumber byte `struc:"byte"`
|
||||
Unknown8 []byte `struc:"[927]byte"`
|
||||
// TODO: each character may have a fixed number of subrecords for inventory
|
||||
}
|
||||
|
||||
@@ -289,13 +312,38 @@ func loadMapFile(filename string) (*GameMap, error) {
|
||||
}
|
||||
|
||||
// Trim any trailing nulls off of the strings
|
||||
trimRight(&out.SetName)
|
||||
trimRight(&out.Title)
|
||||
trimRight(&out.Briefing)
|
||||
nullTerminate(&out.SetName)
|
||||
nullTerminate(&out.Title)
|
||||
nullTerminate(&out.Briefing)
|
||||
|
||||
for i, chr := range out.Characters {
|
||||
nullTerminate(&chr.Name)
|
||||
fmt.Printf("Character %v: %s\n", i, chr.String())
|
||||
}
|
||||
|
||||
fmt.Printf("Mission Title: %q\n", out.Title)
|
||||
fmt.Printf("Mission Briefing: %q\n", out.Briefing)
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func trimRight(s *string) {
|
||||
*s = strings.TrimRight(*s, "\x00")
|
||||
func nullTerminate(s *string) {
|
||||
sCpy := *s
|
||||
idx := strings.Index(sCpy, "\x00")
|
||||
if idx < 0 {
|
||||
return
|
||||
}
|
||||
|
||||
*s = sCpy[0:idx]
|
||||
}
|
||||
|
||||
func (c *Character) String() string {
|
||||
return fmt.Sprintf(
|
||||
"squad=%v pos=(%v,%v) name=%q\n\t%3d %3d %3d %3d %3d\n\t%3d %3d ??? ??? %3d\n",
|
||||
c.SquadNumber,
|
||||
c.XPos, c.YPos,
|
||||
c.Name,
|
||||
c.ActionPoints, c.Health, c.Armor, c.BallisticSkill, c.WeaponSkill,
|
||||
c.Strength, c.Toughness /*c.Initiative, c.Attacks,*/, c.Leadership,
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user