Page 1 of 7

NPC making howto

Posted: Fri Jan 08, 2010 5:22 pm
by darkgod
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:

Code: Select all

local Talents = require("engine.interface.ActorTalents")
Needed because we use talents later.

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,
}
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)

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,
}
A basic skeleton, derived from the above template.

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 },
}
Example of skeleton with talents.
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, },
}
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 !

Re: NPC making howto

Posted: Fri Jan 08, 2010 6:31 pm
by Shoob
how does this sound for now:

ettenmoors
- goblins
- trolls (mountain, stone, cave, hill)
- wolves (regular, wargs)
- crebain
- ogres
- giants

trollshaws
- trolls (stone, forest, cave, hill)
- wolves (both varieties)
- bandits
- "vermin" (what mean you by this?)

if you agree I will make some of them.

also what hostile plants will you have... and should we do spiders as well?

Re: NPC making howto

Posted: Fri Jan 08, 2010 6:48 pm
by darkgod
Hostile plants can be anything not silly :)
Spiders, sure we all love spiders!

I implemented some trolls for the trollshaws, wait for the next RFT :)
I'd remove trolls from ettenmoors to not duplicate too much the trollshaws.

Thanks

Re: NPC making howto

Posted: Fri Jan 08, 2010 7:42 pm
by Shoob
:( but trolls came down from the ettenmoors into the trollshaws :P

but we can say that the giants and the ogres and ettins scared off all the trolls, right :)

and how about midge swarms... they always do 1-2 points of damage and you have to attack them say 20 times before they disappear (they are immune to weapon damage, however spells can kill them sooner (but only beam or ball spells). I'm not sure entirely how to implement this but it would be fun :P (read evil)

Re: NPC making howto

Posted: Fri Jan 08, 2010 7:44 pm
by darkgod
Not sure either :)
But I'll think about it it is indeed evil

Re: NPC making howto

Posted: Fri Jan 08, 2010 8:47 pm
by Shoob
do you want me to add new talents too or just request them...

really all I want is:

STING_POISON

and if you could:
STING_FIRE
STING_COLD
STING_ACID
STING_LIGHTNING

most of these wont even be used really until later though unless you want the ants I am making to be more powerful. and do you really need to me to explain each of them... basically it is just a copy paste of the crawl and replace with sting and then change damage types if needed.

which leaves the question... should I make their bite be in elemental damage and physical or just physical... hmmm... I will stick with just physical as I am trying it out for now.. maybe later I will change it up

and finally, can I set the base energy mod and then change it in the actual thing. most of them will be the same, just curious (thinking about making some faster or slower than normal)

that said should I do different colored ants or just do (soldier, worker, queen)
eventually I would think it would be colored ants with egos of soldier/worker/queen so I am doing colored ants.

Re: NPC making howto

Posted: Fri Jan 08, 2010 8:57 pm
by darkgod
Well if you can code a bit yes do them (be sure to use RFT4).
Just copy/paste will work. Some explanation though:

Code: Select all

		self.combat_apr = self.combat_apr + 1000
		self:attackTarget(target, DamageType.POISON, 2 + self:getTalentLevel(t), true)
		self.combat_apr = self.combat_apr - 1000
The combat_apr means this attack will ignore armor (since we do elemental attack it sounds logical).
The attackTarget line calls the melee attack code, with POISON damage and a damage multiplier of 2 + self:getTalentLevel(t) .

Yes you can set energy mod in the template and change it later on specific npcs.
Yes do colors with ego for the "class".

When doing a npc type, like ants (BTW I think the correct type would be "insect" with subtype "ant"), do not hesitate to put in npcs for higher levels if you can think of them, it'll be useful eventually (and this allows for some nasty OOD encounters) :)

Re: NPC making howto

Posted: Sat Jan 09, 2010 9:29 pm
by Shoob
So I was wondering how to change the attack from physical to something else? (not just a talent)

I read the above but couldnt find it.

I am putting in algroths as well :D

Re: NPC making howto

