Unreal Tournament is the sucessor to the awesome game that was Unreal. Boosting the most advanced gaming engine when it was released, this game kicks some serious arse. Unreal Tournament's got it all without a doubt: ton's of amazing levels, kick-ass weapons, brain-melting modes of play, unbelievably deadly bots, and a slew of other features bound to have your happiness glands working overtime! I have not even mentioned the mod's either, and boy are they bountiful and bloody brilliant, with titles such as Strike Force. So give this game and spin, then crank up a few of it's mods and you will be wondering how you lived without this game!

Post tutorial Report RSS How to make an exploding Barrel. (Uscript)

Quite simple. A Uscript lesson describing how to make a barrel that blows up when you shoot it. =)

Posted by on - Basic Client Side Coding

[page=Introduction]
For all you Uscript newbs that are tired of googling and finding 'Ok newbs, lets make a shotgun/darkmattergun/uberrifle', this Tutorial is a bit...different. Maybe what you were looking for ;).
[page=Getting Prepared]
First step is loading Unreal Level Editor.
After UnrealLevelEditor(henceforth refered to as UEd) loads, click on the Actor Browser to open it. (the picture of the pawn on the top toolbar)
You should now see the Class Tree of all the classes you can use in UEd.
On the top of the Actor Class Browser window, click on the View button, then move your mouse over and click on Show Packages.
Click on the [+] button next to Decoration next.
Right click on Barrel, and hit the button that says "New".
When asking for your package name / class name, put:
Package name : ExplodingBarrelPackage
Class name: xplodingbarrel
Why didn't we name the exploding barrel Exploding Barrel? This is because of a possible class conflict - if another class has the same name as our class, UEd will glitch and not know who's class is for who's package.
After you hit Ok, and the class is generated, you will need to re-extend Actor. For now, just minimize the new blue/green/white window that appears. Click on the [+] button next to Actor. Go down to decoration, repeat, and then repeat on Barrel.
You should notice a class called xplodingbarrel underneath it.
Good.
[page=The Code]
Now open up that weird window again.
You should see the following:

//=============================================================================
// xplodingbarrel.
//=============================================================================
class xplodingbarrel expands Barrel;

Well, we have our xplodingbarrel, but alas, it won't do anything except that which Barrel does.
We need some code to put in here!
Write (or copy-paste :p) the following code into your class:

Auto State Animate
{
	function HitWall (vector HitNormal, actor Wall)
	{
		if (Velocity.Z<-200) TakeDamage(100,Pawn(Owner),HitNormal,HitNormal*10000,'shattered');	
		bBounce = False;
		Velocity = vect(0,0,0);
	}

	function TakeDamage( int NDamage, Pawn instigatedBy, Vector hitlocation, 
						Vector momentum, name damageType)
	{
		Instigator = InstigatedBy;
		bBobbing = false;
		if (Health<0) Return;
		if ( Instigator != None )
			MakeNoise(1.0);
		Health -= NDamage;
		if (Health <0) 	
			SuperBoom();		
		else 
		{
			SetPhysics(PHYS_Falling);
			bBounce = True;
			Momentum.Z = 1000;
			Velocity=Momentum*0.01;
		}
	}

Begin:
}
Function SuperBoom()//this is the big boom! :D
{
	local flame f;
	HurtRadius(170,210, 'exploded', 50000, location);
	spawn(class'smokepuff');
	spawn(class'ut_blacksmoke');
	Spawn(class'ut_ringexplosion4');
	spawn(class'warexplosion');
	f=Spawn(Class'flame');
	If(F!=none)
	{
		f.lifespan=10;
	}
	Frag(class'WoodFragments',vect(0,0,0),1.75,12);		
	Destroy();
}

What this does is makes our barrel call SuperBoom instead of SkinnedFrag(which makes wood chunks), and superboom makes some pretty effects and does damage in a certain radius.
A more detailed explanation on our Function SuperBoom:
1. Refer to a Flame actor
2. Cause damage (170 damage, 210 UU radius, damage type, velocity, where the damage is coming from)
4. Make some smoke
5. Make some more smoke :p
6. Make a cool orange ring
7. Make a boom appear
8. Make a flame
9. If the flame is there,
10. Make it live for 10 seconds

Shoot the barrel as a person walks by, and they'll go BOOM!

[Page=How to keep our barrel]
Now, if we want to keep our precious barrel's code, we're going to need to compile and save it!
You will notice 7 buttons in the code editing window. The first, the blue folder, puts away the current script. Don't hit that.
There are 3 on the right for use of finding certain words...we don't need those right now either.
To the left of those is a button of 2 tools. That opens the Actor Class browser, which is already open. Ignore that.
Now we have 2 buttons left. They are white, and one of them will compile our script, the other one will compile ALL scripts. We don't want to compile all scripts, trust me ;).
Hit the Compile Changed scripts button. If, by acciden, you hit the Compile All scripts button , just close UEd next chance you get and start over. The package hasn't been saved yet, so you won't have to worry about conflicts.
Remember the Show Packages button I made you hit ealier? That made a list of all packages loaded in UEd show themselves. You should see one near the top called ExplodingBarrelPackage. There is a checkbox next to it. Click on it, then hit the picture of the floppy disk in the Actor Class browser.
Viola! Now you have a package in your x:\whateveryourUTdirectoryis\System called ExplodingBarrelPackage.U
[Page=Conclussion]
Now, if you're planning on using this in a map, just remember to load the package by opening it (the button next to save does this), and placing your custom barrel in your map like you would any other decoration. Just remember- when distributing your map, don't forget to include ExplodingBarrelPackage.U with your map's zip, along with instuctions on where to put it. (UTDIRECTORY\System)
[tutorialimg175 NOT FOUND]
That's it!
~Ghost3021

Post comment Comments
critical*shot
critical*shot - - 1 comments

it sounds cool to me :) and i hope so:lol:

Reply Good karma Bad karma+1 vote
goblinraider
goblinraider - - 3 comments

FUNNY! I WANNA MAKE 1! HOW I WATCH THE MOVIE?

Reply Good karma Bad karma+1 vote
goblinraider
goblinraider - - 3 comments

HEY
U
SAID
A
VIDEO
I
WANT
A
VIDEO
I
DONT
KNOW
HOW
TO
GO
ANYWHERE!
IM
NEW
CANT
U
HELP
ME?

Reply Good karma Bad karma0 votes
zacman_the_Damned
zacman_the_Damned - - 58 comments

Um, there is already an exploding barrel for UT...

Reply Good karma Bad karma0 votes
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: