Esempio n. 1
0
    def on_entity_packet(self, packet):
        if self.entity_data is None:
            self.entity_data = create_entity_data()
        mask = packet.update_entity(self.entity_data)
        self.entity_data.mask |= mask
        if self.connection_state==2 and getattr(self.entity_data, 'name', None):
            self.on_join()
            return

        self.scripts.call('on_entity_update', mask=mask)
        # XXX clean this up
        if entity.is_pos_set(mask):
            self.on_pos_update()
        if entity.is_mode_set(mask):
            self.scripts.call('on_mode_update')
        if entity.is_class_set(mask):
            self.scripts.call('on_class_update')
        if entity.is_name_set(mask):
            self.scripts.call('on_name_update')
        if entity.is_multiplier_set(mask):
            self.scripts.call('on_multiplier_update')
        if entity.is_level_set(mask):
            self.scripts.call('on_level_update')
        if entity.is_equipment_set(mask):
            self.scripts.call('on_equipment_update')
        if entity.is_skill_set(mask):
            self.scripts.call('on_skill_update')
        if entity.is_appearance_set(mask):
            self.scripts.call('on_appearance_update')
        if entity.is_charged_mp_set(mask):
            self.scripts.call('on_charged_mp_update')
        if entity.is_flags_set(mask):
            self.scripts.call('on_flags_update')
        if entity.is_consumable_set(mask):
            self.scripts.call('on_consumable_update')
Esempio n. 2
0
    def on_entity_packet(self, packet):
        if self.entity_data is None:
            self.entity_data = create_entity_data()
            self.server.entities[self.entity_id] = self.entity_data

        mask = packet.update_entity(self.entity_data)
        self.entity_data.mask |= mask
        if not self.has_joined and getattr(self.entity_data, 'name', None):
            self.on_join()
            return

        self.scripts.call('on_entity_update', mask=mask)
        # XXX clean this up
        if entity.is_pos_set(mask):
            self.scripts.call('on_pos_update')
        if entity.is_mode_set(mask):
            self.scripts.call('on_mode_update')
        if entity.is_class_set(mask):
            self.scripts.call('on_class_update')
        if entity.is_name_set(mask):
            self.scripts.call('on_name_update')
        if entity.is_multiplier_set(mask):
            self.scripts.call('on_multiplier_update')
        if entity.is_level_set(mask):
            self.scripts.call('on_level_update')
        if entity.is_equipment_set(mask):
            self.scripts.call('on_equipment_update')
        if entity.is_skill_set(mask):
            self.scripts.call('on_skill_update')
        if entity.is_appearance_set(mask):
            self.scripts.call('on_appearance_update')
        if entity.is_charged_mp_set(mask):
            self.scripts.call('on_charged_mp_update')
Esempio n. 3
0
File: ctf.py Progetto: mfgpker/cuwo
    def on_entity_update(self, event):
        entity = self.entity

        if not self.parent.playing or entity.hp <= 0:
            return

        mask = event.mask

        if self.place_entity and entitydata.is_ray_set(mask):
            pos = entity.get_ray_hit()
            pos.z += constants.BLOCK_SCALE // 4
            self.place_entity.set_position(pos)

        if not entitydata.is_pos_set(mask) and not entitydata.is_ray_set(mask):
            return

        if self.flag is not None:
            for base in self.parent.bases:
                if abs(base.pos - entity.pos) < COLLISION_RADIUS:
                    self.flag.set_position(self.flag.spawn_pos)
                    self.server.send_chat(SCORE_POINT.format(name=entity.name))
                    self.server.play_sound(self.parent.config.score_sound)
                    self.flag.holder = None
                    self.flag = None
                    break
            else:
                new_pos = entity.pos.copy()
                new_pos -= entity.get_look_dir() * constants.BLOCK_SCALE * 2
                self.flag.set_position(new_pos)
            return

        for flag in self.parent.flags:
            if flag.holder is not None or flag.placing:
                continue
            if abs(flag.pos - entity.pos) < COLLISION_RADIUS:
                self.server.send_chat(TAKE_FLAG.format(name=entity.name))
                self.server.play_sound(self.parent.config.take_sound)
                self.flag = flag
                flag.holder = self
                flag.set_position(entity.pos)
                break
Esempio n. 4
0
File: ctf.py Progetto: matpow2/cuwo
    def on_entity_update(self, event):
        entity = self.entity

        if not self.parent.playing or entity.hp <= 0:
            return

        mask = event.mask

        if self.place_entity and entitydata.is_ray_set(mask):
            pos = entity.get_ray_hit()
            pos.z += constants.BLOCK_SCALE // 4
            self.place_entity.set_position(pos)

        if not entitydata.is_pos_set(mask) and not entitydata.is_ray_set(mask):
            return

        if self.flag is not None:
            for base in self.parent.bases:
                if abs(base.pos - entity.pos) < COLLISION_RADIUS:
                    self.flag.set_position(self.flag.spawn_pos)
                    self.server.send_chat(SCORE_POINT.format(name=entity.name))
                    self.server.play_sound(self.parent.config.score_sound)
                    self.flag.holder = None
                    self.flag = None
                    break
            else:
                new_pos = entity.pos.copy()
                new_pos -= entity.get_look_dir() * constants.BLOCK_SCALE * 2
                self.flag.set_position(new_pos)
            return

        for flag in self.parent.flags:
            if flag.holder is not None or flag.placing:
                continue
            if abs(flag.pos - entity.pos) < COLLISION_RADIUS:
                self.server.send_chat(TAKE_FLAG.format(name=entity.name))
                self.server.play_sound(self.parent.config.take_sound)
                self.flag = flag
                flag.holder = self
                flag.set_position(entity.pos)
                break
