Having fun spawning things
This commit is contained in:
parent
88573a22b2
commit
d946f792cd
@ -531,10 +531,16 @@ class Netserver(asyncio.DatagramProtocol):
|
|||||||
logger.debug("Fuck that no player wtf man")
|
logger.debug("Fuck that no player wtf man")
|
||||||
return
|
return
|
||||||
p = Packet(payload)
|
p = Packet(payload)
|
||||||
opcode = p.getShort()
|
opcode = p.getByte()
|
||||||
unknown1 = p.getULong()
|
length = p.getByte() # length?
|
||||||
unknown2 = p.getULong()
|
unknown1 = p.getByte()
|
||||||
unknown3 = p.getULong()
|
unknown2 = p.getByte()
|
||||||
|
unknown3 = p.getByte()
|
||||||
|
playerindex = p.getByte()
|
||||||
|
objid = p.getShort()
|
||||||
|
unknown5 = p.getByte()
|
||||||
|
unknown6 = p.getByte()
|
||||||
|
model = p.getULong()
|
||||||
playerx = p.getFloat()
|
playerx = p.getFloat()
|
||||||
playery = p.getFloat()
|
playery = p.getFloat()
|
||||||
playerz = p.getFloat()
|
playerz = p.getFloat()
|
||||||
@ -542,16 +548,19 @@ class Netserver(asyncio.DatagramProtocol):
|
|||||||
unknown5 = p.getULong()
|
unknown5 = p.getULong()
|
||||||
unknown6 = p.getULong()
|
unknown6 = p.getULong()
|
||||||
unknown7 = p.getULong()
|
unknown7 = p.getULong()
|
||||||
unknown8 = p.getULong()
|
orientation = p.getULong() # orientation
|
||||||
unknown9 = p.getULong()
|
unknown9 = p.getULong()
|
||||||
|
|
||||||
player.x = playerx
|
player.x = playerx
|
||||||
player.y = playery
|
player.y = playery
|
||||||
player.z = playerz
|
player.z = playerz
|
||||||
|
player.oid = objid
|
||||||
|
player.o = orientation
|
||||||
|
|
||||||
#logger.info("%s is now at coords (%s,%s,%s)", player.name, player.x, player.y, player.z)
|
#logger.info("%s is now at coords (%s,%s,%s)", player.name, player.x, player.y, player.z)
|
||||||
#await self.server.broadcast_message("%s is now at coords (%s,%s,%s)" % (player.name, player.x, player.y, player.z))
|
await self.server.broadcast_message("%s is now at coords (%s,%s,%s, %s). Model: %s" % (player.name, player.x, player.y, player.z, player.o, model))
|
||||||
await player.session.send_gamedata(b"", acknow=False)
|
#await self.server.broadcast_message("(%s,%s,%s, %s,%s)" % (unknown4, unknown5, unknown6, unknown7, unknown9))
|
||||||
|
|
||||||
elif payload[0] == 0x3a:
|
elif payload[0] == 0x3a:
|
||||||
# CLIENT EXITED
|
# CLIENT EXITED
|
||||||
player = self.get_player(session)
|
player = self.get_player(session)
|
||||||
|
@ -31,6 +31,8 @@ class Map:
|
|||||||
return b"\xc7\x5f\x61\x1f"
|
return b"\xc7\x5f\x61\x1f"
|
||||||
if mappath == "test3.gck":
|
if mappath == "test3.gck":
|
||||||
return b"\x59\xbb\xab\x52"
|
return b"\x59\xbb\xab\x52"
|
||||||
|
if mappath == "Testmap.gck":
|
||||||
|
return b"\x74\x07\x98\xaf"
|
||||||
# \x00\x00\x00\x00: [None]
|
# \x00\x00\x00\x00: [None]
|
||||||
# \x00\x00\x00\x01: <custom map>
|
# \x00\x00\x00\x01: <custom map>
|
||||||
# \x9c\x53\xf4\xdd: Three Way Island - Canyons
|
# \x9c\x53\xf4\xdd: Three Way Island - Canyons
|
||||||
|
@ -25,6 +25,7 @@ class Player(Entity):
|
|||||||
self.id = random.getrandbits(16)
|
self.id = random.getrandbits(16)
|
||||||
self.phase = PlayerPhases.NONE
|
self.phase = PlayerPhases.NONE
|
||||||
self.ping = 1
|
self.ping = 1
|
||||||
|
self.oid = 0
|
||||||
|
|
||||||
async def change_team(self, newteam):
|
async def change_team(self, newteam):
|
||||||
self.team = newteam
|
self.team = newteam
|
||||||
|
@ -6,7 +6,6 @@ import struct
|
|||||||
class Commands:
|
class Commands:
|
||||||
def __init__(self, server):
|
def __init__(self, server):
|
||||||
self.server = server
|
self.server = server
|
||||||
self._nextid = 118
|
|
||||||
|
|
||||||
async def on_player_chat(self, player, type, team, message):
|
async def on_player_chat(self, player, type, team, message):
|
||||||
await self.server.broadcast_message_except(player, "%s: %s" % (player.name, message), color=ChatColor.Yellow)
|
await self.server.broadcast_message_except(player, "%s: %s" % (player.name, message), color=ChatColor.Yellow)
|
||||||
@ -60,8 +59,16 @@ class Commands:
|
|||||||
await player.session.send_gamedata(bytes.fromhex("0b1a0000000002070000a5b0d4c35d9714c450abef354a68fb410914000000020700000402000000")+struct.pack("<L",diemethod)+bytes.fromhex("0000"))
|
await player.session.send_gamedata(bytes.fromhex("0b1a0000000002070000a5b0d4c35d9714c450abef354a68fb410914000000020700000402000000")+struct.pack("<L",diemethod)+bytes.fromhex("0000"))
|
||||||
|
|
||||||
if command[0] == "spawn" and len(command) > 1:
|
if command[0] == "spawn" and len(command) > 1:
|
||||||
await self.server.broadcast_message("Spawning "+command[1]+"")
|
await self.server.broadcast_message("Spawning " + command[1] + "")
|
||||||
await self.server.spawn(self._nextid, "00", command[1])
|
await self.server.spawn(player, 0, int(command[1]))
|
||||||
|
|
||||||
|
if command[0] == "changeme" and len(command) > 1:
|
||||||
|
await self.server.broadcast_message("Changing your model to " + command[1] + "")
|
||||||
|
await self.server.change_model(player, int(command[1]))
|
||||||
|
|
||||||
|
if command[0] == "change" and len(command) > 2:
|
||||||
|
await self.server.broadcast_message("Changing model of "+command[1]+" to "+command[2]+"")
|
||||||
|
await self.server.change_model(self.server.get_player_by_index(int(command[1])), int(command[2]))
|
||||||
|
|
||||||
|
|
||||||
def setup(server):
|
def setup(server):
|
||||||
|
114
server.py
114
server.py
@ -1,3 +1,4 @@
|
|||||||
|
from dpnet.packet import Packet
|
||||||
from giants.map import Map
|
from giants.map import Map
|
||||||
from giants.player import Player
|
from giants.player import Player
|
||||||
from dpnet.netserver import Netserver
|
from dpnet.netserver import Netserver
|
||||||
@ -56,6 +57,8 @@ class Server:
|
|||||||
self.running = True
|
self.running = True
|
||||||
self.ticks = 60
|
self.ticks = 60
|
||||||
|
|
||||||
|
self._nextid = 118
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
#logger.debug("Calling update")
|
#logger.debug("Calling update")
|
||||||
pass
|
pass
|
||||||
@ -144,10 +147,115 @@ class Server:
|
|||||||
continue
|
continue
|
||||||
await pplayer.send_message(text, color=color, type=type)
|
await pplayer.send_message(text, color=color, type=type)
|
||||||
|
|
||||||
async def spawn(self, objid, plix, model):
|
async def spawn(self, player, plix, model):
|
||||||
await self.broadcast_gamedata(bytes.fromhex("05" + plix + struct.pack("<B", objid).hex() + "0000" + model + "00000000"), acknow=False)
|
p = Packet()
|
||||||
await self.broadcast_gamedata(bytes.fromhex("0a32000000" + plix + struct.pack("<B", objid).hex() + "000001" + model + "000000ff00000000000000000000000000000000000000000000000000000000000000000000000a12000000" + plix + struct.pack("<B", objid).hex() + "0000" + model + "020000000000000000"), acknow=False)
|
p.putByte(0x05) # opcode
|
||||||
|
p.putByte(plix)
|
||||||
|
p.putShort(self._nextid)
|
||||||
|
p.putByte(0x00)
|
||||||
|
p.putULong(model)
|
||||||
|
p.putByte(0x00)
|
||||||
|
|
||||||
|
await self.broadcast_gamedata(p.getvalue(), acknow=False)
|
||||||
|
#await self.broadcast_gamedata(bytes.fromhex("05" + plix + struct.pack("<H", self._nextid).hex() + "00" + model + "00000000"), acknow=False)
|
||||||
|
|
||||||
|
p = Packet()
|
||||||
|
p.putByte(0x0a) # opcode
|
||||||
|
p.putByte(0x12) # length
|
||||||
|
p.putByte(0x00) # unknown
|
||||||
|
p.putByte(0x00) # unknown
|
||||||
|
p.putByte(0x00) # unknown
|
||||||
|
p.putByte(plix) # player index
|
||||||
|
p.putShort(self._nextid) # object id
|
||||||
|
p.putByte(0x00) # unknown
|
||||||
|
p.putByte(0x01) # unknown
|
||||||
|
p.putULong(model) # model
|
||||||
|
p.putFloat(player.x) # player x
|
||||||
|
p.putFloat(player.y) # player y
|
||||||
|
p.putFloat(player.z) # player z
|
||||||
|
p.putULong(0x00) # unknown
|
||||||
|
p.putULong(0x00) # unknown
|
||||||
|
p.putULong(0x00) # unknown
|
||||||
|
p.putULong(0x00) # unknown
|
||||||
|
p.putULong(0x00) # orientation
|
||||||
|
p.putULong(0x00) # unknown
|
||||||
|
|
||||||
|
await self.broadcast_gamedata(p.getvalue(), acknow=False)
|
||||||
|
|
||||||
|
self._nextid+=1
|
||||||
|
|
||||||
|
#await self.broadcast_gamedata(bytes.fromhex("0a12000000" + plix + struct.pack("<H", self._nextid).hex() + "0003" + model + "00000000"), acknow=False)
|
||||||
|
#await self.broadcast_gamedata(bytes.fromhex("0a32000000" + plix + struct.pack("<B", self._nextid).hex() + "000001" + model + "000000ff00000000000000000000000000000000000000000000000000000000000000000000000a12000000" + plix + struct.pack("<B", self._nextid).hex() + "0000" + model + "020000000000000000"), acknow=False)
|
||||||
|
|
||||||
|
async def change_model(self, player, model):
|
||||||
|
plid = self.get_player_index(player)
|
||||||
|
# p = Packet()
|
||||||
|
# p.putByte(0x0a) # opcode
|
||||||
|
# p.putByte(0x12) # length
|
||||||
|
# p.putByte(0x00) # unknown
|
||||||
|
# p.putByte(0x00) # unknown
|
||||||
|
# p.putByte(0x00) # unknown
|
||||||
|
# p.putByte(plid) # player index
|
||||||
|
# p.putShort(player.oid) # object id
|
||||||
|
# p.putByte(0x00) # unknown
|
||||||
|
# p.putByte(0x02) # 4 -> death, 3 -> little move
|
||||||
|
# p.putULong(model) # model
|
||||||
|
# p.putFloat(player.x) # x
|
||||||
|
# p.putFloat(player.y) # y
|
||||||
|
# p.putFloat(player.z) # z
|
||||||
|
# p.putULong(0x00) # unknown
|
||||||
|
# p.putULong(0x00) # unknown
|
||||||
|
# p.putULong(0x00) # unknown
|
||||||
|
# p.putULong(0x00) # unknown
|
||||||
|
# p.putULong(player.o + 30) # orientation
|
||||||
|
# p.putULong(0x00) # unknown
|
||||||
|
|
||||||
|
p = Packet()
|
||||||
|
p.putByte(0x0a) # opcode
|
||||||
|
p.putByte(0x32) # length
|
||||||
|
p.putByte(0x00) # unknown
|
||||||
|
p.putByte(0x00) # unknown
|
||||||
|
p.putByte(0x00) # unknown
|
||||||
|
p.putByte(plid) # player index
|
||||||
|
p.putShort(player.oid) # object id
|
||||||
|
p.putByte(0x00) # unknown
|
||||||
|
p.putByte(0x01) # 1 -> stand still, 4 -> death, 3 -> little move
|
||||||
|
p.putULong(model) # model
|
||||||
|
p.putFloat(0x00) # x
|
||||||
|
p.putFloat(player.y) # y
|
||||||
|
p.putFloat(player.z) # z
|
||||||
|
p.putULong(0x00) # unknown
|
||||||
|
p.putULong(0x00) # unknown
|
||||||
|
p.putULong(0x00) # unknown
|
||||||
|
p.putULong(0x00) # unknown
|
||||||
|
p.putULong((player.o + 30) % 360) # orientation
|
||||||
|
p.putULong(0x00) # unknown
|
||||||
|
|
||||||
|
p.putByte(0x0a) # opcode
|
||||||
|
p.putByte(0x12) # length
|
||||||
|
p.putByte(0x00) # unknown
|
||||||
|
p.putByte(0x00) # unknown
|
||||||
|
p.putByte(0x00) # unknown
|
||||||
|
p.putByte(plid) # player index
|
||||||
|
p.putShort(player.oid) # object id
|
||||||
|
p.putByte(0x00) # unknown
|
||||||
|
p.putByte(0x00) # 1 -> stand still, 4 -> death, 3 -> little move
|
||||||
|
p.putULong(model) # model
|
||||||
|
p.putULong(0x00)
|
||||||
|
p.putByte(0x00)
|
||||||
|
p.putByte(0x00)
|
||||||
|
|
||||||
|
await self.broadcast_gamedata(p.getvalue(), acknow=False)
|
||||||
|
#await self.broadcast_gamedata(bytes.fromhex("0a32000000" + plix + struct.pack("<B", objid).hex() + "000001" + model + "000000ff00000000000000000000000000000000000000000000000000000000000000000000000a12000000" + plix + struct.pack("<B", objid).hex() + "0000" + model + "020000000000000000"), acknow=False)
|
||||||
|
|
||||||
|
def get_player_index(self, player):
|
||||||
|
for iplayer in range(len(self.players)):
|
||||||
|
if self.players[iplayer] == player:
|
||||||
|
return iplayer
|
||||||
|
return False
|
||||||
|
|
||||||
|
def get_player_by_index(self, playerindex):
|
||||||
|
return self.players[playerindex]
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
server = Server(name="giantsd", maxplayers=20, register=False, teams=Teams.MvM) #, map=Map("Three Way Island - Canyons.gck"))
|
server = Server(name="giantsd", maxplayers=20, register=False, teams=Teams.MvM) #, map=Map("Three Way Island - Canyons.gck"))
|
||||||
|
Loading…
Reference in New Issue
Block a user