コード例 #1
0
ファイル: GUIREC.py プロジェクト: qnestor/gemrb
def GetBonusSpells (pc):
	bonusSpells = {}
	classes = []
	# cheack each class/kit
	for i in range(11):
		level = GemRB.GetPlayerStat (pc, Classes[i])
		if not level:
			continue

		ClassTitle = GUICommonWindows.GetActorClassTitle (pc, i)
		# find the casting stat
		ClassName = GUICommon.GetClassRowName (i, "index")
		Stat = CommonTables.ClassSkills.GetValue (ClassName, "CASTING")
		if Stat == "*":
			continue
		Stat = GemRB.GetPlayerStat (pc, Stat)
		if Stat < 12: # boni start with positive modifiers
			continue

		# get max spell level we can cast, since only usable boni are displayed
		# check the relevant mxspl* table
		SpellTable = CommonTables.ClassSkills.GetValue (ClassName, "CLERICSPELL")
		if SpellTable == "*":
			SpellTable = CommonTables.ClassSkills.GetValue (ClassName, "MAGESPELL")
		SpellTable = GemRB.LoadTable (SpellTable)
		maxLevel = 0
		for i in range(SpellTable.GetColumnCount()):
			spells = SpellTable.GetValue (str(level), str(i+1)) # not all tables start at 1, so use a named lookup
			if not spells:
				break
			maxLevel = i+1

		classes.append(ClassTitle)
		# check if at casting stat size, there is any bonus spell in BonusSpellTable
		bonusSpells[ClassTitle] = [0] * maxLevel
		for level in range (1, maxLevel+1):
			bonusSpells[ClassTitle][level-1] = BonusSpellTable.GetValue (Stat-12, level-1)

	return bonusSpells, classes
