🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

CAVEMAN 3.0: NPC skills: model it or fake it?

Started by
1 comment, last by Norman Barrows 7 years, 8 months ago

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;

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Advertisement

I might approach it from the angle of the NPC offering "Hey, I learned this neat new defense technique a little while ago, want me to show you?" and then if the player says, "Sure" the NPC teaches what he knows to the player, either granting the skill if it's first exposure to it or providing xp towards that skill. Maybe the whole thing is a trade of some kind where the amount of xp earned is shown before the player agrees. But I'm thinking the player doesn't get to decide what skill is going to be taught and that this could be described as a modeling NPCs coming up with the occasional "innovation" on their own that when coupled with other things learned about a skill builds on the skill's experience level.

It might not work though if you need to consider skills of the characters in your party.

the player doesn't get to decide what skill is going to be taugh

that might work... pick a skill at random, "want me to teach you something about <whatever skill> ?" "yes / no / leave me alone"

but what if the player then turns around an initiates dialog with the NPC and asks for training in the same skill and loses the crap shoot? "they can't teach you anything about that!" When they could just moments before. That's the problem with random fakery, its not consistent. So its ok for one shot responses, but not repeatable stuff.

It might not work though if you need to consider skills of the characters in your party.

Technically speaking, a training session gets you 50 exp. So the teacher should have at least 50 more exp in a skill than the student. Which would require skill tracking for NPC teachers. And would eliminate the crap shoot (random fakery) when asking NPCs to teach you skills - and the crap shoot when offering to teach skills to NPCs.

Of course, with almost 50 skills in the game, making a "pick random skill" routine from the "pick skill" menu might actually be more work than just adding NPC skills!

Heck - I've probably typed more characters in this thread than it would take to implement NPC skills - maybe I should just do it. I suppose it is the right way to do things. It's terrible being so lazy! <g>.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement