Author Topic: Creating an NPC  (Read 3597 times)

Offline DoughyGuy

  • Plaid: It's What's For Dinner!
  • Planewalker
  • *****
  • Posts: 78
  • Rattle-rattle, thunder, clatter, boom-boom-boom!
Creating an NPC
« on: November 14, 2004, 05:31:37 PM »
Howdy all... it's me... Ya know the one who always has a problem :)

Well I'm trying my hand at creating an NPC for BGII, and I spent the last hour or two working on a quick little NPC who is supposed to show up in the Promenade...

The template that I used for the NPC is using Ghreyfain's 'Beginner's Guide For Creating NPCs' and the Weidu documentation, and I thought I had everything correct... Problem is, he's not even showing up...

There's really not much to the text, so I'll post it here so anyone can see if they can spot an error, or if I'm missing a step...
---------------
(ddar0700.baf)

IF
Global("DudeExists","AR0700",0)
THEN
RESPONSE #100
SetGlobal("DudeExists","AR0700",1)
CreateCreature("Dude",[1110.940],3)
END

-----------------
(dude.tp2)

BACKUP ~Dude~
AUTHOR ~DoughyGuy~
BEGIN ~Dude the NPC for BG2:ToB~

COPY ~dudeworks\dude.cre~ ~override\dude.cre~

COMPILE ~dudeworks\dude.d~
USING ~~ // We haven't got a translation file yet.  Ignore this for now.

EXTEND_BOTTOM ~Ar0700.bcs~ ~dudeworks\ddar0700.baf~

--------------
(dude.d)

// creator: DoughyGuy
// argument: bdgdude.dlg
// This is a test of my abilities to make up a joinable NPC
// Step One: One line of dialogue when the character talks to the NPC, with no replies

BEGIN BDGDUDE

IF ~NumTimesTalkedTo(0)~ THEN BEGIN GreetOne /* Greets for the first time */
   SAY ~Hey, <SIRMAAM>... What's up?~
   IF ~~ THEN EXIT
END

---------------------

So, once I had those files created, I created a character by exporting a char from a game, then converted him into a CRE file using NearInfinity, trying to follow the instructions given in the post to edit certain variables (although I didn't know what a Death Variable does, so I left it at 0)

Then, I got to a command line, and ran "weidu dude.tp2"
I get a couple of lines responding to the commands in the tp2 file, the only error I got was that the file weidu.log didn't exist, but once I created a blank one, it worked without that message.

I went in, started a brand new game, and went looking for him, but he wasn't there... I'm an extreme novice to IE programming, as well as programming in general (the last language I could program with any sort of skill was BASIC), so I don't know if I'm doing everything needed to add the NPC to the game... Once I have him added, I can start fiddling with the dialogs and adding scripts and such... All I want him to do at this point is just be there, and allow the character to come up to him and talk so he can deliver his one line...

I would appreciate anyone's help with this, even if it is something very obvious that I'm missing. Also, I have some mods installed, could they be interfering? Maybe I'm not appending the correct AR file? I have DBG, SoS, Chloe, the Flirt and Banter Packs, Ease Of Use, and a couple Item packs installed.

Thanks in advance :)
"That's right! I'm DoughyGuy! I control the world's supply of dairy products! Steak is my ally! Butter does my bidding! Sour cream bows down before me in total abject terror! "

Visit the Land Of The DoughyGuy!

Offline Kismet

  • Devil's Minion #5
  • Global Moderator
  • Planewalker
  • *****
  • Posts: 653
  • Gender: Female
  • Veni; Vidi; Velcro.
    • Pocket Plane Group
Re: Creating an NPC
« Reply #1 on: November 14, 2004, 05:50:41 PM »
Try using EXTEND_TOP instead of EXTEND_BOTTOM.  I think there's something in the Promenade's script that's always returning true and there fore stopping anything added after it from happening.
Cailean - An archer NPC for the insatiably nosy!  Guaranteed more fun than shampooing cats!

Offline DoughyGuy

  • Plaid: It's What's For Dinner!
  • Planewalker
  • *****
  • Posts: 78
  • Rattle-rattle, thunder, clatter, boom-boom-boom!
