Jump to content


Photo

How do you allocate custom items to NPCs?


  • Please log in to reply
20 replies to this topic

#1 Sir Kalthorine

Sir Kalthorine

    Order of Radiant Ugliness

  • Modder
  • 2188 posts

Posted 17 May 2007 - 04:25 AM

OK, if you are installing a custom NPC with custom items, all of which are being installed at the same time, how do you allocate your custom item to a specific gear slot on the NPC?

Basically, I am trying to have the NPC joing the party with a non-removable custom helm. I could have sworn the answer was in a tutorial I read once, but I am darned if I can find it, so I would welcome any suggestions or advice.

Thanks in advance :)

KACH_TS.jpg Chrysta... could helping her to uncover her past threaten your own future?

"Pity the land in need of Heroes."- Bertolt Brecht
"A little madness, now and then, is relished by the wisest men." - Willy Wonka


#2 Kellen

Kellen

    Earn a person's heart, and they'll die a thousand deaths

  • Member
  • 7092 posts

Posted 17 May 2007 - 04:52 AM

Put the helm on her in the cre file?
"She could resist temptation. Really she could. Sometimes. At least when it wasn't tempting." - Calli Slythistle
"She was a fire, and I had no doubt that she had already done her share of burning." - Lord Firael Algathrin
"Most assume that all the followers of Lathander are great morning people. They're very wrong." - Tanek of Cloakwood

we are all adults playing a fantasy together, - cmorgan

#3 ronin

ronin
  • Modder
  • 2114 posts

Posted 17 May 2007 - 05:01 AM

COPY_EXISTING ~test.cre~ ~override~
ADD_CRE_ITEM ~helm01~ #0 #0 #0 ~NONE~ ~HELMET~
ADD_CRE_ITEM ~xbow07~ #0 #0 #0 ~NONE~ ~WEAPON1~
ADD_CRE_ITEM ~sw2h11~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED

for example

weidu docs: http://www.weidu.org...iDU.html#htoc31

Edited by ronin, 17 May 2007 - 05:02 AM.


#4 Gabrielle

Gabrielle

    Do what thou wilt

  • Member
  • 1567 posts

Posted 17 May 2007 - 05:39 AM

Why not just assign it to that slot when you make the cre file? Much easier to do it that way.
For all of your BG modding needs: Chosen of Mystra.

This is The End.

#5 Kellen

Kellen

    Earn a person's heart, and they'll die a thousand deaths

  • Member
  • 7092 posts

Posted 17 May 2007 - 05:42 AM

:whistling:
"She could resist temptation. Really she could. Sometimes. At least when it wasn't tempting." - Calli Slythistle
"She was a fire, and I had no doubt that she had already done her share of burning." - Lord Firael Algathrin
"Most assume that all the followers of Lathander are great morning people. They're very wrong." - Tanek of Cloakwood

we are all adults playing a fantasy together, - cmorgan

#6 Sir Kalthorine

Sir Kalthorine

    Order of Radiant Ugliness

  • Modder
  • 2188 posts

Posted 17 May 2007 - 05:47 AM

Thanks Kellen, but I was trying to be a coding ninja and do it via the TP2, like ronin suggested. :)

COPY_EXISTING ~test.cre~ ~override~
ADD_CRE_ITEM ~helm01~ #0 #0 #0 ~NONE~ ~HELMET~
ADD_CRE_ITEM ~xbow07~ #0 #0 #0 ~NONE~ ~WEAPON1~
ADD_CRE_ITEM ~sw2h11~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED

for example

weidu docs: http://www.weidu.org...iDU.html#htoc31


Thanks ronin - I was looking through tutorials and forgot to check the WeiDU documentation! Dumbass... :doh:

If I could just trouble you further to check the following - if I want to add an undroppable helm "Ka#helm.itm", a suit of identified magical armour "Ka#arm.itm" and a plain spear (equipped) and wanted to add them during the installation of NPC "Butthed.cre" (as opposed to an already-existing NPC), would the following work:

COPY ~Butthed.cre~ ~override~
	ADD_CRE_ITEM ~Ka#helm~ #0 #0 #0 ~IDENTIFIED&UNSTEALABLE&UNDROPPABLE~  ~HELMET~
	ADD_CRE_ITEM ~Ka#armr~ #0 #0 #0 ~IDENTIFIED~ ~ARMOR~
	ADD_CRE_ITEM ~sper01~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED

Thanks in advance :new_thumbs:


Edited to to posting too soon by accident! Never had these problems with premature interjection before... must be my age...

Edited by Sir Kalthorine, 17 May 2007 - 05:50 AM.

