Download (direct link):
Chapter 16: Gaming with GUIs 307
Creating scripts within the GUI.
An icon tells you a script is attached to a layer.
The script that you just entered will now run when the player clicks your button. onAction tells the game that the enclosed lines of code should be run when the player uses the GUI. The following actions will occur:
Play a beep sound: When the player uses the interface, the clicking action plays an electronic beep that indicates an action has occurred.
Activate the target: The targeted door is triggered and will open.
More commands are listed in Chapter 20. Use the list there to create your own combination of actions for your custom GUI.
Saving your Work
Saving your GUI requires that you place it in the proper directory.
1. Choose FileOSave As. Open the folder C:\Program Files\ id Software\Quake 4\q4base by using the File Explorer.
308 Part IV: Going Beyond the Basics
2. Create a new folder called guis and open it. Then create another folder that is unique to your map. In this case, name the folder chapter16 because this is the name of your current map.
3. Enter the chapter16 folder and save your GUI under the name of open.gui.
The name of your custom GUI isn’t too important. Just name it something that makes sense to you when you go to locate it in the mapping editor or wherever you plan to use it. However, naming the containing folder is very important. You must name it something that is unique to your map to avoid conflicts with other maps that already exist or are distributed online. Using the name of your map as the name of your containing folder usually ensures that the game won’t confuse things.
Applying Your Custom Interface
Now that you have your custom GUI put together, you need to put it to use. The purpose of this GUI was to replace the one currently in use to control the opening of your doors. All that needs to be done is to redefine the GUI that is being used in the map.
1. Close the GUI editor and open the mapping editor. Load your chapter16 map.
When you go to load your map, you might find that the editor starts you off in the wrong directory. That’s because it remembers the last folder as where you saved your GUI. So, in the mapping editor’s Open dialog box, navigate to the map folder, which should be C:\Program Files\ id Software\Quake 4\q4base\maps\game.
2. With your map open, locate the func_static where you have defined your GUI by looking for it in the CAM window. Select this entity and open the Entity tab. Click the GUI button.
This dialog box allows you to browse through all the available GUIs, including your custom GUI.
3. Open base/guis/chapter16 folder and find your new GUI, open.gui. Selecting it produces a preview, as shown in Figure 16-27. Press OK to apply the new GUI to your entity.
4. Save your map and then recompile it. After it compiles, open the game and launch your level.
You should be able to walk up to your new GUI and click the area where you defined your button to open the doors, as I have in Figure 16-28.
Chapter 16: Gaming with GUIs 309
Locate and apply your custom GUI.
In the game, a custom GUI always looks great.
310 Part IV: Going Beyond the Basics
Exploring Deeper into the Game
You can do a lot more with your GUI other than just control doors. GUIs are used all over the game, and walking through the levels that come with it can inspire further uses in your work.
Other GUI uses that are not so obvious include loading screens, intro screens, and HUDs. If you want to create your own HUD for the game, all you have to do is use the existing GUIs as a guide and change whatever you like.
To find the original files, start by extracting the following files from the pk001.pk4 file. As outlined in Chapter 14, you can open .pk4 files and explore their contents by using WinZip. The files you want to extract are
hud.gui: Located in the path guis/, this file defines the HUD in the single-player games.
^ hug_Strogg.gui: Located in the path guis/, this file defines the HUD when the player turns into a Strogg in the single-player games.
mplevel: Located in the path guis/loading/, this file defines the multiplayer loading screen.
Although I recommend that you explore more on your own, I don’t recommend that you replace the original game files that control these functions. Many people find it frustrating if you change the original files of a game and distribute them. Instead, you’re better off saving it as a new mod of the game. I explore this further in Chapter 19.
Separating Your Files
In This Chapter
^ Understanding how the game finds and displays mods ^ Discovering that the original game is a mod itself ^ Creating a game-recognized mod
»Everything prior to this point in the book involves creating custom pieces mrn of a game that don’t require any changes to the existing game. Rather, what you have created is in addition to what the gamer already has. You have created additional single-player and multiplayer maps, custom textures, scripts, GUIs, and much more. All these are additional elements of the game that can be added to the player’s experience.