Posted: Sun Jan 10, 2010 12:12 am
by Shoob
ok... I have added wolves and algroths to mine I probably will add an ettin in too, making it massively ood if you find it :D right now I have put wolves into vermin just to test it out but they should go into animals.lua. Do you want to add colors in or just make all wolves umber (except for wargs)? I darkened up umber a bit and made it into DARK_UMBER, which dire wolves use.

Code: Select all

newEntity{
	define_as = "BASE_NPC_WOLF",
	type = "animal", subtype = "wolf",
	display = "C", color=colors.WHITE,
	body = { INVEN = 10 },

	max_stamina = 150,

	
	autolevel = "warrior",
	ai = "dumb_talented_simple", ai_state = { talent_in=3, },
	energy = { mod=1.2 },
	stats = { str=10, dex=17, mag=3, con=7 },
	combat_armor = 1, combat_def = 1,
}

newEntity{ base = "BASE_NPC_WOLF",
	name = "wolf", color=colors.UMBER,
	desc = [[Lean, mean and shaggy, it stares at you with hungry eyes.]],
	level_range = {1, 50}, exp_worth = 1,
	rarity = 4,
	max_life = resolvers.rngavg(40,70),
	combat_armor = 1, combat_def = 3,
	combat = { dam=5, atk=15, apr=10 },
}

newEntity{ base = "BASE_NPC_WOLF",
	name = "great wolf", color=colors.UMBER,
	desc = [[Larger than a normal wolf, it prowls and snaps at you.]],
	level_range = {3, 50}, exp_worth = 1,
	rarity = 6,
	max_life = resolvers.rngavg(60,90),
	combat_armor =2, combat_def = 4,
	combat = { dam=7, atk=15, apr=10 },
}

newEntity{ base = "BASE_NPC_WOLF",
	name = "dire wolf", color=colors.DARK_UMBER,
	desc = [[Easily as big as a horse, this wolf menaces you with its claws and fangs.]],
	level_range = {4, 50}, exp_worth = 1,
	rarity = 7,
	max_life = resolvers.rngavg(80,110),
	combat_armor = 3, combat_def = 5,
	combat = { dam=13, atk=15, apr=10 },
}

newEntity{ base = "BASE_NPC_WOLF",
	name = "white wolf", color=colors.WHITE,
	desc = [[A large and muscled wolf from the northern wastes. Its breath is cold and icy and its fur coated in frost.]],
	level_range = {4, 50}, exp_worth = 1,
	rarity = 7,
	max_life = resolvers.rngavg(70,100),
	combat_armor = 3, combat_def = 4,
	combat = { dam=8, atk=15, apr=10 },

	resists = { [DamageType.FIRE] = -50, [DamageType.COLD] = 100 },
}

newEntity{ base = "BASE_NPC_WOLF",
	name = "warg", color=colors.BLACK,
	desc = [[It is a large wolf with eyes full of cunning.]],
	level_range = {5, 50}, exp_worth = 1,
	rarity = 7,
	max_life = resolvers.rngavg(60,100),
	combat_armor = 5, combat_def = 7,
	combat = { dam=15, atk=17, apr=10 },
}
I find them doable though they are fast but inflict lighter damage

They have no talents right now but I think they should be able to HOWL_FEAR (except the normal wolves). (which will come later as there is nothing similar in the engine yet)

and the algoroth (will be changed to a poison attack instead of physical) (do I need to say this goes in trolls.lua)

Code: Select all

newEntity{ base = "BASE_NPC_TROLL",
	name = "algroth", color=colors.ORANGE,
	desc = [[A powerful troll form. Venom drips from its needlelike claws.]],
	level_range = {13, 50}, exp_worth = 1,
	rarity = 8,
	max_life = resolvers.rngavg(120,140),
	combat_armor = 10, combat_def = 4,
	ai = "dumb_talented_simple", ai_state = { talent_in=1, }, --this doesnt seem to work
	talents = resolvers.talents{ [Talents.T_CLAW_POISON]=2 },

	resists = { [DamageType.POISON] = 100 },
	}