KACH_TS.jpg Chrysta... could helping her to uncover her past threaten your own future?

"Pity the land in need of Heroes."- Bertolt Brecht
"A little madness, now and then, is relished by the wisest men." - Willy Wonka


#7 berelinde

berelinde

    Troublemaker

  • Modder
  • 4916 posts

Posted 17 May 2007 - 05:48 AM

As with everything else, there is more than one correct way to do what you want. I find it easier to assign these items in the tp2 because it allows me more flexibility and saves me from unnecessary NI editing.


By using
ADD_CRE_ITEM ~sw2h11~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED

for example, the creature will spawn with the weapon already equipped and ready to go. If it's just in an item inventory slot during the CRE generation process, it won't be unless you script it. For the helm, this won't matter, but for weapons, that's significant.

Also, should you decide to change the item at a later time, you don't need to come up with a new CRE. You can just edit or delete the lines in the tp2.

Edit: nevermind, question answered.

Edited by berelinde, 17 May 2007 - 05:49 AM.

"Imagination is given to man to console him for what he is not; a sense of humor, for what he is." - Oscar Wilde

berelinde's mods
TolkienAcrossTheWater website
TolkienAcrossTheWater Forum


#8 Sir Kalthorine

Sir Kalthorine

    Order of Radiant Ugliness

  • Modder
  • 2188 posts

Posted 17 May 2007 - 05:51 AM

Thanks for taking time to drop in and help anyway :)

KACH_TS.jpg Chrysta... could helping her to uncover her past threaten your own future?

"Pity the land in need of Heroes."- Bertolt Brecht
"A little madness, now and then, is relished by the wisest men." - Willy Wonka


#9 Gabrielle

Gabrielle

    Do what thou wilt

  • Member
  • 1567 posts

Posted 17 May 2007 - 06:02 AM

Why make a task harder than what it should be? :blink:
For all of your BG modding needs: Chosen of Mystra.

This is The End.

#10 Sir Kalthorine

Sir Kalthorine

    Order of Radiant Ugliness

  • Modder
  • 2188 posts

Posted 17 May 2007 - 06:09 AM

Why make a task harder than what it should be? :blink:

Good question - but in my case it is because I am constantly changing ideas about what the NPC is going to have equipment-wise, what custom items I am going to include, where and how they are going to be equipped, etc. So it is actually easier to make the necessary changes via changing a few characters in the TP2 file than it is to fire up NI, load a CRE file, manually change the items round and then save it again. :)

KACH_TS.jpg Chrysta... could helping her to uncover her past threaten your own future?

"Pity the land in need of Heroes."- Bertolt Brecht
"A little madness, now and then, is relished by the wisest men." - Willy Wonka


#11 Kulyok

Kulyok
  • Modder
  • 2450 posts

Posted 17 May 2007 - 06:13 AM

Why not just assign it to that slot when you make the cre file? Much easier to do it that way.


There are two different approaches, that's all. I think editing .cre file in NI is more reliable than .tp2 patching(when looking at NPC mods which attempt these approaches and the number of item-related bugs in them), but that's just my experience.

#12 berelinde

berelinde

    Troublemaker

  • Modder
  • 4916 posts

Posted 17 May 2007 - 06:27 AM

Why not just assign it to that slot when you make the cre file? Much easier to do it that way.


There are two different approaches, that's all. I think editing .cre file in NI is more reliable than .tp2 patching(when looking at NPC mods which attempt these approaches and the number of item-related bugs in them), but that's just my experience.

The only time I've run into trouble with this is when I tried to do it *both* ways, on the same CRE. Through endless NI CRE editing while deciding on equipment, I wound up with a whole folder full of corrupted CREs, and I'm still cleaning up after that mess in v1.2. For v1.3, I'm starting with a bare CRE, adding any items with the tp2, and it's working just fine.

As long as you stick to one system, whichever you decide, you'll be fine.

Edited by berelinde, 17 May 2007 - 06:29 AM.

"Imagination is given to man to console him for what he is not; a sense of humor, for what he is." - Oscar Wilde

berelinde's mods
TolkienAcrossTheWater website
TolkienAcrossTheWater Forum


#13 igi

igi

    IESDP Guardian

  • Administrator
  • 1058 posts

Posted 17 May 2007 - 10:56 AM

Thanks Kellen, but I was trying to be a coding ninja and do it via the TP2, like ronin suggested.


A coding ninja would write their own patching code, rather than relying on a WeiDU function. And the patching code would contain at last one while loop. :P

Visit the IESDP


#14 Dirt_Squirrel

Dirt_Squirrel
  • Member
  • 552 posts

