| Home Page | Recent Changes

Beginners Guide To UScript

Beginners Guide to UScript

This document is under heavy development and is not meant to be read yet

Bullet: I'm not sure wether I will finish it or keep it up because I currently don't see a way to bring in an order into the stuff I want to tell to the beginners. Anyway I will try to and yes that's it so far.

This site is meant to be an introduction for Beginners what to do and how handle the problems any Beginner may experience.

When I started to learn UScript I had no problems with the syntax or anything that was in connection with the language itself. The main problem was how to do things now, how to find out where I have to change what to get what I want.

Requisites

This text is going to handle the where to do and not the how to do. That means you should be familiar with the basics of UScript, how to declare variables, create classes, compile code and so on. If you don’t met one of these requisites you'd better read the respective tutorial and come back later.

Here we go

Export or download the UT2004 UnrealScript Source and start to read. The best thing to start with are files starting with Mut*. Those files contain the most simple code because they are the mutators shipped with UT2004. Read them and try to understand at least a bit and try to remember tricks they used to achieve their goal. There may be a time where you'd need them. Keep on reading. You need to get an overview over the engine as fast as possible because THEN you can write useful things because THEN you know where to put the screw driver to.

If you want to read more advanced code, go read the weapon source located in XWeapons/. There is everything that has to do with weapons such as their projectiles their pickup-classes and so on. Always have a look at the used functions and their parameters.

If you find a super.SomeFunction() then find out what the base class is and search for SomeFunction there. For weapons for example you may find a few references with super.DoSomething() and will find them in Weapon.uc located in Engine/

If you have a lot of time and a clear brain then you might want to read Actor.uc or Pawn.uc which are both located in Engine/.

About a weapon

The most interesting thing for beginners to do is to modify weapons. If you edit the weapons you can get good effects with small effort! But weapons aren't that easy to understand in UT2004 because they consist not only of one, but a few classes. Here I will try to give an overview over them although my knowledge with weapons isn't that advanced because I'm still a beginner ;)

At the beginning there is a class. The Weapon class, Weapon.uc located in Engine/. It contains any stuff a weapon would need without defining it too straight. Every weapon differs from the others in some way but Weapon.uc is defined to be abstract enough to suit any weapon (if you read the class definition you may notice the abstact keyword). That is: Any weapon has two fire modes (which are of class WeaponFire (UT2003)). Fire and Alt Fire. Plus every weapon keeps track of the ammo remaining for the two fire modes. Then there is a set of functions like MaxOutAmmo(), SuperMaxOutAmmo() and so on. If you want to learn more about the functions every weapon has to offer you may read Weapon now.

Every weapon has to have a pickup class, a subclass of WeaponPickup?. This class defines the appearence and behaviour of your weapon when dropped, how much ammo it will contain and so on. To be honest I didn't have a look at this class but I don't think there's too much of black magic ;)

Every weapon also has a WeaponAttachment class, and this is how the weapon looks from the third person. You can put in effects here like glows or w/e that would appear when looking at someone carrying it.

The next thing to do is to choose between weapons with projectiles or instant-hit weapons.

Projectile weapons spawn real objects when fired. Examples are the rocket launcher, the redeemer, the Link Gun primary fire and so on.

Instant-hit weapons are weapons that check for a hit instantly when fired. Best example would be the lightning gun or the Shock Rifle primary or the Super Shock Rifle. There is no time between the shot and the hit.

This difference is made by the base class they use for their fire class. As mentioned above every weapons has two fire modes. These fire modes are defined by subclasses of either InstantFire ,or ProjectileFire. Whenever someone fires his/her weapon, it calls the corresponding fire mode class.

Weapons: I want to fire now. Instantly.

So this is the section about InstantFire weapons. InstantFire weapons are rather simple.

Whenever the player starts to fire the fire mode class will be told about this event by a call to its InstantFire.DoFireEffect() function. There it basically launch a trace for to see where and what we hit

and then launches the corresponding effect such as a blue beam in case of the ShockRifle?.

The trace part is in fact a bit more complicated because it has to deal with different hit cases such as vehicles, world geometry and the reflection of the beam but with a bit of time you can solve this bit of black magic by looking at DoTrace() in InstantFire.

Weapons: No, projectiles please.

TODO

Quick Notes here: Launches projectiles, SeekingProjectile aims for a target, and yes.

Tarquin: You might want to take a look at UnrealScript Lessons, and see how this page might fit into the sequence of tutes there :)

Bullet: SIR YES SIR :D Will have a look at it at a latter time, okay?

RegularX: To be honest, I would recommend not jumping into weapons right away. Use a vampire mutator or something like that. Weapon code is actually pretty complicated and even more so in UT2004. I used weapons as a starting point when I wrote the UTutes and kinda regretted it. Just a suggestion.

Syntax_Error: Agreed, RegualrX. The weapon tutorial I am writing is meant for more advanced modders who want to really get into UnrealScript that would be useful to a larger mod or TC. My tutorial assumes you have a basic understanding of Uscript, as in a mutator. Sometimes the simpliest weapon ideas are fairly difficult to actually script in. For example, dual pistols seems like a simple extend of assault rifle, but I swear I cannot get them to animate correctly. Just my 2 cents ;)

King Mango Beginner's guide? I think the problem with script is that the people who are good at it have been involved in programming of some sort for so long that they have forgotten what it's like to know nothing about scripting/coding. For someone with no knowledge of any programming language I have found UScript the door that just won't open. The Buzz tutes are great if all you want to do is make the same exact thing they made. All that is is monkey see monkey do. Well that's the end of my rant.

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In