コード例 #2
0
ファイル: GUIREC.py プロジェクト: qnestor/gemrb
def DisplayGeneral (pc):
	Window = RecordsWindow

	#levels
	RecordsTextArea.Append ("[color=ffff00]")
	RecordsTextArea.Append (40308)
	RecordsTextArea.Append (" - ")
	RecordsTextArea.Append (40309)
	levelsum = GemRB.GetPlayerStat (pc, IE_CLASSLEVELSUM)
	# get special level penalty for subrace
	adj = GetECL (pc)
	RecordsTextArea.Append (": "+str(levelsum) )
	RecordsTextArea.Append ("[/color]")
	#the class name for highest
	highest = None
	tmp = 0
	for i in range(11):
		level = GemRB.GetPlayerStat (pc, Classes[i])

		if level:
			Class = GUICommonWindows.GetActorClassTitle (pc, i )
			RecordsTextArea.Append (Class, -1)
			RecordsTextArea.Append (": "+str(level) )
			if tmp<level:
				highest = i
				tmp = level

	RecordsTextArea.Append ("\n")
	#effective character level
	if adj:
		RecordsTextArea.Append (40311,-1)
		RecordsTextArea.Append (": "+str(levelsum+adj) )

	#favoured class
	RecordsTextArea.Append (40310,-1)

	#get the subrace value
	RaceIndex = GetRace (pc)
	Race = CommonTables.Races.GetValue (RaceIndex, 2)
	tmp = CommonTables.Races.GetValue (RaceIndex, 8)

	if tmp == -1:
		tmp = highest
	else:
		tmp = GetFavoredClass(pc, tmp)

	tmp = CommonTables.Classes.GetValue (CommonTables.Classes.GetRowName(tmp), "NAME_REF")
	RecordsTextArea.Append (": ")
	RecordsTextArea.Append (tmp)

	#experience
	RecordsTextArea.Append ("\n\n[color=ffff00]")
	RecordsTextArea.Append (17089)
	RecordsTextArea.Append ("[/color]")

	RecordsTextArea.Append (36928,-1)
	xp = GemRB.GetPlayerStat (pc, IE_XP)
	RecordsTextArea.Append (str(xp))
	RecordsTextArea.Append (17091,-1)
	tmp = GetNextLevelExp (levelsum, adj, 1)
	RecordsTextArea.Append (": "+tmp )

	#current effects
	effects = GemRB.GetPlayerStates (pc)
	if len(effects):
		RecordsTextArea.Append ("\n\n[color=ffff00]")
		RecordsTextArea.Append (32052)
		RecordsTextArea.Append ("[/color]")
		StateTable = GemRB.LoadTable ("statdesc")
		for c in effects:
			tmp = StateTable.GetValue (str(ord(c)-66), "DESCRIPTION")
			RecordsTextArea.Append ("[capital=2]"+c+" ", -1)
			RecordsTextArea.Append (tmp)

	# TODO: Active Feats (eg. Power attack 4)

	#race
	RecordsTextArea.Append ("\n\n[capital=0][color=ffff00]")
	RecordsTextArea.Append (1048)
	RecordsTextArea.Append ("[/color]")

	RecordsTextArea.Append (Race,-1)

	#alignment
	RecordsTextArea.Append ("\n\n[color=ffff00]")
	RecordsTextArea.Append (1049)
	RecordsTextArea.Append ("[/color]")
	tmp = CommonTables.Aligns.FindValue (3, GemRB.GetPlayerStat (pc, IE_ALIGNMENT))
	Align = CommonTables.Aligns.GetValue (tmp, 2)
	RecordsTextArea.Append (Align,-1)

	#saving throws
	DisplaySavingThrows (pc)

	#class features
	if HasClassFeatures(pc):
		RecordsTextArea.Append ("\n\n[color=ffff00]")
		RecordsTextArea.Append (40314)
		RecordsTextArea.Append ("[/color]")
		tmp = GemRB.GetPlayerStat (pc, IE_TURNUNDEADLEVEL)
		if tmp:
			RecordsTextArea.Append (12126,-1)
			RecordsTextArea.Append (": "+str(tmp) )
		# 1d6 at level 1 and +1d6 every two extra rogue levels
		tmp = GemRB.GetPlayerStat (pc, IE_LEVELTHIEF)
		if tmp:
			tmp = (tmp+1)//2
			RecordsTextArea.Append (24898,-1)
			RecordsTextArea.Append (": "+str(tmp)+"d6" )
		tmp = GemRB.GetPlayerStat (pc, IE_LAYONHANDSAMOUNT)
		if tmp:
			RecordsTextArea.Append (12127,-1)
			RecordsTextArea.Append (": "+str(tmp) )
		MonkLevel = GemRB.GetPlayerStat (pc, IE_LEVELMONK)
		if MonkLevel:
			AC = GemRB.GetCombatDetails(pc, 0)["AC"]
			GemRB.SetToken ("number", PlusMinusStat (AC["Wisdom"]))
			RecordsTextArea.Append (39431, -1)
			# wholeness of body
			RecordsTextArea.Append (39749, -1)
			RecordsTextArea.Append (": "+str(MonkLevel*2))

	# favoured enemies; eg Goblins: +2 & Harpies: +1
	RangerLevel = GemRB.GetPlayerStat (pc, IE_LEVELRANGER)
	if RangerLevel:
		RecordsTextArea.Append ("\n\n[color=ffff00]")
		if RangerLevel > 5:
			RecordsTextArea.Append (15982)
		else:
			RecordsTextArea.Append (15897)
		RecordsTextArea.Append ("[/color]\n")
		DisplayFavouredEnemy (pc, RangerLevel)
		for i in range (7):
			DisplayFavouredEnemy (pc, RangerLevel, i)

	#bonus spells
	bonusSpells, classes = GetBonusSpells(pc)
	if len(bonusSpells):
		RecordsTextArea.Append ("\n\n[color=ffff00]")
		RecordsTextArea.Append (10344)
		RecordsTextArea.Append ("[/color]")
		for c in classes:
			if not len(bonusSpells[c]):
				continue
			# class/kit name
			RecordsTextArea.Append ("\n")
			RecordsTextArea.Append (c)
			for level in range(len(bonusSpells[c])):
				AddIndent()
				# Level X: +Y
				RecordsTextArea.Append (delimited_txt(7192, " " + str(level+1)+":", "+" + str(bonusSpells[c][level]), 0))

	#ability statistics
	RecordsTextArea.Append ("\n\n[color=ffff00]")
	RecordsTextArea.Append (40315)
	RecordsTextArea.Append ("[/color]\n")

	# Weight Allowance
	tmp = GemRB.GetAbilityBonus( IE_STR, 3, GemRB.GetPlayerStat(pc, IE_STR) )
	RecordsTextArea.Append (delimited_txt (10338, ":", str(tmp) + " lb."))
	# constitution bonus to hitpoints
	tmp = GUICommon.GetAbilityBonus(pc, IE_CON)
	RecordsTextArea.Append (delimited_txt (10342, ":", PlusMinusStat(tmp)))

	# Magic
	GNZS(pc, 15581, IE_RESISTMAGIC, True)
	#Fire
	GNZS(pc, 14012, IE_RESISTFIRE)
	#Magic Fire
	GNZS(pc, 14077, IE_RESISTMAGICFIRE)
	#Cold
	GNZS(pc, 14014, IE_RESISTCOLD)
	#Magic Cold
	GNZS(pc, 14078, IE_RESISTMAGICCOLD)
	#Electricity
	GNZS(pc, 14013, IE_RESISTELECTRICITY)
	#Acid
	GNZS(pc, 14015, IE_RESISTACID)
	#Spell
	GNZS(pc, 40319, IE_MAGICDAMAGERESISTANCE)
	# Missile
	GNZS(pc, 11767, IE_RESISTMISSILE)
	# Slashing
	GNZS(pc, 11768, IE_RESISTSLASHING)
	# Piercing
	GNZS(pc, 11769, IE_RESISTPIERCING)
	# Crushing
	GNZS(pc, 11770, IE_RESISTCRUSHING)
	# Poison
	GNZS(pc, 14017, IE_RESISTPOISON)

	# Damage Reduction - Spell Effect: Damage Reduction [436] (plain boni are mentioned above as resistances)
	BaseString = 0
	DisplayedHeader = 0
	for damageType in 0, 1:
		if damageType:
			# missile
			BaseString = 11767
		else:
			# general (physical)
			BaseString = 40316

		# cheat a bit and use the reduction at +10 as a modifier to remove from all other values
		# it will hold all the non-enchantment related resistance (there are no +10 weapons)
		mod = GemRB.GetDamageReduction (pc, damageType, 10)
		if mod == -1:
			mod = 0
		for enchantment in range(6):
			damage = GemRB.GetDamageReduction (pc, damageType, enchantment)
			if damage == -1 or damage-mod <= 0:
				continue
			if not DisplayedHeader:
				RecordsTextArea.Append ("\n\n[capital=0][color=ffff00]")
				RecordsTextArea.Append (39325)
				RecordsTextArea.Append ("[/color]\n")
				DisplayedHeader = 1

			enchantment += 1 # since we were checking what is allowable, not what bypasses it
			if enchantment:
				enchantment = "+" + str(enchantment)
			else:
				enchantment = "-"
			reduction = "%d/%s" %(damage-mod, enchantment)
			RecordsTextArea.Append (delimited_txt(BaseString, ":", reduction, 1))

	return
