Sound and visual FX and spawning from dialogue
Last night I added a little thing at Co8 for the Lareth fight. Absurdly simple, just:
ONE mp3 copied from elsewhere in the game
TWO lines in the dlg file
ONE addition to the py file (a chunk of script)
And now if you beat Lareth down to under 50% hp, when he stops the fight and tries to talk his way out of it, if you continue fighting he will call on Lolth for aid (fully vocalised call of course, like all my NPC mods :-D) and Lolth will send him some allies, complete with summoning effects when they arrive. The point of this is to compensate for the fact you are fighting him alone, having already killed off his boyos, whereas in the original module he would of course have come out and helped and you would have had to fight the squad of evil mercenaries and the higher-than-you-lvl cleric all at once (much tougher!)
Lets go through it step by step, that will teach us:
How to add visual effects
How to add sound effects
How to spawn new critters
Go and get the files here if you haven't already and we will look at them. There is only 3!
First the dlg file. The two lines I added are:
{700}{Lolth! Protect me!}{Lolth! Protect me!}{}{}{}{game.particles( 'sp-Curse Water', npc ); create_spiders(npc, pc)}
{701}{[attack]}{}{1}{}{0}{npc.attack( pc )}
You should be able to analyse these easily by now. First, Lareth calls out for Lolth, there is a couple things in the 'execute' field, and the second line is the PC response, which is common (1 Int), ends the dialogue (line 0) and initiates combat (npc.attack( pc )). O and i fiddled a few lines earlier to GET to line 700: namely, several lines that otherwise said something like:
{We fight now.}{}{1}{}{0}{npc.attack( pc )}
I changed to this:
{We fight now.}{}{1}{}{700}{}
Two changes, both obvious.
So, now Lareth calls on Lolth before the combat starts. What else happens? The first executable command is a glorious little thing, it allows us to add game particles. Thats what we call visual effects such as spell effects, monster visual stuff (not the models but things like the Balor's fire and glowing eyes, things like that) other things, anything that looks like a visual effect rather thna a model :-) I think they are sprites but I am not sure.
What are our options for this? Well, to see them all (or even add new ones) open the files partsys0.tab, partsys1.tab, partsys2.tab in the rules folder or in ToEE4.dat/rules if you have unpacked it (you HAVE to unpack these if you want to mod!! For instance, partsys2.tab is not in the rules folder of your normal game - only modified files are in there normally and we have to access a lot of files modding even though we may not actually modify them). Being tab files, open them in 'Proto Ed' like you would protos.tab (makes it much easier to view them). Now you can see all the visual effects :-) Of course, there is one for each spell.
If you don't want to look at them now, thats ok, we'll keep going. Suffice it to say, game.particles( 'sp-Curse Water', npc ) adds the visual effect (NOT the sound or anything, JUST the visual efffect) of casting that spell, so when Lareth calls out, a creepy looking red cross appears over him: you know he is doing more than just squealing ;-).
Notice you can just script these straight in the dlg executable thing? How cool is that?!?! Easy to add stuff.
Now... what do you suppose create_spiders(npc, pc) does? Hmmm...
Unfortunately, this requires a touch MORE than just the executable. This actually accesses something already defined in the .py file. So pop that file and lets find it. Go right down and you will see:
def create_spiders( attachee, triggerer ):
________spider1 = game.obj_create( 14397, location_from_axis (470L, 536L) )
________game.particles( "sp-summon monster I", spider1 )
________spider1.turn_towards(game.party[0])
________spider2 = game.obj_create( 14398, location_from_axis (481L, 536L) )
________game.particles( "sp-summon monster I", spider2 )
________spider2.turn_towards(game.party[0])
________spider3 = game.obj_create( 14620, location_from_axis (482L, 529L) )
________game.particles( "sp-summon monster I", spider3 )
________spider3.turn_towards(game.party[0])
________spider4 = game.obj_create( 14417, location_from_axis (529L, 544L) )
________spider5 = game.obj_create( 14417, location_from_axis (532L, 555L) )
________return RUN_DEFAULT
So here we define the create spiders thing. It is a variant of the scripts Calmert and Terjon use to call each other if you attack them in the church. I also used it to summon the Daemon at the end of Desperate Housewives.
As you can see it repeats a lot so we don't have to go over every line.
Firstly, lets compare:
create_spiders( attachee, triggerer ) with
create_spiders( npc , pc )
In the .py file we talk in the abstracts that define the event, in the .dlg we talk about the specific characters who trigger it. You'll get used to that. Certainly you will never see 'attachee' in the .dlg file, because the .py files are straight Python scripts that get compiled by the game when you access them (if they have not already). These are the identical .pyc files in the Scr folder. You may have some that don't have .pyc files, they haven't been accessed in your current game yet.
Now, the first line:
spider1 = game.obj_create( 14397, location_from_axis (470L, 536L) )
This both creates a spider, and defines it as a string called 'spider1' we can subsequently use in other scripts. :-) The specific spider is proto number 14397, a small fiendish spider from memory. Spider2 is a medium one, Spider3 a large one, and 4 & 5 are Black Widows for elsewhere in the game (a little surprise). So essentially we are saying, create object 14397 and call it 'spider1'. We could of course create anything and call it anything :-) We could create a Hezrou at this point and call it 'Fifi' if we have such a need.
location_from_axis is important, this says where to put it on the map, but how do we find that value? Well, when you want to add something, you go to the spot with your lead character (the leftmost one in the party lineup shown down the bottom of the screen).
Now, bring up the console (press [shift] and [~]). Type in
from utilities import * [hit enter]
This tells the game we are going to access the utilities.py file in the data/scr folder. Thats a file well worth looking at btw.
Next, we ask the game to give us the location we are at. So type in:
location_to_axis(game.party[0].location) [hit enter]
This is a little script added to the utilities.py file by the original ToEE creators for just such a moment. Agetian improved it so you only have to type loc, clever fellow! Later you can look for that improved utilities.py at Co8. For now, jot down the number that you see when you hit enter: that will be the location you will later put in your creating coordinates. Game.party[0] is your leftmost character (the 'leader'), then [1], [2] etc. And note we use location_TO_axis to find it but location_FROM_axis to use it. :-)
Next line:
game.particles( "sp-summon monster I", spider1 )
Well, we know what that does, don't we? It creates the particle effect of the summon monster spell, and the target for it is spider1. Compare this to the previous one we saw with the curse water effect, there the location for the spell effect was npc (ie on Lareth himself). You could also script in coordinates here if you wanted it to appear nearby for some reason, or put in game.party[0] if you wanted an effect to appear on your party leader for instance.
spider1.turn_towards(game.party[0])
We've seen this one before too, it turns the spiders toward at least one member of the party , rather than facing the wall or something when they appear (that looks stupid). Might vary those later so they turn towards different member so the party, or we could even get them to turn towards the nearest, but not quite so easily ;-).
And THATS IT! The rest just spawns different spiders in different locations (different proto numbers and coordinates). Thats all :-) Spider4 and Spider5 spawn somewhere else in the moathouse, so we don't need to turn them to face the player or show particles. Only needs to be mentioned that these spiders are already flagged 'KOS' in their protos, so we don't have to do anything to make them attack, they will wade right in.
Now... what about sound effects? Time to do that.
For .dlg files, adding sound is easy. As it is, many characters (particularly PC followers, or at least potential ones like Lareth) come with vocal lines. So we just have to put those in.
Now, if we want, we can put in ANY mp3 file: a spell sound, a trumpet charge, geese squawking, anything. In this case, I simply added a vocal of Lareth actually yelling out "Lolth, protect me!" I could have added some spell effect sounds as well for the summoning, or layered them with a sound editing program or something, but I didn't!
Where did I get a sound of Lareth saying something? Well, if you pop 00060Lareth.dlg and scroll down to the bottom, you will see that he has a few combat sounds that really don't get used. I looked for a plea to Lolth, and sure enough, there is one at line {12080}.
So: I opened ToEE3.dat/sound/speech. In here you will find all the vocal lines of all the characters who have voice recordings (not all of the NPCs of course). They are divided into folders according to their .dlg/.py number, so Lareth is folder number 00060. For some reason, Ostler's stuff is just lying around loose in the speech folder. Messy damn programmers!
Open the folder. The mp3s are accessed by line number. So, for {12080} we need v12080_m.mp3. The 'm' means it is the male version of the line, this will be the default if the male and female versions are identical. If there is a seperate female version (saying 'hey lass' or something) it will be v12080_f.mp3 (but in this case there isn't).
We are adding line 700, so we simply copy this mp3, then go to our game folder and open data/sound/speech. We need a new folder, so we create one called 00060. Then we open it and go in, and paste that mp3 file. Then right click on it and rename it v700_m.mp3. Its that simple!
If you have my mod installed you can look elsewhere in the speech folder, everything here (at the time of writing) was added by me, because I am the only one who has done this sort of modding so far. You will find:
spell sounds fired from dialogue lines (00295, 00299 etc)
a bleating sheep (00298)
giggling kids (and a howling Cujo) (00228)
and lots of new dialogue made my blending existing rare and unused vocal tracks (00017, 00091, ooo97 etc).
Well, thats if for today! Now your npc.attack( pc ) episodes can have some cunning twists ;-)
Next tutorial is right here and is about getting your NPCs chatter to each other.
2 Comments:
um...
yea...
sumthin liek dat...
I'll write something more interesting tomorrow :)
Post a Comment
<< Home