The Month of the NPC - Roadplan in OP, creature-rewrite branch in repo

You seem fresh on CataDDA forums; navigate your way through Git Branch and share whatever insight with developers. One thing I know, they would appreciate it. :slight_smile:

In 50 minutes I’ll basically be gone on Thanksgiving holiday stuff until this weekends, so it will be out of my thoughts until then, yeah, as I won’t be near my computer. I might end up doing some json stuff on someone else’s, but real coding and stuff will wait.

But the plan right now is essentially to build them from scratch, and to try and get the new model to share a parent with the player model instead of repeating a bunch of code. We’d like to have different AI’s that we can hook in, to get NPCs that have noticeably different behaviour. Beyond that, like I said, the last plan for doing that I came up with was overly ambitious and kind of garbage, so the immediate plan is just to create a parent class for the player character, an npc class that inherits from it, and to get those NPCs to appear on the map as dumb objects.

@vultures: thanks, but the link you gave me leads to Jenkins. you wouldn’t happen to have a link to this particular discussion?
I guess I’ll just go through the discussion when I find it, and then maybe make a branch and give refactoring a go.

I suggest completely avoiding any kind of party behavior for now - no following the player, no taking orders. A good simple beginning would best best:

  1. believable hostile to player and hostile to mobs combat behavior.
  2. believable dialogue and neutral behavior to player
  3. quest givers and receivers
  4. trade
  5. insert into the game in stationary locations.

I’d like to contribute to this. I have limited skill with C++, although I understand the basic structure, I would just need to look up a lot of the stuff we’re using to actually understand how the code works, as I’ve only ever done very basic C++.

Mmmm mmmm NPCs! I want them far far more than z-levels :smiley:

Anyway, perhaps now may be the time to address the issue where NPCs seem invincible sometimes because the torso or head must be killed and repeated leg/arm shots when legs and arms are already 0hp doesn’t harm them? Maybe the idea where a 0hp limb that gets hit gets dismembered could be a fix, but as it is right now player character is tied to the same ruleset the NPCs are, so its shared arm/leg invincibility :smiley:

[quote=“moist_zombie, post:46, topic:3188”]Mmmm mmmm NPCs! I want them far far more than z-levels :smiley:

Anyway, perhaps now may be the time to address the issue where NPCs seem invincible sometimes because the torso or head must be killed and repeated leg/arm shots when legs and arms are already 0hp doesn’t harm them? Maybe the idea where a 0hp limb that gets hit gets dismembered could be a fix, but as it is right now player character is tied to the same ruleset the NPCs are, so its shared arm/leg invincibility :D[/quote]

Well, this is a little off topic anyway, but we could use a negative HP system - or at least make the current threshold for a broken limb not be the lowest that limb’s health can go, because it seems a little ridiculous to be dismembered when you break an arm…

Yeah… Dismemberment is kind of traumatic :smiley: Perhaps just pull torso hp when broken/0hp limbs take damage?? But with an entire rewrite npcs might not even be considered player-type constructs afterward, nullifying this whole issue…

So! It may be ugly, it may depend on tons of technically nonfunctioning shims, and it may disable every technique and melee special effect currently in the game, but I’ve gotten players and monsters to use the same base class in melee combat! This is just the first step we need to take in order to unify everything together into one class hierarchy (which is itself just the first step to writing functioning NPCs), and it probably sucks, but hey, progress is progress.

Feast your eyes upon it here: https://github.com/swwu/Cataclysm-DDA/tree/creature-rework

Or don’t, because it’s ugly as hell.

Stuff:

[ul][li]The new base class is called “creature” (as discussed here and on dev IRC), in creature.cpp/h.[/li]
[li]Combat refers to creature instead of player/monster, cutting the melee combat loc in two.[/li]
[li]It compiles! In fact, it might even not segfault![/li]
[li]There’s tons of non-functioning function stubs all over the place to make the damn thing compile.[/li]
[li]As mentioned, basically every single technique and melee special effect is disabled in that code, because they rely on diseases or effects depending on player or monster, so we’ll need to merge diseases and effects into a single system before those can be made to work again.[/li]
[li]Also, the player’s armor is always set to 0 for melee attacks, because lazy stub function.[/li][/ul]

I’ve been working on the same thing today. However, I stumbled across some circular dependencies in the code. Though it is outside the scope of a NPC rework, I’m gonna try to resolve these for overall code maintainability.

Heruedhel: I can give you push on my repo if you want and we can use that as the staging until Glyph gets back from his vacation? Not sure how extensive your changes will be but it might be nice to not have to merge them (twice).

Another possibility to consider is whether we should try to make NPCs actually function concerning all the Faction stuff that’s already in-game from good ol’ Whales days… I’ve always liked it, myself. Could be used as a roadmap of sorts…

I’m not sure it’s good to have factions immediately after cataclysm. They should arise after you’ve played some.

What about making them spawn ONLY after a year of playing plus exploring a lot. They would have bases like the factions in Stalker or just groups of people?

We won’t even be thinking about factions and stuff just yet. This is just getting the foundations stable.

Thanks for all your work, guys - your code certainly IS ugly, swwu, but that doesn’t stop it from being beautiful. :wink:

So now what we need is to create a base class for Player that is a child of Creature, but can also be a parent to the NPC.

So that we can collaborate more easily, would you guys want access to the CleverRaven repo, and then we can push up a dev branch for the NPC rewrite, but we can still all basically work with and stay up to date with the most recent branch?

Alternatively, we could just work off swwu’s repo, which would be fine.

are you going to json the npcs? I belive the discussion was in part around

  1. mob type monsters
  2. npc types that wear equipment and have interactions.

is that correct?

Either sounds fine to me. It might make more sense to have the new branch be on main repo (just so it will be easier to find for anyone who wanders in later) but it’s not super important to me, whichever’s more convenient for you guys.

I should have shared effects/diseases for the base creature class in by tonight and then we can start planning out how to actually do NPC things after?

re: factions, yeah, from where I’m looking at the code from here they are probably going to be a long ways off :wink:

I want to help! I just need to know what there is to be done.

i don’t even know what this would mean, honestly? But at least some NPC definitions will end up existing in the JSON so I can fill the kickstarter rewards.

Okay, all monster effects now use the new effects system (although in name only, since their processing/whatever is still done in exactly the same way, and we won’t be able to really change that until player diseases get fully ported). Both players and monsters now also use the “down” and “stun” effect (rather than disease) so some of the combat is back. The rest of the player diseases are still… being worked on - in general the handling of player diseases is a lot looser than the handling of monster effects, so they’re more difficult to track down (some of them also hit bodyparts, which means effects will have to be bodypart-aware, even if most monsters won’t actually have multiple bodyparts).

Should be up on my repo now (https://github.com/swwu/Cataclysm-DDA/tree/creature-rework), I cheated my skills to 10 and managed to kill a few hundred Zs with various weapons without any segfaults, so hopefully it’s sorta stable.