コード例 #3
0
ファイル: GUIREC.py プロジェクト: scriptedfate/gemrb
def DisplayGeneral(pc):
    Window = RecordsWindow

    #levels
    RecordsTextArea.Append("[color=ffff00]")
    RecordsTextArea.Append(40308)
    RecordsTextArea.Append(" - ")
    RecordsTextArea.Append(40309)
    levelsum = GemRB.GetPlayerStat(pc, IE_CLASSLEVELSUM)
    #TODO: get special level penalty for subrace
    adj = 0
    RecordsTextArea.Append(": " + str(levelsum))
    RecordsTextArea.Append("[/color]")
    #the class name for highest
    highest = None
    tmp = 0
    for i in range(11):
        level = GemRB.GetPlayerStat(pc, Classes[i])

        if level:
            Class = GUICommonWindows.GetActorClassTitle(pc, i)
            RecordsTextArea.Append(Class, -1)
            RecordsTextArea.Append(": " + str(level))
            if tmp < level:
                highest = i
                tmp = level

    RecordsTextArea.Append("\n")
    #effective character level
    if adj:
        RecordsTextArea.Append(40311, -1)
        RecordsTextArea.Append(": " + str(levelsum + adj))

    #favoured class
    RecordsTextArea.Append(40310, -1)
    AlignTable = GemRB.LoadTable("aligns")

    #get the subrace value
    Value = GemRB.GetPlayerStat(pc, IE_RACE)
    Value2 = GemRB.GetPlayerStat(pc, IE_SUBRACE)
    if Value2:
        Value = Value << 16 | Value2
    tmp = CommonTables.Races.FindValue(3, Value)
    Race = CommonTables.Races.GetValue(tmp, 2)
    tmp = CommonTables.Races.GetValue(tmp, 8)

    Label = Window.GetControl(0x1000000f)
    Label.SetText(Race)

    if tmp == -1:
        tmp = highest
    else:
        tmp = GetFavoredClass(pc, tmp)

    tmp = CommonTables.Classes.GetValue(tmp, 0)
    RecordsTextArea.Append(": ")
    RecordsTextArea.Append(tmp)

    #experience
    RecordsTextArea.Append("\n\n[color=ffff00]")
    RecordsTextArea.Append(17089)
    RecordsTextArea.Append("[/color]")

    RecordsTextArea.Append(36928, -1)
    xp = GemRB.GetPlayerStat(pc, IE_XP)
    RecordsTextArea.Append(": " + str(xp))
    RecordsTextArea.Append(17091, -1)
    tmp = GetNextLevelExp(levelsum, adj)
    RecordsTextArea.Append(": " + tmp)

    #current effects
    effects = GemRB.GetPlayerStates(pc)
    if len(effects):
        RecordsTextArea.Append("\n\n[color=ffff00]")
        RecordsTextArea.Append(32052)
        RecordsTextArea.Append("[/color][capital=2]")
        StateTable = GemRB.LoadTable("statdesc")
        for c in effects:
            tmp = StateTable.GetValue(ord(c) - 66, 0)
            RecordsTextArea.Append(c + " ", -1)
            RecordsTextArea.Append(tmp)

    #race
    RecordsTextArea.Append("\n\n[capital=0][color=ffff00]")
    RecordsTextArea.Append(1048)
    RecordsTextArea.Append("[/color]")

    RecordsTextArea.Append(Race, -1)

    #alignment
    RecordsTextArea.Append("\n\n[color=ffff00]")
    RecordsTextArea.Append(1049)
    RecordsTextArea.Append("[/color]")
    tmp = AlignTable.FindValue(3, GemRB.GetPlayerStat(pc, IE_ALIGNMENT))
    Align = AlignTable.GetValue(tmp, 2)
    RecordsTextArea.Append(Align, -1)

    #saving throws
    RecordsTextArea.Append("\n\n[color=ffff00]")
    RecordsTextArea.Append(17379)
    RecordsTextArea.Append("[/color]")
    tmp = GemRB.GetPlayerStat(pc, IE_SAVEFORTITUDE)
    tmp -= GemRB.GetPlayerStat(pc, IE_SAVEFORTITUDE, 1)
    if tmp < 0: stmp = str(tmp)
    else: stmp = "+" + str(tmp)
    RecordsTextArea.Append(17380, -1)
    RecordsTextArea.Append(": " + stmp)
    tmp = GemRB.GetPlayerStat(pc, IE_SAVEREFLEX)
    tmp -= GemRB.GetPlayerStat(pc, IE_SAVEREFLEX, 1)
    if tmp < 0: stmp = str(tmp)
    else: stmp = "+" + str(tmp)
    RecordsTextArea.Append(17381, -1)
    RecordsTextArea.Append(": " + stmp)
    tmp = GemRB.GetPlayerStat(pc, IE_SAVEWILL)
    tmp -= GemRB.GetPlayerStat(pc, IE_SAVEWILL, 1)
    if tmp < 0: stmp = str(tmp)
    else: stmp = "+" + str(tmp)
    RecordsTextArea.Append(17382, -1)
    RecordsTextArea.Append(": " + stmp)

    #class features
    if HasClassFeatures(pc):
        RecordsTextArea.Append("\n\n[color=ffff00]")
        RecordsTextArea.Append(40314)
        RecordsTextArea.Append("[/color]\n")
        tmp = GemRB.GetPlayerStat(pc, IE_TURNUNDEADLEVEL)
        if tmp:
            RecordsTextArea.Append(12146, -1)
            RecordsTextArea.Append(": " + str(tmp))
        tmp = GemRB.GetPlayerStat(pc, IE_BACKSTABDAMAGEMULTIPLIER)
        if tmp:
            RecordsTextArea.Append(24898, -1)
            RecordsTextArea.Append(": " + str(tmp) + "d6")
        tmp = GemRB.GetPlayerStat(pc, IE_LAYONHANDSAMOUNT)
        if tmp:
            RecordsTextArea.Append(12127, -1)
            RecordsTextArea.Append(": " + str(tmp))

    #bonus spells
    if HasBonusSpells(pc):
        RecordsTextArea.Append("\n\n[color=ffff00]")
        RecordsTextArea.Append(10344)
        RecordsTextArea.Append("[/color]\n")

    #ability statistics
    RecordsTextArea.Append("\n\n[color=ffff00]")
    RecordsTextArea.Append(40315)
    RecordsTextArea.Append("[/color]")

    RecordsTextArea.Append(10338, -1)  #strength
    tmp = GemRB.GetAbilityBonus(IE_STR, 3, GemRB.GetPlayerStat(pc, IE_STR))
    RecordsTextArea.Append(": " + str(tmp))
    tmp = GetAbilityBonus(pc, IE_CON)
    RecordsTextArea.Append(10342, -1)
    RecordsTextArea.Append(": " + str(tmp))  #con bonus

    RecordsTextArea.Append(15581, -1)  #spell resistance
    tmp = GemRB.GetPlayerStat(pc, IE_MAGICDAMAGERESISTANCE)
    RecordsTextArea.Append(": " + str(tmp))

    return