Esempio n. 1
0
    def fire(self, player, monster):
        # THIS IS ESSENTIALLY COPPIED FROM CLICK HANDLER AND IMPLEMENTED FOR MONSTER ONCE IT CHOOSES A TARGET :d, NO TIME TO MAKE IT NICER ON BOTH ENDS AND OPTIMIZE UNFORTUNATELY
        # SET MAGIC SPRITE ATTACK ANIMATION
        numRows, numCol, startRow, startCol, endRow, endCol, key = getRandomMagicWeapon(
            monster.magic)
        # SET MAGIC SPRITE WEAPON WITH The above
        precisionX = random.randrange(0, 90)
        precisionY = random.randrange(0, 90)
        precisionY -= 45
        precisionX -= 45
        pos = player.particle.pos.copy().add(Vector(precisionX, precisionY))
        radius = 0
        if monster.magic < 500:
            radius = 15
        if monster.magic < 1000 and radius == 0:
            radius = 20
        if monster.magic < 5000 and radius == 0:
            radius = 25
        if monster.magic < 20000 and radius == 0:
            radius = 30
        if monster.magic < 50000 and radius == 0:
            radius = 35
        if monster.magic > 50000 and radius == 0:
            radius = 40

        weapon = Weapon(pos, Vector(0, 0),
                        0, pos, 0, 0, radius, key, spriteDictionary, 20,
                        getUid(), numRows, numCol, startRow, startCol, endRow,
                        endCol, False, True, monster.magic)
        # BIND SPRITE TO MONSTER and MONSTER TO SPRITE to remember who kills who
        weapon.idPlayer = monster.idObject
        weapon_set.add(weapon)

        # SET MAGIC SPRITE CASTING ANIMATION USE PARTICLE CLASS ADD TO VISUAL SET
        # SHIFT ALL MAGIC SPRITES UP FOR MONSTER IF SMALL
        pos = monster.particle.pos.copy()
        if monster.particle.dim.getY() < 120:
            pos.y -= 30
        numRows, numCol, startRow, startCol, endRow, endCol, key = getRandomMagicCast(
            monster.magic)
        particle = Particle(True, pos, Vector(0, 0), 0, pos, 0, 0,
                            0, 0, key, spriteDictionary, 15, False, True,
                            getUid(), numRows, numCol, startRow, startCol,
                            endRow, endCol)
        visual_set.add(particle)

        monster.particle.vel.multiply(0)
        monster.particle.nextPosTime = time.time()
        monster.particle.nextPos = monster.particle.pos
        monster.hasFired = True
Esempio n. 2
0
    def spawnT1(
        self
    ):  # WITHIN 25% OF MAP CENTER, OPERATION RANGE OF 1000, ATTACK RANGE OF 500 t1, 1500,t2, 2500 t3? for lols
        # the following locations on the map X axis and y axis randomly:   \_________XXXXXX___________\
        pos = Vector(
            random.randint(int(MAP_WIDTH / 2 - MAP_WIDTH / 3),
                           int(MAP_WIDTH / 2 + MAP_WIDTH / 3)),
            random.randint(int(MAP_HEIGHT / 2 - MAP_HEIGHT / 3),
                           int(MAP_HEIGHT / 2 + MAP_HEIGHT / 3)))
        vel = Vector(0, 0)
        maxVel = 100  # why not

        aBack, numRows, numCol, startRow, startCol, endRow, endCol, key = getRandomMonster(
            1)
        monster = Monster(pos, vel, 0, pos, maxVel, 0, 50,
                          key, spriteDictionary, 15, getUid(), False,
                          Vector(0, 0), 1, numRows, numCol, startRow, startCol,
                          endRow, endCol, 1, aBack, False,
                          random.randrange(6000, 10000), pos.copy(),
                          pos.copy().normalize().multiply(1000), 200, 500)

        monster.setSpriteState(2)

        monster.totalLife = monster.life
        monster.magic = random.randrange(200, 1000)
        monster.range = random.randrange(200, 1000)
        monster_set.add(monster)
