I don't need to test my programs. I have an error-correcting modem.

Difference between revisions of "How to Make an Inventory"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
(In the Editor)
(Inventory Creation)
Line 96: Line 96:
  
 
<uscript>StaticMesh=StaticMesh'folder.folder.NameOfMesh'</uscript>
 
<uscript>StaticMesh=StaticMesh'folder.folder.NameOfMesh'</uscript>
Links the prepared static mesh to the code. The static mesh can be exported directly from 3DsMax or a similar program, or you can use one from UT3.
+
Links the prepared static mesh to the code. The static mesh can be exported directly from 3DsMax or a similar 3D program, or you can use one from UT3.
  
  
Line 138: Line 138:
 
This name is what will appear in the list in the UT3 editor.
 
This name is what will appear in the list in the UT3 editor.
  
Remembering that you name the '''NewItem''' the same as in the previous code.
+
Remembering that you name the '''NewItem''' the same as in the previous code so that it reads properly.
  
  
Line 171: Line 171:
  
 
Now to compile the code.
 
Now to compile the code.
 
 
 
  
 
== Compiling the Code ==
 
== Compiling the Code ==

Revision as of 02:29, 11 May 2008

This is a tutorial for Unreal Tournament 3.

I will show you a really easy way of creating a customisable inventory for your mods. This tutorial also uses a static mesh component that you can either create yourself or use one already prepared earlier.

I am not going to go into really in-depth information about it all, if you need more info check out the rest of wiki.beyondUnreal.com



The Basics and Downloads

This tutorial uses basic coding, so you will (if you haven't already) download yourself a copy of ConTEXT Editor, or Notepad++. Both programs are for Windows, but I'm sure there would be similar ones for other operating systems.

I use ConText because the syntax highlighter is available making coding easier. You may need to right-click the link and choose Save Target As... and place it in the Program Files\ConTEXT\Highlighters folder to enable syntax highlighting.


You may also need to download the source code files. You will have to unzip and export them into C:\Documents and Settings\My Documents\My Games\Unreal Tournament 3\UTGame\Src

If the folder doesn't exist, then you can create it.


Setting up the Scripts

In the C:\Documents and Settings\My Documents\My Games\Unreal Tournament 3\UTGame\Src folder create a new folder and name it something along the lines of "NewInventory". Then open that folder and create a new one called "Classes". This is where you should save all of your new code.


You have to tell the game about your new inventory, so UT3 has the ability to recognise your unpublished scripts.

Open My Documents\My Games\Unreal Tournament 3\UTGame\Config\UTEditor.ini in ConTEXT and search (Control+F) for [ModPackages]. Underneath the line that reads ModOutputDir=..\UTGame\Unpublished\CookedPC\Script, add the following line:


      ModPackages=NewInventory



Setting up the Compiler

On your desktop you should have an Unreal Tournament 3 icon displayed. Copy the icon and paste it in the C:\Documents and Settings\My Documents\My Games\Unreal Tournament 3\UTGame\Src\NewInventory\Classes folder Right-click on it and open the Properties. In the Target line, after "C:/.../Unreal3/Binaries/UT3.exe" type make This creates the compiler.

I keep my compiler in with the code I write because it is easier to find.


Now to begin!



Inventory Creation

Create a new ConText file:

class NewItem extends UTInventory;
defaultproperties
{
  Begin object Class=StaticMeshComponent Name=StaticMeshComponent1
  StaticMesh=StaticMesh'folder.folder.NameofMesh'
  scale=1
  Rotation=(pitch=16384, yaw=0, roll=0)
 
  End Object
 
  DroppedPickupMesh=StaticMeshComponent1
  PickupFactoryMesh=StaticMeshComponent1
}


Save the file as NewItem.uc



Now going through the important parts of the code:


class NewItem extends...

The NewItem name can be named to anything you want, just make sure that the filename has the same name.


StaticMesh=StaticMesh'folder.folder.NameOfMesh'

Links the prepared static mesh to the code. The static mesh can be exported directly from 3DsMax or a similar 3D program, or you can use one from UT3.


scale=1

Sizes the mesh up or down, according to your tastes.


Rotation=(pitch=16384, yaw=0, roll=0)

Rotates the mesh. The 16384 is a 90 degree rotation.






Now create a new ConText document:

class PickupItem_NewItem extends UTPickupInventory;
defaultproperties
{
  InventoryType=class'NewItem'
 
  Begin object Name=BaseMeshComp
  StaticMesh=StaticMesh'folder.folder.NameofMesh'
  scale=1
  Rotation=(pitch=16384, yaw=0, roll=0)
 
  End Object
}



Save this one as PickupItem_NewItem.uc This name is what will appear in the list in the UT3 editor.

Remembering that you name the NewItem the same as in the previous code so that it reads properly.



Now to go through the important parts of the code once again.


...extends UTPickupInventory;

This tells UT3 that you are extending the PickupInventory class so that the item will be a pickup when placed in the game.



InventoryType=class'NewItem'

This tells the PickupInventory that there is a new item that can be selected.



  StaticMesh=StaticMesh'folder.folder.NameOfMesh'
           scale=1
           Rotation=(pitch=16384, yaw=0, roll=0)

If you change the size or the rotation of the static mesh in one piece of code you must change the other as well.


Congratulations!


Now to compile the code.

Compiling the Code

Double-click on the compiler icon in the C:\Documents and Settings\My Documents\My Games\Unreal Tournament 3\UTGame\Src\NewInventory\Classes\ folder and watch it compile.


There should not be any errors, if there are, double-check the syntaxes.


Now to open the Editor...


Make sure that you have saved both your files as .uc. If you get the error Unexpected 'i', copy the code into a new file and re-save it. This just means that the UT3 compiler doesn't recognise the format that the file was saved under, even if it was saved as a .uc.



In the Editor

In the Generic Browser click on the Actor Classes tab.

Go to Navigation Point then PickupFactory

Open the UTPickupFactory and your item should be there in the list of pickups!!

Select it then right click in the Perspective View and select Add PickupItem_NewItem Here

And that is it!



Good luck!


Izanagi