def generate_npc( species=None, job=None, gender=None, rank=None, team=None, upgrade=False, fac=None ):
    if not species:
        species = choose_faction_appropriate( fac, characters.PC_SPECIES )
    if not gender:
        gender = random.randint(0,1)
    if not rank:
        rank = min(random.randint(1,10),random.randint(1,10))

    npc = base.NPCharacter( species=species(), gender=gender )
    npc.roll_stats()
    npc.team = team

    if not job:
        choices = chargen.get_possible_levels( npc ) + chargen.get_possible_levels( npc, NPC_CLASSES )
        job = choose_faction_appropriate( fac, choices )

    if not job.can_take_level( npc ):
        tries = 100
        while ( tries > 0 ) and not job.can_take_level( npc ):
            npc.roll_stats()
            tries += -1

    ji = job( rank=rank, pc=npc )
    npc.levels.append( ji )
    chargen.give_starting_equipment( npc )
    npc.tags.append( context.CHAR_NPC )

    npc.name = gen_monster_name(npc)
    npc.choose_random_spells()
    npc.gold = treasuretype.gold_for_rank( rank )

    if upgrade:
        upgrade_equipment( npc, rank )            

    return npc
Example #2
0
def generate_npc( species=None, job=None, gender=None, rank=None, team=None ):
    if not species:
        species = random.choice( characters.PC_SPECIES )
    if not gender:
        gender = random.randint(0,1)
    if not rank:
        rank = random.randint(1,10)

    npc = characters.Character( species=species(), gender=gender )
    npc.roll_stats()
    npc.team = team

    if not job:
        choices = chargen.get_possible_levels( npc ) + chargen.get_possible_levels( npc, NPC_CLASSES )
        job = random.choice( choices )

    if not job.can_take_level( npc ):
        tries = 100
        while ( tries > 0 ) and not job.can_take_level( npc ):
            npc.roll_stats()
            tries += -1

    ji = job( rank=rank, pc=npc )
    npc.levels.append( ji )
    chargen.give_starting_equipment( npc )
    npc.tags.append( context.CHAR_NPC )

    npc.name = gen_monster_name(npc)
    npc.choose_random_spells()

    return npc