NPC making howto
Posted: Fri Jan 08, 2010 5:22 pm
Ok so Madmonk and Shoob expressed interrest into doing grunt work 
A bit of "theory" first:
- There is no global npc list as in T2/T3. Instead each zone comes with a npcs.lua file, this file can define NPCs specific to this zone (like a dungeon guardian) and/or load a "common" list of npcs. I.E. Amon Sul loads a global list of skeletons, vermins and molds and defines a specific Shade of Angmar
- All NPCs can level. A NPC is defined as a level 1 and then auto-leveled. It has a level_range which defined the minimun and maximun level (will also affect npc generation). In ToME npcs in zones will be leveled to be around the player's level for the first level of a zone ad then gain one more level each level (which is why a 40 levels zone is highly unlikely, unless the player somehow manages to gain 1level per level)
- NPCs possess the same potential as players, they can (and must) have stats, they can have talents, they can have equipment, inventory, mana, stamina, ...
- "canon fodder" NPCs must be designed to be a tad weaker than a player (slow attack if not using weapons, lower strength, less life, ...) but not too weak
- Bosses must be obviously more powerfull
- Drops should NOT be plentifull, I dont want to have to add an automatizer, so keep drops low. (Money should be short to come by)
- NPCs can inherit NPCs, you'll see in the example. Try to define common properties for a group in the base entity. Like drops, base stats, ...
Ok an example, the skeletons from Amon Sul:
Needed because we use talents later.
The base entity, this will never be generated in game it serves as template (a npc is only randomly generated if it has both a rarity and level_range field).
Several interresting fields here:
- autolevel: defines what stats/talents/.. it will gain by leveling. You can get wild, invent new ones and explain what they should do I'll code it.
- energy = { mod = 1 } : the "speed" stat. 1 is default, 0.5 is half as slow, 2 is twice as fast
- ai : if you want a simply talent using monster, use this one and change talent_in. A npc will use an talent 1 in talent_in times.
- equipment: hat stuff does it wield/wear, given in the form of a filters list like : { {type="weapon", subtype="greatsword"}, {type="armor", subtype="massive"} } . *WARNING* it must have the neccesary stats/talents to use them. By default equipment is NOT dropped on death unless it was an ego/artifact.
- inventory: items that will drop, same filter type.
- combat: this is used for attack in case there is no wielded weapons (liek some trolls/animals/... do not use weapons)
A basic skeleton, derived from the above template.
Example of skeleton with talents.
Oh and combat_armor, combat_def replace the use of real armor equipment.
An other talent example.
Oh and we see level_range for all of them is defined up to 50, so they can be used in multiple zones.
http://www.net-core.org/tome/t4/zones.ods
You can see some planned zones, so your first task is: think of monster types to fill them up and then we'll create them.
If you can think of nice talents/whatever for them to use, say so I'll implement it (or say no ;> )
Thanks !

A bit of "theory" first:
- There is no global npc list as in T2/T3. Instead each zone comes with a npcs.lua file, this file can define NPCs specific to this zone (like a dungeon guardian) and/or load a "common" list of npcs. I.E. Amon Sul loads a global list of skeletons, vermins and molds and defines a specific Shade of Angmar
- All NPCs can level. A NPC is defined as a level 1 and then auto-leveled. It has a level_range which defined the minimun and maximun level (will also affect npc generation). In ToME npcs in zones will be leveled to be around the player's level for the first level of a zone ad then gain one more level each level (which is why a 40 levels zone is highly unlikely, unless the player somehow manages to gain 1level per level)
- NPCs possess the same potential as players, they can (and must) have stats, they can have talents, they can have equipment, inventory, mana, stamina, ...
- "canon fodder" NPCs must be designed to be a tad weaker than a player (slow attack if not using weapons, lower strength, less life, ...) but not too weak
- Bosses must be obviously more powerfull
- Drops should NOT be plentifull, I dont want to have to add an automatizer, so keep drops low. (Money should be short to come by)
- NPCs can inherit NPCs, you'll see in the example. Try to define common properties for a group in the base entity. Like drops, base stats, ...
Ok an example, the skeletons from Amon Sul:
Code: Select all
local Talents = require("engine.interface.ActorTalents")
Code: Select all
newEntity{
define_as = "BASE_NPC_SKELETON",
type = "undead", subtype = "skeletons",
display = "s", color=colors.WHITE,
combat = { dam=1, atk=1, apr=1 },
body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 },
equipment = resolvers.equip{ {type="weapon", subtype="greatsword"} },
drops = resolvers.drops{chance=20, nb=1, {} },
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=4, },
energy = { mod=1 },
stats = { str=14, dex=12, mag=10, con=12 },
tmasteries = resolvers.tmasteries{ ["physical/other"]=0.3, ["physical/2hweapon"]=0.3 },
blind_immune = 1,
see_invisible = 2,
undead = 1,
}
Several interresting fields here:
- autolevel: defines what stats/talents/.. it will gain by leveling. You can get wild, invent new ones and explain what they should do I'll code it.
- energy = { mod = 1 } : the "speed" stat. 1 is default, 0.5 is half as slow, 2 is twice as fast
- ai : if you want a simply talent using monster, use this one and change talent_in. A npc will use an talent 1 in talent_in times.
- equipment: hat stuff does it wield/wear, given in the form of a filters list like : { {type="weapon", subtype="greatsword"}, {type="armor", subtype="massive"} } . *WARNING* it must have the neccesary stats/talents to use them. By default equipment is NOT dropped on death unless it was an ego/artifact.
- inventory: items that will drop, same filter type.
- combat: this is used for attack in case there is no wielded weapons (liek some trolls/animals/... do not use weapons)
Code: Select all
newEntity{ base = "BASE_NPC_SKELETON",
name = "degenerated skeleton warrior", color=colors.WHITE,
level_range = {1, 50}, exp_worth = 1,
rarity = 4,
max_life = resolvers.rngavg(40,50),
combat_armor = 5, combat_def = 1,
}
Code: Select all
newEntity{ base = "BASE_NPC_SKELETON",
name = "skeleton warrior", color=colors.SLATE,
level_range = {2, 50}, exp_worth = 1,
rarity = 3,
max_life = resolvers.rngavg(90,100),
combat_armor = 5, combat_def = 1,
talents = resolvers.talents{ [Talents.T_STAMINA_POOL]=1, [Talents.T_STUNNING_BLOW]=1, [Talents.T_DEATH_BLOW]=1 },
}
Oh and combat_armor, combat_def replace the use of real armor equipment.
Code: Select all
newEntity{ base = "BASE_NPC_SKELETON",
name = "skeleton mage", color=colors.LIGHT_RED,
level_range = {4, 50}, exp_worth = 1,
rarity = 6,
max_life = resolvers.rngavg(50,60),
max_mana = resolvers.rngavg(70,80),
combat_armor = 3, combat_def = 1,
stats = { str=10, dex=12, cun=14, mag=14, con=10 },
talents = resolvers.talents{ [Talents.T_MANA_POOL]=1, [Talents.T_FLAME]=2, [Talents.T_MANATHRUST]=3 },
equipment = resolvers.equip{ {type="weapon", subtype="staff"} },
autolevel = "caster",
ai = "dumb_talented_simple", ai_state = { talent_in=6, },
}
Oh and we see level_range for all of them is defined up to 50, so they can be used in multiple zones.
http://www.net-core.org/tome/t4/zones.ods
You can see some planned zones, so your first task is: think of monster types to fill them up and then we'll create them.
If you can think of nice talents/whatever for them to use, say so I'll implement it (or say no ;> )
Thanks !