Esempio n. 5
0
    def on_entity_packet(self, packet):
        if self.entity is None:
            self.entity = self.world.create_entity(self.entity_id)
            self.entity.connection = self

        mask = packet.update_entity(self.entity)
        self.entity.mask |= mask
        if not self.has_joined and getattr(self.entity, 'name', None):
            self.on_join()
            return

        self.scripts.call('on_entity_update', mask=mask)
        # XXX clean this up
        if entitydata.is_pos_set(mask):
            self.on_pos_update()
        if entitydata.is_vel_set(mask):
            if self.mounted_entity:
                self.mount(None)
        if entitydata.is_mode_set(mask):
            self.scripts.call('on_mode_update')
        if entitydata.is_class_set(mask):
            self.scripts.call('on_class_update')
        if entitydata.is_name_set(mask):
            self.scripts.call('on_name_update')
        if entitydata.is_multiplier_set(mask):
            self.scripts.call('on_multiplier_update')
        if entitydata.is_level_set(mask):
            self.scripts.call('on_level_update')
        if entitydata.is_equipment_set(mask):
            self.scripts.call('on_equipment_update')
        if entitydata.is_skill_set(mask):
            self.scripts.call('on_skill_update')
        if entitydata.is_appearance_set(mask):
            self.scripts.call('on_appearance_update')
        if entitydata.is_charged_mp_set(mask):
            self.scripts.call('on_charged_mp_update')
        if entitydata.is_flags_set(mask):
            self.scripts.call('on_flags_update')
        if entitydata.is_consumable_set(mask):
            self.scripts.call('on_consumable_update')
Esempio n. 6
0
    def on_entity_packet(self, packet):
        if self.entity is None:
            self.entity = self.world.create_entity(self.entity_id)
            self.entity.connection = self

        mask = packet.update_entity(self.entity)
        self.entity.mask |= mask
        if not self.has_joined and getattr(self.entity, 'name', None):
            self.on_join()
            return

        self.scripts.call('on_entity_update', mask=mask)
        # XXX clean this up
        if entitydata.is_pos_set(mask):
            self.on_pos_update()
        if entitydata.is_vel_set(mask):
            if self.mounted_entity:
                self.mount(None)
        if entitydata.is_mode_set(mask):
            self.scripts.call('on_mode_update')
        if entitydata.is_class_set(mask):
            self.scripts.call('on_class_update')
        if entitydata.is_name_set(mask):
            self.scripts.call('on_name_update')
        if entitydata.is_multiplier_set(mask):
            self.scripts.call('on_multiplier_update')
        if entitydata.is_level_set(mask):
            self.scripts.call('on_level_update')
        if entitydata.is_equipment_set(mask):
            self.scripts.call('on_equipment_update')
        if entitydata.is_skill_set(mask):
            self.scripts.call('on_skill_update')
        if entitydata.is_appearance_set(mask):
            self.scripts.call('on_appearance_update')
        if entitydata.is_charged_mp_set(mask):
            self.scripts.call('on_charged_mp_update')
        if entitydata.is_flags_set(mask):
            self.scripts.call('on_flags_update')
        if entitydata.is_consumable_set(mask):
            self.scripts.call('on_consumable_update')
Esempio n. 7
0
    def on_entity_packet(self, packet):
        if self.entity_data is None:
            self.entity_data = create_entity_data()
            self.server.entities[self.entity_id] = self.entity_data

        mask = packet.update_entity(self.entity_data)
        self.entity_data.mask |= mask
        if not self.has_joined and getattr(self.entity_data, 'name', None):
            self.on_join()
            return

        self.scripts.call('on_entity_update', mask=mask)
        # XXX clean this up
        if entity.is_pos_set(mask):
            self.scripts.call('on_pos_update')
        if entity.is_mode_set(mask):
            self.scripts.call('on_mode_update')
        if entity.is_class_set(mask):
            self.scripts.call('on_class_update')
        if entity.is_name_set(mask):
            self.scripts.call('on_name_update')
        if entity.is_multiplier_set(mask):
            self.scripts.call('on_multiplier_update')
        if entity.is_level_set(mask):
            self.scripts.call('on_level_update')
        if entity.is_equipment_set(mask):
            self.scripts.call('on_equipment_update')
        if entity.is_skill_set(mask):
            self.scripts.call('on_skill_update')
        if entity.is_appearance_set(mask):
            self.scripts.call('on_appearance_update')
        if entity.is_charged_mp_set(mask):
            self.scripts.call('on_charged_mp_update')
        if entity.is_flags_set(mask):
            self.scripts.call('on_flags_update')
        if entity.is_consumable_set(mask):
            self.scripts.call('on_consumable_update')