RSS

Learn basic unreal script – Variables part 2

10 Feb

Variables Part 2

Object actors continued

in unreal  every actor  startes with a root class of some kind.

For instance pickup is the root class of all items that can be picked up by a player and it extends actor , Pickup has it own set of properties like pickupcount , itemname etc  That only apply to the class pickup and not  root class actor

A root class of pickup can be anything that extends pickup like weapon , but it can only assign properties of pickup and not  a childclass weapin to the info.

To do that you can declare the structure as  weapon like this

weapon(pickupclass).ammocount = 6;

Using this allows your class  variable to be more broad but still have access to child classes.

certian classes like weapon and mutator have specific extra instruction set like postrender or checkreplament that are  only avaliblew in tho classes.

Using a actor intance , you can edit any thing in the map Thats not bsp. If you know what you doing , or you can add custom objects into the maps or onto players , you can modify them in many ways.

you want a mutator that changes the charge of powershields in the map to a higher number it easy.

  1. var shieldbelt sb;
  2. for allactor ‘shieldbelt’ , sb
  3. {
  4. sb.charge = “9001”;
  5. log(“its over 9000”,’shielbeltboost’);
  6. }

It slighly more complex then that , as you need to check if the actor is in state sleeping other wise it will also increase the armor on players as well since they are carrying a shieldbelt mabye. Note: you should use checkreplacment instead or foractor , and then cast to shieldbelt from actor , but this block of code will work in any actor class , not just mutator, I  will get into that later.

resources as vars

Objects can also be references to a resource, like  a sound or texture.

var texture mytexture;

for exaple is a texture assainged to a var.

referencing outside vars and files

to reference something outside the basic unreal packages or your mods files  like a sound package or texure or even another mods files,   if your in the editor making script you need to have it  open it in the editor. and you can instance it easily like var someothermod modreference;

if your compiling via ucc (witch you should learn to do) it gets more complex to reference things but not much more diffucult.

first off the file needs to be in the editpackages so it can preload the files. then you need to declare you reference in a exec statment.

#exec OBJ LOAD FILE=..\textures\belt_fx.utx PACKAGE=belt_fx.utx

I will get more into exec statments at a later point.

The problem with doing this is that now you mod will require the new import to load, so if you are referencing  some big file like utweapons , any body who downloads or used you mod , will need to also have utweapons to run your mod.

you can even call fuctions and grab variables from other referenced mods.

There is a way around this issue  or to load files that we dont ‘need’ at all times , but it has it own issues and special uses.

Dynamic loading things

dynamic loadobject is a very handy feature , it lets you load a class you have no references to from your file.without it being a required package. this is usfull for side loading pickups or classes from other mods that are not directly connected to your mod , like say if you has a mod that gives the player weapons , you mod wont know at compile time what those weapons are , but it can load them later if they are avalible.

The downside to dynamicloadclass , it that we have to be non specific about what we load usally ,Since the engine has no idea wat we are loading. you if you were loading a custom weapon class , you can only reference it as a root class weapon , and we cant access the custom properties the weapon might have.

when you use dynamicload , any packages you dynamic load wont be loaded on your serverpackages , so you need to add those seperatly.

You can dynamic load any resource like a sound , map,texture , class etc

dynamicload can also be used  to test if a package /map is avalible  on the server as well. In advanced situations , you can use dynamicload  and some cleverness to create a serverside replacment instruction set for you mod to use that you can update without requiring the user to redownload the files.

* you can also use consolecoomand to get and set vars but that  i will get to later

Advertisements
 
Leave a comment

Posted by on February 10, 2012 in Uncategorized

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s