Ejemplo n.º 1
0
def InitSpellSelection(obj, classLvlNew=-1, classLvlIncrement=1):
    if char_editor.get_class_code(
    ) != classEnum:  # This is strictly a beguiler benefit (in case it's being accessed externally from something like Mystic Theurge / Archmage)
        return 0

    classLvl = obj.stat_level_get(classEnum)
    if classLvlNew <= 0:
        classLvlNew = classLvl + 1
    maxSpellLvl = char_editor.get_max_spell_level(obj, classEnum, classLvlNew)

    spAvail = GetAdvancedLearningList(obj, maxSpellLvl)

    # Add the spell level labels
    for p in range(1, maxSpellLvl + 1):
        spAvail.append(
            char_editor.KnownSpellInfo(spell_label_level_0 + p, 0, classEnum))
    spAvail.sort()

    char_editor.append_available_spells(spAvail)

    # Add a single spell slot
    vacant_slot = char_editor.KnownSpellInfo(spell_vacant, 3, classEnum)
    spEnums = [vacant_slot]
    char_editor.append_spell_enums(spEnums)
    return 0
Ejemplo n.º 2
0
def LevelupSpellsFinalize( obj, classLvlNew = -1 ):
	classLvl = obj.stat_level_get(classEnum)
	classLvlNew = classLvl + 1
	if classLvlNew < 4: # late-starting caster
		return 0
	maxSpellLvl = char_editor.get_max_spell_level( obj, classEnum, classLvlNew )
	class_spells = char_editor.get_learnable_spells(obj, classEnum, maxSpellLvl)
	char_editor.spell_known_add(class_spells)
	return 0
Ejemplo n.º 3
0
def LevelupSpellsFinalize(obj, classLvlNew=-1, classLvlIncrement=1):
    classLvl = obj.stat_level_get(classEnum)
    if classLvlNew <= 0:
        classLvlNew = classLvl + 1

    maxSpellLvl = char_editor.get_max_spell_level(obj, classEnum, classLvlNew)
    class_spells = char_editor.get_learnable_spells(obj, classEnum,
                                                    maxSpellLvl)
    char_editor.spell_known_add(class_spells)
    return 0
Ejemplo n.º 4
0
    def _apply_classes(self, pc):
        assert isinstance(pc, toee.PyObjHandle)

        if (not self.class_levels): return
        index = -1
        for t in self.class_levels:
            pc_class = t[0]
            pc_class_levels = t[1]
            pc.make_class(pc_class, pc_class_levels)
            index += pc_class_levels

            if (pc.highest_arcane_caster_level
                    or pc.highest_divine_caster_level):
                maxSpellLvl = char_editor.get_max_spell_level(
                    pc, pc_class, pc_class_levels)
                if (maxSpellLvl):
                    class_spells = char_editor.get_learnable_spells(
                        pc, pc_class, maxSpellLvl)
                    char_editor.spell_known_add2(class_spells, pc)
                domain_1 = pc.obj_get_int(toee.obj_f_critter_domain_1)
                domain_2 = pc.obj_get_int(toee.obj_f_critter_domain_2)
                domain_1_spells = char_editor.get_learnable_spells(
                    pc, domain_1, maxSpellLvl, 1)
                domain_2_spells = char_editor.get_learnable_spells(
                    pc, domain_2, maxSpellLvl, 1)
                char_editor.spell_known_add2(domain_1_spells, pc)
                char_editor.spell_known_add2(domain_2_spells, pc)
            break
            for i in range(0, pc_class_levels):
                index += 1
                print("{}: {}".format(index, pc_class))
                pc.obj_set_idx_int(toee.obj_f_critter_level_idx, index,
                                   pc_class)

        pc.obj_set_int(toee.obj_f_hp_pts, -65535)
        hp = pc.stat_level_get(toee.stat_hp_current)

        xp = 0
        if (index == 1 - 1): xp = 0
        elif (index == 2 - 1): xp = 1000
        elif (index == 3 - 1): xp = 3000
        elif (index == 4 - 1): xp = 6000
        elif (index == 5 - 1): xp = 10000
        elif (index == 6 - 1): xp = 15000
        elif (index == 7 - 1): xp = 21000
        elif (index == 8 - 1): xp = 28000
        elif (index == 9 - 1): xp = 36000
        elif (index == 10 - 1): xp = 45000
        elif (index == 11 - 1): xp = 55000
        elif (index == 12 - 1): xp = 66000

        pc.obj_set_int(toee.obj_f_critter_experience, xp)
        return
Ejemplo n.º 5
0
def LevelupCheckSpells(obj):
    classLvl = obj.stat_level_get(classEnum)
    classLvlNew = classLvl + 1
    maxSpellLvl = char_editor.get_max_spell_level(obj, classEnum, classLvlNew)

    spell_enums = char_editor.get_spell_enums()
    for spInfo in spell_enums:
        if spInfo.spell_enum == spell_vacant:
            if maxSpellLvl >= 4 and spInfo.spell_level == 0:  # in case the cantrips are causing problems
                continue
            return 0
    return 1
Ejemplo n.º 6
0
def InitSpellSelection(obj, classLvlNew = -1, classLvlIncrement = 1):
	classLvl = obj.stat_level_get(classEnum)
	classLvlNew = classLvl + 1
	maxSpellLvl = char_editor.get_max_spell_level(obj, classEnum,
	                                              classLvlNew)  # this regards spell list extension by stuff like Mystic Theurge (no need to use spellListLvl as below)

	# Available Spells
	spAvail = char_editor.get_learnable_spells(obj, classEnum, maxSpellLvl)
	# add spell level labels
	for p in range(0, maxSpellLvl + 1):
		spAvail.append(char_editor.KnownSpellInfo(spell_label_level_0 + p, 0, classEnum))
	spAvail.sort()
	char_editor.append_available_spells(spAvail)

	# Spell Slots

	spellListLvl = obj.stat_level_get(stat_spell_list_level,
	                                  classEnum) + 1  # the effective level for getting the number of spells known
	spEnums = char_editor.get_known_class_spells(obj, classEnum)  # get all spells known for this class

	for spellLvl in range(1, maxSpellLvl + 1):
		spEnums.append(char_editor.KnownSpellInfo(spell_label_level_0 + spellLvl, 0, classEnum))  # add label
		# add spell slots
		newSpellsKnownCount = char_class_utils.GetSpellsKnownAddedCount(spells_known, spellListLvl, spellLvl)
		for q in range(0, newSpellsKnownCount):
			spEnums.append(char_editor.KnownSpellInfo(spell_new_slot_lvl_0 + spellLvl, 3, classEnum))

	isReplacing = 0
	if spellListLvl >= 6 and ((spellListLvl - 6) % 2) == 0:  # spell replacement
		isReplacing = 1
	if char_editor.get_class_code() != classEnum:  # grant this benefit only for strict levelup (also to prevent some headache...)
		isReplacing = 0

	if isReplacing == 0:
		spEnums.sort()
		char_editor.append_spell_enums(spEnums)
		return 0

	# mark as replaceable
	for p in range(0, len(spEnums)):
		spEnum = spEnums[p].spell_enum
		if spell_vacant <= spEnum <= spell_label_level_9:
			continue
		if spell_new_slot_lvl_0 <= spEnum <= spell_new_slot_lvl_9:
			continue
		if char_editor.get_spell_level(spEnum, classEnum) <= maxSpellLvl - 2:
			spEnums[p].spell_status = 1

	spEnums.sort()
	char_editor.append_spell_enums(spEnums)
	return 0
Ejemplo n.º 7
0
def LevelupSpellsFinalize( obj, classLvlNew = -1 ):
	#Add the normal spells
	classLvl = obj.stat_level_get(classEnum)
	if classLvlNew <= 0:
		classLvlNew = classLvl + 1

	maxSpellLvl = char_editor.get_max_spell_level( obj, classEnum, classLvlNew )
	class_spells = char_editor.get_learnable_spells(obj, classEnum, maxSpellLvl)
	char_editor.spell_known_add(class_spells) # internally takes care of duplicates and the labels/vacant slots	
	
	#Add Anything from advanced learning
	spEnums = char_editor.get_spell_enums()
	char_editor.spell_known_add(spEnums) # internally takes care of duplicates and the labels/vacant slots	
	return 0