Posted 17 May 2007 - 12:32 PM

For my NPC, I just coded it into the TP2 and everything runs fine.
I think doing it in the TP2 (well, I like doing *it* anywhere....but that's a different story, I geuss) I just find it's easier.

DS
Knowledge is Power, and power corrupts, so study hard and be Evil!

I'm so good that, if I didn't already exist, someone would invent me!

#15 Sir Kalthorine

Sir Kalthorine

    Order of Radiant Ugliness

  • Modder
  • 2188 posts

Posted 17 May 2007 - 01:00 PM

Thanks Kellen, but I was trying to be a coding ninja and do it via the TP2, like ronin suggested.


A coding ninja would write their own patching code, rather than relying on a WeiDU function. And the patching code would contain at last one while loop. :P

Hence the ermphasis on "trying" ;)

KACH_TS.jpg Chrysta... could helping her to uncover her past threaten your own future?

"Pity the land in need of Heroes."- Bertolt Brecht
"A little madness, now and then, is relished by the wisest men." - Willy Wonka


#16 Cuv

Cuv

    Area Maker (retired)

  • Modder
  • 925 posts

Posted 17 May 2007 - 01:27 PM

Umm... you can also do it with scripting. Either in a .bcs, bs or even through dialog.

IF
				 Global("NPCGear","LOCALS",1)
	//Whatever my other conditions will be
THEN
	RESPONSE #100
		SetGlobal("NPCGear","LOCALS",1)
		GiveItemCreate("NPCArmor",Myself,0,0,0) // Armor
		FillSlot(SLOT_ARMOR)
		GiveItemCreate("NPCShiny",Myself,0,0,0) // Amulet
		FillSlot(SLOT_AMULET)
		GiveItemCreate("NPCSword",Myself,0,0,0) // sword
		FillSlot(SLOT_WEAPON1)
		GiveItemCreate("NPCBow",Myself,0,0,0) // bow
		FillSlot(SLOT_WEAPON2)
		GiveItemCreate("POTN55",Myself,5,1,1) // Potion of Superior Healing
								FillSlot(SLOT_MISC1)
END

Hope this helps give you ideas

Cuv

#17 berelinde

berelinde

    Troublemaker

  • Modder
  • 4916 posts

Posted 17 May 2007 - 02:14 PM

If you're going to go that route, your first trigger had better be

Global("NPCGear","LOCALS",0)

:)

"Imagination is given to man to console him for what he is not; a sense of humor, for what he is." - Oscar Wilde

berelinde's mods
TolkienAcrossTheWater website
TolkienAcrossTheWater Forum


#18 Cuv

Cuv

    Area Maker (retired)

  • Modder
  • 925 posts

Posted 17 May 2007 - 03:57 PM

If you're going to go that route, your first trigger had better be

Global("NPCGear","LOCALS",0)

:)


LOL... of course, me bad. :wacko: Just trying to give sir K some other options.

You can also CreateItemSlot

Cuv

#19 igi

igi

    IESDP Guardian

  • Administrator
  • 1058 posts

Posted 18 May 2007 - 09:23 AM

You could also use a spell and opcode #143 "Item: Create Item in Slot", though you'd need a way to trigger it (perhaps an embedded effect with opcode #272).

Visit the IESDP


#20 cmorgan

cmorgan
  • Modder
  • 2301 posts

Posted 18 May 2007 - 10:46 AM

Too late to help, (wow things move fast around here) but some points of observation, for folks looking through this thread for tips:

if you are looking for things to work across different platform installs, the tp2 way allows the most flexibility and the quickest fix (no need to open anything other than a text editor, edit a line, and save - RTG). It takes care of Tutu's dynamic sttref problem, and leaves you with a single code "snapshot" of your .cre, including sound references, items, proficiencies, etc., etc. . I am kind of leaning towards just creating all creatures from existing resources and patching them, instead of distributing .cres, but that's because I am crazy.

The 2k file for a .cre put through NI or DLTCEP is the simplest to do graphically. I don't know whether a separate file or 30 lines in a tp2 is more space saving or not.

The caveat for both is make sure the associated BAMs are available in non-ToB installs - you could either distribute the custom item BAMs directly, or just make sure you use stock ones from SoA (those will work across Tutu, BGT, BG2 SoA and ToB). That saves you corrupted or missing icons bug reports when your ToB based item is installed on a SoA or Tutu install...


(so if Chrysta has BG1 content of any type, and you wanted to go for Tutu and BGT, tp2 is the way to go. Assign soundset, items, animations, you name it - and you are all done!)

Edited by cmorgan, 18 May 2007 - 10:46 AM.