func (m *NpcList) LoadNpcList() (bool, string) { var entities []models.NpcJoinOutfitJoinEvent err := g_orm.SetTable("npc").Join("INNER", "npc_outfit", "npc_outfit.Idnpc = npc.Idnpc").Join(" INNER", "npc_events", "npc_events.Idnpc = npc.Idnpc").FindAll(&entities) if err != nil { return false, err.Error() } for _, entity := range entities { // Create new NPC object with data from database npc := NewNpc() npc.IsNew = false npc.DbId = int64(entity.Idnpc) npc.Name = entity.Name npc.SetOutfitPart(pul.OUTFIT_HEAD, entity.Head) npc.SetOutfitPart(pul.OUTFIT_NEK, entity.Nek) npc.SetOutfitPart(pul.OUTFIT_UPPER, entity.Upper) npc.SetOutfitPart(pul.OUTFIT_LOWER, entity.Lower) npc.SetOutfitPart(pul.OUTFIT_FEET, entity.Feet) positionHash := entity.Position npc.Position = pos.NewPositionFromHash(positionHash) npc.Events = entity.Event npc.EventInitId = entity.Initid // Load NPC pokemon npc.LoadPokemon() // Save in Npc map m.Npcs[npc.DbId] = npc } return true, "" }
func (m *Map) GetTile(_hash int64) (*Tile, bool) { mapId := pos.NewPositionFromHash(_hash).Z tiles := m.tileMap[mapId] if tiles == nil { tiles = make(map[int64]*Tile) } tile, found := tiles[_hash] return tile, found }
func (c *Client) SendPokecenterList() { packet := NewPacketExt(HEADER_SEND_POKECENTER_LIST) packet.AddUint16(uint16(len(g_locations.locations))) for index, pokecenter := range g_locations.pokecenters { packet.AddUint16(uint16(index)) position := pos.NewPositionFromHash(pokecenter.Position) packet.AddUint16(uint16(position.X)) packet.AddUint16(uint16(position.Y)) packet.AddUint16(uint16(position.Z)) packet.AddString(pokecenter.Description) } c.Send(packet) }