예제 #1
0
def monster_dead(i):
    global active_button
    #make the display look better
    monster_list[i].hp = 0
    #add info to listbox_move; add gold and xp
    main.print_message("The " + monster_list[i].name + " dies.")

    if len(monster_list[i].on_death) == 0:
        gold = monster_list[i].gold
        player.give_stat("gold", gold)
        main.print_message("You find " + str(gold) + " " +
                           g.gold_name.lower() + ",")

        exp = monster_list[i].exp
        main.print_message("and get " + str(exp) + " " + g.exp_name.lower() +
                           ".")
        player.add_exp(exp)
    else:
        action.activate_lines(g.xgrid, g.ygrid, g.zgrid,
                              monster_list[i].on_death)

    #finish up
    if can_leave() == 1:
        g.break_one_loop += 1
        #		main.canvas_map.delete("battle")
        #		back_to_main.set("2")
        g.cur_window = "main"
        global did_run
        did_run = 0
    else:
        for i in range(len(monster_list)):
            if monster_list[i].hp > 0:
                active_button = i
                break
        refresh()
예제 #2
0
def use_item(item_index=-1):
    #	if action.has_dialog == 1: return 0
    if item_index == -1:
        if curr_item >= len(item.inv) or item.inv[curr_item] == -1:
            return 0

        #put the item[] index of the item into item_value
        try:
            item_value = item.inv[curr_item]
        except IndexError:
            return 0

        #put the equip slot into item_loc
        item_loc = item.item[item_value].type
        #if equipment
        if item_loc < 6:
            wear_item()
            return
        if item_loc == 15:
            return
        main.print_message("You use your " + item.item[item_value].name)
    else:
        item_value = item_index
        item_loc = item.item[item_index].type
    #if item is healing
    if item_loc == 11:
        #heal the player, delete the item
        player.give_stat("hp", item.item[item_value].quality)
        if item_index == -1:
            item.drop_inv_item(curr_item)
    if item_loc == 16 or item_loc == 17:
        if action.activate_lines(g.xgrid, g.ygrid, g.zgrid,
                                 item.item[item_value].scripting) == 1:
            if item_index == -1:
                item.drop_inv_item(curr_item)

    if item_index == -1:
        refresh_use()
        refresh_stat_display()
예제 #3
0
def useskill(free_skill=0):
    #sanity checks
    skill_index = curr_item
    if skill_index >= len(player.skill): return 0

    if free_skill == 0:
        if player.skill[skill_index][5] == 0: return 0
        if player.skill[skill_index][2] > player.ep: return 0

    if player.skill[skill_index][1] == 5 or \
                    player.skill[skill_index][1] == 6:  #Scripted
        tempxy = (g.xgrid, g.ygrid, g.zgrid)
        #If the scripting ends with an "end" command,
        if action.activate_lines(g.xgrid, g.ygrid, g.zgrid,
                                 player.skill[skill_index][6]) == 1:
            if free_skill == 0:
                #pay for the skill
                player.give_stat("ep", -1 * player.skill[skill_index][2])
        main.refresh_bars()
        refresh_stat_display()
        if tempxy != (g.xgrid, g.ygrid, g.zgrid):
            return "end"
    return 1