oh and this went in colors.lua

Code: Select all

defineColor('DARK_UMBER', 0x6C, 0x23, 0x00)

Re: NPC making howto

Posted: Sun Jan 10, 2010 1:11 am
by Shoob
hehehe... made this:

Code: Select all

newEntity{ base = "BASE_NPC_TROLL",
	name = "ettin", color=colors.BLUE,
	desc = [[A massive two-headed troll, larger and stronger than many men together.]],
	level_range = {30, 50}, exp_worth = 2,
	rarity = 33,
	max_life = resolvers.rngavg(1200,1400),
	combat_armor = 30, combat_def = 18,
	stats = { str=50, dex=12, mag=6, con=45 },
	combat = { dam=resolvers.rngavg(35,50), atk=10, apr=10, physspeed=2 },
	talents = resolvers.talents{ [Talents.T_STAMINA_POOL]=3, [Talents.T_STUN]=5, [Talents.T_KNOCKBACK]=4, },
}
note that is less hp than what it had in t2... should damage be upped?

and also note that I ran into this the very first level after I had changed the settings to lvl 30 with a rarity of 33 :P

oh and I will be working on plants soon... off the top of my head I can think of poison ivy, giant venus fly traps. Orchids (no attack just a chance to sleep)

hmmm.. I should think of some more.

Re: NPC making howto

Posted: Sun Jan 10, 2010 1:17 am
by darkgod
1200 HP is a LOT. Remember this is HP at level 1.
You set HP as level 1 and then can use life_rating (defaults to 10) to say how much HP it gains per level.
(CON adds 5 HP per points too)
A player by default have around 80/100 HP at level 1

STR=50 is also at level 1 .. taht's too much :)

Damage of combat section is increased by strength, same formula as the player, rememebr that :)

The wolves look fine :)

Re: NPC making howto

Posted: Sun Jan 10, 2010 1:26 am
by darkgod
I have added the wolves, they'll be in next RFT
Thanks !

Do not do the ettenmoors BTW, pick some of the higher zone first, and let's discuss npc list for it :)

Re: NPC making howto

Posted: Sun Jan 10, 2010 2:05 am
by Shoob
fine... I did think it was a tad powerful :D I am running a char now that could beat one if I would run into it, but I ran into one at lvl 1 which was too early :D but now I cant find one :(

make it 700 hp with 30 str then? or should I make it 500 with a 15 life_rating?

the thing is, this one will be easy for mages to take out (given enough room), but hard for fighters... esp considering the armor and defense I gave it.

and yep, had not yet even started looking into the ettenmoors yet, so I will hold off on that.

Re: NPC making howto

Posted: Sun Jan 10, 2010 2:28 am
by darkgod
500 is still a lot lot lot IMO.
Or ake it very very rare

Re: NPC making howto

Posted: Sun Jan 10, 2010 6:42 am
by Shoob
hmmm... ok... how about this...

in t2 regular trolls had an average hp of around 120-140... the ettin had 1500 (wow... even I didnt think it was *that* much of a difference) :/

looking at what we have now, the other trolls are about the same... so yeah, I would say make it rare.

bump it up to lvl 40? with 100+ rarity so it is an end game troll?

the main problem is that manathrust can be maxed at clvl 2 now and do about 120 damage then and then at lvl 5 it can do 200+ damage (if you spend skill points like I do). So my guess is by the time one is encountered they would be able to be killed in 2 or 3 hits... (even with the 1500hp) not quite what I have in mind, so hmmmm... it is your game though so, I will do whatever. I have gotten a non-crit manathrust up to the 300-400's before.

I could put more in-between trolls in (like the eldrak, which had about 375 hp on average in t2) but there are not many in-between trolls.

hmmm... I guess another "solution" would be to make it so that manathrust does damage based on the level of the pc... cant think of a good formula as clvl/50 makes it too weak... maybe a log(clvl)/log(50) would work. I would be fine with having an ettin at a lower hp then.