func processRows(_map *Map) {

	_map.AddMap(0, "")
	tiles := _map.tiles[0]

	for {
		row := <-rowChan
		if row == nil {
			fmt.Println("Map IO Channel closed!")
			break
		}
		x := puh.DBGetInt(row[0])
		y := puh.DBGetInt(row[1])
		z := puh.DBGetInt(row[2])
		position := pos.NewPositionFrom(x, y, z)
		layer := puh.DBGetInt(row[7])
		sprite := puh.DBGetInt(row[6])
		blocking := puh.DBGetInt(row[4])
		// row `idteleport` may be null sometimes.
		var tp_id = 0
		if row[5] != nil {
			tp_id = puh.DBGetInt(row[5])
		}
		idlocation := puh.DBGetInt(row[3])

		tile, found := _map.GetTile(position.Hash())
		if found == false {
			tile = NewTile(position)
			tile.Blocking = blocking

			// Get location
			location, found := g_game.Locations.GetLocation(idlocation)
			if found {
				tile.Location = location
			}

			// Teleport event
			if tp_id > 0 {
				tp_x := puh.DBGetInt(row[8])
				tp_y := puh.DBGetInt(row[9])
				tp_z := puh.DBGetInt(row[10])
				tp_pos := pos.NewPositionFrom(tp_x, tp_y, tp_z)
				tile.AddEvent(NewWarp(tp_pos))
			}

			tiles[tile.Position.Hash()] = tile
		}

		tile.AddLayer(layer, sprite)
	}
}
Exemple #2
0
func (g *Game) internalCreatureSay(_creature pul.ICreature, _speakType int, _message string) bool {
	list := make(pul.CreatureList)
	if _speakType == pnet.SPEAK_YELL {
		position := _creature.GetPosition() // Get position of speaker

		g.mutexPlayerList.RLock()
		defer g.mutexPlayerList.RUnlock()
		for _, player := range g.Players {
			if player != nil {
				if position.IsInRange3p(player.GetPosition(), pos.NewPositionFrom(27, 21, 0)) {
					list[player.GetUID()] = player
				}
			}
		}
	} else {
		list = _creature.GetVisibleCreatures()
	}

	// Send chat message to all visible players
	for _, creature := range list {
		if creature.GetType() == CTYPE_PLAYER {
			player := creature.(*Player)
			// player.sendCreatureSay(_creature, _speakType, _message)
			player.sendToChannel(_creature, _speakType, _message, pnet.CHANNEL_LOCAL, 0)
		}
	}

	return true
}
func (io *IOMapDB2) processRows(_map *Map) {
	for {
		row := <-io.rowChan
		if row == nil {
			break
		}
		x := puh.DBGetInt(row[0])
		y := puh.DBGetInt(row[1])
		z := puh.DBGetInt(row[2])
		position := pos.NewPositionFrom(x, y, z)
		layer := puh.DBGetInt(row[7])
		sprite := puh.DBGetInt(row[6])
		blocking := puh.DBGetInt(row[4])
		// row `idteleport` may be null sometimes.
		var tp_id = 0
		if row[5] != nil {
			tp_id = puh.DBGetInt(row[5])
		}
		idlocation := puh.DBGetInt(row[3])

		tile, found := _map.GetTileFromPosition(position)
		if found == false {
			tile = NewTile(position)
			tile.Blocking = blocking

			// Get location
			location, found := g_game.Locations.GetLocation(idlocation)
			if found {
				tile.Location = location
			}

			// Teleport event
			if tp_id > 0 {
				tp_x := puh.DBGetInt(row[8])
				tp_y := puh.DBGetInt(row[9])
				tp_z := puh.DBGetInt(row[10])
				tp_pos := pos.NewPositionFrom(tp_x, tp_y, tp_z)
				tile.AddEvent(NewWarp(tp_pos))
			}

			_map.AddTile(tile)
		}

		tile.AddLayer(layer, sprite)
	}
}
Exemple #4
0
func (g *Game) playerWhisper(_player *Player, _text string) bool {
	list := _player.GetVisibleCreatures()
	position := _player.GetPosition()

	for _, creature := range list {
		if creature.GetType() == CTYPE_PLAYER {
			tmpPlayer := creature.(*Player)
			if position.IsInRange3p(tmpPlayer.GetPosition(), pos.NewPositionFrom(1, 1, 0)) {
				tmpPlayer.sendCreatureSay(_player, pnet.SPEAK_WHISPER, _text)
			}
		}
	}

	return true
}
Exemple #5
0
// NewTileExt creates a Position from _x, _y, _z and then calls NewTile to create a new Tile object
func NewTileExt(_x int, _y int, _z int) *Tile {
	return NewTile(pos.NewPositionFrom(_x, _y, _z))
}
Exemple #6
0
func (m *Map) GetTileFrom(_x, _y, _z int) (*Tile, bool) {
	position := pos.NewPositionFrom(_x, _y, _z)
	return m.GetTileFromPosition(position)
}