Re: Creating an NPC
« Reply #2 on: November 14, 2004, 06:09:27 PM »
Hrm, no didn't seem to work with EXTEND_TOP either... Would I have to leave the area (since the saved game I am using has them in that area) and come back in order for any changes to be visible?

Also, I thought maybe that since the coordinates are so close to the fountain that me may not be appearing because the coordinates are occupied by the fountain.. Doesn't Debug Mode have a command that allows you to get a set of coordinates by using a Ctrl+(?) command? Maybe if I change to coordinates to somewhere a big away from the fountain he might appear...

"That's right! I'm DoughyGuy! I control the world's supply of dairy products! Steak is my ally! Butter does my bidding! Sour cream bows down before me in total abject terror! "

Visit the Land Of The DoughyGuy!

Offline Kismet

  • Devil's Minion #5
  • Global Moderator
  • Planewalker
  • *****
  • Posts: 653
  • Gender: Female
  • Veni; Vidi; Velcro.
    • Pocket Plane Group
Re: Creating an NPC
« Reply #3 on: November 14, 2004, 06:47:56 PM »
Yes, you'll need to use a game where you haven't been to the Promenade.  If you hit X then you'll get the coords of your mouse pointer.
Cailean - An archer NPC for the insatiably nosy!  Guaranteed more fun than shampooing cats!

Offline DoughyGuy

  • Plaid: It's What's For Dinner!
  • Planewalker
  • *****
  • Posts: 78
  • Rattle-rattle, thunder, clatter, boom-boom-boom!
Re: Creating an NPC
« Reply #4 on: November 14, 2004, 07:26:41 PM »
Hrm still nuthin...

I went ahead and changed the location to the Docks, since that was an unexplored location in my Test Save game, and used the command you told me to find the coordinates... Then went back, updated the files with the new data, then 'recompiled' and loaded the saved game... He was supposed to be standing right next to the upper right entrance of the Docks, but he ain't there :)

Ah well... I'll keep fiddling with it and see if he will show up... Maybe the CRE file is bad or something... Or maybe I can try summoning him with the CLUA console and see if it's just the location patch that's gone wrong...

Thanks for your help :)

"That's right! I'm DoughyGuy! I control the world's supply of dairy products! Steak is my ally! Butter does my bidding! Sour cream bows down before me in total abject terror! "

Visit the Land Of The DoughyGuy!

Offline neriana

  • Planewalker
  • *****
  • Posts: 585
  • Gender: Female
    • Darien NPC for BG2
Re: Creating an NPC
« Reply #5 on: November 14, 2004, 07:28:13 PM »
Are you using an .exe based on WeiDU to install?
The color of infinity inside an empty glass.

Offline DoughyGuy

  • Plaid: It's What's For Dinner!
  • Planewalker
  • *****
  • Posts: 78
  • Rattle-rattle, thunder, clatter, boom-boom-boom!
Re: Creating an NPC
« Reply #6 on: November 14, 2004, 07:56:50 PM »
Are you using an .exe based on WeiDU to install?

No, I'm using the weidu program itself on the command line (the exact command i'm entering is 'weidu dude.tp2')

Is there another program I should be using to add him into the area?

One the CLUA front, I discovered something interesting... The TP2 file isn't copying the CRE file into the override directory, so I put it (and the DLG file) into the directory myself...  Then, when I used CreateCreature("Dude"), he appears like magic :) Of course, his dialog doesn't work, he has no name pop up in the tooltip, and his circle is green, rather than blue, but those are probably all things I need to use NI or ShadowKeeper to fix, so I'll fiddle around with that...

This is good practice, though :) Ya learn the most from your mistakes, I guess...

 
"That's right! I'm DoughyGuy! I control the world's supply of dairy products! Steak is my ally! Butter does my bidding! Sour cream bows down before me in total abject terror! "

Visit the Land Of The DoughyGuy!

Offline neriana

  • Planewalker
  • *****
  • Posts: 585
  • Gender: Female
    • Darien NPC for BG2
