Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions internal/character_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ func SendParameterChunk(ctx context.Context, c *Client, chunkData []byte, chunk
})
}

func IsForce(charPkt *commands.CharacterSummary) bool {
return charPkt.Visual.ClassFlags > 80
}

// Performs a create or update/delete depending on whether the user followed the
// "dressing room" or "recreate" flows (as indicated by a client flag).
func (s *CharacterServer) handleCharacterUpdate(ctx context.Context, c *Client, charPkt *commands.CharacterSummary) error {
Expand Down Expand Up @@ -506,7 +510,6 @@ func (s *CharacterServer) handleCharacterUpdate(ctx context.Context, c *Client,
},
// Set the character's attributes directly from the preview packet.
Visual: charPkt.Visual,
// TechLevels:
},
Signature: 0xC87ED5B1,
OptionFlags: 0x00040058,
Expand All @@ -516,7 +519,7 @@ func (s *CharacterServer) handleCharacterUpdate(ctx context.Context, c *Client,

visualConfig := DefaultVisualConfigHunterRanger
// TODO: Sooner or later probably ought to add constants for the classes.
if charPkt.Visual.ClassFlags == 0x80 {
if IsForce(charPkt) {
visualConfig = DefaultVisualConfigForce
}
copy(newCharacter.DisplayData.Config[:], visualConfig)
Expand All @@ -528,8 +531,32 @@ func (s *CharacterServer) handleCharacterUpdate(ctx context.Context, c *Client,
// Set up the starting inventory.
copied := copy(newCharacter.Inventory.Items[:], DefaultInventory[:])
copied += copy(newCharacter.Inventory.Items[copied:], DefaultWeaponsByClass[int(charPkt.Visual.Class)])

colorIdx := charPkt.Visual.Costume
if class := charPkt.Visual.Class; class == 2 || class == 4 || class == 5 || class == 9 {
colorIdx = charPkt.Visual.Skin
}

// Set up the starting Mag.
mag := DefaultMag
mag.Item.Data2[3] = DefaultMagColors[charPkt.Visual.Class][colorIdx]

copied += copy(newCharacter.Inventory.Items[copied:], []commands.CharacterInventoryItem{mag})
newCharacter.Inventory.NumItems = uint8(copied)

// All characters start with no techniques.
techLevels := [20]uint8{}
for i := range techLevels {
// disabled
techLevels[i] = 0xFF
}

// Forces, however, start with Foie.
if IsForce(charPkt) {
techLevels[0] = 0x00
}
copy(newCharacter.DisplayData.TechLevels[:], techLevels[:])

// We're done, persist the new character.
err = shipgate.Shipgate.UpsertCharacter(ctx, c.Account.ID, charPkt.Slot, newCharacter)
if err != nil {
Expand Down
15 changes: 15 additions & 0 deletions internal/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,18 @@ var DefaultVisualConfigForce = []uint8{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}

var DefaultMagColors = [][]uint8{
{0x09, 0x01, 0x02, 0x11, 0x0A, 0x05, 0x06, 0x0B, 0x05, 0x00, 0x07, 0x0B, 0x0C, 0x04, 0x05, 0x06, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x01, 0x02, 0x11, 0x04, 0x05, 0x06, 0x08, 0x11, 0x0D, 0x01, 0x02, 0x0C, 0x04, 0x05, 0x06, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x01, 0x02, 0x11, 0x04, 0x0E, 0x06, 0x01, 0x0E, 0x09, 0x07, 0x02, 0x11, 0x04, 0x05, 0x06, 0x04, 0x11, 0x0D, 0x01, 0x0B, 0x11, 0x0D, 0x05, 0x06},
{0x00, 0x01, 0x0B, 0x11, 0x04, 0x05, 0x06, 0x0F, 0x05, 0x09, 0x07, 0x02, 0x11, 0x04, 0x05, 0x0F, 0x06, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x01, 0x0B, 0x11, 0x0A, 0x05, 0x06, 0x06, 0x09, 0x09, 0x01, 0x02, 0x11, 0x0A, 0x0E, 0x06, 0x01, 0x04, 0x0D, 0x07, 0x01, 0x0C, 0x0A, 0x05, 0x06},
{0x10, 0x07, 0x02, 0x11, 0x0A, 0x05, 0x0A, 0x00, 0x07, 0x00, 0x01, 0x08, 0x11, 0x04, 0x09, 0x0F, 0x0D, 0x02, 0x0A, 0x07, 0x02, 0x0C, 0x04, 0x0E, 0x0E},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x10, 0x01, 0x00, 0x07, 0x02, 0x0C, 0x04, 0x05, 0x06, 0x10, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x0D, 0x01, 0x02, 0x11, 0x04, 0x05, 0x06, 0x00, 0x11, 0x08, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x04, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x10, 0x05, 0x09, 0x01, 0x0B, 0x0C, 0x04, 0x05, 0x06, 0x0E, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x01, 0x02, 0x0C, 0x04, 0x05, 0x0F, 0x0A, 0x04, 0x0D, 0x01, 0x08, 0x11, 0x04, 0x05, 0x0F, 0x05, 0x10, 0x10, 0x07, 0x02, 0x0B, 0x0A, 0x0A, 0x0F},
{0x00, 0x01, 0x0B, 0x0C, 0x04, 0x05, 0x06, 0x08, 0x0A, 0x0D, 0x07, 0x02, 0x11, 0x0A, 0x05, 0x06, 0x01, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x07, 0x02, 0x11, 0x04, 0x05, 0x06, 0x09, 0x0C, 0x00, 0x01, 0x02, 0x11, 0x0D, 0x05, 0x10, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
}
3 changes: 2 additions & 1 deletion internal/items.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ var DefaultInventory = []commands.CharacterInventoryItem{
{Item: NewItemData(0x0301000000040000, 0)},
{Item: NewItemData(0x0300000000040000, 0)},
{Item: NewItemData(0x0101000000000000, 0), Flags: commands.ItemFlagEquipped},
{Item: NewItemData(0x02000500F4010000, 0x0000000028000012), Flags: commands.ItemFlagEquipped},
}

var DefaultMag = commands.CharacterInventoryItem{Item: NewItemData(0x02000500F4010000, 0x0000000028000012), Flags: commands.ItemFlagEquipped}

// DefaultWeaponsByClass are the class specific starting weapons, in canonical order of class.
var DefaultWeaponsByClass = [][]commands.CharacterInventoryItem{
{{Item: NewItemData(0x0001000000000000, 0), Flags: commands.ItemFlagEquipped}},
Expand Down
Loading