コード例 #1
0
ファイル: state.py プロジェクト: cybergrind/rtf-proxy
 def warn_message(self, msg):
     # return
     _from = b'Toool'
     if isinstance(msg, str):
         msg = msg.encode('utf8')
     # r, g, b = 81, 245, 66 # green
     r, g, b = 255, 66, 245
     payload = struct.pack(
         f'!BH{len(_from)}sBBBBIIBHH{len(msg)}sH{len(msg)}s',
         23,
         len(_from),
         _from,
         0x00,
         r,
         g,
         b,
         self.me.entry.id,
         0xffffffff,  # 0x46,
         0x5,
         0,
         len(msg),
         msg,
         len(msg),
         msg,
     )
     self.local_writer.write(payload_to_packet(payload))
コード例 #2
0
def multiply_damage(state, payload):
    mask = '!BBHHIB'
    curr = struct.unpack(mask, payload)
    shot_id = curr[2]
    counter = curr[3]
    enemy_id = curr[4]
    if (enemy_id, counter) in SKIP_BASE:
        return payload

    ids = [(enemy_id, counter)]
    enemy_id = curr[4]
    for i in range(MULTIPLY_COEFF):
        new_counter = counter + 1 + i
        if (enemy_id, new_counter) in SKIP_BASE:
            continue
        ids.append((enemy_id, new_counter))
        payload += payload_to_packet(
            struct.pack(mask, 0x4c, 0, shot_id, new_counter, enemy_id, 0))
    asyncio.create_task(delay_delete(ids))
    return payload
コード例 #3
0
ファイル: state.py プロジェクト: cybergrind/rtf-proxy
 def move_to_slot(self,
                  inv_id,
                  item_id,
                  to_slot=None,
                  from_slot=None,
                  to_id=0xffffffff):
     if self.location in const.NO_ACTION:
         return
     _type = 59
     ts = self.gen_ts()
     pos_x, pos_y = self.mypos
     inv_id = inv_id
     if not from_slot:
         from_slot = self.get_item_idx(inv_id, item_id)
     item_id = item_id
     who_pickup = self.me.entry.id
     if not to_slot:
         slot, to_slot = self.get_free_slot()
     print(
         f'MOVE {item_id} TO SLOT: {to_slot} From: {from_slot} [obj: {inv_id}]'
     )
     if not to_slot:
         print(f'CANNOT MOVE TO SLOT. NO SLOTS: {item_id}')
         return
     payload = struct.pack(
         '!BIffIBIIBI',
         _type,
         ts,
         pos_x,
         pos_y,
         inv_id,
         from_slot,
         item_id,
         who_pickup,
         to_slot,
         to_id,
     )
     print(f'Move write: {payload}')
     # self.me.dct.raw[slot] = '<moving>'
     self.remote_writer.write(payload_to_packet(payload))
コード例 #4
0
ファイル: state.py プロジェクト: cybergrind/rtf-proxy
    def ability_shot(self, target=None):
        if self.location in const.NO_ACTION:
            return

        if not self.shot_allowed:
            return
        _type = 49
        ts = self.gen_ts()
        who = self.me.entry.id
        idx = 1
        item = self.me.dct['item_2']
        if not target:
            pos_x = self.mypos[0] + 1
            pos_y = self.mypos[1] + 1
        else:
            pos_x, pos_y = target
        end = 1
        pl = struct.pack('!BIIBIffB', _type, ts, who, idx, item, pos_x, pos_y,
                         end)
        self.log_write(f'Write skull push: {pl}')
        self.remote_writer.write(payload_to_packet(pl))
        asyncio.create_task(self.after_shot())
コード例 #5
0
ファイル: state.py プロジェクト: cybergrind/rtf-proxy
 def use_bag_item(self, bag, slot_id):
     if self.location in const.NO_ACTION:
         raise Exception('use bag item')
         return
     item = bag.dct.raw[slot_id]
     idx = self.bag_indexes[slot_id]
     out_type = 49
     ts = self.gen_ts() + idx
     if ts == self.ts:
         ts += 1
     _id = bag.entry.id
     i1 = 0
     i2 = 0
     b1 = 1
     print(out_type, ts, _id, idx, item, i1, i2, b1)
     pl = struct.pack('!BIIBIIIB', out_type, ts, _id, idx, item, i1, i2, b1)
     what = payload_to_packet(pl)
     self.ts_ensure_bigger = ts
     assert len(what) == 23 + 4
     msg = f'!!Autoopen: {what}   TS: {self.ts} Gen: {ts} : {idx} && {slot_id}\n'
     print(msg)
     # self.state.log_write(msg)
     # self.state.to_send.append(what)
     self.remote_writer.write(what)