collapse

Author Topic: Adding Items To NPCs  (Read 1239 times)

Offline anaphylactic

  • Fledgling
  • *
  • Posts: 8
Adding Items To NPCs
« on: April 07, 2016, 05:03:44 AM »
I'm new the forums, but I've been playing VTMB since release with a few iterations of Wesp's patches :)  I started a new install/play through a few weeks ago (9.5 UP) and I've been getting into modding (more than just the usual use other people's mods stuff).  I'm not a pro, but I've done this for a number of games, and I do read the manuals (such as the mod guide), and I've pretty much been able to figure most of what I wanted to do out.

However, I'm currently stuck trying to add items to an NPC so that if (when) I kill it, the items drop and I can loot them.  I can see plenty of trivial ways for me to get items and money through the command line or just adding pc.x commands in dialogs, but this isn't just for me to cheese through a specific run through, I'm actually trying to practice working on mods that would (ideally) be shareable with other players, and usable by other characters on other play throughs.

Specifically, I am trying to edit McFly, the meal that Heather brings back to the Haven.  You can bully him to line 121 (UP) where he will give the pc $50 through the MoneyAdd command, so (in game), he had $50.  You can kill him afterwards.  However, if you kill him without bullying him for the money, there is no way to get it.

My "project" is to to add a wallet with $50 to McFly such that he drops it if he dies.  If the pc bullies McFly first, the wallet would be emptied or removed (so no double dipping).

I tried the obvious -- npc.GiveItem("item}m_wallet", 50) in the dlg, but (while it didn't crash), it didn't do anything.  I tried npc.GiveItem("item_w_knife") to see if I could make him drop a knife when killed, but that didn't work either.  [I added these lines as Action Items in earlier dialog lines).

I've seen lots of stuff about manipulating the pc's inventory, just not much on the npcs.  I'm hoping the people who work on the Companion mod might have some insight (I haven't tried or done anything with it yet).

Offline Malkav

  • Antediluvian
  • *****
  • Posts: 1712
Re: Adding Items To NPCs
« Reply #1 on: April 07, 2016, 04:13:32 PM »
You can't do that kind of thing via dialog. For this you have to edit the map. Weapons are added to the npc with "additionalequipment" "item_w_ithaca_m_37" and "alternateequipment" "...". Then the npcwill dropthe last used weapon on death.
Other items need a python script that is called by the entity input "OnDeath". Check the script for the Cathayan in santamonica.py for this.
Co Author of Camarilla Edition Mod

Offline anaphylactic

  • Fledgling
  • *
  • Posts: 8
Re: Adding Items To NPCs
« Reply #2 on: April 08, 2016, 07:09:14 AM »
1) By "edit the map", do you mean the actual maps/*.bsp file?

2) In which file (directory/extension) would I use the addadditionalequipment command?

3) I looked through python/santamonica/santamonica.py and couldn't find any reference to a Cathayan or OnDeath...I did find asianVampireDeath, which seems to have the code similar to what I am looking for.  Is there a guide or anything that explains how to name these functions or hook them to npcs?  I.e., how do I add an "OnDeath" function to an npc that doesn't have one?

McFly (and prostitutes, my next target to mod) aren't in any one region (they are 'generic' as far as dialogs go). so I'm not sure how I'd deal with them on a per-map (or per map.py) location...I'd (unfortunately) assume that I'd have to dupe the code.

Offline Malkav

  • Antediluvian
  • *****
  • Posts: 1712
Re: Adding Items To NPCs
« Reply #3 on: April 09, 2016, 07:15:03 AM »
Yes, you have to edit the actual map files. That means you have to use the map tools from vpk tools or the mapextract function from VTMBEdit. Both tools are part of the SDK. Forthis Iwouldn't recommend using Hammer.
Then you have to find the map entity for in this case McFly and add a line like this:
"OnDeath" ",,,0,-1,mcflyDeath(),"
All these commas are important. Look in Dheu's manual why.

The python script you're looking for is in santamonica.py:
#ASIAN VAMP ARENA: Called when vamp is killed, changed by wesp
def asianVampDeath():


The "additionalequipment" line is part of the map entityfor the character.
So if you want to make changes for McFly you have to edit the maps fpor all the havens: sm_apartment_1, la_chantry_1, la_hub_1 and la_skyline_1, and the python script must be in vamputil.py.
Co Author of Camarilla Edition Mod

Offline anaphylactic

  • Fledgling
  • *
  • Posts: 8
Re: Adding Items To NPCs
« Reply #4 on: April 12, 2016, 07:45:07 PM »
Thanks!  I'll see how far I can get with this.