Ejemplo n.º 1
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
}
Ejemplo n.º 2
0
func (g *Game) internalCreatureChangeVisible(_creature pul.ICreature, _visible bool) {
	list := _creature.GetVisibleCreatures()
	for _, tmpCreature := range list {
		if tmpCreature.GetType() == CTYPE_PLAYER {
			tmpCreature.(*Player).sendCreatureChangeVisibility(_creature, _visible)
		}
	}
}
Ejemplo n.º 3
0
func (g *Game) OnCreatureTurn(_creature pul.ICreature, _direction int) {
	if _creature.GetDirection() != _direction {
		_creature.SetDirection(_direction)

		visibleCreatures := _creature.GetVisibleCreatures()
		for _, value := range visibleCreatures {
			value.OnCreatureTurn(_creature)
		}
	}
}