Ejemplo n.º 1
0
 def set(self):
     rot = self.get_rot()
     look_vec = rot * Vector3((0.0, 1.0, 0.0))
     up_vec = rot * Vector3((0.0, 0.0, 1.0))
     look_vec += self.pos
     gluLookAt(self.pos.x, self.pos.y, self.pos.z, look_vec.x, look_vec.y,
               look_vec.z, up_vec.x, up_vec.y, up_vec.z)
Ejemplo n.º 2
0
 def get_look_dir(self):
     yaw = math.radians(self.body_yaw + 90)
     pitch = math.radians(self.body_pitch)
     x = math.cos(yaw) * math.cos(pitch)
     y = math.sin(yaw) * math.cos(pitch)
     z = math.sin(pitch)
     return Vector3(x, y, z)
Ejemplo n.º 3
0
def teleport(script, a, b=None):
    """Teleport to a chunk or player."""
    entity = script.connection.entity

    if b is None:
        player = script.get_player(a)
        pos = player.entity.pos
    else:
        pos = Vector3(int(a), int(b), 0) * constants.CHUNK_SCALE
        pos.z = script.world.get_height(pos.xy) or entity.pos.z

    update_packet = script.server.update_packet
    chunk = script.connection.chunk

    packet = create_teleport_packet(pos, chunk.pos, entity.entity_id)
    update_packet.static_entities.append(packet)

    def send_reset_packet():
        if chunk.static_entities:
            chunk.static_entities[0].update()
        else:
            packet = create_teleport_packet(pos, chunk.pos, 0)
            update_packet.static_entities.append(packet)

    script.loop.call_later(0.1, send_reset_packet)
Ejemplo n.º 4
0
    def load_config(self):
        self.saved_config = self.server.load_data(KOTH_DATA, {})

        if 'location_x' in self.saved_config:
            self.event_location = Vector3(self.saved_config['location_x'],
                                          self.saved_config['location_y'],
                                          self.saved_config['location_z'])
        if 'radius' in self.saved_config:
            self.proximity_radius = self.saved_config['radius']

        if self.event_location is not None:
            self.start(self.event_location)
Ejemplo n.º 5
0
 def set_lighting(self):
     v1 = Vector3((0.3, -0.7, -0.6)).normalized
     light1_position = GLfloat_4(v1.x, v1.y, v1.z, 0.0)
     diffuse = 0.6
     light_diffuse = GLfloat_4(diffuse, diffuse, diffuse, 1.0)
     light_ambient = GLfloat_4(0.0, 0.0, 0.0, 1.0)
     specular = 0.0
     light_specular = GLfloat_4(specular, specular, specular, 1.0)
     glLightfv(GL_LIGHT0, GL_POSITION, light1_position)
     glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse)
     glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient)
     glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular)
     v2 = Vector3((-0.3, 0.7, -0.6)).normalized
     light2_position = GLfloat_4(v2.x, v2.y, v2.z, 0.0)
     glLightfv(GL_LIGHT1, GL_POSITION, light2_position)
     glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse)
     glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient)
     glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular)
     f = 0.6
     light_model = GLfloat_4(f, f, f, 1.0)
     glLightModelfv(GL_LIGHT_MODEL_AMBIENT, light_model)
Ejemplo n.º 6
0
def damage_player(script, player, damage=0, stun_duration=0):
    packet = HitPacket()
    packet.entity_id = player.entity_id
    packet.target_id = player.entity_id
    packet.hit_type = HIT_NORMAL
    packet.damage = damage
    packet.critical = 1
    packet.stun_duration = stun_duration
    packet.something8 = 0
    packet.pos = player.position
    packet.hit_dir = Vector3()
    packet.skill_hit = 0
    packet.show_light = 0
    script.server.update_packet.player_hits.append(packet)
Ejemplo n.º 7
0
 def silent_damage(self, damage):
     packet = HitPacket()
     packet.critical = 0
     packet.damage = damage
     packet.entity_id = self.connection.entity_id
     packet.target_id = self.connection.entity_id
     packet.hit_dir = Vector3()
     packet.pos = self.connection.entity.pos
     packet.hit_type = 2
     packet.show_light = 0
     packet.something8 = 0
     packet.stun_duration = 0
     packet.skill_hit = 0
     self.server.update_packet.player_hits.append(packet)
Ejemplo n.º 8
0
def create_teleport_packet(pos, chunk_pos, user_id):
    packet = static.StaticEntityPacket()
    header = static.StaticEntityHeader()
    packet.header = header
    packet.chunk_x = chunk_pos[0]
    packet.chunk_y = chunk_pos[1]
    packet.entity_id = 0
    header.set_type('Bench')
    header.size = Vector3(0, 0, 0)
    header.closed = True
    header.orientation = static.ORIENT_SOUTH
    header.pos = pos
    header.time_offset = 0
    header.something8 = 0
    header.user_id = user_id
    return packet
