예제 #1
0
def BuyHeal ():
	Index = GemRB.GetVar ("Index")
	Cure = GemRB.GetStoreCure (Index)
	gold = GemRB.GameGetPartyGold ()
	if gold < Cure['Price']:
		ErrorWindow (11048)
		return

	GemRB.GameSetPartyGold (gold-Cure['Price'])
	pc = GemRB.GameGetSelectedPCSingle ()
	Spell = GemRB.GetSpell (Cure['CureResRef'])
	# for anything but raise/resurrect, the talker should be the caster, so
	# self-targetting spells work properly. Raise dead is an exception as
	# the teleporting to the temple would not work otherwise
	if Spell["SpellTargetType"] == 3: # non-living
		GemRB.ApplySpell (pc, Cure['CureResRef'], Store['StoreOwner'])
	else:
		GemRB.ApplySpell (pc, Cure['CureResRef'], pc)

	if SpellTable:
		sound = SpellTable.GetValue(Cure['CureResRef'], "SOUND")
	else:
		#if there is no table, simply use the spell's own completion sound
		Spell = GemRB.GetSpell(Cure['CureResRef'])
		sound = Spell['Completion']
	GemRB.PlaySound (sound)
	UpdateStoreHealWindow ()
	return
예제 #2
0
def BuyHeal ():
	Index = GemRB.GetVar ("Index")
	Cure = GemRB.GetStoreCure (Index)
	gold = GemRB.GameGetPartyGold ()
	if gold < Cure['Price']:
		ErrorWindow (11048)
		return

	GemRB.GameSetPartyGold (gold-Cure['Price'])
	pc = GemRB.GameGetSelectedPCSingle ()
	GemRB.ApplySpell (pc, Cure['CureResRef'], Store['StoreOwner'])
	UpdateStoreHealWindow ()
	return
예제 #3
0
def AddClassAbilities(pc, table, Level=1, LevelDiff=1, align=-1):
    TmpTable = GemRB.LoadTable(table)
    import Spellbook

    # gotta stay positive
    if Level - LevelDiff < 0:
        return

    # we're doing alignment additions
    if align == -1:
        iMin = 0
        iMax = TmpTable.GetRowCount()
    else:
        # alignment is expected to be the row required
        iMin = align
        iMax = align + 1

    # make sure we don't go out too far
    jMin = Level - LevelDiff
    jMax = Level
    if jMax > TmpTable.GetColumnCount():
        jMax = TmpTable.GetColumnCount()

    for i in range(iMin, iMax):
        # apply each spell from each new class
        for j in range(jMin, jMax):
            ab = TmpTable.GetValue(i, j, 0)
            if ab and ab != "****":
                # seems all SPINs act like GA_*
                if ab[:4] == "SPIN":
                    ab = "GA_" + ab

                # apply spell (AP_) or gain spell (GA_)
                if ab[:2] == "AP":
                    GemRB.ApplySpell(pc, ab[3:])
                elif ab[:2] == "GA":
                    SpellIndex = Spellbook.HasSpell(pc, IE_SPELL_TYPE_INNATE,
                                                    0, ab[3:])
                    if SpellIndex == -1:
                        GemRB.LearnSpell(pc, ab[3:], LS_MEMO)
                    else:
                        # make room for one more memorization
                        max_mem_cnt = GemRB.GetMemorizableSpellsCount(
                            pc, IE_SPELL_TYPE_INNATE, 0, 0)
                        GemRB.SetMemorizableSpellsCount(
                            pc, max_mem_cnt + 1, IE_SPELL_TYPE_INNATE, 0)
                        # memorize another spell instance
                        GemRB.MemorizeSpell(pc, IE_SPELL_TYPE_INNATE, 0,
                                            SpellIndex)
                else:
                    print "ERROR, unknown class ability (type): ", ab
예제 #4
0
def AddClassAbilities(pc, table, Level=1, LevelDiff=1, align=-1):
    TmpTable = GemRB.LoadTable(table)
    import Spellbook

    # gotta stay positive
    if Level - LevelDiff < 0:
        return

    # we're doing alignment additions
    if align == -1:
        iMin = 0
        iMax = TmpTable.GetRowCount()
    else:
        # alignment is expected to be the row required
        iMin = align
        iMax = align + 1

    # make sure we don't go out too far
    jMin = Level - LevelDiff
    jMax = Level
    if jMax > TmpTable.GetColumnCount():
        jMax = TmpTable.GetColumnCount()

    for i in range(iMin, iMax):
        # apply each spell from each new class
        for j in range(jMin, jMax):
            ab = TmpTable.GetValue(i, j, GTV_STR)
            if ab and ab != "****":
                # seems all SPINs act like GA_*
                if ab[:4] == "SPIN":
                    ab = "GA_" + ab

                # apply spell (AP_) or gain spell (GA_)
                if ab[:3] == "AP_":
                    GemRB.ApplySpell(pc, ab[3:])
                elif ab[:3] == "GA_":
                    Spellbook.LearnSpell(pc, ab[3:], IE_SPELL_TYPE_INNATE, 0,
                                         1, LS_MEMO)
                elif ab[:3] == "FS_":
                    Gain(26320, ab[3:])
                elif ab[:3] == "FA_":
                    Gain(10514, ab[3:])
                else:
                    GemRB.Log(LOG_ERROR, "AddClassAbilities",
                              "Unknown class ability (type): " + ab)
