View Single Post
  #1  
Old 03-25-2002, 10:35 AM
ScotchTape
Fire Beetle
 
Join Date: Mar 2002
Posts: 12
Default Working towards Animal Instincts in NPCs

This is a divergent view from eqlive. Purists should skip this thread. I'm hashing it out here because, I don't quite have access to the tools I need to do any development work. It'll be ultimately up to the base maintainers if they want to include this.Regardless, I plan on putting in a flag to turn such experiments on/off.

The goal is to put in place some instincts for the critters that walk about the face of norrath. For example, a hungry wolf will attack, while a full wolf may not. Secondly, I've always viewed a zone as a kind of fishbowl and I'd like to make my fish do stupid tricks.

The first part of this is going to introduce hunger code for NPCs. It is a rather primative instinct. Either you are hungry or you aren't. And there are thresholds, such as being stuffed full makes you cranky, and not eating enough makes you cranky, but eating just the right amount makes you (generally) healthy, wealthy, and wise.

I'm thinking a simple struct, a struct so I can easily expand it later, might look like
Code:
NPC
class
{
protected:
struct_AnimalInstincts* AnimalInstincts;
}

struct struct_AnimalInstincts
{
    sint8 Hunger;
};
-100 < Hunger < 100

With 0 being equilibrium.

Now if you're hungry (hunger < 0), then you need food. I'm thinking that if you give the item (check Consume_Struct), then you are hungry. Next, we need a command in (i think client.cpp) that processes the command #Hungry?

If an NPC is Hungry, it tells you as much. If not, then not.
(need pseudo code script ;)
Code:
//isnpc check and stuff
Message(0, "Hunger: %i", target->AnimalInstincts->Hunger);

Message(0, "I need no food.");
or
Message(0, "I need food. Feed me!");
Now we need to feed the fish. I'm thinking a fish is fed when four food items, nonstacked, are given to it. This has the effect of possibly raising the hunger of the npc by something like rand() % 2 == 1 ? 1 : 0. 'course, there will need to be bounds checking with max(100) and min(-100).

Now, over time the NPC will go hungry. So, their hunger should be increased (which actually decreases the Hunger value). At some point, this should probably work off the existing eat-food timer, but for testing I want all my NPCs to starve.

Which brings in the second command for client.cpp: #StrikeFamineInZone which causes all the npcs hunger to drop to -100.

This doesn't classify itself as an instinct quite yet, and I'm fearful of putting in any kind of silly check such as (if Hungry, go find food!) as all the NPCs will flock to the first available food source... rather, instead, I have two ideas I'm kicking around. The first goes back to the healthy, wealthy, and wise argument.

If an NPC is fed well, we'll say 0 < hunger < 50, then

a. their wisdom score goes up (perhaps skills too, but last I checked these were hardcoded at 252 with a big TODO flocked next to it).
b. their strength score goes up (or maybe minimum damage)
c. they get extra cash ( a few silver or something small)

Alternatively, I'd just like to tint the npcs a different color. However, I don't know if the client supports this.
Reply With Quote