forked from hipstercat/giantsd
New bullets
This commit is contained in:
parent
5b6820b8b3
commit
14cc33b3d8
@ -112,22 +112,53 @@ class MSG_DROP_WEAPON():
|
|||||||
p.putByte(0x00)
|
p.putByte(0x00)
|
||||||
return p.getvalue()
|
return p.getvalue()
|
||||||
|
|
||||||
class MSG_BULLET_EXPLOSION():
|
class MSG_NEW_PROJECTILE():
|
||||||
def __init__(self, player, projectile, x, y, z):
|
def __init__(self, player, oid, projectiletype, x, y, z, o):
|
||||||
self.player = player
|
self.player = player
|
||||||
self.projectile = projectile
|
|
||||||
self.x = x
|
self.x = x
|
||||||
self.y = y
|
self.y = y
|
||||||
self.z = z
|
self.z = z
|
||||||
|
self.o = o
|
||||||
|
self.projectiletype = projectiletype
|
||||||
|
self.oid = oid
|
||||||
|
|
||||||
|
def to_packet(self):
|
||||||
|
p = Packet()
|
||||||
|
p.putByte(0x09) # opcode
|
||||||
|
p.putULong(0x23)
|
||||||
|
p.putByte(self.player.get_index())
|
||||||
|
p.putShort(self.player.oid)
|
||||||
|
p.putByte(0x00)
|
||||||
|
p.putByte(0x10)
|
||||||
|
p.putULong(0x02)
|
||||||
|
p.putFloat(self.x)
|
||||||
|
p.putFloat(self.y)
|
||||||
|
p.putFloat(self.z)
|
||||||
|
p.putULong(self.o)
|
||||||
|
p.putShort(self.oid)
|
||||||
|
p.putShort(0x00)
|
||||||
|
p.putByte(self.projectiletype)
|
||||||
|
p.putByte(0x00)
|
||||||
|
return p.getvalue()
|
||||||
|
|
||||||
|
|
||||||
|
class MSG_BULLET_EXPLOSION():
|
||||||
|
def __init__(self, player, oid, x, y, z, isbackpackitem):
|
||||||
|
self.player = player
|
||||||
|
self.oid = oid
|
||||||
|
self.x = x
|
||||||
|
self.y = y
|
||||||
|
self.z = z
|
||||||
|
self.isbackpackitem = isbackpackitem
|
||||||
|
|
||||||
def to_packet(self):
|
def to_packet(self):
|
||||||
p = Packet()
|
p = Packet()
|
||||||
p.putByte(0x09) # opcode
|
p.putByte(0x09) # opcode
|
||||||
p.putULong(0x1a)
|
p.putULong(0x1a)
|
||||||
p.putByte(self.player.get_index())
|
p.putByte(self.player.get_index())
|
||||||
p.putShort(0x0631)
|
p.putShort(self.oid)
|
||||||
p.putByte(0x00)
|
p.putByte(0x00)
|
||||||
p.putByte(0x03)
|
p.putByte(0x03) if not self.isbackpackitem else p.putByte(0x01) # 0x01 for backpackitem, 0x03 for anything else?
|
||||||
p.putULong(0x4d)
|
p.putULong(0x4d)
|
||||||
p.putFloat(self.x)
|
p.putFloat(self.x)
|
||||||
p.putFloat(self.y)
|
p.putFloat(self.y)
|
||||||
@ -187,4 +218,41 @@ class MSG_PLAYER_TELEPORT():
|
|||||||
p.putFloat(self.newy)
|
p.putFloat(self.newy)
|
||||||
p.putFloat(self.newz)
|
p.putFloat(self.newz)
|
||||||
p.putByte(0x00)
|
p.putByte(0x00)
|
||||||
return p.getvalue()
|
return p.getvalue()
|
||||||
|
|
||||||
|
|
||||||
|
class MSG_PLAYER_USE_BACKPACK():
|
||||||
|
def __init__(self, player, backpackitem):
|
||||||
|
self.player = player
|
||||||
|
self.backpackitem = backpackitem
|
||||||
|
|
||||||
|
def to_packet(self):
|
||||||
|
p = Packet()
|
||||||
|
p.putByte(0x09) # opcode
|
||||||
|
p.putULong(0x12)
|
||||||
|
p.putByte(self.player.get_index())
|
||||||
|
p.putShort(self.player.oid)
|
||||||
|
p.putByte(0x00)
|
||||||
|
p.putByte(self.backpackitem) # popup?
|
||||||
|
p.putULong(0x02)
|
||||||
|
p.putULong(0x46aae90a) # ?
|
||||||
|
p.putByte(0x00)
|
||||||
|
return p.getvalue()
|
||||||
|
|
||||||
|
|
||||||
|
class MSG_PLAYER_DROP_BACKPACK():
|
||||||
|
def __init__(self, player):
|
||||||
|
self.player = player
|
||||||
|
|
||||||
|
def to_packet(self):
|
||||||
|
p = Packet()
|
||||||
|
p.putByte(0x09) # opcode
|
||||||
|
p.putULong(0x13)
|
||||||
|
p.putByte(self.player.get_index())
|
||||||
|
p.putShort(self.player.oid)
|
||||||
|
p.putByte(0x11)
|
||||||
|
p.putULong(0x02)
|
||||||
|
p.putULong(0x3a04)
|
||||||
|
p.putByte(0x0a)
|
||||||
|
p.putByte(0x00)
|
||||||
|
return p.getvalue()
|
||||||
|
@ -668,18 +668,30 @@ class Netserver(asyncio.DatagramProtocol):
|
|||||||
return
|
return
|
||||||
await player.send_message("PROJECTILE SHOOT: %s" % payload.hex())
|
await player.send_message("PROJECTILE SHOOT: %s" % payload.hex())
|
||||||
await self.server.broadcast_gamedata_except(player, payload)
|
await self.server.broadcast_gamedata_except(player, payload)
|
||||||
await self.server.broadcast_event("on_player_shoot", player)
|
await self.server.broadcast_event("on_player_shoot", player, payload)
|
||||||
elif payload[0] == 0x09 and payload[1] == 0x1a:
|
elif payload[0] == 0x09 and payload[1] == 0x1a:
|
||||||
player = self.get_player(session)
|
player = self.get_player(session)
|
||||||
if not player:
|
if not player:
|
||||||
logger.debug("Fuck that no player wtf man")
|
logger.debug("Fuck that no player wtf man")
|
||||||
return
|
return
|
||||||
await player.send_message("PROJECTILE EXPLOSION: %s" % payload.hex())
|
await player.send_message("PROJECTILE EXPLOSION: %s" % payload.hex())
|
||||||
#await self.server.broadcast_gamedata_except(player, payload)
|
await self.server.broadcast_gamedata_except(player, payload)
|
||||||
|
oid = struct.unpack("<H", payload[6:8])[0]
|
||||||
x = struct.unpack("<f", payload[14:18])[0]
|
x = struct.unpack("<f", payload[14:18])[0]
|
||||||
y = struct.unpack("<f", payload[18:22])[0]
|
y = struct.unpack("<f", payload[18:22])[0]
|
||||||
z = struct.unpack("<f", payload[22:26])[0]
|
z = struct.unpack("<f", payload[22:26])[0]
|
||||||
await self.server.broadcast_gamedata(MSG_BULLET_EXPLOSION(player, 10, x, y, z).to_packet())
|
#await self.server.broadcast_gamedata(MSG_BULLET_EXPLOSION(player, oid, x, y, z).to_packet())
|
||||||
|
|
||||||
|
# POPUP
|
||||||
|
#popupoid = self.server.new_oid()
|
||||||
|
#type = 12 # maybe
|
||||||
|
#await self.server.broadcast_gamedata(MSG_NEW_PROJECTILE(player, popupoid, type, x, y, z, 0).to_packet())
|
||||||
|
|
||||||
|
#await self.server.broadcast_gamedata(bytes.fromhex("09160000000438000002250000000a00000004070000091300000004070000110200000004"+ struct.pack("<H", popupoid).hex() +"000a090e00000004380000032500000000")) # put popup on backpack
|
||||||
|
#await self.server.broadcast_gamedata(MSG_PLAYER_DROP_BACKPACK(player).to_packet()) # drop popup
|
||||||
|
#await self.server.broadcast_gamedata(MSG_BULLET_EXPLOSION(player, popupoid, x, y, z, True).to_packet()) # explode popup
|
||||||
|
#await self.server.broadcast_gamedata(MSG_PLAYER_USE_BACKPACK(player, 0x16).to_packet()) # use popup
|
||||||
|
|
||||||
elif payload[0] == 0x09 and payload[1] == 0x0f:
|
elif payload[0] == 0x09 and payload[1] == 0x0f:
|
||||||
player = self.get_player(session)
|
player = self.get_player(session)
|
||||||
if not player:
|
if not player:
|
||||||
@ -705,11 +717,9 @@ class Netserver(asyncio.DatagramProtocol):
|
|||||||
logger.debug("Fuck that no player wtf man")
|
logger.debug("Fuck that no player wtf man")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
await self.server.broadcast_event("on_player_hit", player, None, None)
|
||||||
await player.send_message("HIT: %s" % payload.hex())
|
await player.send_message("HIT: %s" % payload.hex())
|
||||||
for p in self.server.players:
|
|
||||||
if p.name == "[Server]":
|
|
||||||
continue
|
|
||||||
await self.server.broadcast_gamedata(MSG_PLAYER_DIE(p, 1).to_packet())
|
|
||||||
else:
|
else:
|
||||||
player = self.get_player(session)
|
player = self.get_player(session)
|
||||||
if not player:
|
if not player:
|
||||||
|
28
plugins/bullets.py
Normal file
28
plugins/bullets.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
from dpnet.gamepackets import *
|
||||||
|
import struct
|
||||||
|
|
||||||
|
class Bullets:
|
||||||
|
def __init__(self, server):
|
||||||
|
self.server = server
|
||||||
|
|
||||||
|
async def on_player_chat(self, player, type, team, message):
|
||||||
|
command = message.split(" ")
|
||||||
|
if len(command) > 1 and command[0] == "bullet":
|
||||||
|
t = int(command[1])
|
||||||
|
player.opts["bullet"] = t
|
||||||
|
|
||||||
|
async def on_player_shoot(self, player, payload):
|
||||||
|
if "bullet" in player.opts and player.opts["bullet"] != 0:
|
||||||
|
oid = struct.unpack("<H", payload[31:33])[0]
|
||||||
|
print(oid)
|
||||||
|
x = struct.unpack("<f", payload[14:18])[0]
|
||||||
|
y = struct.unpack("<f", payload[18:22])[0]
|
||||||
|
z = struct.unpack("<f", payload[22:26])[0]
|
||||||
|
o = struct.unpack("<L", payload[26:30])[0]
|
||||||
|
await self.server.broadcast_gamedata(MSG_BULLET_EXPLOSION(player, oid, x, y, z, False).to_packet())
|
||||||
|
await self.server.broadcast_gamedata(MSG_NEW_PROJECTILE(player, self.server.new_oid(), player.opts["bullet"], x, y, z, o).to_packet())
|
||||||
|
|
||||||
|
|
||||||
|
def setup(server):
|
||||||
|
plugin = Bullets(server)
|
||||||
|
server.add_plugin(plugin)
|
@ -147,8 +147,7 @@ class Commands:
|
|||||||
if len(command) > 1 and command[0] == "drop":
|
if len(command) > 1 and command[0] == "drop":
|
||||||
weap = int(command[1])
|
weap = int(command[1])
|
||||||
await player.send_message("Dropped weapon %s" % weap, color=ChatColor.Cyan)
|
await player.send_message("Dropped weapon %s" % weap, color=ChatColor.Cyan)
|
||||||
await self.server.broadcast_gamedata(MSG_DROP_WEAPON(player, self.server._nextid, weap, 255).to_packet())
|
await self.server.broadcast_gamedata(MSG_DROP_WEAPON(player, self.server.new_oid(), weap, 255).to_packet())
|
||||||
self.server._nextid += 1
|
|
||||||
|
|
||||||
if command[0] == "coords":
|
if command[0] == "coords":
|
||||||
await player.send_message("You are at (%s,%s,%s)" % (player.x, player.y, player.z), color=ChatColor.Cyan)
|
await player.send_message("You are at (%s,%s,%s)" % (player.x, player.y, player.z), color=ChatColor.Cyan)
|
||||||
@ -161,6 +160,25 @@ class Commands:
|
|||||||
await player.send_message("Teleporting you to (%s,%s,%s)" % (x, y, z), color=ChatColor.Cyan)
|
await player.send_message("Teleporting you to (%s,%s,%s)" % (x, y, z), color=ChatColor.Cyan)
|
||||||
await self.server.broadcast_gamedata(MSG_PLAYER_TELEPORT(player, x, y, z, o).to_packet())
|
await self.server.broadcast_gamedata(MSG_PLAYER_TELEPORT(player, x, y, z, o).to_packet())
|
||||||
|
|
||||||
|
if len(command) > 1 and command[0] == "fire":
|
||||||
|
weap = int(command[1])
|
||||||
|
|
||||||
|
if len(command) > 2:
|
||||||
|
i = int(command[2])
|
||||||
|
else:
|
||||||
|
i = 1
|
||||||
|
|
||||||
|
for _ in range(i):
|
||||||
|
x = randint(-200, 200)
|
||||||
|
y = randint(-200, 200)
|
||||||
|
z = randint(-200, 200)
|
||||||
|
o = 0
|
||||||
|
await player.send_message("Firing to (%s,%s,%s)" % (x, y, z), color=ChatColor.Cyan)
|
||||||
|
await self.server.broadcast_gamedata(MSG_NEW_PROJECTILE(player, self.server.new_oid(), weap, x, y, z, o).to_packet())
|
||||||
|
|
||||||
|
if command[0] == "popup":
|
||||||
|
await player.send_message("Spawned popup", color=ChatColor.Cyan)
|
||||||
|
await self.server.broadcast_gamedata(bytes.fromhex("09160000000438000002250000000a000000040700000913000000040700001102000000041d00000a090e00000004380000032500000000"))
|
||||||
|
|
||||||
def setup(server):
|
def setup(server):
|
||||||
plugin = Commands(server)
|
plugin = Commands(server)
|
||||||
|
@ -24,34 +24,34 @@ class Instagib:
|
|||||||
# give stuff
|
# give stuff
|
||||||
await self.give_stuff(player)
|
await self.give_stuff(player)
|
||||||
|
|
||||||
async def on_player_shoot(self, player):
|
async def on_player_shoot(self, player, payload):
|
||||||
await self.spawn_sniper(player)
|
await self.spawn_sniper(player)
|
||||||
|
|
||||||
async def on_player_hit(self, player, shooter, damage, weapon):
|
async def on_player_hit(self, player, shooter, damage, weapon):
|
||||||
# make player die
|
# make player die
|
||||||
await self.server.broadcast_gamedata(MSG_PLAYER_DIE(player, 1))
|
#await self.server.broadcast_gamedata(MSG_PLAYER_DIE(player, 1))
|
||||||
|
pass
|
||||||
|
|
||||||
async def give_stuff(self, player):
|
async def give_stuff(self, player):
|
||||||
# remove current weapon
|
# remove current weapon
|
||||||
await self.remove_current_weapon(player)
|
#await self.remove_current_weapon(player)
|
||||||
|
|
||||||
# add sniper
|
# add sniper
|
||||||
await self.spawn_sniper(player)
|
await self.spawn_sniper(player)
|
||||||
|
|
||||||
async def spawn_sniper(self, player):
|
async def spawn_sniper(self, player):
|
||||||
await self.server.broadcast_gamedata(MSG_DROP_WEAPON(player, self.server._nextid, 6, 255).to_packet())
|
await self.server.broadcast_gamedata(MSG_DROP_WEAPON(player, self.server.new_oid(), 6, 255).to_packet())
|
||||||
self.server._nextid += 1
|
|
||||||
|
|
||||||
async def remove_current_weapon(self, player):
|
async def remove_current_weapon(self, player):
|
||||||
await self.server.broadcast_gamedata(MSG_SWITCH_WEAPON(player, 0xff).to_packet())
|
await self.server.broadcast_gamedata(MSG_SWITCH_WEAPON(player, 0xff).to_packet())
|
||||||
|
|
||||||
async def random_teleport(self, player):
|
async def random_teleport(self, player):
|
||||||
# random teleport
|
# random teleport
|
||||||
maxdist = 300
|
maxdist = 2000
|
||||||
x = randint(-(maxdist/2), maxdist/2)
|
x = randint(-(maxdist/2), maxdist/2)
|
||||||
y = randint(-(maxdist/2), maxdist/2)
|
y = randint(-(maxdist/2), maxdist/2)
|
||||||
z = randint(-(maxdist/2), maxdist/2)
|
z = randint(-(maxdist/2), maxdist/2)
|
||||||
await self.server.broadcast_gamedata(MSG_PLAYER_TELEPORT(player, x, y, z).to_packet())
|
await self.server.broadcast_gamedata(MSG_PLAYER_TELEPORT(player, x, y, z, 0).to_packet())
|
||||||
|
|
||||||
|
|
||||||
def setup(server):
|
def setup(server):
|
||||||
|
@ -268,6 +268,11 @@ class Server:
|
|||||||
await self.broadcast_gamedata(p.getvalue(), acknow=False)
|
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)
|
#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 new_oid(self):
|
||||||
|
a = self._nextid
|
||||||
|
self._nextid += 1
|
||||||
|
return a
|
||||||
|
|
||||||
def get_player_index(self, player):
|
def get_player_index(self, player):
|
||||||
for iplayer in range(len(self.players)):
|
for iplayer in range(len(self.players)):
|
||||||
if self.players[iplayer] == player:
|
if self.players[iplayer] == player:
|
||||||
|
Loading…
Reference in New Issue
Block a user