Since early 2002, Shee Labs has been a group of individuals working to produce free game and media downloads. With ever-fluctuate staffing, Shee Labs continues working behind the scenes on various exciting projects for a bewildering array of areas. Shee Labs ceased to exist in September 2009.
This tutorial will show you how to write a mutator that attaches a spotlight to a player. The code was written by Luke 'Ambershee' Parkes-Haskell for Shee Labs Mutator Week.
Posted by ambershee on Feb 28th, 2008
Basic Server Side Coding.
Many of you will be waiting for the third and final part of the 4th tutorial, but hopefully this will tie you over until I can fight it past the ModDB text editor!
Today we're going to recreate a mutator I wrote for Shee Labs Mutator Week! You can read about it here: Moddb.com
It's very short, very sweet and easy to modify to suit your needs. We're going to attach a spotlight to players in the game. This will make it as so they have a torch in the game! Perfect for if you plan to play on any super dark maps any time soon. We'll give red team players red torches, and blue team players blue torches too, just to mix things up a bit.
First things first, we need a class and some properties! This should be easy by now.
Yeah, easy as pie. I bet you could have done that in shorter time than it took you to read it. The next part is more tricky, and it's all one big function, so let's take a look at it and break it down bit by bit.
We use the ModifyPlayer function to modify our players every time they are spawned, and we create a SpotLightComponent to use as our torch. This part is pretty simple. First things first, we check to make sure what we have is a UTPawn - and Unreal Tournament player. When we find one, we create a brand new LightAttachment for that pawn.
We then get some details about the game mode - we want to know if it is a team game, or a free for all game. Every game mode has a boolean bTeamGame, which we can retrieve from the WorldInfo. If it's true, then we'll check what team the pawn is on, by checking the PlayerReplicationInfo in the player controller. If the team is 0, then the player is on the red team. If it is 1, then they are on the blue team. We set the light brightness to the relevant colour. If not, we set the normal colour.
Finally, we allow the LightAttachment to cast shadows and, we turn it on (SetEnabled), and attach it to the pawn using the AttachComponent function. We call the super function of ModifyPlayer to make sure all modify player is dealt with.
Compile, and play!
That's really it, it's that easy.