Exemple #1
0
func player_walk(player player.Player, packet encoding.Decodable) {
	var walkPacket *game_protocol.InboundPlayerWalkBlock
	switch p := packet.(type) {
	case *game_protocol.InboundPlayerWalk:
		walkPacket = (*game_protocol.InboundPlayerWalkBlock)(p)
	case *game_protocol.InboundPlayerWalkMap:
		walkPacket = (*game_protocol.InboundPlayerWalkBlock)(p)
	default:
		panic(fmt.Sprintf("got invalid walk packet: %T", p))
	}

	height := player.Position().Z()
	origin := position.NewAbsolute(int(walkPacket.OriginX), int(walkPacket.OriginY), height)

	waypoints := make([]*position.Absolute, len(walkPacket.Waypoints))

	wpq := player.WaypointQueue()
	wpq.Clear()
	wpq.Push(origin)
	for i, wp := range walkPacket.Waypoints {
		x1, y1 := int(wp.X), int(wp.Y)
		x2, y2 := int(origin.X()), int(origin.Y())
		waypoints[i] = position.NewAbsolute(int(x1+x2), int(y1+y2), height)

		wpq.Push(waypoints[i])
	}
}
Exemple #2
0
func jsonObjToProfile(p *Profile, js jsonProfile) {
	/*
		Don't set the username or password, because the Profile will have been constructed with the correct values
			p.setUsername(js.Username)
			p.setPassword(js.Password)
	*/

	p.setRights(js.Rights)
	p.SetPosition(position.NewAbsolute(js.Position.X, js.Position.Y, js.Position.Z))

	skills := p.Skills().(*Skills)
	skills.setCombatLevel(js.Skills.CombatLevel)

	appearance := p.Appearance().(*Appearance)
	appearance.setGender(js.Appearance.Gender)
	appearance.setHeadIcon(js.Appearance.HeadIcon)

	appearance.setModel(player.Torso, js.Appearance.TorsoModel)
	appearance.setModel(player.Arms, js.Appearance.ArmsModel)
	appearance.setModel(player.Legs, js.Appearance.LegsModel)
	appearance.setModel(player.Head, js.Appearance.HeadModel)
	appearance.setModel(player.Hands, js.Appearance.HandsModel)
	appearance.setModel(player.Feet, js.Appearance.FeetModel)
	appearance.setModel(player.Beard, js.Appearance.BeardModel)

	appearance.setColor(player.Hair, js.Appearance.HairColor)
	appearance.setColor(player.Torso, js.Appearance.TorsoColor)
	appearance.setColor(player.Legs, js.Appearance.LegsColor)
	appearance.setColor(player.Feet, js.Appearance.FeetColor)
	appearance.setColor(player.Skin, js.Appearance.SkinColor)
}
Exemple #3
0
// NewGameClient constructs a new GameClient
func (client *Player) Init(conn *server.Connection, worldInst *world.Instance) {
	client.Connection = conn
	client.world = worldInst
	client.serverRandKey = []uint32{
		uint32(rand.Int31()), uint32(rand.Int31()),
	}

	nilPosition := position.NewAbsolute(0, 0, 0)
	client.sector = worldInst.Sector(nilPosition.Sector())
	client.loadedRegion = nilPosition.RegionOf()

	wpq := entityimpl.NewSimpleWaypointQueue()
	client.GenericMob = entityimpl.NewGenericMob(wpq)

	client.animations = NewAnimations()
	client.index = entity.NextIndex()
}
Exemple #4
0
func TestSnapshot(t *testing.T) {
	lock := py.NewLock()
	defer lock.Unlock()

	dummyPos := position.NewAbsolute(3500, 3500, 1)

	dummyPlayer := &PlayerSnapshot{
		flags:        entity.MobFlagWalkUpdate,
		loadedRegion: dummyPos.RegionOf(),
		profile: &ProfileSnapshot{
			username: "******",
			password: "******",
			rights:   RightsPlayer,
			pos:      dummyPos,

			skills: &SkillsSnapshot{
				combatLevel: 8,
			},
			appearance: &AppearanceSnapshot{
				gender:   1,
				headIcon: 1,
				models:   map[BodyPart]int{},
				colors:   map[BodyPart]int{},
			},
		},
		animations: &AnimationsSnapshot{
			anims: map[Anim]int{},
		},
		waypointQueue: &WaypointQueueSnapshot{
			currentDirection: 1,
			lastDirection:    2,
		},
	}

	snapshot := Snapshot(dummyPlayer)

	if !comparePlayers(dummyPlayer, snapshot) {
		t.Error("snapshotted player didn't match")
	}
}