Ted's RPG Rant

A place to rant about RPG games, particularly the Temple of Elemental Evil. Co8 members get a free cookie for stopping by. Thats ONE cookie each, no seconds.

Friday, August 19, 2005

Writing Dialogue for ToEE Part 3

Today we're actually going to write some dialogue! Pop 00275demo.dlg again, and lets go back to line 1.

{1}{G:}{G:}{}{}{}{}

You should know what each of these are, though you might wonder why the opening line of this NPC is simply 'G:'. The brighter folks reading this will have figured out:

a) G: is a command of some sort (you don't usually see colons in dialogue ;-))

b) It is short for 'greeting' and is a shortcut to add greetings.

Or you might have picked that up from looking at Phalzyr's thread. Whatever, them's the facts!

By using the letter 'G:', you can have the one single greeting line, and it will change to suit the circumstances of the greeting. If it is the first time the player has chatted to this NPC, you can have an introductory comment: if they have met before, it can be a 'welcome back' comment, if the PC has done something to anger the NPC it can be reflected in the greeting. These comments are all stored at the end in specific line numbers. Scroll down the template and you will see them, line numbers 10008-11004. By specific line numbers, I mean the comment for greeting a naked PC is 10015 in every dlg file. Why is this? So the 'G:' command can access them of course! If you have been doing your homework, you may have noticed many .dlg files don't have these lines at the end: there are also default ones that can be used. So you don't HAVE to add them, you can still use 'G:' and the game will then supply an appropriate, if generic comment.

What benefit is there in using 'G:' if you just then have to write in the appropriate lines at the end of the file anyway? Well, it allows you to simplify the scripting that accesses the dlg file. You will remember we are starting with a very simple script:

def san_dialog( attachee, triggerer ):
______________triggerer.begin_dialog( attachee, 1 )
______________attachee.turn_towards(triggerer)
______________return SKIP_DEFAULT

This always starts the dialogue at line 1. By using G: we can get away with this, always start at the same line but still have a dialogue that changes to suit circumstances.

What about the PC's comment, how do they change? Well, looking at the template this is apparent:

{2}{Hello, I am @pcname@.}{}{8}{not npc.has_met(pc)}{10}{}
{3}{Hi! Me @pcname@!}{}{-7}{not npc.has_met(pc)}{10}{}
{4}{K:}{}{1}{npc.has_met(pc)}{20}{}
{5}{E:}{}{1}{npc.has_met(pc)}{0}{}

Note that npc.has_met(pc) and not npc.has_met(pc) are in the conditional brackets as we defined them in the last tutorial: that is, these are conditions that have to be met to see these lines. Obviously, the introductory lines 2 & 3 are for when the PC & NPC have never met before: or, to use logical langaue, when the condition 'npc.has_met(pc)' is NOT true. Now, write some dialogue! Write in your own greeting. Note the '8' and '-7' for the intelligence condition: also note the use of '@pcname@': whatever the name of the PC who does the talking, will be substituted here. This is how the game knows to call you by name, whatever that name may be.

Done a couple greetings? Well, when you feel like it, you can do all the ones down the bottom of the template as well. You don;t have to, you can always delete these when the time comes and the game will insert the generic onces, but you should at least have some idiosyncratic introductory lines at 10008 and 10009.

Perhaps you want to add a few more specific greetings: have different comments for evil or good parties, or for specific races or classes. Perhaps the NPC is an Elf and you want Elven PCs to acknowledge their kinsman, or perhaps the NPC is a priest of Hextor and you want PC Paladins or followers of Heironeous to have a few choice words to say. To do this, we add conditional lines similar to those we saw last time. I will copy Phalzyr's list here.

pc.skill_level_get(npc, skill_gather_information) == #
pc.stat_level_get( stat_deity ) == #
pc.stat_level_get( stat_gender ) == gender_male //gender_female
pc.stat_level_get(stat_alignment) == LAWFUL_GOOD
(for instance)
pc.stat_level_get(stat_level_paladin) == #
pc.stat_level_get(stat_level_wizard) == #
pc.stat_level_get(stat_race) == race_orc
(for instance)
pc.stat_level_get(stat_strength) >= #

Notice some have spaces and some don't - they are irrelevant, Python is a bit smarter than that. Also notice that 'stat' is used in a wider sense than D&D devotees might use it (ie just for attributes like Strength). Those above are pretty obvious since we have already seen the skills in action. 'Stat_deity' is checked by number according to deity.mes (this is in the Rules folder in ToEE3.dat, if you are serious about ToEE modding you HAVE to crack open those .dat files! Ask at Co8 for how).

Some other handy ones are:

anyone( pc.group_list(), "has_follower", # ) This checks for a specific follower in the party (eg when doing the Preston Wetz 'sore tooth' quest, if you have Bertram in the party you are not only a worry, but you also have the option at that point of saying, hey I have a dentist right here! Or was that a ranger... :-/)

anyone( pc.group_list(), "has_item", # ) This checks if any PC has a particular item in their inventory: ideal for quests, since you don't have to worry about whether the speaker has the item or whether perhaps the strongest PC carries everything but someone else does all the talking.

In both these cases, the # is from protos.tab. However, the number is from col 22 (in Proto-Ed) which is the 'name' of the object. If you open the protos.tab in Proto-Ed for, say, Elmo, you will discover his proto number is 14013, his 'name' in col 22 is 8000 and his id # is 20008! Confusing? Unfortunately, yes it is! In many cases these 3 numbers will be identical, but for NPCs (particularly followers) it can be awkward, because the game has seperate id #s for when they are a stranger and when you have met them. So if you click on Elmo from a distance, he should show up as 'drunk villager' but once u have met him, it will be Elmo. Just be aware of this.

One more condition to introduce here (that I didn't see in Phalzyr's thread but is probably there somewhere) is:

game.party_alignment == CHAOTIC_EVIL (for instance). This is for the alignment you chose for the beginning, ideal for things affecting the opening vignette quests.

Ok, thats it for now, I will try to update this with another post after work. In the mean time, get writing dialogue! Use those conditions to add lines 6, 7, 8 and 9 to the opening dialogue. Also, write some specific dialogue for the various greetings at the end: its that attention to detail (not bothering with the generic default stuff) that makes for an immersive game!

One more thing: you can group conditions with Boolean stuff like 'and' & 'or'. So for the opening lines, you might want something like:

{8}{I'll do the talking, runt.}{}{8}{not npc.has_met(pc) and game.party_alignment == CHAOTIC_EVIL}{50}{}

Note you need '==' for conditions, one '=' won't cut it! This is another very common error.

On to chapter 4: click [THIS].

1 Comments:

At 6:32 am, Anonymous Gaear said...

I hope Edwin & Spike are paying close attention here . . . practice makes perfect!

 

Post a Comment

<< Home