Vehicle Tutorial Part 4

From Mod Wiki

Advanced Scripting

There are a plethora of other things you can do with your vehicle to set it up. I'm going to go into some of them here.

Vehicle HUD

When you are in a vehicle in ETQW a HUD section is added in the bottom left showing details about the vehicle - health, passengers, etc. These are quite simple to create, as they are all done through templates. The only new asset you need to create is an icon for it - it should be pretty easy from looking at the existing icons. They're made up from a border and a fill image, a couple of examples are guis/assets/icons/vehicles/gdf_top_husky_border.tga and guis/assets/icons/vehicles/gdf_top_husky_fill.tga.

To make the material you'll need to create a new .mtr file and place it in a materials directory in your mod directory. I'm calling mine buggy_tute.mtr. The material is created using a template, so we'll need to include the template file before we can create the material. Here is the result for mine. Note that I'm reusing the Husky's icon:

#include <materials/guis/hud/gdf.include>

material guis/assets/hud/vehicles/buggy_tute
{		
    _vehicle_icon( "guis/assets/icons/vehicles/gdf_top_husky" )
}

Now you can make the GUI. You'll need to make a .gui file and place this in a guis directory in your mod directory. I'm calling mine buggy_tute.gui. Again, we'll need to include a template file first:

#include <guis/game/vehicles/gdf/cockpits.include>

gui guis/vehicles/buggy_tute {
    properties {
        float flags = immediate( flags ) | GUI_FULLSCREEN;
    }
    materials {
        "icon"		"guis/assets/hud/vehicles/buggy_tute"
    }
    _class_icons
    _base_icon
    _hud_materials
    _position( 0, 1.5, 10 )
}

Next add the following key to the entityDef:

    "gui_vehicle"                   "guis/vehicles/buggy_tute"