Re: Creating an NPC
« Reply #7 on: November 14, 2004, 08:08:26 PM »
The NPC tutorial doesn't actually tell you everything you need to do, unfortunately.

Make a copy of weidu.exe in your BG2 directory, and rename it Setup-nameofyourtp2.exe. Run it, and let us know what happens. Also, could you copy the entire contents of your .tp2 here?

You probably have some problems in your game now; I hope you have an unmodified copy of BG2 on your computer, because you may need to reinstall. The same thing happened to me.
« Last Edit: November 14, 2004, 08:10:21 PM by neriana »
The color of infinity inside an empty glass.

Offline DoughyGuy

  • Plaid: It's What's For Dinner!
  • Planewalker
  • *****
  • Posts: 78
  • Rattle-rattle, thunder, clatter, boom-boom-boom!
Re: Creating an NPC
« Reply #8 on: November 14, 2004, 08:32:18 PM »
Make a copy of weidu.exe in your BG2 directory, and rename it Setup-nameofyourtp2.exe. Run it, and let us know what happens. Also, could you copy the entire contents of your .tp2 here?

Ok, I did that... I also moved the D, BAF, TP2, and CRE files to the main directory with it... But when i ran the exe, it tells me that it can't find the 'target'' files... Hrm...

The tp2 file is as follows -
--------------------------
BACKUP ~Dude~
AUTHOR ~DoughyGuy~
BEGIN ~Dude the NPC for BG2:ToB~


// The following is the copying of Vondo's .cre file

COPY ~dude.cre~ ~\override\dude.cre~    <--- After typing the whole msg I think that's the mistake here :)


// The following is telling WeiDU to compile the following .d files

COMPILE ~dude.d~
USING ~~ // We haven't got a translation file yet.  Ignore this for now.

// The following is compilling the script and placing it in the override

// COMPILE ~VondoTheNPC\J#Vondo.baf~

// The following is appending what we wrote in J#AR1000.bcs to the (top) of
// AR1000.bcs

EXTEND_BOTTOM ~Ar0300.bcs~ ~ddar0300.baf~

// The following is some .2DA appending for Vondo

// APPEND ~pdialog.2da~
// ~J#Vondo J#VondoP J#VondoJ J#VondoD J#Von25P J#Von25J J#Von25D J#Vond25~
// UNLESS ~J#Vondo~
-------------------------------------

I commented out the parts about 2da and scripts for the time being... Right now I just want him to be there and say one thing... Unless I need other scripts to have it work... I'll do some more fiddling and see what I come up with

"That's right! I'm DoughyGuy! I control the world's supply of dairy products! Steak is my ally! Butter does my bidding! Sour cream bows down before me in total abject terror! "

Visit the Land Of The DoughyGuy!

Offline neriana

  • Planewalker
  • *****
  • Posts: 585
  • Gender: Female
    • Darien NPC for BG2
Re: Creating an NPC
« Reply #9 on: November 14, 2004, 08:51:57 PM »
Make a copy of weidu.exe in your BG2 directory, and rename it Setup-nameofyourtp2.exe. Run it, and let us know what happens. Also, could you copy the entire contents of your .tp2 here?

Ok, I did that... I also moved the D, BAF, TP2, and CRE files to the main directory with it... But when i ran the exe, it tells me that it can't find the 'target'' files... Hrm...
You can leave all files but the .tp2 file in Dude's own directory within the BG2 directory. It keeps things neater :).

Quote
The tp2 file is as follows -
--------------------------
BACKUP ~Dude~
AUTHOR ~DoughyGuy~
BEGIN ~Dude the NPC for BG2:ToB~


// The following is the copying of Vondo's .cre file

COPY ~dude.cre~ ~\override\dude.cre~    <--- After typing the whole msg I think that's the mistake here :)
Yes, you don't need the extra slash in front of override.

Quote
// The following is telling WeiDU to compile the following .d files

COMPILE ~dude.d~
USING ~~ // We haven't got a translation file yet.  Ignore this for now.
I don't know if it will cause problems, but you might just want to comment that USING line out.

Quote
// The following is compilling the script and placing it in the override