Ejemplo n.º 9
0
 def update(self, dt):
     move = Vector3()
     if self.up:
         move.y = 1.0
     elif self.down:
         move.y = -1.0
     if self.left:
         move.x = -1.0
     elif self.right:
         move.x = 1.0
     if self.shift:
         speed = 150
     else:
         speed = 50
     speed *= dt
     self.pos += self.get_rot() * (move * speed)
Ejemplo n.º 10
0
 def damage(self, damage=0, stun_duration=0):
     packet = packets.HitPacket()
     packet.entity_id = self.entity_id
     packet.target_id = self.entity_id
     packet.hit_type = packets.HIT_NORMAL
     packet.damage = damage
     packet.critical = 1
     packet.stun_duration = stun_duration
     packet.something8 = 0
     packet.pos = self.pos
     packet.hit_dir = Vector3()
     packet.skill_hit = 0
     packet.show_light = 0
     self.world.server.update_packet.player_hits.append(packet)
     if self.hp <= 0:
         return
     self.hp -= damage
     if self.connection and self.hp <= 0:
         self.connection.scripts.call('on_die', killer=None)
Ejemplo n.º 11
0
def create_appearance_data():
    appearance = AppearanceData()
    appearance.not_used_1 = 0
    appearance.not_used_2 = 0
    appearance.hair_red = 0
    appearance.hair_green = 0
    appearance.hair_blue = 0
    appearance.flags = 0
    appearance.scale.set(1.0, 1.0, 1.0)
    appearance.head_model = -32767
    appearance.hair_model = -32767
    appearance.hand_model = -32767
    appearance.foot_model = -32767
    appearance.body_model = -32767
    appearance.back_model = -32767
    appearance.shoulder_model = -32767
    appearance.wing_model = -32767
    appearance.head_scale = 1.0
    appearance.body_scale = 1.0
    appearance.hand_scale = 1.0
    appearance.foot_scale = 1.0
    appearance.shoulder_scale = 1.0
    appearance.weapon_scale = 1.0
    appearance.back_scale = 1.0
    appearance.unknown = 1.0
    appearance.wing_scale = 1.0
    appearance.body_pitch = 0
    appearance.arm_pitch = 0
    appearance.arm_roll = 0
    appearance.arm_yaw = 0
    appearance.feet_pitch = 0
    appearance.wing_pitch = 0
    appearance.back_pitch = 0
    appearance.body_offset = Vector3()
    appearance.head_offset = Vector3()
    appearance.hand_offset = Vector3()
    appearance.foot_offset = Vector3()
    appearance.back_offset = Vector3()
    appearance.wing_offset = Vector3()
    return appearance
Ejemplo n.º 12
0
})

APPEARANCES = dict({
    2: {'scale': 0.96,
        'radius': 0.96,
        'height': 2.16,
        'scale_head': 1.01,
        'scale_feet': 0.98,
        'scale_hand': 1.00,
        'scale_body': 1.00,
        'scale_back': 0.80,
        'scale_shoulder': 1.00,
        'scale_weapon': 0.98,
        'scale_wing': 1.00,
        'scale_unknown': 1.00,
        'offset_body': Vector3(0, 0, -5),
        'offset_head': Vector3(0, 0.5, 5),
        'offset_hand': Vector3(6, 0, 0),
        'offset_foot': Vector3(3, 1, -10.5),
        'offset_back': Vector3(0, -8, 2),
        'offset_wing': Vector3(0, 0, 0),
        'model_head': range(1246, 1251 + 1),
        'model_hair': range(1252, 1266 + 1),
        'model_feet': (432, ),
        'model_hand': (430, 431),
        'model_body': (1, ),
        'model_back': (-1, ),
        'model_shoulder': (-1, ),
        'model_wing': (-1, )},

    3: {'scale': 0.96,
Ejemplo n.º 13
0
    def start(self, location):
        print("King of the hill mode activated at " + str(location))
        self.event_location = location.copy()
        self.event_active = True

        entity = self.event_entity
        if entity is None:
            entity = create_entity_data(self.world)

            entity.hostile_type = constants.FRIENDLY_TYPE
            entity.entity_type = 138

            entity.appearance.flags = 1 << 8
            entity.appearance.scale.set(3.0, 3.0, 4.0)
            entity.appearance.body_model = 2565
            entity.appearance.head_scale = 0.0
            entity.appearance.hand_scale = 0.0
            entity.appearance.body_offset = Vector3(0, 0, 25)

            entity.level = math.pow(2, 31) - 1
            entity.power_base = 0

            entity.name = "King ofthe Hill"

        entity.mask = 0x0000FFFFFFFFFFFF
        entity.pos = location.copy()
        entity.pos += Vector3(0, 0, 100000)
        entity.spawn_pos = entity.pos
        entity.hp = 10000000000

        self.event_entity = entity

        # Create a dummy entity that is hostile, only way
        # HitPacket will grant xp
        dummy = self.event_dummy
        if dummy is None:
            dummy = create_entity_data(self.world)
            dummy.mask = constants.FULL_MASK
            dummy.hostile_type = 1
            dummy.pos = Vector3(0, 0, 100000000) + entity.pos
            dummy.spawn_pos = entity.pos
            dummy.hp = 10000000000
            dummy.power_base = 1
            dummy.name = "KOTHDummy!"
            dummy.appearance.flags = 1 << 8

            self.event_dummy = dummy

        # Create entities in a circle around the main pillar
        radius_ents = 10
        for i in range(radius_ents):
            radius_entity = None
            id = 1002 + i
            if id in self.event_radius_entities:
                radius_entity = self.event_radius_entities[id]

            if radius_entity is None:
                radius_entity = create_entity_data(self.world)

                radius_entity.mask = constants.FULL_MASK
                radius_entity.hostile_type = 2
                radius_entity.entity_type = 136

                radius_entity.hp = 10000000000
                radius_entity.level = math.pow(2, 31) - 1
                radius_entity.power_base = 0
                radius_entity.spawn_pos = self.event_entity.pos

                radius_entity.appearance.scale.set(1.0, 1.0, 1.5)
                radius_entity.appearance.body_offset.set(0, 0, 0)
                radius_entity.appearance.flags = 1 << 8
                radius_entity.appearance.body_model = 2475
                radius_entity.appearance.head_scale = 0.0
                radius_entity.appearance.hand_scale = 0.0

                radius_entity.name = "King ofthe Hill"

            r = math.pi * 2 / radius_ents * i
            x = math.sqrt(self.proximity_radius) * math.sin(r)
            y = math.sqrt(self.proximity_radius) * math.cos(r)
            radius_entity.pos = Vector3(x, y, 0) + self.event_entity.pos
            radius_entity.hp = 10000000000
            radius_entity.mask = 0x0000FFFFFFFFFFFF
            radius_entity.velocity = Vector3(0, 0, -100000)
            self.event_radius_entities[id] = radius_entity
            self.world.entities[id] = radius_entity

        self.create_mission_data()

        self.save_config()
Ejemplo n.º 14
0
def create_entity_data(world):
    entity = world.create_entity()
    entity.mask = constants.FULL_MASK
    entity.pos = Vector3(0, 0, 0)
    entity.body_roll = 0
    entity.body_pitch = 0
    entity.body_yaw = 0
    entity.velocity = Vector3()
    entity.accel = Vector3()
    entity.extra_vel = Vector3()
    entity.look_pitch = 0
    entity.physics_flags = 17
    entity.hostile_type = 0
    entity.entity_type = 0
    entity.current_mode = 0
    entity.mode_start_time = 0
    entity.hit_counter = 0
    entity.last_hit_time = 0
    entity.appearance = create_appearance_data()
    entity.flags = 64
    entity.roll_time = 0
    entity.stun_time = -10000
    entity.slowed_time = 0
    entity.make_blue_time = 0
    entity.speed_up_time = 0
    entity.show_patch_time = 0
    entity.class_type = 0
    entity.specialization = 0
    entity.charged_mp = 0
    entity.not_used_1 = 0
    entity.not_used_2 = 0
    entity.not_used_3 = 0
    entity.not_used_4 = 0
    entity.not_used_5 = 0
    entity.not_used_6 = 0
    entity.ray_hit = Vector3()
    entity.hp = 100
    entity.mp = 0
    entity.block_power = 0
    entity.max_hp_multiplier = 100
    entity.shoot_speed = 1
    entity.damage_multiplier = 1
    entity.armor_multiplier = 1
    entity.resi_multiplier = 1
    entity.not_used7 = 0
    entity.not_used8 = 0
    entity.level = 1
    entity.current_xp = 0
    entity.parent_owner = 0
    entity.unknown_or_not_used1 = 1
    entity.unknown_or_not_used2 = 0
    entity.power_base = 0
    entity.unknown_or_not_used4 = -1
    entity.not_used12 = 0
    entity.super_weird = 0
    entity.spawn_pos = Vector3(0, 0, 0)
    entity.not_used19 = 0
    entity.consumable = create_item_data()
    entity.equipment = []
    for _ in range(13):
        new_item = create_item_data()
        entity.equipment.append(new_item)
    entity.skills = []
    for _ in range(11):
        entity.skills.append(0)
    entity.mana_cubes = 0
    entity.name = ""
    return entity
Ejemplo n.º 15
0
 def __init__(self):
     self.pos = Vector3((40.31, 158.36, 173.21))