Ejemplo n.º 8
0
def IsSelectingSpellsOnLevelup(obj):
	if char_editor.get_class_code() !=  classEnum: # This is strictly a warmage benefit (in case it's being accessed externally from something like Mystic Theurge / Archmage)
		return 0
	
	classLvl = obj.stat_level_get(classEnum)
	classLvlNew = classLvl + 1
	
	#levels 3, 6, 11, and 16 get advanced learning otherwise there is nothing to select
	if classLvlNew in [3, 6, 11, 16]:
		maxSpellLvl = char_editor.get_max_spell_level( obj, classEnum, classLvlNew )
		AdvancedLearningList = GetAdvancedLearningList(obj, maxSpellLvl)
		if AdvancedLearningList:
			return 1
	return 0
Ejemplo n.º 9
0
def LevelupSpellsFinalize( obj, classLvlNew = -1 ):
	classLvl = obj.stat_level_get(classEnum)
	if classLvlNew <= 0:
		classLvlNew = classLvl + 1

	maxSpellLvl = char_editor.get_max_spell_level( obj, classEnum, classLvlNew )
	class_spells = char_editor.get_learnable_spells(obj, classEnum, maxSpellLvl)
	char_editor.spell_known_add(class_spells)

	# Domain spells:
	domain_1 = obj.obj_get_int(obj_f_critter_domain_1)
	domain_2 = obj.obj_get_int(obj_f_critter_domain_2)
	domain_1_spells = char_editor.get_learnable_spells(obj, domain_1, maxSpellLvl, 1)
	domain_2_spells = char_editor.get_learnable_spells(obj, domain_2, maxSpellLvl, 1)
	char_editor.spell_known_add(domain_1_spells)
	char_editor.spell_known_add(domain_2_spells)
	return 0
Ejemplo n.º 10
0
def InitSpellSelection(obj, classLvlNew=-1, classLvlIncrement=1):

    classLvl = obj.stat_level_get(classEnum)
    if classLvlNew <= 0:
        classLvlNew = classLvl + 1
    maxSpellLvl = char_editor.get_max_spell_level(
        obj, classEnum, classLvlNew
    )  # this regards spell list extension by stuff like Mystic Theurge

    # Available Spells
    spAvail = char_editor.get_learnable_spells(obj, classEnum, maxSpellLvl)
    # cull cantrips
    p = 0
    while p < len(spAvail):
        if spAvail[p].spell_level == 0:
            del (spAvail[p])
        else:
            p = p + 1
    # add spell level labels
    for p in range(1, maxSpellLvl + 1):
        spAvail.append(
            char_editor.KnownSpellInfo(spell_label_level_0 + p, 0, classEnum))
    spAvail.sort()
    char_editor.append_available_spells(spAvail)

    # Spell slots
    spEnums = []
    vacant_slot = char_editor.KnownSpellInfo(
        spell_vacant, 3, classEnum)  # sets it to spell level -1
    if classLvlNew == 1:  # newly taken class
        spEnums.append(
            char_editor.KnownSpellInfo(spell_label_level_1, 0, classEnum))
        for p in range(0, 2):
            spEnums.append(vacant_slot)
        intScore = obj.stat_level_get(stat_intelligence)
        intMod = (intScore - 10) / 2
        for p in range(0, intMod):
            spEnums.append(vacant_slot)
    else:  # add 2 new spell slots
        for p in range(0, 2):
            spEnums.append(vacant_slot)
    char_editor.append_spell_enums(spEnums)

    return 0