// COMPILE ~VondoTheNPC\J#Vondo.baf~
If you want your NPC to walk up to the PC and say his bit, you'll need to include a .baf for him. To start, just:
IF
See([PC])
NumTimesTalkedTo(0)
THEN
RESPONSE #100
Dialogue (Nearest([PC]))
END


It'll get MUCH bigger soon, especially if you plan on making a romanceable NPC.

Quote
// The following is appending what we wrote in J#AR1000.bcs to the (top) of
// AR1000.bcs

EXTEND_BOTTOM ~Ar0300.bcs~ ~ddar0300.baf~

// The following is some .2DA appending for Vondo

// APPEND ~pdialog.2da~
// ~J#Vondo J#VondoP J#VondoJ J#VondoD J#Von25P J#Von25J J#Von25D J#Vond25~
// UNLESS ~J#Vondo~
-------------------------------------

I commented out the parts about 2da and scripts for the time being... Right now I just want him to be there and say one thing... Unless I need other scripts to have it work... I'll do some more fiddling and see what I come up with

That's fine for now, as far as I know. It's also a good idea to look at the one-day NPC Ghareth and some Iron Mods for examples of coding that are much simpler to wade through than any big mods, and usually in more "modern" coding.

Oh, I just realized from your first post that you left DeathVariable at 0. Don't do that. Use Dude, or whatever. I don't know exactly what it does, but I believe DeathVariable is how the game identifies your creature as existing. Whatever it does precisely, it's extremely important. Also, I think DLTCEP is a lot better for creating creatures than NI. You can find it here: http://www.dragonlancetc.com/forums/index.php?board=9
The color of infinity inside an empty glass.

Offline DoughyGuy

  • Plaid: It's What's For Dinner!
  • Planewalker
  • *****
  • Posts: 78
  • Rattle-rattle, thunder, clatter, boom-boom-boom!
Re: Creating an NPC
« Reply #10 on: November 14, 2004, 08:55:13 PM »
rofl... Well the fun never stops...

First off, I fixed the problem with the weidu not working... Seems it was looking for all the files in a directory with the same name as the tp2 file... Didn't realize ti did that, and mine was called dudeworks as opposed to just dude.

So, I installed it, properly this time... Or at least I thought... I went over to the docks, walked a little bit, and lo and behold there's Dude! Only problem is that Dude appeared to be going through a reproductive phase, as one more of him would show up every second or so... It was kinda funny for a couple of seconds... But I had used Shadowkeeper to turn him from PC to Neutral, so his circle isn't green anymore (should he be Neutral or Ally if I eventually want him to be a joinable NPC?)

His dlg file worked correctly worked, but the engine still can't seem to have a name for him (No "Dude-" before his words, and no name in the tooltip)... I can probably fiddle with that if I can get NI to agree with me...  I couldn't get it to locate the CRE file, but maybe now that I've officially installed it, it could work....

It's the multiplication problem that worries me the most (they were crowding around my party in kind of a creepy Agent Smith sort of way after a while...) Probably something wrong with the way I'm checking the DudeExists variable, I'll try to fiddle with it...

Oh, and the reinstall isn't a problem... Right now, I'm just trying to get the template to work, then I'm going to completely reinstall the game, and start with an unmodded game for troubleshooting purposes as I work... My ultimate goal is to create a joinable Monk NPC with voicing and everything :) Ambitious for a neophyte like myself, but I'm having fun :)




"That's right! I'm DoughyGuy! I control the world's supply of dairy products! Steak is my ally! Butter does my bidding! Sour cream bows down before me in total abject terror! "

Visit the Land Of The DoughyGuy!

Offline Kismet

  • Devil's Minion #5
  • Global Moderator
  • Planewalker
  • *****
  • Posts: 653
  • Gender: Female
  • Veni; Vidi; Velcro.
    • Pocket Plane Group
Re: Creating an NPC
« Reply #11 on: November 14, 2004, 09:03:47 PM »
In the script where you create him, make sure you increment the variable properly. 

You have to edit his .cre file and make sure that he's marked as neutral (and that flags are set to "none" rather than "exportable")

