CAVEMAN 3.0: NPC skills: model it or fake it?
Caveman v3.0 - a stone age FPSRPG.
The are about 50 skill in the game. The game tracks exp in skills for PCs, but not NPCs. So far, when i've needed NPC skills, I've been faking it. Random chance they have the skill, only checked once so the player can't spam it - that kind of thing.
Now i'm adding spontaneous dialog initiated by NPCs. Offer to teach skill is one of the dialog options.
if I fake it...
1. the player could chose a skill, and the NPC may or may not be able to teach them (random chance). But "they can't teach you anything about that" all the time gets old, and you only get one try per encounter.
=or=
2. the NPC automatically knows whatever they select and can teach them (somewhat fakey). Since the game doesn't track NPC skills (yet), I can't show a menu with just those skill the NPC has more experience in - but I suppose i could generate a random list... but the next time the NPC talks to the PC, the list would be different... IE it would be random, but not persistent.
if I don't fake it...
I have to add NPC skills to the game.
declare skill vars in the declaration for NPC_struct:
int xp[MAX_SKILLS];
memset is used to clear the array of NPC_structs, so no init code required.
load it:
for a=0 a<MAX_NPCS a++
for b=0 b<MAX_SKILLS b++
read_int(f,&NPC[a].xp);
save it:
for a=0 a<MAX_NPCS a++
for b=0 b<MAX_SKILLS b++
write_int(f,NPC[a].xp);
set them to some value when an NPC is created the first time:
for a=0 a<MAX_SKILLS a++
npc[n].xp[a]=sqrt((float)dice(10000))*10; // 0-1000 inverse parabolic curve distribution
and then i have exp values for NPC skills that i can use:
for a=0; a<MAX_SKILLS; a++
if npc[n].xp[a] > bandmember.xp[a]
// add to menu of skills NPC can teach the player
So I can add NPC skills with literally just twelve lines of code.
But then of course, having NPC skills means you should use them, right?
So I'd want to change the existing code for "teach NPC skill, and "learn skill from NPC" to something similar to the above last 3 lines of code.
So 6 lines of code to mod the exiting code base to use the new NPC skill variables.
So 18 lines of code altogether to add NPC skills and make existing features use them.
But there's still stuff like making NPC skills affect combat etc....
Does continuing to fake it seem adequate?
Should I just implement NPC skills - especially given the trivial nature of the code changes required? (this is the first time I've calculated them).
faking it by using "random chance a NPC can teach a skill" is sort of like a crap shoot mini-game. You get 10 dialog interactions per day with a NPC. You can spam all 10 on "learn skill" in the hopes you get lucky. Eventually the players will figure this out.
when faking it, NPCs offering to teach you skills is the same idea - except you only get one try to pick a skill they have a random chance of being able to teach you. And what if they say they can't teach you the first time, but say they can the next time you ask them? That would not compute! <g>
NPC WALKS UP TO PLAYER: "Want me to teach you a skill?"
PLAYER: "Sure! Know anything about defense?"
NPC: "Defense? No problem! Let me show you what I know..."
PLAYER: "WTF dude? This morning you said you didn't know jack about defense! And all you've done is wander around the camp all day. I haven't seen you fight any animals or anything like that - nothing that would teach you defense skills since this morning."
PLAYER THINKING TO THEMSELVES: "This is stupid. This game sucks."
EDIT:
19 lines of code. teach skill to NPC would require the following addition:
npc[n].skill+=50;