Ejemplo n.º 11
0
def LevelupSpellsFinalize( obj, classLvlNew = -1 ):
	classLvl = obj.stat_level_get(classEnum)
	if classLvlNew <= 0:
		classLvlNew = classLvl + 1

	maxSpellLvl = char_editor.get_max_spell_level(obj, classEnum, classLvlNew)
	class_spells = char_editor.get_learnable_spells(obj, classEnum, maxSpellLvl)
	char_editor.spell_known_add(class_spells)

	# for paladins - change to evil
	algn = obj.obj_get_int(obj_f_critter_alignment)
	if algn & ALIGNMENT_GOOD:
		algn = algn ^ ALIGNMENT_GOOD

	algn = algn | ALIGNMENT_EVIL
	obj.obj_set_int(obj_f_critter_alignment, algn)

	pal_lvl = obj.stat_level_get(stat_level_paladin)
	if pal_lvl >= 1:
		obj.feat_add("Smite Good")
	if pal_lvl >= 5:
		obj.feat_add(feat_sneak_attack)
	return 0
Ejemplo n.º 12
0
def InitSpellSelection(obj, classLvlNew=-1, classLvlIncrement=1):
    classLvl = obj.stat_level_get(classEnum)
    if classLvlNew <= 0:
        classLvlNew = classLvl + 1
    maxSpellLvl = char_editor.get_max_spell_level(
        obj, classEnum, classLvlNew
    )  # this regards spell list extension by stuff like Mystic Theurge

    # Available Spells (spells you can choose, on the left side)
    spAvail = char_editor.get_learnable_spells(obj, classEnum, maxSpellLvl)
    # add spell level labels
    for p in range(0, maxSpellLvl + 1):
        spAvail.append(
            char_editor.KnownSpellInfo(spell_label_level_0 + p, 0, classEnum))
    spAvail.sort()
    char_editor.append_available_spells(spAvail)

    # Create Known Spells list (right side) spEnums
    # Case 1 - newly taken class
    if classLvlNew == 1:
        spEnums = []
        spEnums.append(
            char_editor.KnownSpellInfo(spell_label_level_0, 0,
                                       classEnum))  # add "Level 0" label
        for p in range(0, 4):  # 4 cantrips
            spEnums.append(
                char_editor.KnownSpellInfo(spell_new_slot_lvl_0, 3, classEnum))
        spEnums.append(
            char_editor.KnownSpellInfo(spell_label_level_1, 0,
                                       classEnum))  # add "Level 1" label
        for p in range(0, 2):  # 2 level 1 spells
            spEnums.append(
                char_editor.KnownSpellInfo(spell_new_slot_lvl_1, 3, classEnum))
        char_editor.append_spell_enums(spEnums)
        return 0

    # Case 2 - Incrementing class level
    spellListLvl = obj.stat_level_get(
        stat_spell_list_level, classEnum
    ) + classLvlIncrement  # the effective level for getting the number of spells known
    if spellListLvl <= 20:
        spEnums = char_editor.get_known_class_spells(
            obj,
            classEnum)  # get all spells known by this character for this class
        for spellLvl in range(0, maxSpellLvl + 1):
            spEnums.append(
                char_editor.KnownSpellInfo(spell_label_level_0 + spellLvl, 0,
                                           classEnum))  # add label
            # add spells
            newSpellsKnownCount = char_class_utils.GetSpellsKnownAddedCount(
                spells_known, spellListLvl, spellLvl)
            # print("new num spells for spell level " + str(spellLvl) + ": " + str(newSpellsKnownCount))
            for q in range(0, newSpellsKnownCount):
                spEnums.append(
                    char_editor.KnownSpellInfo(spell_new_slot_lvl_0 + spellLvl,
                                               3, classEnum))
    else:  # Epic Level sorcerer - add a single spell of any level (kind of like a freebie Spell knowledge feat, since there isn't one yet)
        spEnums = []
        vacant_slot = char_editor.KnownSpellInfo(
            spell_vacant, 3, classEnum)  # sets it to spell level -1
        spEnums.append(vacant_slot)
        char_editor.append_spell_enums(spEnums)
        return 0

    # Handle spell replacement on even levels
    isReplacing = 0
    if spellListLvl >= 4 and (spellListLvl % 2) == 0:  # spell replacement
        isReplacing = 1
    if char_editor.get_class_code(
    ) != classEnum:  #grant this benefit only for strict levelup (also to prevent some headache...)
        isReplacing = 0

    if isReplacing == 0:
        spEnums.sort()
        char_editor.append_spell_enums(spEnums)
        return 0

    # mark as replaceable
    for p in range(0, len(spEnums)):
        spEnum = spEnums[p].spell_enum
        if spell_vacant <= spEnum <= spell_label_level_9:
            continue
        if spell_new_slot_lvl_0 <= spEnum <= spell_new_slot_lvl_9:
            continue
        if char_editor.get_spell_level(spEnum, classEnum) <= maxSpellLvl - 2:
            spEnums[p].spell_status = 1  # marked as replaceable

    # Finally, return spEnums list to the engine
    spEnums.sort()
    char_editor.append_spell_enums(spEnums)
    return 0
