The Black Sheep Wiki
The Black Sheep Wiki
Search:
Ued2 | Key Movers

The contents of this tutorial were written by By: IceLord (NL) at http://www.planetunreal.com/uedlab/keymovers.htm


The concept of the KeyMover:

To explain the concept of the KeyMover an example map is provided downloads:KeyMoverTutorial.ZIP. In this example map you can only open the door when you are in possession of the flashlight (it doesn’t make any sense, but it works ).

- Copy the example map to your \UnrealTournament\Maps directory and startup UT.

- Start a Practice Session, set the GameType to Tournament DeathMatch, select DM-KeyMoverExample as your map, set the number of bots to 0, and click on Start…

As you have seen: no flashlight, no entry. But if you do have the flashlight, the door will open when it is bumped.

The concept of the KeyMover is pretty simple, all I needed in this example is:

    * One KeyMover       (SpecificKey = Class’UnrealShare.Flashlight’)
    * One “Key” (the flashlight)     (Tag is irrelevant, Event = None) 

The KeyMover works like this:

The KeyMover is an ordinary Mover, except that it needs a specific key to be opened. When a player or bot is touching the KeyMover, it searches in their inventory whether or not it contains (a copy of) the specific key (in our case the flashlight). If it does, the KeyMover will move (open). If the player or bot is not in possession of the specific key, the KeyMover will stay closed (won’t open).

The KeyMover:

Before we can add any KeyMovers to our level, we first have to do some scripting.

Lucky us, the scripting has already been done by someone else. I have only changed some minor things (like removing the comments), so I can’t take any credit. All the credit goes to “i thought i saw a crack_addict” and the guys at www.planetunreal.com/chimeric

(For the original script see the HTML-document)

Back to the tutorial:

Just follow me:

1. Startup UnrealED 2.0

2. Open up the Actor Class Browser > Brush > Mover

3. Right click mouse New…

4. Package: MyLevel

Name: KeyMover

5. Copy the following lines into the script (overwriting all the text there is):

// =============================================
// KeyMover
// =============================================

class KeyMover expands Mover;



var() class SpecificKey;

state() BumpOpenTimed

{

function Bump(actor Other)

{

local Inventory key;

BroadcastMessage(Other.Name$" is trying to open the door!!!");

if (Other.IsA('Pawn') && SpecificKey != NONE)

{

BroadcastMessage("Searching for "$SpecificKey);

Key = Pawn(Other).FindInventoryType(SpecificKey);

if (Key != NONE)

{

Broadcastmessage("Found the key!!!");

Super.Bump(Other);

}



else BroadcastMessage("Couldn't find key!!!");



}

}

}

6. Compile the script with hitting F7

7. Close the script

8. In the Actor Class Browser click on View and select Show Packages

9. Select MyLevel and click on Save Pkgs.

If you don’t want all those messages appearing in your game, you can edit this script and remove all the lines which contains “BroadcastMessage” or, even better, write “//” before each line that contains “BroadcastMessage” (so these lines will become comments (green), and will be ignored when compiling the script).

That’s all for the scripting part.

Now we can add a KeyMover to our level, just like a RotatingMover or ElevatorMover, by right-clicking on the add-mover-button and selecting KeyMover.

The rest:

Thus: instead of adding a normal Mover as your door/lift, add a KeyMover to your level.

Then add the key (in our case the flashlight) to your level.

Then open up the properties of your KeyMover. Goto KeyMover SpecificKey, and click on [Use]

Setup the KeyFrames and make sure that the KeyMover is BumpOpenTimed.

Add sounds

Test level…

Good luck,

IceLord (NL)

If you rebuild now you will notice that you cannot see the clouds we put in the sky box. That is because we currently have no lighting! Well let us put some lights in the skybox. Right click on the cloud texture we just added in the sky box and select Add Light Here. You should now be able to see the clouds:

Pop-quiz:

Question: Why do we immediately edit the KeyMover’s properties after the required key is added to our level? (see below)

Important notes:

The KeyMover searches your inventory, so setting up a decoration-object (like a book) as your key is of no use. If you do want to have “real” keys, you’ll have to make them yourself.

Page last modified on March 18, 2006, at 07:39 AM