Beispiel #1
0
func (p *Player) OnCreatureMove(_creature pul.ICreature, _from pul.ITile, _to pul.ITile, _teleport bool) {
	if _creature.GetUID() == p.GetUID() {
		p.lastStep = PUSYS_TIME()
		return
	}

	from := _from.(*Tile)
	to := _to.(*Tile)

	canSeeFromTile := CanSeePosition(p.GetPosition(), from.Position)
	canSeeToTile := CanSeePosition(p.GetPosition(), to.Position)

	if canSeeFromTile && !canSeeToTile { // Leaving viewport
		p.sendCreatureMove(_creature, from, to)

		p.RemoveVisibleCreature(_creature)
		_creature.RemoveVisibleCreature(p)
	} else if canSeeToTile && !canSeeFromTile { // Entering viewport
		p.AddVisibleCreature(_creature)
		_creature.RemoveVisibleCreature(p)

		p.sendCreatureMove(_creature, from, to)
	} else { // Moving inside viewport
		p.AddVisibleCreature(_creature)
		_creature.AddVisibleCreature(p)

		p.sendCreatureMove(_creature, from, to)
	}
}
Beispiel #2
0
func (n *Npc) OnCreatureAppear(_creature pul.ICreature, _isLogin bool) {
	// Check if _creature is a Player, otherwise return
	if _creature.GetType() != CTYPE_PLAYER {
		return
	}

	canSeeCreature := CanSeeCreature(n, _creature)
	if !canSeeCreature {
		return
	}

	// We're checking the existence of _creature inside the AddVisibleCreature method
	// so no need to check here
	n.AddVisibleCreature(_creature)
	_creature.AddVisibleCreature(n)
}
Beispiel #3
0
func (p *Player) OnCreatureAppear(_creature pul.ICreature, _isLogin bool) {
	if _creature.GetUID() == p.GetUID() {
		return
	}

	if _isLogin {
		// Check if creature is in friendlist
		p.UpdateFriend(_creature.GetName(), true)
	}

	canSeeCreature := CanSeeCreature(p, _creature)
	if !canSeeCreature {
		return
	}

	// We're checking inside the AddVisibleCreature method so no need to check here
	p.AddVisibleCreature(_creature)
	_creature.AddVisibleCreature(p)
}
Beispiel #4
0
func (n *Npc) OnCreatureMove(_creature pul.ICreature, _from pul.ITile, _to pul.ITile, _teleport bool) {
	// Check if _creature is a Player, otherwise return
	if _creature.GetType() != CTYPE_PLAYER {
		return
	}

	canSeeFromTile := CanSeePosition(n.GetPosition(), _from.GetPosition())
	canSeeToTile := CanSeePosition(n.GetPosition(), _to.GetPosition())

	if canSeeFromTile && !canSeeToTile { // Leaving viewport
		n.RemoveVisibleCreature(_creature)
		_creature.RemoveVisibleCreature(n)
	} else if canSeeToTile && !canSeeFromTile { // Entering viewport
		n.AddVisibleCreature(_creature)
		_creature.RemoveVisibleCreature(n)
	} else { // Moving inside viewport
		n.AddVisibleCreature(_creature)
		_creature.AddVisibleCreature(n)
	}
}