When you copy his .cre file in the .tp2 you have to assign his name there (and any soundset stuff)

COPY ~dude.cre~ ~override\dude.cre~
SAY NAME1 ~Dude~
SAY NAME2 ~Dude~
Cailean - An archer NPC for the insatiably nosy!  Guaranteed more fun than shampooing cats!

Offline DoughyGuy

  • Plaid: It's What's For Dinner!
  • Planewalker
  • *****
  • Posts: 78
  • Rattle-rattle, thunder, clatter, boom-boom-boom!
Re: Creating an NPC
« Reply #12 on: November 14, 2004, 09:07:33 PM »
Oh, I just realized from your first post that you left DeathVariable at 0. Don't do that. Use Dude, or whatever. I don't know exactly what it does, but I believe DeathVariable is how the game identifies your creature as existing. Whatever it does precisely, it's extremely important. Also, I think DLTCEP is a lot better for creating creatures than NI. You can find it here: http://www.dragonlancetc.com/forums/index.php?board=9

Hehe, that probably explains his state of mitosis...I'll change that and see what happens...

I'll try to get that other program to edit the CRE, hopefully I can find the name field (thought I fixed that last time through Shadowkeeper...)

(Before I posted this came in :) )

When you copy his .cre file in the .tp2 you have to assign his name there (and any soundset stuff)

COPY ~dude.cre~ ~override\dude.cre~
SAY NAME1 ~Dude~
SAY NAME2 ~Dude~

Oh, so that's how you do that... Here I was adding strings and assigning variables... hehe

Cool... Ok, off to try to solve my last two problems :)
"That's right! I'm DoughyGuy! I control the world's supply of dairy products! Steak is my ally! Butter does my bidding! Sour cream bows down before me in total abject terror! "

Visit the Land Of The DoughyGuy!

Offline neriana

  • Planewalker
  • *****
  • Posts: 585
  • Gender: Female
    • Darien NPC for BG2
Re: Creating an NPC
« Reply #13 on: November 14, 2004, 09:08:13 PM »
The multiplication problem is actually easy to solve, if it's happening for the normal reason. Put a global in there to stop him spawning. So it should look like this:

IF
Global("DudeExists","Global",0)//this is step one of stopping him from spawning repeatedly
THEN
RESPONSE #100
SetGlobal("DudeExists","AR0300",1)
CreateCreature("Dude",[xcoordinate.ycoordinate],3) //3 is the facing, you can play around with that
SetGlobal("DudeExists","Global",1)//this is step 2 of stopping him from spawning repeatedly
END
The color of infinity inside an empty glass.

Offline DoughyGuy

  • Plaid: It's What's For Dinner!
  • Planewalker
  • *****
  • Posts: 78
  • Rattle-rattle, thunder, clatter, boom-boom-boom!
Re: Creating an NPC
« Reply #14 on: November 14, 2004, 09:21:55 PM »
Yep, I already have that... it's the ddar0300.baf file...

But when I went back I figured out my mistake... :) I didn't change all the references to AR0700 to AR0300... Hehe... Thank you for making me go back and look...



"That's right! I'm DoughyGuy! I control the world's supply of dairy products! Steak is my ally! Butter does my bidding! Sour cream bows down before me in total abject terror! "

Visit the Land Of The DoughyGuy!

Offline DoughyGuy

  • Plaid: It's What's For Dinner!
  • Planewalker
  • *****
  • Posts: 78
  • Rattle-rattle, thunder, clatter, boom-boom-boom!
Re: Creating an NPC
« Reply #15 on: November 15, 2004, 02:54:17 PM »
Thank you all very much for your help last night in trying to hash out my problems... Everything is just ducky now, I've created a set of 'skeleton' files that I can use to create and test my NPC now, and almost everything works perfectly, exactly as I wanted.

However, there is one single line in my .d file which is giving me difficulties:
---

IF ~NumTimesTalkedTo(>1)~ THEN BEGIN GreetElse /* Greets you the third time and there on out */
SAY ~Sigh... Why do you keep bugging me?~
IF ~~ THEN EXIT
END

---

