forked from hipstercat/giantsd
29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
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)
|