Esempio n. 3
0
def randomGrass():
    width, height = int(config['MAP']['WIDTH']), int(config['MAP']['HEIGHT'])
    # Calculate some random grass values

    lightId = 1
    medId = 2
    darkId = 3

    for x in range(0, int(width / 512)+1):
        for y in range(0, int(height / 512)+1):
            winner = 0
            dh = random.randrange(80, 100) / 100
            dl = random.randrange(1, 30) / 100
            mh = random.randrange(60, 100) / 100
            ml = random.randrange(1, 50) / 100
            if y > (height / 512) * dh or y < (height / 512) * dl or x > (width / 512) * dh or x < (width / 512) * dl:
                grass = getRandomString('en_l1_gs_d_', 5)

            elif (y > (height / 512) * mh or y < (height / 512) * ml) or (
                    x > (width / 512) * mh or x < (width / 512) * ml):

                grass = getRandomString('en_l1_gs_m_', 5)
            else:

                grass = getRandomString('en_l1_gs_l_', 5)
            # Grass
            pos = Vector(x * 512, y * 512)

            env_l1_set.add(Particle(False, pos, Vector(0, 0), 0, pos, 0, 0, 0, 0,
                                    grass, spriteDictionary, 0.0001, False, False, getUid(), 1, 1, 1, 1, 1, 1))
Esempio n. 4
0
    def spawnT3(
        self
    ):  # WITHIN 25% OF MAP CENTER, OPERATION RANGE OF 1000, ATTACK RANGE OF 500 t1, 1500,t2, 2500 t3? for lols

        topBand = Vector(random.randrange(0, int(MAP_WIDTH)),
                         random.randrange(0, int(MAP_HEIGHT *
                                                 0.15)))  # bottom 25% of map

        bottomBand = Vector(
            random.randrange(0, int(MAP_WIDTH)),
            random.randrange(int(MAP_HEIGHT * 0.85),
                             int(MAP_HEIGHT)))  # top 25% of map

        leftBand = Vector(random.randrange(0, int(MAP_WIDTH * 0.15)),
                          random.randrange(0,
                                           int(MAP_HEIGHT)))  # left 25% of map

        rightBand = Vector(
            random.randrange(int(MAP_WIDTH * 0.85), int(MAP_WIDTH)),
            random.randrange(0, int(MAP_HEIGHT)))  # right 25% of map

        num = random.randrange(0, 400)
        if num > 300:
            pos = topBand
        elif num > 200:
            pos = bottomBand
        elif num > 100:
            pos = leftBand
        else:
            pos = rightBand

        # the following locations on the map X axis and y axis randomly:   \XXXXX______________________XXXXX\
        vel = Vector(0, 0)
        maxVel = 200  # why not
        aBack, numRows, numCol, startRow, startCol, endRow, endCol, key = getRandomMonster(
            3)
        monster = Monster(pos, vel, 0, pos, maxVel, 0, 100,
                          key, spriteDictionary, 15, getUid(), False,
                          Vector(0, 0), 1, numRows, numCol, startRow, startCol,
                          endRow, endCol, 3, aBack, False,
                          random.randrange(500000, 1000000), pos.copy(),
                          pos.copy().normalize().multiply(1000), 500, 1000)
        monster.setSpriteState(2)

        monster.life = random.randrange(500000, 1000000)
        monster.totalLife = monster.life
        monster.magic = random.randrange(50000, 100000)

        monster.operationOrigin = pos.copy()

        monster_set.add(monster)
