Scattered Evil NPCs

Adding NPCs

There are two distinct “entitites”: a map thing, aka Actor, which uses sprites, walks and fights, and secondly a “person” – a conventional entity that defines the conversation (latter was added by me).


Adding a new thing

How to add new thing. There are two problems: register new class for the engine, and register new type in the DB.
Actor classes are registered by adding them to /koraxrpg/basepak.pk3/actors/ (also just /koraxrpg/actors/ – because engine checks both pk3 and subfolders). These text files are read at engine startup. Their format is called DECORATE, and is thoroughly explained in ZDoom wiki:

Let’s do a simple sample thing. Open /koraxrpg/basepak.pk3/actors/krpg/townfolk.txt and find this line:

 actor NPCTownFellow1 : NPCStrifePeasant 19003

This is an actor declaration. It makes a type “NPCTownFellow1” inherit all properties of base type NPCStrifePeasant (which defines all the animations). 19003 is map thing id.

Make a copy of the whole block of text:

 actor NPCTownFellow2 : NPCStrifePeasant 19010
 ConversationID 4
 Scale 1.20

Now you have NPCTownFellow2 thing of map Id = 19010 and with Conversation id = 4.

If you do not like to keep same sprites as for basic peasant, you shall replace them in a way similar to how it is done for NPCStrifePeasant. What you will see in its declaration is a classic state-machine: there is a number of actor states (names are quite self-explanatory) each having number of actions. See

For example:

 PEAS A 10 A_Look2

This runs when actor is spawned on map. “PEAS” is first 4 letters of sprite name, next follow sprite frame (“A”), third is frame’s delay (in 1/40 second IIRC). Finally it is an AI function to call (“A_Look2”). There are a lot of available AI functions, but that takes time to learn, so you may just copy these from existing actors and monsters.
If you want several frames to play in order with identical delay, you may write this:

 PEAS ABCDE 10 A_Look2

This way 5 frames (A to E) will play one after another. A_Look2 ai function will be called on EVERY frame. If you want it be called only on the first frame, split this sequence in two:

 PEAS A 10 A_Look2
 PEAS BCDE 10 A_Look2

“Loop” command means loop this state commands forever (actually – until state changes). “Goto” command means switch to another state.

If all you want is just use different sprite group, simply replace PEAS names with something else. For instance, replacing them with BISH will make new actor have Dark Bishop’s sprites.
Just be careful: the sprite set you are using should at least have all the same frames (BISHA.., BISHB.., etc), or the game will crash.


Adding a new conversation

Go to koraxrpg/data.pk3/ and find coninfo.txt. This is the base conversation script. I’d recommend not to put actual conversations there and use it only to import other files, like:

 import town1

this will use town1.txt for conversations.

There should be example of conversation I added for shopkeeper. It has this header:

 conitem NPCShoppeAttendant 100, ShoppeAttendantMain 0

First goes official “person” name and its Id. It is this Id that is assigned in the Actor’s declaration (ConversationID). Then goes conversation item script name and its related Id. You may have unlimited number of conv.items per person and switch between them in game by using SetActiveConItem(person_id, conitem_id) command in map script.


NPC Sprites

104npc104peasant womannoMago
105npc105church honchonoMago
107npc107legion honchonoMago
108npc108arcanum honchonoMago
112npc112townswoman, green dressnoMago
113npc113townswoman, brown dressnoMago
114npc114townswoman, white blousenoMago
116npc116old mageyesMago
117npc117bearded clericyesMago
119npc119peasant / townsmanyesRogue Entertainment
120npc120hooded magenoRaven Software
121clericclericyesRaven Software
122fighterfighteryesRaven Software
123npc120mageyesRaven Software
124k124a0bald tavernkeepernoFirebrand
126k126a0golden guardnoFirebrand
127magecrimson magenoRaven Software