Max Payne :: FSM's and messagingFile: /articles/fsm.phpUpdated: 29.08.2001 - 11:22 - @432 click here for a printable version Version: 1.0 Content: 1. IntroductionThis tutorial is to tutorials like a hotdog is to meat. It has bits and pieces from all sorts of aspects of MaxEd. There’s only info on the message system of MaxEd, but they span from creating sounds, using particle effects, and even making breakable objects. I’m going to assume that you do know how to use MaxEd, but that you only have a very simple understanding of messages.
2. Message BasicsMessages seem somewhat difficult in MaxEd, but once you see how they work, and understand what it means to be ‘object oriented’, they are actually quite simple. To really understand them we need to look at what we call a ‘target’.All messages must be sent to something, and whatever receives the
message is the target. The most basic way to target something is by typing
out its name. For example, For example, Say you have several sisters. You want to one to go make you some ice cream, so you need to send her a message. To send her the message, you need to make sure that you are telling the correct sister by using her name, but also that you are telling YOUR sister, and not someone else’s, by making sure she is a child of your parents. If we were to send this message in MaxEd, it would look like
Is it starting to make sense? One last step, let’s say that neither
your sister, nor your cousin want to get you your ice cream, so you have
to get it yourself. This would look like
" (remember, that messages has auto-complete with TAB, so if you write "c_anim" and press TAB, it will complete the message to "c_animate( );". Also, your basic editing-commands like ctrl-c, ctrl-v and ctrl-x works normally --mixuk)
3. SoundsSounds are one of the simpler messages to use. The hardest part about them is having to find which sound you want. It’s nearly impossible to find a useable sound in Max, without extracting the X_data.ras file. I suggest you do that now so you can follow along.Once you extract it, it’ll create a large directory called \data\, filled with needed info for adding all sorts of special things in your level. We are going to add a sound, so we’ll be looking in the ‘data\database\sounds’ directory. We’re going to add a sound from an enemy, so open the enemy.txt file. I want a slightly more interesting sound, so we’ll skip over the junkies and go straight to the killersuit_alert tag. Now that we’ve found a sound we want, let’s add an enemy so it’ll be appropriate. Make a level (exit and all), and add an enemy entity. We want to make our enemy send the alert sound at an appropriate time, so let’s place a player_collide trigger in front of him. Group everything to your room. Now the message we need to send the sound is ‘A_play3dsound(a%,b%,c%);’. What a% stands for is the .txt file that you found the info on which sound you want to play, in this case ‘enemy’. What b% stands for is the tag given before the sound, in this case ‘killersuit_alert’. What c% stands for is which bone to play the sound from, and since enemies speak from their heads, we want to use the ‘head’ bone. Now we need to add the sound message to the trigger. Open the message
dialogue for the trigger and in the top section add:
Then we want our guy to do combat, so add the same target, but send ‘->c_setstatemachine(merccombat);’ as the message. Now disable the trigger itself with ‘this->t_enable(false);’ and you’re ready to go. Run your map and listen to your new sound.
4. Particle EffectsParticle effects are even easier than sounds, since they require a little less effort in way of typing and searching. Now in the \data\database\particles\ directory from your x_data.ras file, you’ll find a particles.txt.This is the only text file you need to search for you particle effect. We want to try and make a snowfall effect, so search for the ‘snowfall’ section. Now I suggest using ‘medium_snowfall_7m_loop’, since we’re just going to be making a small room. Make a working room, then add a floating FSM to the ceiling. Edit its
messages and place the message,
5 – BreakablesNow making breakable boxes and glass is surprisingly simple once you know how to make sounds and particle effects. Make your level, keeping in mind if you want to create a box or some glass. I suggest a wooden box, since it is slightly easier, and you don’t have to consider making it a poly. Once you’ve got your level made, make yourself a box. Make it dynamic by pressing ‘d’ in transform mode, and then make sure all collisions are on. Now you just need to add your messages.First we need to figure out a way to get our box to know when to break.
The best method I’ve found is to give your box hitpoints, and then have it
break when it ‘dies’. To do this, add a
Then on the ‘OnDeath’ tab, we want to add all the sounds and debris. Go into the message dialogue and add the sound you want (I’ll let you find an appropriate one, and write the message yourself). You can also create the needed box or glass debris with the particle effect message (I’ll let you find the best fit particle effect, and write this one on your own, too). Now we have a box/window which will sound and look like it breaks, but it won’t disappear. We need to add one more message in the ‘OnDeath’ tab, which is ‘this->DO_hide(true);’. That will hide the box/window mesh, and will make everything work out nicely. Now you can make breakables!
6. Conclusion.Now that you know the general basics of FSMs, and know how to make 3d sounds, utilize particle effects, and even combine them, you should try more advanced things on your own. Try making music, or an ambient sound for your level. If you want a real challenge, try adding your own custom sounds, without having to replace the original Max Payne ones.Well, good luck with your future mapping.
--Carl Hapley aka SpazWad slightly edited by mixuk If you want to comment this article, mail SpazWad |