Example #1
0
def whereis(script, name=None):
    player = script.get_player(name)
    if player is script.connection:
        message = 'You are at %s'
    else:
        message = '%s is at %%s' % player.name
    return message % (get_chunk(player.position), )
Example #2
0
def whereis(script, name=None):
    player = script.get_player(name)
    if player is script.connection:
        message = 'You are at %s'
    else:
        message = '%s is at %%s' % player.name
    return message % (get_chunk(player.position),)
Example #3
0
File: mitm.py Project: CarlosX/cuwo
 def send_debug(self):
     reactor.callLater(0.01, self.send_debug)
     if self.entity_id is None:
         return
     entity = self.entities[self.entity_id]
     from cuwo.vector import Vector3
     shoot = ShootPacket()
     shoot.entity_id = 2
     shoot.chunk_x, shoot.chunk_y = get_chunk(
         Vector3(entity.x, entity.y, entity.z))
     import random
     shoot.something5 = random.randrange(0, 10)
     shoot.something13 = 0
     shoot.something14 = 0
     shoot.something15 = 0
     shoot.something19 = 10.49137020111084
     shoot.something20 = 0.5
     shoot.something21 = 1.0
     shoot.something22 = 0.0
     shoot.something23 = 0
     shoot.something24 = 0
     shoot.something25 = 0
     shoot.something26 = 0
     shoot.something27 = 0
     shoot.something28 = 0
     shoot.pos = Vector3(entity.x, entity.y, entity.z + 150000)
     shoot.velocity = Vector3(93.929801940, -34.1773529054, -3.0167741775)
     self.relay_client.transport.write(write_packet(shoot))
Example #4
0
 def on_pos_update(self):
     if self.server.world:
         chunk = get_chunk(self.position)
         if chunk != self.chunk_pos:
             self.server.world.get_chunk(*chunk).addCallback(self.on_chunk)
             self.chunk_pos = chunk
     self.scripts.call('on_pos_update')
Example #5
0
def whereis(script, name = None):
    if name is None:
        player = script.protocol
        message = 'You are at %s'
    else:
        player = get_player(script.factory, name)
        message = '%s is at %%s' % player.get_name()
    return message % (get_chunk(player.get_position()),)
Example #6
0
def whereis(script, name=None):
    if name is None:
        player = script.connection
        message = 'You are at %s'
    else:
        player = get_player(script.server, name)
        message = '%s is at %%s' % player.name
    return message % (get_chunk(player.position),)
Example #7
0
 def on_pos_update(self):
     try:
         chunk_pos = get_chunk(self.position)
     except ValueError:
         self.on_invalid_packet('position')
         return
     if not self.chunk or chunk_pos != self.chunk.pos:
         self.chunk = self.world.get_chunk(chunk_pos)
     self.scripts.call('on_pos_update')
Example #8
0
 def on_pos_update(self):
     try:
         chunk_pos = get_chunk(self.position)
     except ValueError:
         self.on_invalid_packet('position')
         return
     if not self.chunk or chunk_pos != self.chunk.pos:
         self.chunk = self.world.get_chunk(chunk_pos)
     self.scripts.call('on_pos_update')
Example #9
0
 def drop_item(self, item_data, pos):
     item = packets.ChunkItemData()
     item.drop_time = 750
     # XXX provide sane values for these
     item.scale = 0.1
     item.rotation = 185.0
     item.something3 = item.something5 = item.something6 = 0
     item.pos = pos
     item.item_data = item_data
     self.world.get_chunk(get_chunk(pos)).add_item(item)
Example #10
0
 def drop_item(self, item_data, pos):
     item = packets.ChunkItemData()
     item.drop_time = 750
     # XXX provide sane values for these
     item.scale = 0.1
     item.rotation = 185.0
     item.something3 = item.something5 = item.something6 = 0
     item.pos = pos
     item.item_data = item_data
     self.world.get_chunk(get_chunk(pos)).add_item(item)
Example #11
0
 def get_height(self, pos):
     chunk_pos = get_chunk(pos)
     try:
         chunk = self.chunks[chunk_pos]
     except KeyError:
         return None
     if chunk.data is None:
         return None
     pos -= chunk_pos * constants.CHUNK_SCALE
     pos //= constants.BLOCK_SCALE
     return chunk.data.get_height(pos.x, pos.y) * constants.BLOCK_SCALE
Example #12
0
 def drop_item(self, item_data, pos):
     item = ChunkItemData()
     item.drop_time = 750
     # XXX provide sane values for these
     item.scale = 0.1
     item.rotation = 185.0
     item.something3 = item.something5 = item.something6 = 0
     item.pos = pos
     item.item_data = item_data
     self.chunk_items[get_chunk(pos)].append(item)
     self.items_changed = True
Example #13
0
 def get_height(self, pos):
     chunk_pos = get_chunk(pos)
     try:
         chunk = self.chunks[chunk_pos]
     except KeyError:
         return None
     if chunk.data is None:
         return None
     pos -= chunk_pos * constants.CHUNK_SCALE
     pos //= constants.BLOCK_SCALE
     return chunk.data.get_height(pos.x, pos.y) * constants.BLOCK_SCALE