예제 #4
0
def useskill(skill_index, free_skill=0):
    global active_button
    #don't do anything if monster is dead.
    if can_leave() == 1:
        return 0

    clear_slashes()

    #sanity checks
    if skill_index >= len(player.skill): return 0

    if free_skill == 0:
        if player.skill[skill_index][5] == 0: return 0
        if player.skill[skill_index][2] > player.ep: return 0
        if player.skill[skill_index][1] == 5: return 0

    #actually use the skill.
    if player.skill[skill_index][1] == 0:  #rage
        if free_skill == 0:
            #pay for the skill
            player.give_stat("ep", -1 * player.skill[skill_index][2])
        main.print_message("You fly into a rage.")
        #increase attack ability
        player.give_stat("adj_attack", (1 + int(player.level) / 4))
        main.refresh_bars()
        main.refresh_inv_icon()
        attack_player()

    elif player.skill[skill_index][1] == 1:  #Sneak away
        if free_skill == 0:
            #pay for the skill
            player.give_stat("ep", -1 * player.skill[skill_index][2])
        global run_attempts
        if g.die_roll(1, 10 + int(player.level) + run_attempts) > 4:
            runaway(True)
            global did_run
            did_run = 1
        else:
            run_attempts += 3
            main.print_message("You fail to sneak away.")
            attack_player()
    elif player.skill[skill_index][1] == 2:  #Frenzy
        if free_skill == 0:
            #pay for the skill
            player.give_stat("ep", -1 * player.skill[skill_index][2])
        mon_num = select_monster()
        for i in range(2 + int(player.level) / 4):
            if monster_list[mon_num].hp < 1:
                mon_num = select_monster()
            if mon_num == -1: return 0
            attack_monster(mon_num, player.adj_attack)
            if can_leave() == 1:
                break
            active_button = -1
            monster_mouse_move((0, 0))
            refresh()
        if can_leave() == 0: attack_player()
    elif player.skill[skill_index][1] == 3:  #Dismember
        if free_skill == 0:
            #pay for the skill
            player.give_stat("ep", -1 * player.skill[skill_index][2])
        mon_num = select_monster()
        if mon_num == -1: return 0
        damage = (player.adj_attack)
        monster_hurt(mon_num, damage)
        if can_leave() == 0:
            attack_player()
    elif player.skill[skill_index][1] == 4 or \
                    player.skill[skill_index][1] == 6:  #Scripted
        #If the scripting ends with an "end" command,
        if action.activate_lines(g.xgrid, g.ygrid, g.zgrid,
                                 player.skill[skill_index][6]) == 1:
            if free_skill == 0:
                #pay for the skill
                player.give_stat("ep", -1 * player.skill[skill_index][2])
        if can_leave() == 0:
            attack_player()
        main.refresh_bars()

    if can_leave() == 1:
        inv.leave_inner()
        return 0
    active_button = -1
    monster_mouse_move((0, 0))
    refresh()

    #replace the cursor
    if free_skill == 0:
        inv.leave_inner()
        refresh_buttons()
예제 #5
0
def useitem(item_index, leave_item=0):
    global active_button
    #don't do anything if battle is over.
    if can_leave() == 1 or item_index == -1:
        return 0
    clear_slashes()
    item_value = item_index
    item_type = g.item.item[item_value].type

    #if item is healing
    if item_type == 11:
        #heal the player, delete the item
        player.give_stat("hp", g.item.item[item_value].quality)
        main.print_message("You are healed for " +
                           str(g.item.item[item_value].quality) + " " +
                           g.hp_name + ".")
        if leave_item == 0:
            g.item.drop_inv_item(g.item.find_inv_item(item_value))
            attack_player()

    #if item is a gem
    if item_type == 14:
        global old_attack
        old_attack = player.adj_attack
        gem_power = g.item.item[item_value].quality
        #gem power increases attack strength potential
        player.give_stat("adj_attack", gem_power * 0.75)
        #gem power increases num_dice (ie. chance to hit and total damage)
        global num_dice
        num_dice = num_dice + gem_power / 4
        main.print_message("The " + g.item.item[item_value].name +
                           " focuses the power of your " +
                           g.attack_name.lower() + ".")
        main.refresh_bars()
        if leave_item == 0:
            g.item.drop_inv_item(g.item.find_inv_item(item_value))
        global used_gem
        used_gem = 1
        if leave_item == 0: attack()

    #if item is explosive
    if item_type == 12:
        sel_mon = select_monster()
        if sel_mon == -1: return 0
        #if monster is still alive
        if monster_list[sel_mon].hp > 0:
            damage = int(g.item.item[item_value].quality)
            if leave_item == 0:
                g.item.drop_inv_item(g.item.find_inv_item(item_value))
            monster_hurt(sel_mon, damage)
            if can_leave() == 0 and leave_item == 0:
                attack_player()
        active_button = -1

    #If item is scripted:
    if item_type == 15 or item_type == 17:
        #If the scripting ends with an "end" command,
        if action.activate_lines(g.xgrid, g.ygrid, g.zgrid,
                                 g.item.item[item_value].scripting) == 1:
            if leave_item == 0:
                g.item.drop_inv_item(g.item.find_inv_item(item_value))
        if can_leave() == 0 and leave_item == 0:
            attack_player()
        active_button = -1

    #If item is equippable:
    if item_type < 6:
        #trade the item and whatever's in the equip slot
        temp = player.equip[item_type]
        player.equip[item_type] = item_index
        g.item.drop_inv_item(g.item.find_inv_item(item_index))
        g.item.take_inv_item(temp)
        main.print_message("You equip yourself with your " +
                           g.item.item[player.equip[item_type]].name + ".")
        player.reset_stats()
        if can_leave() == 0 and leave_item == 0:
            attack_player()

    if can_leave() == 1:
        inv.leave_inner()
        return 0
    refresh()

    #back to battle
    if leave_item == 0:
        inv.leave_inner()
        refresh_buttons()