| Home Page | Recent Changes | Preferences

Stat Points System

This tutorial is for creating a stat-based system in which to modify UT2003 (Like UT2003RPG).

For now we will be working with the firing rate of the minigun. If you have not already done so, you will have to obtain the Unrealscript sources for UT2003. You will also need to Set Up Package Folders for this mod. Once you have done that, copy MinigunFire.uc from XWeapons to the folder you just created for this mod.

 

You need to change the name first: (so you don't overwrite anything)

class SPSMinigunFire extends InstantFire

After that you should see a line that looks something like this:

simulated function PostBeginPlay()
{
    Super.PostBeginPlay();
    FireRate = 1.f / (RoundsPerRotation * BarrelRotationsPerSec);
    MaxRollSpeed = 65536.f*BarrelRotationsPerSec;
    Gun = Minigun(Owner);
}

In order to use the variable we want, we will have to add it to the variable definitions at the top of the page. The variable Definitions look like this:

var() float MaxRollSpeed;
var() float RollSpeed;
var() float BarrelRotationsPerSec;
var() int   RoundsPerRotation;
var() float FireTime;
var() Sound WindingSound;
var() Sound FiringSound;
var MiniGun Gun;
var() float WindUpTime;

var() String FiringForce;
var() String WindingForce;
 

This declares the variables used. (Yeah, we probably know this – skip this step and give a link to the variable syntax page instead)

We will be adding a line to it that looks like this

var() float StatPoints

After that you will need to set up a system for determining stat points. I'll cover that here: /StatPointDetermination?

Anyway, add this line to under PostBeginPlay

function ModeTick(float dt)
    {
        if (StatPoints > 0)
        {        
                NewFireRate = FireRate + (StatPoints / 5);
        else
                FireRate = 1.f / (RoundsPerRotation * BarrelRotationsPerSec);
        }
    }
}

The final code should look like this:

simulated function PostBeginPlay()
{
    Super.PostBeginPlay();
    FireRate = 1.f / (RoundsPerRotation * BarrelRotationsPerSec);
    MaxRollSpeed = 65536.f*BarrelRotationsPerSec;
    Gun = Minigun(Owner);
    function ModeTick(float dt)
    {
          if (StatPoints > 0)
          {        
                NewFireRate = FireRate + (StatPoints / 5);
          else
                FireRate = 1.f / (RoundsPerRotation * BarrelRotationsPerSec);
          }
    }
}

That should do it! I'm not completely sure on the uscript format, but here is it in easy to understand format:

 If the variable StatPoints is greater than 0, then the firing rate is the old fire rate + the value of the variable 
 StatPoints divided by 5.  If it is not above zero, then the firing rate is rounds per rotation * barrel rotations 
 per sec, ie. normal firing rate.

Hope I got this right!

Comments

RDGDanClark: I didn't check the code itself, I just noticed that you had !>, which is invalid. The way to write "not greater than" is "less than or equal to", which is <=. For example "Negative two is not greater than zero" is the same as "Negative two is less than (or equal to) zero".

Dragonmaw: Thanks. I meant it to be greater than 0, but I pressed a wrong key.

Solid Snake: Good tutorial. I don't know what the replication will be like on the network since adjusting those values is client side? I'll have to have a look into that a little later. Also you may want to tell people that they will also have to subclass a weapon and change the fireclass to this one (I'll bet you will get a question in how to use this script...).

Related Topics

/Ammo Modifier:Your next suggested step, this explains how to modify ammo capacity using a stat-based system

UnrealScript Lessons

Category Custom Class

Category Tutorial

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

Mapping Topics

Mapping Lessons

UnrealEd Interface

Questions&Answers

Scripting Topics

Scripting Lessons

Making Mods

Class Tree

Questions&Answers

Modeling Topics

Questions&Answers

Log In