The top line is the one giving me difficulties, and I'm sure I don't have the syntax right, but I don't get any errors. Basically what I want is if you've talked to him at least twice, he simply gives the same response every time he talks to you. I tried looking at a few deconstructed dlg files, but I can't find another example of what I want... If anyone could help me with this, I'd appreciate it...

Alternately, does anyone know of any resources for IE variables/commands? Something like the charts they have on the weidu-readme, I find those very easy to understand and they've been very helpful...

Again, thanks in advance for any help anyone could offer :)
 
"That's right! I'm DoughyGuy! I control the world's supply of dairy products! Steak is my ally! Butter does my bidding! Sour cream bows down before me in total abject terror! "

Visit the Land Of The DoughyGuy!

Offline Andyr

  • Dance Commander
  • PPG
  • Planewalker
  • *****
  • Posts: 3178
  • Gender: Male
    • The Gibberlings Three IE mod community
Re: Creating an NPC
« Reply #16 on: November 15, 2004, 03:07:52 PM »
What you want is NumTimesTalkedToGT(0) or !NumTimesTalkedTo(0) as your condition. :)
"We are the Gibberlings Three, as merry a band as you ever did see..." - Home of IE mods

<jcompton> Suggested plugs include "Click here so Compton doesn't ban me. http://www.pocketplane.net/ub"

I am unfortunately not often about these days so the best way to get hold of me is via email.

Offline jcompton

  • Niche Exploiter
  • Administrator
  • Planewalker
  • *****
  • Posts: 7246
Re: Creating an NPC
« Reply #17 on: November 15, 2004, 03:13:19 PM »
Personally, I find NumTimesTalkedTo more trouble than it's worth. I'd rather use variables as flags in most cases, since an inordinate number of headaches seem to be tied to NumTimes.
Cespenar says, "Kelsey and friends be at the Pocket Plane? Ohhh yesssss!" http://www.pocketplane.net

Offline DoughyGuy

  • Plaid: It's What's For Dinner!
  • Planewalker
  • *****
  • Posts: 78
  • Rattle-rattle, thunder, clatter, boom-boom-boom!
Re: Creating an NPC
« Reply #18 on: November 15, 2004, 03:17:21 PM »
Andyr, worked perfectly, thank you :)

jcompton, yeah I'll probably change it to a global variable eventually because it'll be tied to a subquest... But hehe I'm getting ahead of myself... Took me almost a full day just to have him show up and engage in a little conversation :D

Thanks again, all :)

 
"That's right! I'm DoughyGuy! I control the world's supply of dairy products! Steak is my ally! Butter does my bidding! Sour cream bows down before me in total abject terror! "

Visit the Land Of The DoughyGuy!

Offline DoughyGuy

  • Plaid: It's What's For Dinner!
  • Planewalker
  • *****
  • Posts: 78
  • Rattle-rattle, thunder, clatter, boom-boom-boom!
Re: Creating an NPC
« Reply #19 on: November 15, 2004, 09:09:57 PM »
Hey, you guys have been great in helping me iron out the wrinkles with the NPC I'm creating...

I was wondering if you might be able to do me another favor... I spent the afternoon making up a background for the character, and I just got fininished translating a bunch of it into his 'introductio' to the party, in the form of a dialogue..

Basically, he shows up, you talk to him a couple of times, then he asks you to help him out and explains his situation...

I would appreciate it greatly if someone else could try this out for me, and give me some criticism (constructive or otherwise) on how I've done... Ya'know, is the story too hackneyed, does it present any problems with gameplay? You guys are the pros at modding, so I would sincerely appreciate your feedback about my first effort...

I have the whole thing zipped up and ready to go, but I didn't want to post it here because I don't know the exact rules about posting files to messages (its about 350k)... I could, as well, put the file into my Angelfire website so it can be dowloaded... If I have a willing victim... er... volunteer, I would appreciate your input :)

"That's right! I'm DoughyGuy! I control the world's supply of dairy products! Steak is my ally! Butter does my bidding! Sour cream bows down before me in total abject terror! "

Visit the Land Of The DoughyGuy!

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: