Exemple #1
0
        def grenade_exploded(self, grenade):
            # inknade

            if self.team is not None:
                # adjust position
                pos = grenade.position.copy()
                mp = self.protocol.map

                for i in range(0, 1):
                    if mp.get_solid(int(pos.x), int(pos.y), int(pos.z)) or \
                        mp.get_solid(int(pos.x), int(pos.y), int(pos.z) - 1) or \
                        mp.get_solid(int(pos.x), int(pos.y), int(pos.z) - 2):
                        break
                    pos.z -= 1.0

                pts = []

                for i in range(0, INKNADE_RAYS):
                    orient = Vertex3(random.gauss(0.0, 1.0), random.gauss(0.0, 1.0), random.gauss(0.0, 1.0))
                    orient.normalize()
                    dummy_character = world.Character(grenade.world, pos, orient)

                    loc = dummy_character.cast_ray(INKNADE_RANGE * 2.0)
                    if loc:
                        x, y, z = loc
                        if (Vertex3(x, y, z) - pos).length_sqr() > INKNADE_RANGE*INKNADE_RANGE:
                            # out of range
                            continue
                        pts.append((x, y, z))
                self.protocol.paint_block_by_team_splat(self, pts, self.team, random.randint(INKNADE_DROP_SIZE_MIN, INKNADE_DROP_SIZE_MAX))

            return connection.grenade_exploded(self, grenade)
Exemple #2
0
        def on_hit(self, hit_amount, hit_player, type, grenade):
            if self != hit_player and type in [WEAPON_KILL, HEADSHOT_KILL] and self.team is not None:
                # inkdamage
                pos = hit_player.world_object.position
                pts = []
                for i in range(0, INKDAMAGE_RAYS):
                    orient = Vertex3(random.gauss(0.0, 1.0), random.gauss(0.0, 1.0), random.gauss(0.0, 1.0))
                    orient.normalize()
                    dummy_character = world.Character(self.world_object.world, pos, orient)

                    loc = dummy_character.cast_ray(INKDAMAGE_RANGE * 2.0)
                    if loc:
                        x, y, z = loc
                        if (Vertex3(x, y, z) - pos).length_sqr() > INKDAMAGE_RANGE*INKDAMAGE_RANGE:
                            # out of range
                            continue
                        pts.append((x, y, z))
                self.protocol.paint_block_by_team_splat(self, pts, self.team, random.randint(INKDAMAGE_DROP_SIZE_MIN, INKDAMAGE_DROP_SIZE_MAX))

                # heal
                if HEAL_BY_FRIENDLY_FIRE and self.team == hit_player.team:
                    if hit_player.hp < 100:
                        hit_player.set_hp(min(hit_player.hp + hit_amount, 100))
                        hit_player.send_chat("N%% You were healed by %s" % hit_player.name)
                    return False

            return connection.on_hit(self, hit_amount, hit_player, type, grenade)
Exemple #3
0
        def _on_fire(self):
            if self.team is not None and self.world_object is not None:
                bullets = self.weapon_object.generate_bullet_direction(self.world_object.orientation)
                params = weapon_trajectory_param[self.weapon_object.id]
                weapon_range = params['range']

                pts = []
                for bullet in bullets:

                    dummy_character = world.Character(self.world_object.world, self.world_object.position, bullet)

                    loc = dummy_character.cast_ray(weapon_range * 2.0)
                    if loc:
                        x, y, z = loc
                        if (Vertex3(x, y, z) - self.world_object.position).length_sqr() > weapon_range*weapon_range:
                            # out of range
                            continue
                        pts.append((x, y, z))
                self.protocol.paint_block_by_team_splat(self, pts, self.team, params['drop_size'])