Ejemplo n.º 13
0
def InitSpellSelection( obj, classLvlNew = -1, classLvlIncrement = 1):
	classLvl = obj.stat_level_get(classEnum)
	if classLvlNew <= 0:
		classLvlNew = classLvl + 1
	maxSpellLvl = char_editor.get_max_spell_level( obj, classEnum, classLvlNew ) # this regards spell list extension by stuff like Mystic Theurge
	
	# Available Spells
	spAvail = char_editor.get_learnable_spells(obj, classEnum, maxSpellLvl)
	# add spell level labels
	for p in range(0,maxSpellLvl+1):
		spAvail.append(char_editor.KnownSpellInfo(spell_label_level_0 + p, 0, classEnum))
	spAvail.sort()
	char_editor.append_available_spells(spAvail)
	
	# newly taken class
	if classLvlNew == 1:
		spEnums = []
		spEnums.append(char_editor.KnownSpellInfo(spell_label_level_0, 0, classEnum)) # add "Level 0" label
		for p in range(0,4): # 4 cantrips
			spEnums.append(char_editor.KnownSpellInfo(spell_new_slot_lvl_0, 3, classEnum))
		spEnums.append(char_editor.KnownSpellInfo(spell_label_level_1, 0, classEnum)) # add "Level 1" label
		for p in range(0,2): # 2 level 1 spells
			spEnums.append(char_editor.KnownSpellInfo(spell_new_slot_lvl_1, 3, classEnum))
		char_editor.append_spell_enums(spEnums)
		return 0
	
	# Incrementing class level
	spellListLvl = obj.stat_level_get(stat_spell_list_level, classEnum) + classLvlIncrement # the effective level for getting the number of spells known
	spEnums = char_editor.get_known_class_spells(obj, classEnum) # get all spells known for this class
	for spellLvl in range(0, maxSpellLvl+1):
		spEnums.append(char_editor.KnownSpellInfo(spell_label_level_0 + spellLvl, 0, classEnum))  # add label
		# add spells
		newSpellsKnownCount = char_class_utils.GetSpellsKnownAddedCount( spells_known , spellListLvl, spellLvl)
		print "new num spells for spell level " + str(spellLvl) + ": " + str(newSpellsKnownCount)
		for q in range(0, newSpellsKnownCount):
			spEnums.append(char_editor.KnownSpellInfo(spell_new_slot_lvl_0 + spellLvl, 3, classEnum))
	
	isReplacing = 0
	if spellListLvl >= 4 and (spellListLvl % 2) == 0: # spell replacement
		isReplacing = 1
	if char_editor.get_class_code() !=  classEnum: #grant this benefit only for strict levelup (also to prevent some headache...)
		isReplacing = 0
	
	if isReplacing == 0:
		spEnums.sort()
		char_editor.append_spell_enums(spEnums)
		return 0
	
	# mark as replaceable
	for p in range(0,len(spEnums)):
		spEnum = spEnums[p].spell_enum
		if spell_vacant <= spEnum <= spell_label_level_9:
			continue
		if spell_new_slot_lvl_0 <= spEnum <= spell_new_slot_lvl_9:
			continue
		if char_editor.get_spell_level(spEnum, classEnum) <= maxSpellLvl-2:
			spEnums[p].spell_status = 1 # marked as replaceable
	
	spEnums.sort()
	char_editor.append_spell_enums(spEnums)
	return 0