Пример #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
Пример #2
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
Пример #3
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
Пример #4
0
def san_insert_item(attachee, triggerer):
	assert isinstance(attachee, PyObjHandle)
	assert isinstance(triggerer, PyObjHandle)

	if (not (attachee.item_flags_get() & OIF_NO_RANGED_USE)):
		lastDenyMessage = ""
		for idx in range(0, 19):
			spell = attachee.obj_get_spell(obj_f_item_spell_idx, idx)
			if (spell.spell_enum == 0): break
			#print(spell)
			spellName = spell_get_name(spell)
			#print(spellName)
			#print(spell.spell_enum)
			#breakp("san_insert_item 0")
			spi = char_editor.KnownSpellInfo()
			spi.spell_enum = spell.spell_enum
			spi.spell_status = 1
			spi.spell_class = spell.spell_class
			spi.spell_level = spell.spell_level
			caster_class = spi.get_casting_class()
			#print(spi)
			#print(caster_class)
			#caster_stat = caster_class2caster_stat_level(caster_class)
			#print(caster_stat)
			#breakp("san_insert_item 1")
			current_level = triggerer.stat_level_get(caster_class)
			need_level_caster = get_caster_class_level(caster_class, spell.spell_level)
			#print("triggerer.stat_level_get(caster_class: {}): {}".format(caster_class, current_level))
			#print("need level: {}".format(need_level_caster))
			#breakp("san_insert_item 2")
			if (spell.spell_level > current_level):
				lastDenyMessage = "Spell {} cannot be added, as target requires spell level {} of {} but has {}!".format(spellName, need_level_caster, caster_class, current_level)
				print(lastDenyMessage)
				break
			lastDenyMessage = ""
			if (not triggerer.is_spell_known(spell.spell_enum)):
				triggerer.spell_known_add(spell.spell_enum, spell.spell_class, spell.spell_level)
				triggerer.float_text_line("Added new spell {}!".format(spellName), Green)
				attachee.item_flag_set(OIF_NO_RANGED_USE)
			else: triggerer.float_text_line("Spell {} already known!".format(spellName), Yellow)
			break

	if (lastDenyMessage != ""):
		triggerer.float_text_line(lastDenyMessage, Red)
		game.create_history_freeform(lastDenyMessage)
	return RUN_DEFAULT
Пример #5
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
Пример #6
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