Example #14
0
 def drop_item(self, item_data, pos):
     item = ChunkItemData()
     item.drop_time = 750
     # XXX provide sane values for these
     item.scale = 0.1
     item.rotation = 185.0
     item.something3 = item.something5 = item.something6 = 0
     item.pos = pos
     item.item_data = item_data
     self.chunk_items[get_chunk(pos)].append(item)
     self.items_changed = True
Example #15
0
def who_where(script, include_where):
    server = script.server
    player_count = len(server.players)
    if player_count == 0:
        return 'No players connected'
    formatted_names = []
    for player in list(server.players.values()):
        name = '%s #%s' % (player.name, player.entity_id)
        if include_where:
            name += ' %s' % (get_chunk(player.position),)
        formatted_names.append(name)
    noun = 'player' if player_count == 1 else 'players'
    msg = '%s %s connected: ' % (player_count, noun)
    msg += ', '.join(formatted_names)
    return msg
Example #16
0
def who_where(script, include_where):
    server = script.server
    player_count = len(server.players)
    if player_count == 0:
        return 'No players connected'
    formatted_names = []
    for player in server.players.values():
        name = '%s #%s' % (player.name, player.entity_id)
        if include_where:
            name += ' %s' % (get_chunk(player.position), )
        formatted_names.append(name)
    noun = 'player' if player_count == 1 else 'players'
    msg = '%s %s connected: ' % (player_count, noun)
    msg += ', '.join(formatted_names)
    return msg
Example #17
0
    def teleport(self, to_x, to_y, to_z):
        packet = EntityUpdate()

        self.entity_data.pos.x = to_x
        self.entity_data.pos.y = to_y
        self.entity_data.pos.z = to_z

        self.chunk = get_chunk(self.entity_data.pos)
        self.old_pos = self.entity_data.pos

        packet.set_entity(self.entity_data, 0)
        self.send_packet(packet)

        packet.set_entity(self.entity_data, self.entity_id)
        self.relay_packet(packet)
Example #18
0
 def on_pos_update(self):
     chunk = get_chunk(self.position)
     if self.chunk is None:
         self.chunk = chunk
     elif chunk != self.chunk:
         # Distance check
         if (abs(chunk[0]-self.chunk[0]) > 1) or (abs(chunk[1]-self.chunk[1]) > 1):
             self.disconnect('[ANTICHEAT] Traveled distance to large')
             print '[ANTICHEAT] Traveled distance of %s was to large' % self.name
             return False
         if abs(chunk[0]) < 2 or abs(chunk[1]) < 2:
             self.disconnect('[ANTICHEAT] Out of world border')
             self.teleport(550301073408, 550301073408, 1000000)
             print '[ANTICHEAT] %s was out of world border' % self.name
             return False
         self.chunk = chunk
     self.scripts.call('on_pos_update')
     return True
Example #19
0
    def retire_chunks(self):
        retire_time = self.chunk_retire_time
        if retire_time is None:
            return

        chunks = list(self.chunks.values())
        for chunk in chunks:
            chunk.last_visit += self.dt

        for entity in self.entities.values():
            if entity.is_tgen:
                continue
            chunk_pos = get_chunk(entity.pos)
            if not chunk_pos in self.chunks:
                continue
            self.get_chunk(chunk_pos).last_visit = 0

        for chunk in chunks:
            if chunk.last_visit < retire_time:
                continue
            chunk.destroy()
Example #20
0
    def retire_chunks(self):
        retire_time = self.chunk_retire_time
        if retire_time is None:
            return

        chunks = list(self.chunks.values())
        for chunk in chunks:
            chunk.last_visit += self.dt

        for entity in self.entities.values():
            if entity.is_tgen:
                continue
            chunk_pos = get_chunk(entity.pos)
            if not chunk_pos in self.chunks:
                continue
            self.get_chunk(chunk_pos).last_visit = 0

        for chunk in chunks:
            if chunk.last_visit < retire_time:
                continue
            chunk.destroy()
Example #21
0
    def retire_chunks(self):
        retire_time = self.chunk_retire_time
        if retire_time is None:
            return

        chunks = set(self.chunks.values())
        seen = set()
        for chunk in chunks:
            chunk.last_visit += self.dt

        for entity in self.entities.values():
            if entity.is_tgen:
                continue
            chunk_pos = get_chunk(entity.pos)
            if not chunk_pos in self.chunks:
                continue
            chunk = self.get_chunk(chunk_pos)
            seen.add(chunk)
            chunk.last_visit = 0

        for chunk in chunks:
            if (chunk.last_visit >= retire_time
                    or (not chunk.has_generation and chunk not in seen)):
                chunk.destroy()
Example #22
0
    def retire_chunks(self):
        retire_time = self.chunk_retire_time
        if retire_time is None:
            return

        chunks = set(self.chunks.values())
        seen = set()
        for chunk in chunks:
            chunk.last_visit += self.dt

        for entity in self.entities.values():
            if entity.is_tgen:
                continue
            chunk_pos = get_chunk(entity.pos)
            if not chunk_pos in self.chunks:
                continue
            chunk = self.get_chunk(chunk_pos)
            seen.add(chunk)
            chunk.last_visit = 0

        for chunk in chunks:
            if (chunk.last_visit >= retire_time or
                    (not chunk.has_generation and chunk not in seen)):
                chunk.destroy()