Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Another Random Creature Script  (Read 15115 times)

Roses

  • Bay Watcher
    • View Profile
Another Random Creature Script
« on: July 15, 2014, 10:32:54 am »

Download here

Let me just start by saying that I don't think there is anything wrong with any of the other random creation scripts around, I was just looking for something a little different, and instead of asking the authors to change (or add more options) to theirs I decided to make my own.

Background:
I originally made this script for my own use (which is why it is not very polished, and overall poorly written from a coders perspective), but with the downtime at the start of the new release (DFHack being updated, bugs being squashed) I decided that now was an ok time to get it a least somewhat usable by others.

Differences to others:
What makes this random creature script different is that it assembles creatures from a group of templates that the user can dynamically add or subtract from. These templates cover;
  • Body Parts
  • Body Materials
  • Biomes
  • Interactions
  • Extracts
  • Castes
  • Types
  • Attacks

For a short example of the templates, this is what one of the HEAD, body part templates looks like.
Code: [Select]
[HEAD:HEAD_SMALL] <- name of the template, must be unique
{#DESCRIPTION;a small head} <- the description to add to the creature
{#ATTACKS;NONE} <- if there is an attack associated with the body part, you put its template ID here
{#ARGS;NONE} <- these allow for extra customization, see below
{#TOKENS;#HEAD} <- these tells the script that the creature now has a head
{#BODY;HEAD_SMALL} <- the actual body part (as used by DF itself)
{#LINK;NONE} <- what the body part links too, this is explained in more detail later

Structure:
The general structure of the code is as follows (more information on each of these steps will be given below);
  • Generate Body:
    • Pick Torso
    • Pick Head
    • Pick Limbs (Arms, Legs, Hands, Feet)
    • Pick Face (Eyes, Mouth, Ears, Nose)
    • Pick 0-2 Head Attachments (horns, antlers, tusks, mandibles, etc...)
    • Pick 0-2 Torso Attachments (tails, wings, stingers, etc...)
    • Pick 0-2 Limb Attachments (spikes, growths, etc...)
    • Pick 0-2 Misc Attachments (whatever you want)
  • Generate Body Materials
  • Generate Creature Biome
  • Generate Creature Type
  • Generate Creature Extracts
  • Generate Creature Interactions
  • Generate Creature Attacks
  • Repeat for X number of creatures

Since each one of these steps is individually customizable, you can see that you have a lot of options.

Templates:
Here is an example of each of the types of templates to give you an idea of how they work.
Biome:
Code: [Select]
[TEMPLATE:TEMPERATE_DENSE] <- template ID
{#DESCRIPTION;Can be found in any dense temperate location.} <- description to add to creature
{#TOKENS;#TEMPERATE} <- Token to be used by other templates
[SHRUBLAND_TEMPERATE] <- Actual raws to add to the creature
[ANY_TEMPERATE_FOREST]
Body Materials:
Code: [Select]
[TEMPLATE:SCALE]
{#DESCRIPTION;A scaled creature}
{#NAME;NONE} <- Not currently used, will be used in the future to help with name generation for creatures
{#ARGS;#SCALE} <- Arguments allow for additional customization within each template, more information on arguments below
{#TOKENS;#SCALE}
{#BP_COLORS;SCALE} <- What body parts might need random colors
[BODY_DETAIL_PLAN:#MATERIALS]
[REMOVE_MATERIAL:SKIN]
[REMOVE_MATERIAL:LEATHER]
[REMOVE_MATERIAL:HAIR]
[USE_MATERIAL:SCALE:CREATURE_MAT:ANIMAL:SCALE_#ARG1]
[BODY_DETAIL_PLAN:#TISSUES]
[REMOVE_TISSUE:HAIR]
[REMOVE_TISSUE:SKIN]
[USE_TISSUE_TEMPLATE:SCALE:SCALE_TEMPLATE_LEVEL_#ARG1]
[BODY_DETAIL_PLAN:VERTEBRATE_TISSUE_LAYERS:SCALE:FAT:MUSCLE:BONE:CARTILAGE]
[SELECT_TISSUE_LAYER:HEART:BY_CATEGORY:HEART]
[PLUS_TISSUE_LAYER:SKIN:BY_CATEGORY:THROAT]
[TL_MAJOR_ARTERIES]
[BODY_DETAIL_PLAN:STANDARD_HEAD_POSITIONS]
[BODY_DETAIL_PLAN:HUMANOID_RIBCAGE_POSITIONS]
[TENDONS:CREATURE_MAT:ANIMAL:SINEW:200]
[LIGAMENTS:CREATURE_MAT:ANIMAL:SINEW:200]
[BLOOD:CREATURE_MAT:ANIMAL:BLOOD:LIQUID]
[PUS:CREATURE_MAT:ANIMAL:PUS:LIQUID]
[HAS_NERVES]
[GETS_WOUND_INFECTIONS]
[GETS_INFECTIONS_FROM_ROT]
Castes:
Code: [Select]
[TEMPLATE:FEMALE_EGG]
{#DESCRIPTION;The females lay eggs.}
{#ARGS;#EGG_SIZE,#CLUTCH_MIN,#CLUTCH_MAX}
{#TOKENS;#EGG}
[CASTE:FEMALE]
[DESCRIPTION:#DESC]
[CASTE_NAME:#NAME:#NAMEs:#NAME]
[FEMALE]
[LAYS_EGGS]
[EGG_MATERIAL:LOCAL_CREATURE_MAT:EGGSHELL:SOLID]
[EGG_MATERIAL:LOCAL_CREATURE_MAT:EGG_WHITE:LIQUID]
[EGG_MATERIAL:LOCAL_CREATURE_MAT:EGG_YOLK:LIQUID]
[EGG_SIZE:#ARG1]
[CLUTCH_SIZE:#ARG2:#ARG3]
[POP_RATIO:100]
Extracts:
Code: [Select]
[TEMPLATE:VENOM_1]
{#DESCRIPTION;It has a painful venom.}
{#ARGS;#SEV,#END}
{#TOKENS;#VENOM}
[USE_MATERIAL_TEMPLATE:VENOM:CREATURE_EXTRACT_TEMPLATE]
[STATE_NAME:ALL_SOLID:frozen #NAME venom]
[STATE_ADJ:ALL_SOLID:frozen #NAME venom]
[STATE_NAME:LIQUID:#NAME venom]
[STATE_ADJ:LIQUID:#NAME venom]
[STATE_NAME:GAS:boiling #NAME venom]
[STATE_ADJ:GAS:boiling #NAME venom]
[PREFIX:NONE]
[ENTERS_BLOOD]
[REACTION_CLASS:VENOM]
[SYNDROME]
[SYN_NAME:#NAME venom]
[SYN_INJECTED]
[SYN_CONTACT]
[CE_PAIN:SEV:#ARG1:PROB:100:RESISTABLE:SIZE_DILUTES:LOCALIZED:VASCULAR_ONLY:START:0:PEAK:10:END:#ARG2]
[EXTRACT:LOCAL_CREATURE_MAT:VENOM]
Interactions:
Code: [Select]
[TEMPLATE:VENOM_SPIT]
{#DESCRIPTION;It is able to spit its venom at range.}
{#ARGS;NONE}
{#TOKENS;#VENOM_SPIT}
[CAN_DO_INTERACTION:MATERIAL_EMISSION]
[CDI:ADV_NAME:Spit venom]
[CDI:USAGE_HINT:ATTACK]
[CDI:MATERIAL:LOCAL_CREATURE_MAT:VENOM:LIQUID_GLOB]
[CDI:VERB:spit venom:spits venom:NA]
[CDI:TARGET:C:LINE_OF_SIGHT]
[CDI:TARGET_RANGE:C:6]
[CDI:MAX_TARGET_NUMBER:C:1]
[CDI:WAIT_PERIOD:5000]
Type:
Code: [Select]
[TEMPLATE:TRADE_WAGON]
{#DESCRIPTION;It is used as a wagon pulling animal.}
{#ARGS;#CAPACITY}
{#TOKENS;#TRADE}
[WAGON_PULLER]
[TRADE_CAPACITY:#ARG1]

Now by this point you might be asking yourself, "This sounds all well and good, but how do I actually go about using any of this nonsense?"

Well for that I need to introduce the last (and probably most confusing) piece of the puzzle, the Configuration file. Here is what mine (and so the currently implemented choices) looks like;
Code: [Select]
shearable_percent = 10 # This percent of creatures with hair will have the #SHEARABLE flag true
webber_percent = 10 # This percent of creatures will have the #WEBBER flag true
web_spray_percent = 50 # This percent of creatures that have #WEBBER will have #WEB_SPRAY
predator_percent = 10 # This percent of creatures will have the #PREDATOR flag true
venom_percent = 10 # This percent of creatures will have the #VENOM flag true
venom_spit_percent = 25 # This percent of creature that have #VENOM will have #VENOM_SPIT
hive_percent = 5 # This percent of vermin will have the #HIVE flag true
flying_percent = 90 # The percent of creatures with wings that have the #FLYING flag true
trade_percent = 10 # The percent of creatures above trade_size that have the #TRADE flag true
train_percent = 90 # The percent of creature with the #TRAIN flag true
roaming_percent = 50
general_percent = 50 # The percent of creatures that will have an additional type token
egg_percent = 10 # The percent of females that lay eggs
milk_percent = 10 # The percent of females that give milk
interaction_simple_percent = 10 # The percent of creatures that will have the #SIMPLE_INTERACTION flag true

vermin_size = 500 # Smaller than this size sets the #VERMIN flag true
tiny_size = 5 # Smaller than this size sets the #TINY flag true
trade_size = 100000 # The minimum size of all trade animals

mean_size = 200000 # Max size of creature is selected between 1 and this value with a triangular distribution function
sigma_size = 125000 # Standard deviation in size

max_attacks = 1 # Creatures will have a number of attacks between 1 and this value
max_age = 100 # Max age of creature will be between 2 and this value
max_venom_severity = 500 # Venom extracts will have a severity between 1 and this value with a triangular distribution function
max_venom_length = 10000 # Venom extract will have a length between 1000 and this value with a triangular distribution function
max_population = 100 # For non-vermin creatures sets a maximum population number with a triangular distribution function
max_cluster = 10 # For non-vermin creatures sets a maximum cluster number with a triangular distribution function

min_population = 1 # For non-vermin creatures sets a minimum population number with a triangular distribution function
min_cluster = 1 # For non-vermin creatures sets a minimum cluster number with a triangular distribution function

base_pet_value = 50 # Base value of all pets before size and modifier scaling
size_pet_divider = 5000 # Amount to divide size by before adding to pet value

max_misc_tags = 5 # Number of extra tags a given creature can have (misc tags are specified below)
max_active_tags = 1 # Number of active tags a given creature can have (active tags are specified below

#'!BODY_DETAIL_TEMPLATE': '!DESCRIPTION MODIFIER',
material = {'MATERIALS_LEVEL_1': 'This creature has weak materials',
'MATERIALS_LEVEL_2': '',
'MATERIALS_LEVEL_3': 'This creature has strong materials',
'MATERIALS_LEVEL_4': 'This creature has very strong materials'
}

tissue = {'MATERIALS_LEVEL_1': 'TISSUES_LEVEL_1',
  'MATERIALS_LEVEL_2': 'TISSUES_LEVEL_2',
  'MATERIALS_LEVEL_3': 'TISSUES_LEVEL_3',
  'MATERIALS_LEVEL_4': 'TISSUES_LEVEL_4'
  }

#'!ACTIVITY TAG': '!DESCRIPTION MODIFIER',
active = {'CREPUSCULAR': 'at dawn and dusk',
  'NOCTURNAL': 'at night',
  'DIURNAL': 'during the day',
  'MATUTINAL': 'at dawn',
  'VESPERTINE': 'at dusk',
  'ALL_ACTIVE': 'all the time'
}

#'!TAG': '!PREFSTRING',
misc = {'ADOPTS_OWNER': 'loyalty',
'AMBUSHPREDATOR': 'ability to stalk prey',
'BENIGN': 'benign nature',
'BONECARN': 'like of bones',
'CARNIVORE': 'taste for meat',
'CAVE_ADAPT': 'adeptness underground',
'COMMON_DOMESTIC': 'ability to domesticate',
'CURIOUSBEAST_EATER': 'curiosity',
'CURIOUSBEAST_GUZZLER': 'curiosity',
'CURIOUSBEAST_ITEM': 'curiosity',
'EXTRAVISION': 'ability to see at night',
'FLEEQUICK': 'ability to run away',
'HUNTS_VERMIN': 'ability to hunt vermin',
'LIKES_FIGHTING': 'ferocious attitude',
'MEANDERER': 'random behaviour',
'MISCHIEVIOUS': 'mischieviousness',
'MOUNT': 'use as a mount',
'MOUNT_EXOTIC': 'use as a mount',
'NO_AUTUMN': 'autumnal hibernation',
'NO_DIZZINESS': 'resistance to dizziness',
'NO_DRINK': 'ability to go long periods without drink',
'NO_EAT': 'ability to go long periods without food',
'NO_FEVERS': 'lack of fevers',
'NO_SLEEP': 'no need of sleep',
'NO_SPRING': 'spring hibernation',
'NO_SUMMER': 'summer hibernation',
'NO_WINTER': 'winter hibernation',
'NOBREATHE': 'no need to breath',
'NOEMOTION': 'lack of emotion',
'NOEXERT': 'incredible endurance',
'NOFEAR': 'lack of fear',
'NONAUSEA': 'resistance to nausea',
'NOPAIN': 'resistance to pain',
'NOSTUN': 'resistance to being stunned',
'PARALYZEIMMUNE': 'resistance to paralysis',
'TRANCES': 'ability to enter martial trances',
'TRAPAVOID': 'ability to avoid traps',
'UBIQUITOUS': 'over abundentness',
'VERMINHUNTER': 'expert vermin hunting',
'WEBIMMUNE': 'ability to slip out of webbing'
}

#'!SELF DECLARED ARGUMENT (in all template.txt)': '!VALUE OF ARGUMENT',
args = {'#SHELL': 'random.randint(1,4)',
'#SCALE': 'random.randint(1,4)',
'#CHITIN': 'random.randint(1,4)',
'#TOOTH': 'random.randint(1,2)',
'#HOOF': 'random.randint(1,2)',
'#HORN': 'random.randint(1,2)',
'#NAIL': 'random.randint(1,2)',
'#SEV': 'int(random.triangular(1,max_venom_severity))',
'#END': 'int(random.triangular(1000,max_venom_length))',
'#MILK': '20000',
'#EGG_SIZE': 'int(size_r/1000)+1',
'#CLUTCH_MIN': 'random.randint(1,5)',
'#CLUTCH_MAX': 'random.randint(6,10)',
'#CAPACITY': 'int(size_r/200)',
'#DIVISOR': '1000'
}

#'!SELF DECLARED ARGUMENT (in template_BODY.txt)': !BOOLEAN FLAG,
body_token = {'#SHEAR_HAIR': False,
'#CHITIN': False,
'#SHELL': False,
'#SCALE': False,
'#WINGS': False
}

#'!SELF DECLARED ARGUMENT (in template_BIOME.txt)': !BOOLEAN FLAG,
biome_token = {'#WATER_ONLY': False,
'#DESERT': False,
'#TEMPERATE': False,
'#TROPICAL': False,
'#MOUNTAIN': False,
'#FREEZING': False,
'#UNDERGROUND': False
}

#'!SELF DECLARED ARGUMENT (in template_TYPE.txt)': '!REQUIRMENTS FOR TRUE',
main_token = {'#MUNDANE': 'True',
'#SAVAGE': 'False',
'#CHAOS': 'False',
'#PURGED': 'False',
'#FANCIFUL': 'False'
}

#'!SELF DECLARED ARGUMENT (in template_TYPE.txt)': '!REQUIRMENTS FOR TRUE',
sub_token = {'#TRADE': '((size_r > trade_size) and (random.randint(1,100) < trade_percent))',
'#VERMIN_WATER': '((biome_token_flag["#WATER_ONLY"]) and (size_r <= vermin_size))',
'#VERMIN_GROUND': '((not biome_token_flag["#WATER_ONLY"]) and (size_r <= vermin_size))',
'#VERMIN_TINY': 'size_r <= tiny_size',
'#FLYING': '((random.randint(1,100) < shearable_percent) and (body_token_flag["#WINGS"]))',
'#TRAIN': 'random.randint(1,100) < train_percent',
'#ROAMING': 'random.randint(1,100) < roaming_percent',
'#PREDATOR': 'random.randint(1,100) < predator_percent',
'#WATER': 'biome_token_flag["#WATER_ONLY"]',
'#SHEARABLE': '((random.randint(1,100) < shearable_percent) and (body_token_flag["#SHEAR_HAIR"]))',
'#WEBBER': 'random.randint(1,100) < webber_percent',
'#GENERAL': 'random.randint(1,100) < general_percent',
'#UNDERGROUND': 'biome_token_flag["#UNDERGROUND"]',
}

#'!SELF DECLARED ARGUMENT (in template_EXTRACT.txt)': '!REQUIRMENTS FOR TRUE',
extract_token = {'#VENOM': 'random.randint(1,100) < venom_percent',
        '#HIVE': '((random.randint(1,100) < hive_percent) and (size_r <= vermin_size))'
}

#'!SELF DECLARED ARGUMENT  (in template_CASTE.txt)': '!REQUIRMENTS FOR TRUE',
caste_token = {'#MALE': 'True',
   '#FEMALE': 'egg_percent+milk_percent < caste_r <= 100',
   '#EGG': 'milk_percent < caste_r <= egg_percent+milk_percent',
               '#MILK': 'caste_r <= milk_percent',
}

caste_numbers = {'#MALE_NUMBER': 1,
'#FEMALE_NUMBER': 1,
'#EGG_NUMBER': 1,
'#MILK_NUMBER': 1,
}

#'!SELF DECLARED ARGUMENT  (in template_CASTE.txt)': '!REQUIRMENTS FOR TRUE',
interaction_token = {'#CLEAN': 'False',
'#BUMP': 'False',
'#SIMPLE': 'random.randint(1,100) < interaction_simple_percent',
'#HIDE': 'False',
'#VENOM_SPIT': 'extract_token_flag["#VENOM"] and random.randint(1,100) < venom_spit_percent',
'#WEB_SPRAY': 'sub_token_flag["#WEBBER"] and random.randint(1,100) < web_spray_percent'
}

#'TISSUE TOKEN TO COLOR (from template_BODY.txt)': 'TISSUE_NAME' <- what the names for the body parts that get color tokens are
color_token = {'SCALE': 'scales',
   'SKIN': 'skin',
   'EYE': 'eyes',
   'CHITIN': 'chitin',
   'SHELL': 'shell'
}

#'!SELF DECLARED ARGUMENT  (any argument from above)': PET VALUE MODIFIER <- If any of the flags are true, will multiply the value of the creature by (1+#)
value_token = {'#VENOM': 1,
     '#SHEARABLE': 1,
     '#WEBBER': 1,
     '#TRAIN': 1,
     '#HIVE': 1,
     '#EGG': 1,
     '#MILK': 1
     }

As you can see, this system is not simple. It is not a basic 'click and run' random creature script. It is highly customizable and adaptable. You can add templates too any of the template files, you can add extra tokens and arguments, you can change the percent probabilities of certain flags being set true, you can basically do whatever you want.

Want to make 10 large, forest dwelling, web spitting, savage, creatures? You can do that.
Want to make 1000 random size, random biome, random trait creatures? You can do that too.

All by just changing some of the parameters in the configuration file and the templates.

Instructions for use will come in the following post.
« Last Edit: July 16, 2014, 11:36:41 am by Roses »
Logged

Roses

  • Bay Watcher
    • View Profile
Re: Another Random Creature Script
« Reply #1 on: July 15, 2014, 10:33:28 am »

"Ok, ok, you convinced me, it has its uses (even if it does seem needlessly complicated). So what do I have to do to get it to actually work?"

Great question! Lets do a step by step walkthrough!

Files you will need to change:
configuration.txt
templates_BIOME.txt
templates_BODY_MATERIALS.txt
templates_BODY_PARTS.txt
templates_CASTE.txt
templates_EXTRACT.txt
templates_INTERACTION.txt
templates_TYPE.txt

Files you will not need to change:
random_creatures.py
rc_functions.py

STEP 1: Templates
The first step is to read through all the templates_*.txt files and get a feel for how each one works. I have included several different templates in each of the files, there should be more than enough examples for you to figure out how to create your own templates. You can freely add or subtract any of the templates that you want, just make sure the general naming convention is followed.

STEP 2: Template tokens and arguments
Now that you have a feel for the templates and have made a couple of your own, its time to look at tokens and arguments, and how to effectively use them. Let's start with an example already included in the current templates. Look at this template from the templates_EXTRACT.txt file:
Code: [Select]
[TEMPLATE:VENOM_1]
{#DESCRIPTION;It has a painful venom.}
{#ARGS;#SEV,#END}
{#TOKENS;#VENOM}
[USE_MATERIAL_TEMPLATE:VENOM:CREATURE_EXTRACT_TEMPLATE]
[STATE_NAME:ALL_SOLID:frozen #NAME venom]
[STATE_ADJ:ALL_SOLID:frozen #NAME venom]
[STATE_NAME:LIQUID:#NAME venom]
[STATE_ADJ:LIQUID:#NAME venom]
[STATE_NAME:GAS:boiling #NAME venom]
[STATE_ADJ:GAS:boiling #NAME venom]
[PREFIX:NONE]
[ENTERS_BLOOD]
[REACTION_CLASS:VENOM]
[SYNDROME]
[SYN_NAME:#NAME venom]
[SYN_INJECTED]
[SYN_CONTACT]
[CE_PAIN:SEV:#ARG1:PROB:100:RESISTABLE:SIZE_DILUTES:LOCALIZED:VASCULAR_ONLY:START:0:PEAK:10:END:#ARG2]
[EXTRACT:LOCAL_CREATURE_MAT:VENOM]
You will note that it has two arguments and one token. The arguments are then labeled as #ARG1 and #ARG2 inside of the raws portion of the template (you may also notice #NAME, that is a special argument which will always pass the creatures name). Another thing you may notice is that there is no reference to the token in the raws portion. This is because the token merely specifies which type of template this is. Now that we have made this template, we need to come up with a way to add it to creatures, or in other words, we need to 'activate' it.

STEP 3: Activating tokens and defining arguments
Now we move on to the configuration.txt file, there you will look for two sections. The first is the arguments section where (in the release as of the time of this writing) you will find;
Code: [Select]
args = {'#SHELL': 'random.randint(1,4)',
'#SCALE': 'random.randint(1,4)',
'#CHITIN': 'random.randint(1,4)',
'#TOOTH': 'random.randint(1,2)',
'#HOOF': 'random.randint(1,2)',
'#HORN': 'random.randint(1,2)',
'#NAIL': 'random.randint(1,2)',
'#SEV': 'int(random.triangular(1,max_venom_severity))', <-
'#END': 'int(random.triangular(1000,max_venom_length))', <-
'#MILK': '20000',
'#EGG_SIZE': 'int(size_r/1000)+1',
'#CLUTCH_MIN': 'random.randint(1,5)',
'#CLUTCH_MAX': 'random.randint(6,10)',
'#CAPACITY': 'int(size_r/200)',
'#DIVISOR': '1000'
}
I have pointed out our two arguments from the extract template. This means that your venom template will be created with a severity of between 1 and the variable max_venom_severity and it will have a duration of between 1000 and the variable max_venom_length.

These variables are added by yourself at the top of the configuration.txt file, in the current file they are;
Code: [Select]
max_venom_severity = 500 # Venom extracts will have a severity between 1 and this value with a triangular distribution function
max_venom_length = 10000 # Venom extract will have a length between 1000 and this value with a triangular distribution function

Now we have defined our arguments we need to activate the token. To do this we find the extract_token section in the configuration.txt file;
Code: [Select]
extract_token = {'#VENOM': 'random.randint(1,100) < venom_percent', <-
'#HIVE': '((random.randint(1,100) < hive_percent) and (size_r <= vermin_size))'
}
This shows you that currently the percentage of creatures which will have the #VENOM flag set true, and thus pick an extract that has the #VENOM token is venom_percent (again defined by you at the top of the configuration file).

So for a recap;
Arguments - These are all handled in one place, and allow for individual customization inside of a template, so that two creatures that pick the same template will have different values.
Tokens - These specify which templates a creature can pick from. When the creature is generated it will analyze each token group separately and set the corresponding flags to True or False. Each flag that is set True means that the creature can choose only from those with the corresponding token.
NOTE:
  • Castes, Extracts, Interactions, and Types all require tokens and if there are not provided and activated as shown in the above two steps, they will not be included in the randomly generated creatures.
  • Biome tokens are set when the biome is chosen and can be used in other flags (e.g. in the type tokens '#WATER': 'biome_token_flag["#WATER_ONLY"]')
  • Body Part tokens are handled differently, they are only used when determining what is required to link to
  • Body Material function in the same manner as biome tokens.

STEP 4: Configuration file wrap up
Two sections of the configuration file that have not been talked about yet are the body_detail_template declarations and the raw_token declarations.
1. body_detail_template
These are for use in the templates_BODY_MATERIALS.txt file. Namely, wherever you see #MATERIALS it will randomly be replaced by one of these material templates, correspondingly any #TISSUES will be replaced by the associated tissue template. (In vanilla you would simply have STANDARD_MATERIALS and STANDARD_TISSUES)
Code: [Select]
#'!BODY_DETAIL_TEMPLATE': '!DESCRIPTION MODIFIER',
material = {'MATERIALS_LEVEL_1': 'This creature has weak materials',
'MATERIALS_LEVEL_2': '',
'MATERIALS_LEVEL_3': 'This creature has strong materials',
'MATERIALS_LEVEL_4': 'This creature has very strong materials'
}

tissue = {'MATERIALS_LEVEL_1': 'TISSUES_LEVEL_1',
  'MATERIALS_LEVEL_2': 'TISSUES_LEVEL_2',
  'MATERIALS_LEVEL_3': 'TISSUES_LEVEL_3',
  'MATERIALS_LEVEL_4': 'TISSUES_LEVEL_4'
  }
2. raw_tokens
Here's where all the extra miscellaneous tokens you might want to add to a creature go. Note that you can add these tokens in the templates themselves, but this allows for more variability within individual creatures as well. From the current configuration.txt;
Code: [Select]
#'!ACTIVITY TAG': '!DESCRIPTION MODIFIER', <- A section just for activity tags, add or remove as you desire. The script will pick one for the creature.
active = {'CREPUSCULAR': 'at dawn and dusk',
  'NOCTURNAL': 'at night',
  'DIURNAL': 'during the day',
  'MATUTINAL': 'at dawn',
  'VESPERTINE': 'at dusk',
  'ALL_ACTIVE': 'all the time'
}

#'!TAG': '!PREFSTRING', <- A section for the various quirks of an animal. These will be chosen at random (in a random, but configurable amount). And will provide the creature with prefstrings
misc = {'ADOPTS_OWNER': 'loyalty',
'AMBUSHPREDATOR': 'ability to stalk prey',
'BENIGN': 'benign nature',
'BONECARN': 'like of bones',
'CARNIVORE': 'taste for meat',
'CAVE_ADAPT': 'adeptness underground',
'COMMON_DOMESTIC': 'ability to domesticate',
'CURIOUSBEAST_EATER': 'curiosity',
'CURIOUSBEAST_GUZZLER': 'curiosity',
'CURIOUSBEAST_ITEM': 'curiosity',
'EXTRAVISION': 'ability to see at night',
'FLEEQUICK': 'ability to run away',
'HUNTS_VERMIN': 'ability to hunt vermin',
'LIKES_FIGHTING': 'ferocious attitude',
'MEANDERER': 'random behaviour',
'MISCHIEVIOUS': 'mischieviousness',
'MOUNT': 'use as a mount',
'MOUNT_EXOTIC': 'use as a mount',
'NO_AUTUMN': 'autumnal hibernation',
'NO_DIZZINESS': 'resistance to dizziness',
'NO_DRINK': 'ability to go long periods without drink',
'NO_EAT': 'ability to go long periods without food',
'NO_FEVERS': 'lack of fevers',
'NO_SLEEP': 'no need of sleep',
'NO_SPRING': 'spring hibernation',
'NO_SUMMER': 'summer hibernation',
'NO_WINTER': 'winter hibernation',
'NOBREATHE': 'no need to breath',
'NOEMOTION': 'lack of emotion',
'NOEXERT': 'incredible endurance',
'NOFEAR': 'lack of fear',
'NONAUSEA': 'resistance to nausea',
'NOPAIN': 'resistance to pain',
'NOSTUN': 'resistance to being stunned',
'PARALYZEIMMUNE': 'resistance to paralysis',
'TRANCES': 'ability to enter martial trances',
'TRAPAVOID': 'ability to avoid traps',
'UBIQUITOUS': 'over abundentness',
'VERMINHUNTER': 'expert vermin hunting',
'WEBIMMUNE': 'ability to slip out of webbing'
}

Lastly, in your configuration file, you will find a group of variables that are not connected to any templates. These are the various size, speed, age, population number, etc... variables. These can be changed to suit your needs and are labeled with what each one does.

Now that you have completed modifying the templates and made the necessary changes to your configuration file, you are ready to generate some creatures!

STEP 5: Run
Simply run random_creatures.py and when it asks you for how many creatures you would like to generate type in your desired number. And PRESTO! You now have a group of random creatures!

So at the end what do you get? Something like this; (Note that this still has the 34x speed system and no attacks, currently in the process of updating)
Code: [Select]
[CREATURE:MUNDANE_0000]
[NAME:nas-emar]
[CREATURE_TILE:'M']
[COLOR:0:5:0]
[PET][PETVALUE:130]
[NOCTURNAL]
[FREQUENCY:100]
[POPULATION_NUMBER:1:78]
[CLUSTER_NUMBER:1:6]
[PREFSTRING:lack of fevers]
[PREFSTRING:expert vermin hunting]
[PREFSTRING:over abundentness]
[PREFSTRING:use as a mount]
[BODY_SIZE:0:0:770]
[BODY_SIZE:1:0:7709]
[BODY_SIZE:2:0:77091]
[CHILD:1]
[MAXAGE:61:74]
[SPEED:2079]
[SWIMS_INNATE][SWIM_SPEED:2500]
[NO_FEVERS]
[VERMINHUNTER]
[UBIQUITOUS]
[MOUNT]
[BIOME:GLACIER]
[BIOME:TUNDRA]
[BIOME:OCEAN_ARCTIC]
[BIOME:TAIGA]
[BODY:TORSO_1PART:HEAD_NORMAL:LIMBS_LEGS_4TENTACLES:LIMBS_ARMS_2ARMS:FACE_EYES_8EYES:FACE_MOUTH_BILL:FACE_NOSE_SNOUT:FACE_EARS_LARGEEARS:ORGANS_STANDARD:SKELETAL_STANDARD:LIMBS_HANDS_CLAWSARM:LIMBS_FEET_CLUBSTENTACLE]
[USE_MATERIAL:CLAW:CREATURE_MAT:ANIMAL:NAIL_2]
[USE_TISSUE_TEMPLATE:CLAW:CLAW_TEMPLATE_LEVEL_2]
[BODY_DETAIL_PLAN:MATERIALS_LEVEL_2]
[REMOVE_MATERIAL:HAIR]
[REMOVE_MATERIAL:BONE]
[BODY_DETAIL_PLAN:TISSUES_LEVEL_2]
[REMOVE_TISSUE:HAIR]
[REMOVE_TISSUE:BONE]
[BODY_DETAIL_PLAN:MOLLUSC_TISSUE_LAYERS:SKIN:FAT:MUSCLE]
[BLOOD:CREATURE_MAT:ANIMAL:ICHOR:LIQUID]
[PUS:CREATURE_MAT:ANIMAL:PUS:LIQUID]
[SET_TL_GROUP:BY_CATEGORY:ALL:SKIN]
[TL_COLOR_MODIFIER:BUFF:1]
[TLCM_NOUN:skin:PLURAL]
[NATURAL]
[MUNDANE]
[MEANDERER]
[LARGE_ROAMING]
[LIKES_FIGHTING]
[LARGE_PREDATOR]
[TRAINABLE_WAR]
[CASTE:FEMALE]
[DESCRIPTION:(Max Size = 78, Value = 130) A common animal found in the wilderness. A hairless and boneless creature with a single part body, a head with eight eyes, a snout, a large bill, and large ears. It has two arms with claws, and four lower tentacles with clubs. Is only found in freezing biomes. Active  at night It roams around. It is a vicious predator. It can be trained to fight.]
[CASTE_NAME:nas-emar:nas-emars:nas-emar]
[FEMALE]
[POP_RATIO:100]
[CASTE:MALE]
[(Max Size = 78, Value = 130) A common animal found in the wilderness. A hairless and boneless creature with a single part body, a head with eight eyes, a snout, a large bill, and large ears. It has two arms with claws, and four lower tentacles with clubs. Is only found in freezing biomes. Active  at night It roams around. It is a vicious predator. It can be trained to fight.]
[CASTE_NAME:nas-emar:nas-emars:nas-emar]
[MALE]
[POP_RATIO:100]
[SELECT_CASTE:ALL]
[EXTRA_BUTCHER_OBJECT:BY_TYPE:THOUGHT]
[EBO_ITEM:SMALLGEM:NONE:INORGANIC:SOUL_GEM_ONE]

CURRENT ISSUES:
Here is a list of the current issues with generated creatures;
  • Name generation is basically non-existent, oh it will generate a random name for your creatures, but it will just pick between 1 and 3 random words from the dwarf language file and name your creature that. Not exactly useful. I will be adding support for naming conventions based on the various templates and tokens a creature uses.
  • Graphics are also non-existent. I am not sure what to do with that, but for now its all ascii
« Last Edit: July 15, 2014, 11:33:52 am by Roses »
Logged

Roses

  • Bay Watcher
    • View Profile
Re: Another Random Creature Script
« Reply #2 on: July 15, 2014, 11:35:07 am »

Done for now, you will notice there is no download as I am just finishing up some things. But feel free to post and comment.
Logged

Roses

  • Bay Watcher
    • View Profile
Re: Another Random Creature Script
« Reply #3 on: July 16, 2014, 11:36:20 am »

Download attached to the original post. Everything worked for me, but since it's such a hodge podge of code I am sure something will be broken. For any that use it please post any additional templates you make in this thread so that others can benefit from them as well.

Here is a couple of the descriptions from some creatures I just generated
Code: [Select]
A creature covered in chitin with a single part body, three heads and no eyes, a large trunk, a beak, and large ears, and two arms with large pincers and four lower flippers . Is only found in oceans. Active  at dawn and dusk It can be trained to hunt. It is aquatic. It roams around.   This creature has very strong materials
Code: [Select]
A feathered creature with a single part body, two heads and two eyes, no nose, a beak, and small ears, and two arms and hands with four claws each and eight legs and feet with four toes each. Can only be found in sandy places. Active  at night It can be trained to hunt. It roams around.   This creature has weak materials
Code: [Select]
A creature covered in chitin with a four part body with a large stinger attached, a small head with two horns and no eyes, a large trunk, a beak, and pointed ears, and no arms  and fifty legs and feet with four claws each and is slow. Is found in places devoid of life Active  at dawn It can be trained to fight and hunt
Code: [Select]
A scaled creature with a four part body, two heads with a single horn and three eyes, no nose, a beak, and no ears, and two upper tentacles with clubs and two lower flippers. Can be found on any land Active  during the day It can be trained to fight and hunt. It has a painful venom which causes swelling.   This creature has strong materials
Code: [Select]
A creature covered in chitin with a four part body with two wings attached, a large head and no eyes, no nose, a large bill, and no ears, and no arms and eight lower tentacles with clubs and is fast. Can be found everywhere Active  during the day It is generally benign. The females lay eggs.  This creature has weak materials
Note that the names for the creatures are still atrocious, but oh well, and as you can see sometimes the descriptions don't quite read right.
Logged

Bralbaard

  • Bay Watcher
    • View Profile
Re: Another Random Creature Script
« Reply #4 on: July 16, 2014, 04:01:44 pm »

This is definitely something I'll try when there is more stable df version.
Logged

Knight Otu

  • Bay Watcher
  • ☺4[
    • View Profile
Re: Another Random Creature Script
« Reply #5 on: September 02, 2014, 03:48:22 pm »

From what I can tell, this script at least needs a more up-to-date version of mwe_creatures than what you have in the Modding with Excel download?
Logged
Direforged Original
Random Raw Scripts - Randomly generated Beasts , Vermin, Hags, Vampires, and Civilizations
Castle Otu

Roses

  • Bay Watcher
    • View Profile
Re: Another Random Creature Script
« Reply #6 on: September 02, 2014, 04:14:34 pm »

Yes, the Modding with Excel downloads are out of date. I have updated versions that are preliminary, but they have taken a back seat to my DFHack interests. I will get around to updating them sometime soonish. There didn't seem to be much interest so I decided not to fast track the update.
Logged

Knight Otu

  • Bay Watcher
  • ☺4[
    • View Profile
Re: Another Random Creature Script
« Reply #7 on: September 03, 2014, 12:44:03 pm »

Thanks, I'll wait then. I probably should have tested this when I first found it with a search.
Logged
Direforged Original
Random Raw Scripts - Randomly generated Beasts , Vermin, Hags, Vampires, and Civilizations
Castle Otu

Roses

  • Bay Watcher
    • View Profile
Re: Another Random Creature Script
« Reply #8 on: September 03, 2014, 03:58:20 pm »

I updated the download to at least include the most updated version I have (which was generating useable creatures for me in .40.03) so you should be able to use it, unless there are more issues that I am missing.
Logged

Dee

  • Bay Watcher
    • View Profile
Re: Another Random Creature Script
« Reply #9 on: August 11, 2015, 11:19:34 pm »

 this is something I would like to try out, but the configuration.txt file wasn't in the download

edit,  copy and pasted the example configuration.txt from the example
« Last Edit: August 12, 2015, 02:55:28 am by Dee »
Logged

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: Another Random Creature Script
« Reply #10 on: August 13, 2015, 01:56:08 pm »

This sounds a lot like the random creature library I made for First Landing, but my script is a lot less flexible :) Basically I did the same thing, made sections that were picked from a list (I used a semi-recursive weighted list).

Too bad this wasn't available then, and too bad it's a Python script and as such would be hard to use with Rubble...
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Roses

  • Bay Watcher
    • View Profile
Re: Another Random Creature Script
« Reply #11 on: August 15, 2015, 01:53:26 am »

this is something I would like to try out, but the configuration.txt file wasn't in the download

edit,  copy and pasted the example configuration.txt from the example

My current plan for this is to change the way certain variables and things work so that it is smoother and even more flexible (with an included gui). But I'm not going to be able to work on it until mid September. I'm not sure if it is usable  at all in its current format.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Another Random Creature Script
« Reply #12 on: August 16, 2015, 09:58:50 am »

Some kind of UI would be great. Talvieno had a .exe that made random creatures, people really liked that feature in Masterwork for 34.11, but it has never been updated. It made creatures and civs every time it was run, and people could select how many creatures.
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Noobboyo

  • Bay Watcher
    • View Profile
Hello are you able to make the animals tameable by chance
« Reply #13 on: August 16, 2019, 01:27:39 pm »

Because if so then how exactly sorry I'm still pretty new to df
Logged