Esempio n. 5
0
    def spawnT2(
        self
    ):  # WITHIN 25-75% OF MAP CENTER, OPERATION RANGE OF 3000, ATTACK RANGE OF 500 t1, 1500,t2, 2500 t3? for lols
        topBand = Vector(random.randrange(0, int(MAP_WIDTH)),
                         random.randrange(int(MAP_HEIGHT * 0.1),
                                          int(MAP_HEIGHT *
                                              0.25)))  # bottom 25% of map

        bottomBand = Vector(random.randrange(0, int(MAP_WIDTH)),
                            random.randrange(int(MAP_HEIGHT * 0.75),
                                             int(MAP_HEIGHT *
                                                 0.9)))  # top 25% of map

        leftBand = Vector(
            random.randrange(int(MAP_WIDTH * 0.1), int(MAP_WIDTH * 0.25)),
            random.randrange(0, int(MAP_HEIGHT)))  # left 25% of map

        rightBand = Vector(
            random.randrange(int(MAP_WIDTH * 0.75), int(MAP_WIDTH * 0.9)),
            random.randrange(0, int(MAP_HEIGHT)))  # right 25% of map

        num = random.randrange(0, 400)
        if num > 300:
            pos = topBand
        elif num > 200:
            pos = bottomBand
        elif num > 100:
            pos = leftBand
        else:
            pos = rightBand

        maxVel = 120  # why not
        vel = Vector(0, 0)

        aBack, numRows, numCol, startRow, startCol, endRow, endCol, key = getRandomMonster(
            2)
        monster = Monster(pos, vel, 0, pos, maxVel, 0, 75,
                          key, spriteDictionary, 15, getUid(), False,
                          Vector(0, 0), 1, numRows, numCol, startRow, startCol,
                          endRow, endCol, 2, aBack, False,
                          random.randrange(50000, 300000), pos.copy(),
                          pos.copy().normalize().multiply(1000), 300, 700)
        monster.setSpriteState(2)

        monster.totalLife = monster.life
        monster.magic = random.randrange(10000, 30000)
        monster.range = random.randrange(10000, 30000)

        monster_set.add(monster)
Esempio n. 6
0
def randomTrees():
    width, height = int(config['MAP']['WIDTH']), int(config['MAP']['HEIGHT'])
    # Calculate some random grass values

    lightId = 1
    medId = 2
    darkId = 3
    cut = 50
    for y in range(0, int(height // cut)):
        for x in range(0, int(width // cut)):

            winner = 0
            dh = random.randrange(80, 100) / 100
            dl = random.randrange(1, 30) / 100
            mh = random.randrange(60, 100) / 100
            ml = random.randrange(1, 50) / 100
            prob = 0
            if y > (height / cut) * dh or y < (height / cut) * dl or x > (width / cut) * dh or x < (width / cut) * dl:
                prob = 500

            elif (y > (height / cut) * mh or y < (height / cut) * ml) or (
                    x > (width / cut) * mh or x < (width / cut) * ml):
                prob = 250

            else:
                prob = 125

            # Grass
            pos = Vector(x * cut, y * cut)

            num = random.randrange(0, int(config['MAP']['TREE_RANGE']))
            tree = getRandomString('en_l2_ts_1x1_', 22)
            t1 = Particle(False, pos, Vector(0, 0), 0, pos, 0, 0, 0, 0,
                          tree, spriteDictionary, 0.0001, False, False, getUid(), 1, 1, 1, 1, 1, 1)
            t1.radius /= 1.6
            if num > prob:
                pass
            else:
                rand=random.randint(1,2)
                if rand==1:
                    tree = getRandomString('en_l2_ts_1x1_', 22)
                    t1 = Particle(False, pos, Vector(0, 0), 0, pos, 0, 0, 0, 0,
                                  tree, spriteDictionary, 0.0001, False, False, getUid(), 1, 1, 1, 1, 1, 1)
                    t1.radius /= 1.6
                if rand==2:
                    rand=random.randint(1,3)
                    if rand==1:
                        tree='en_l2_ts_15x4_1'
                        t1 = Particle(True, pos, Vector(0, 0), 0, pos, 0, 0, 0, 0,
                                      tree, spriteDictionary, 0.5, False, False, getUid(), 4, 15, 1, 1, 4, 15)
                        t1.radius/=2

                    if rand==2:
                        tree = 'en_l2_ts_6x5_1'
                        t1 = Particle(True, pos, Vector(0, 0), 0, pos, 0, 0, 0, 0,
                                      tree, spriteDictionary, 24, False, False, getUid(), 5, 6, 1, 1, 5, 6)
                        t1.radius/=1.6

                env_l2_list.append(t1)

                # half tree radius to get nice coverage for updating choice intercection

            env_l2_list.reverse()