예제 #5
0
def HLADonePress():
    """Saves the new HLAs and closes the HLA selection window."""

    # save all of our HLAs
    for i in range(len(HLANewAbilities)):
        # see if we're going to learn this ability
        if HLANewAbilities[i] == 0:
            continue

        # figure out the ability type
        HLARef = HLAAbilities[i][0]
        HLAType = HLARef[5:7]
        if HLAType == "PR":
            HLAType = IE_SPELL_TYPE_PRIEST
            HLALevel = int(HLARef[7]) - 1
        elif HLAType == "WI":
            HLAType = IE_SPELL_TYPE_WIZARD
            HLALevel = int(HLARef[7]) - 1
        else:
            HLAType = IE_SPELL_TYPE_INNATE
            HLALevel = 0

        # do we need to apply or learn it?
        if HLARef[:2] == "AP":
            GemRB.ApplySpell(pc, HLARef[3:])
        elif HLARef[:2] == "GA":
            # make sure it isn't already learned
            SpellIndex = Spellbook.HasSpell(pc, HLAType, HLALevel, HLARef[3:])
            if SpellIndex < 0:  # gotta learn it
                GemRB.LearnSpell(pc, HLARef[3:], 8)
            else:  # memorize it again
                GemRB.MemorizeSpell(pc, HLAType, HLALevel, SpellIndex)

        #save the number of this HLA memorized
        #TODO: check param2 (0 seems to work ok)
        GemRB.ApplyEffect(pc, "HLA", HLAAbilities[i][2], 0, HLARef[3:])

    # close the window
    if HLAWindow:
        HLAWindow.Unload()

    # so redraw skills knows we're done
    GemRB.SetVar("HLACount", 0)

    return
예제 #6
0
def HLADonePress():
    """Saves the new HLAs and closes the HLA selection window."""

    # save all of our HLAs
    for i in range(len(HLANewAbilities)):
        # see if we're going to learn this ability
        if HLANewAbilities[i] == 0:
            continue

        # figure out the ability type
        HLARef = HLAAbilities[i][0]
        HLAType = HLARef[5:7]
        if HLAType == "PR":
            HLAType = IE_SPELL_TYPE_PRIEST
            HLALevel = int(HLARef[7]) - 1
        elif HLAType == "WI":
            HLAType = IE_SPELL_TYPE_WIZARD
            HLALevel = int(HLARef[7]) - 1
        else:
            HLAType = IE_SPELL_TYPE_INNATE
            HLALevel = 0

        # do we need to apply or learn it?
        if HLARef[:2] == "AP":
            GemRB.ApplySpell(pc, HLARef[3:])
        elif HLARef[:2] == "GA":
            # learn it or memorize another one
            Spellbook.LearnSpell(pc, HLARef[3:], HLAType, HLALevel, 1, LS_MEMO)

        #save the number of this HLA memorized
        #TODO: check param2 (0 seems to work ok)
        GemRB.ApplyEffect(pc, "HLA", HLAAbilities[i][2], 0, HLARef[3:])

    # close the window
    if HLAWindow:
        HLAWindow.Unload()

    # so redraw skills knows we're done
    GemRB.SetVar("HLACount", 0)

    import LevelUp
    LevelUp.LevelUpWindow.Invalidate()

    return
예제 #7
0
def AddClassAbility(pc, ab):
    if not ab or ab == "****":
        return

    # seems all SPINs act like GA_*
    if ab[:4] == "SPIN":
        ab = "GA_" + ab

    # apply spell (AP_) or gain spell (GA_)
    if ab[:3] == "AP_":
        GemRB.ApplySpell(pc, ab[3:])
    elif ab[:3] == "GA_":
        Spellbook.LearnSpell(pc, ab[3:], IE_SPELL_TYPE_INNATE, 0, 1, LS_MEMO)
    elif ab[:3] == "FS_":
        Gain(26320, ab[3:])
    elif ab[:3] == "FA_":
        Gain(10514, ab[3:])
    else:
        GemRB.Log(LOG_ERROR, "AddClassAbilities",
                  "Unknown class ability (type): " + ab)
예제 #8
0
def FixAnomen(idx):
    #lawful neutral
    if (GemRB.GetPlayerStat(idx, IE_ALIGNMENT) == 0x12):
        GemRB.ApplySpell(idx, "SPIN678")
    return
예제 #9
0
def FixEdwin(idx):
    GemRB.ApplySpell(idx, "SPIN661")
    return