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

**URL:** <https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188>\
**Category:** The Lab\
**Created:** [September 23, 2013, 9:57pm UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188 "2013-09-23T21:57:00Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![vultures](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/vultures/32/69_2.png) [@vultures](https://discourse.cataclysmdda.org/u/vultures)\
**Post date:** [November 27, 2013, 6:06pm UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/41 "2013-11-27T18:06:56Z")

</div>

You seem fresh on CataDDA forums; navigate your way through [Git Branch](http://ci.narc.ro/view/Cataclysm-DDA/) and share whatever insight with developers. One thing I know, they would appreciate it. 🙂

---

<div class="post-metadata">

**Author:** ![GlyphGryph](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/glyphgryph/32/847_2.png) [@GlyphGryph](https://discourse.cataclysmdda.org/u/GlyphGryph)\
**Post date:** [November 27, 2013, 6:13pm UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/42 "2013-11-27T18:13:15Z")

</div>

> [@Heruedhel](#):
>
> Can you share the outline of this plan for discussion? or is this something that’s completely out of your thought process until the weekend?

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.

---

<div class="post-metadata">

**Author:** ![Heruedhel](https://avatars.discourse-cdn.com/v4/letter/h/dec6dc/32.png) [@Heruedhel](https://discourse.cataclysmdda.org/u/Heruedhel)\
**Post date:** [November 27, 2013, 7:17pm UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/43 "2013-11-27T19:17:15Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Mr\_Lolz](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@Mr\_Lolz](https://discourse.cataclysmdda.org/u/Mr_Lolz)\
**Post date:** [November 27, 2013, 11:27pm UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/44 "2013-11-27T23:27:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Taraq](https://avatars.discourse-cdn.com/v4/letter/t/c57346/32.png) [@Taraq](https://discourse.cataclysmdda.org/u/Taraq)\
**Post date:** [November 27, 2013, 11:49pm UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/45 "2013-11-27T23:49:22Z")

</div>

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++.

---

<div class="post-metadata">

**Author:** ![moist\_zombie](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/moist_zombie/32/131_2.png) [@moist\_zombie](https://discourse.cataclysmdda.org/u/moist_zombie)\
**Post date:** [November 28, 2013, 2:37am UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/46 "2013-11-28T02:37:54Z")

</div>

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

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 😃

---

<div class="post-metadata">

**Author:** ![Taraq](https://avatars.discourse-cdn.com/v4/letter/t/c57346/32.png) [@Taraq](https://discourse.cataclysmdda.org/u/Taraq)\
**Post date:** [November 28, 2013, 2:45am UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/47 "2013-11-28T02:45:18Z")

</div>

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

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…

---

<div class="post-metadata">

**Author:** ![moist\_zombie](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/moist_zombie/32/131_2.png) [@moist\_zombie](https://discourse.cataclysmdda.org/u/moist_zombie)\
**Post date:** [November 28, 2013, 7:22am UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/48 "2013-11-28T07:22:44Z")

</div>

Yeah… Dismemberment is kind of traumatic 😃 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…

---

<div class="post-metadata">

**Author:** ![swwu](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@swwu](https://discourse.cataclysmdda.org/u/swwu)\
**Post date:** [November 28, 2013, 11:22am UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/49 "2013-11-28T11:22:24Z")

</div>

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](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]

---

<div class="post-metadata">

**Author:** ![Heruedhel](https://avatars.discourse-cdn.com/v4/letter/h/dec6dc/32.png) [@Heruedhel](https://discourse.cataclysmdda.org/u/Heruedhel)\
**Post date:** [November 28, 2013, 12:06pm UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/50 "2013-11-28T12:06:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![swwu](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@swwu](https://discourse.cataclysmdda.org/u/swwu)\
**Post date:** [November 28, 2013, 5:29pm UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/51 "2013-11-28T17:29:42Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![moist\_zombie](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/moist_zombie/32/131_2.png) [@moist\_zombie](https://discourse.cataclysmdda.org/u/moist_zombie)\
**Post date:** [November 29, 2013, 7:24am UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/52 "2013-11-29T07:24:16Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![Murphy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/murphy/32/2371_2.png) [@Murphy](https://discourse.cataclysmdda.org/u/Murphy)\
**Post date:** [November 29, 2013, 3:21pm UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/53 "2013-11-29T15:21:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![StopSignal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/stopsignal/32/1923_2.png) [@StopSignal](https://discourse.cataclysmdda.org/u/StopSignal)\
**Post date:** [November 29, 2013, 3:27pm UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/54 "2013-11-29T15:27:03Z")

</div>

> [@Murphy](#):
>
> 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?

---

<div class="post-metadata">

**Author:** ![GlyphGryph](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/glyphgryph/32/847_2.png) [@GlyphGryph](https://discourse.cataclysmdda.org/u/GlyphGryph)\
**Post date:** [November 29, 2013, 4:18pm UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/55 "2013-11-29T16:18:17Z")

</div>

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. 😉

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.

---

<div class="post-metadata">

**Author:** ![youtoo](https://avatars.discourse-cdn.com/v4/letter/y/779978/32.png) [@youtoo](https://discourse.cataclysmdda.org/u/youtoo)\
**Post date:** [November 29, 2013, 7:25pm UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/56 "2013-11-29T19:25:27Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![swwu](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@swwu](https://discourse.cataclysmdda.org/u/swwu)\
**Post date:** [November 29, 2013, 7:30pm UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/57 "2013-11-29T19:30:53Z")

</div>

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 😉

---

<div class="post-metadata">

**Author:** ![CodeHero](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/codehero/32/128_2.png) [@CodeHero](https://discourse.cataclysmdda.org/u/CodeHero)\
**Post date:** [November 30, 2013, 2:10am UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/58 "2013-11-30T02:10:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GlyphGryph](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/glyphgryph/32/847_2.png) [@GlyphGryph](https://discourse.cataclysmdda.org/u/GlyphGryph)\
**Post date:** [November 30, 2013, 4:41am UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/59 "2013-11-30T04:41:03Z")

</div>

> [@youtoo](#):
>
> are you going to json the npcs?

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.

---

<div class="post-metadata">

**Author:** ![swwu](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@swwu](https://discourse.cataclysmdda.org/u/swwu)\
**Post date:** [November 30, 2013, 6:27am UTC](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188/60 "2013-11-30T06:27:21Z")

</div>

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](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.

[Previous page](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188.md?page=2)

[Next page](https://discourse.cataclysmdda.org/t/the-month-of-the-npc-roadplan-in-op-creature-rewrite-branch-in-repo/3188.md?page=4)
