Example #1
0
def IdentifyUseScroll():
    """Identifies the item with a scroll or other item."""

    global ItemIdentifyWindow

    pc = GemRB.GameGetSelectedPCSingle()
    slot = GemRB.GetVar("ItemButton")
    if ItemIdentifyWindow:
        ItemIdentifyWindow.Unload()
    if ItemInfoWindow:
        ItemInfoWindow.Unload()
    if GemRB.HasSpecialItem(pc, 1, 1):
        GemRB.ChangeItemFlag(pc, slot, IE_INV_ITEM_IDENTIFIED, OP_OR)
    OpenItemInfoWindow()
    return
Example #2
0
def IdentifyUseSpell ():
	"""Identifies the item with a memorized spell."""

	global ItemIdentifyWindow

	pc = GemRB.GameGetSelectedPCSingle ()
	slot = GemRB.GetVar ("ItemButton")
	if ItemIdentifyWindow:
		ItemIdentifyWindow.Unload ()
	GemRB.HasSpecialSpell (pc, 1, 1)
	if ItemInfoWindow:
		ItemInfoWindow.Unload ()
	GemRB.ChangeItemFlag (pc, slot, IE_INV_ITEM_IDENTIFIED, OP_OR)
	GemRB.PlaySound(DEF_IDENTIFY)
	OpenItemInfoWindow()
	return
Example #3
0
def IdentifyUseScroll ():
	"""Identifies the item with a scroll or other item."""

	global ItemIdentifyWindow

	pc = GemRB.GameGetSelectedPCSingle ()
	if GameCheck.IsPST():
		slot, slot_item = GUIINV.ItemHash[GemRB.GetVar ('ItemButton')]
	else:
		slot = GemRB.GetVar ("ItemButton")
	if ItemIdentifyWindow:
		ItemIdentifyWindow.Unload ()
	if ItemInfoWindow:
		ItemInfoWindow.Unload ()
	if GemRB.HasSpecialItem (pc, 1, 1):
		GemRB.ChangeItemFlag (pc, slot, IE_INV_ITEM_IDENTIFIED, OP_OR)
	GemRB.PlaySound(DEF_IDENTIFY)
	OpenItemInfoWindow(slot)
	return
Example #4
0
def OpenItemInfoWindow():
    pc = GemRB.GameGetSelectedPCSingle()
    if GUICommon.GameIsPST():
        slot, slot_item = GUIINV.ItemHash[GemRB.GetVar('ItemButton')]
    else:
        slot = GemRB.GetVar("ItemButton")
        slot_item = GemRB.GetSlotItem(pc, slot)
    item = GemRB.GetItem(slot_item["ItemResRef"])

    #auto identify when lore is high enough
    if item["LoreToID"] <= GemRB.GetPlayerStat(pc, IE_LORE):
        GemRB.ChangeItemFlag(pc, slot, IE_INV_ITEM_IDENTIFIED, OP_OR)
        slot_item["Flags"] |= IE_INV_ITEM_IDENTIFIED
        GUIINV.UpdateInventoryWindow()

    if slot_item["Flags"] & IE_INV_ITEM_IDENTIFIED:
        value = 1
    else:
        value = 3
    DisplayItem(slot_item["ItemResRef"], value)
    return
Example #5
0
def GiveEquipment(MyChar, ClassName, KitIndex):
    # get the kit (or use class if no kit) to load the start table
    if KitIndex == 0:
        EquipmentColName = ClassName
        # sorcerers are missing from the table, use the mage equipment instead
        if EquipmentColName == "SORCERER":
            EquipmentColName = "MAGE"
    else:
        EquipmentColName = CommonTables.KitList.GetValue(KitIndex, 0)

    EquipmentTable = GemRB.LoadTable("25stweap")

    # a map of slots in the table to the real slots
    # SLOT_BAG is invalid, so use the inventory (first occurence)
    # SLOT_INVENTORY: use -1 instead, that's what CreateItem expects
    RealSlots = [ SLOT_ARMOUR, SLOT_SHIELD, SLOT_HELM, -1, SLOT_RING, \
       SLOT_RING, SLOT_CLOAK, SLOT_BOOT, SLOT_AMULET, SLOT_GLOVE, \
       SLOT_BELT, SLOT_QUIVER, SLOT_QUIVER, SLOT_QUIVER, \
       SLOT_ITEM, SLOT_ITEM, SLOT_ITEM, SLOT_WEAPON, SLOT_WEAPON, SLOT_WEAPON ]
    inventory_exclusion = 0

    #loop over rows - item slots
    for slot in range(0, EquipmentTable.GetRowCount()):
        slotname = EquipmentTable.GetRowName(slot)
        item_resref = EquipmentTable.GetValue(slotname, EquipmentColName)

        # no item - go to next
        if item_resref == "*":
            continue

        # the table has typos for kitted bard's armor
        if item_resref == "LEATH14":
            item_resref = "LEAT14"

        # get empty slots of the requested type
        realslot = GemRB.GetSlots(MyChar, RealSlots[slot], -1)
        if RealSlots[slot] == SLOT_WEAPON:
            # exclude the shield slot, so the offhand stays empty
            realslot = realslot[1:]

        if realslot == ():  # fallback to the inventory
            realslot = GemRB.GetSlots(MyChar, -1, -1)

        if realslot == ():  # this shouldn't happen!
            print "Eeek! No free slots for", item_resref
            continue

        # if an item contains a comma, the rest of the value is the stack
        if "," in item_resref:
            item_resref = item_resref.split(",")
            count = int(item_resref[1])
            item_resref = item_resref[0]
        else:
            count = 0

        targetslot = realslot[0]
        SlotType = GemRB.GetSlotType(targetslot, MyChar)
        i = 1
        item = GemRB.GetItem(item_resref)

        if inventory_exclusion & item['Exclusion']:
            # oops, too many magic items to equip, so just dump it to the inventory
            targetslot = GemRB.GetSlots(MyChar, -1, -1)[0]
            SlotType = -1
        else:
            # if there are no free slots, CreateItem will create the item on the ground
            while not GemRB.CanUseItemType (SlotType["Type"], item_resref, MyChar) \
            and i < len(realslot):
                targetslot = realslot[i]
                SlotType = GemRB.GetSlotType(targetslot, MyChar)
                i = i + 1

        GemRB.CreateItem(MyChar, item_resref, targetslot, count, 0, 0)
        GemRB.ChangeItemFlag(MyChar, targetslot, IE_INV_ITEM_IDENTIFIED, OP_OR)
        inventory_exclusion |= item['Exclusion']

    # grant the slayer change ability to the protagonist
    if MyChar == 1:
        GemRB.LearnSpell(MyChar, "SPIN822", LS_MEMO)
    return
Example #6
0
def TryAutoIdentification(pc, item, slot, slot_item, enabled=0):
	if enabled and item["LoreToID"]<=GemRB.GetPlayerStat (pc, IE_LORE):
		GemRB.ChangeItemFlag (pc, slot, IE_INV_ITEM_IDENTIFIED, OP_OR)
		slot_item["Flags"] |= IE_INV_ITEM_IDENTIFIED
		return True
	return False