RSS

Tag Archives: experience

Know Where You Stand

Between adding pawn changing functionality to my PlayerController class and contemplating necessary data structure changes I decided to take a little walk to stretch my legs and get some much needed sunshine. During that walk I came across an interesting looking place (images bellow). I liked the way the place looked and so I started snapping some referential shots with my phone. I like to document such places for inspirational reasons since they could help get the creative juices flowing for future level design work.

While I was standing over a bridge overlooking the spot a middle aged man crossed behind me. He was probably heading back home since it was around 5pm. He stopped and asked me what I was taking a picture of. He seemed very happy, probably looking forward to a nice relaxing weekend. I told him that I liked the way it looked. He then asked if I had an idea for it? I figured I should explain myself a little more so I told him that I design games and I like to snap pictures of places that could prove inspirational. He continued:

The Man: “No, no… you know what my idea is?”

Me: “What is it?”

The Man: “A waterfall!”

I glanced at the space and replied: “Yes it would seem nice” trying to be polite as I was thinking of something else entirely.

The man: “You see, this whole place used to be a river! It used to stretch far from way up there and go down all the way to the sea right underneath where you are standing right now!”

He then pointed at some geological facts that fortified his claim. He felt the need to justify although I believed him entirely…

The man: “See those rocks there? See how they look like?” Then he points at another cluster of stones “do you see these? see how they are scattered? These are all signs that there used to be a river here!”

He justified a while longer since he saw that I was impressed by what he was saying. I think he knew about this river from his youth or from stories his parents or grandparents used to tell him… or maybe he’s just a whimsical Geology professor…

The man: “So if you want to give them an idea tell them to make it into a waterfall! Put benches here *the man points* plant some grass there *points somewhere else* it would be a very nice place for people to come! Tell them about it, take pictures and propose the idea to them!”

I had no idea who “they” were but I was too distracted imagining the place to ask. He then walked away while I was still picturing it all. It seemed that was the end of our conversation… Until he turned back, raised his hands, and looked towards me saying: “TEN DOLLARS! I’d charge TEN DOLLAR entrance!” then he smiled and walked away as I laughed and continued my walk.

I didn’t ask him his name mostly because I never really do that (a foolish flaw mayhaps) but it was irrelevant. It was a nice chance meet on a bridge overlooking an old river one Friday afternoon.

Here’s a slideshow of some of the pictures I snapped, sorry for the quality, that is all my phone can do.

This slideshow requires JavaScript.

Now back to PlayerControllers and Data structures.

Advertisements
 
Leave a comment

Posted by on 06/05/2011 in Experiences

 

Tags: , , , , ,

UnrealScript: Kismet Nodes Part Two – Simple Variable Links

In my previous post I introduced the idea of writing your own Kismet Nodes that would be tailored to your game’s needs. Now I’m going to expand on that and explain how you would use Variable Links for your Kismet Node.

Difficulty: Beginners

This tutorial is aimed at those who know their way around UnrealScript and programming and would like to expand their knowledge concerning a few topics. If you don’t know what UnrealScript is or how to program using it then I suggest you look for a few getting started tutorials before attempting any of this yourself. I will one day write up a few introductory tutorials but for now I’ll stick to selective topics I feel people will most benefit from.

Note: as with most tutorials, code and concepts expressed here are simplified and are meant to serve as a stepping stone for you programming endeavors.

What are Variable Links

Variable links allow you to connect variables to your Kismet Node. Let me give you a simple example. Let us imagine we wanted to write a Kismet Node that takes two integers and adds them up. You would use Variable Links to linkup the 2 variables you want to add together and the variable that will store the result. There is no need to write this since UDK already comes with a handy array of math nodes we can use. Check the image bellow.

UDK's AddInt Node

UDKs AddInt Node

The first thing you should notice is that this node differs from the nodes we wrote in my previous post in that we can connect variable nodes to it through its Variable Links. You might notice a difference in the way the variable links appear. In the image the square links (labeled with a white a) are input links. Input Links allow you to pass variables as input to the node. The triangle links (labeled with a b) are output links. Output Links allow you to write into a kismet variable some result.

So in the image – the two input links are connected to two int variables. It adds them up and spits out the value into the variable connected to the output link.

Scenario

Imagine you wrote some basic functionality that allows the player to gather experience. Your player controller now has something along the lines of:


...
/**How much exp does the player currently have**/
var float currentEXP;
...

and a new function:


/**
* Modifies the player's current exp by adding expGive to it
* @note expGive can be a negative value although will likely never be so
* @param float expGive : how much exp to give/take
**/
function modifyExp(const float expGive)
{
currentEXP += expGive;
}

Note: this is a very primitive exp system and is not one that would go into a game but will be used for the purpose of this tutorial.

Now this is fine if we want to increase the player’s experience within unreal script. But what if you want to award the player for accomplishing a level specific action? For example, let us imagine the player discovered a new area and you want to reward him with 200 experience points how can we allow our designers to modify the player’s experience through kismet?

SeqAct_GiveExp

The obvious answer is to write a Kismet Node that will handle this for us. Create a new .uc file and name it something appropriate. I called mine: DH_SeqAct_GiveExp. Open up your file and (similar to our previous post) extend SequenceAction and write the following:


/**
* This kismet node is used to give the PC exp
* @author : Daniel G Haddad
*/
class DH_SeqAct_GiveExp extends SequenceAction;

var() float expGive;
var float result;

/**
* When activated this node triggers the DH_PlayerController’s modifyExp()
**/
event Activated()
{
local DH_PlayerController PC;

PC = DH_PlayerController(GetWorldInfo().GetALocalPlayerController());
PC.modifyExp(expGive);
result = PC.currentEXP;
}

defaultproperties
{
ObjName=”Reward Exp”
ObjCategory=”DH_PlayerController”

VariableLinks.Empty;
VariableLinks(0)=(ExpectedType=class’SeqVar_Float’,bWriteable = false, LinkDesc=”expGive”,PropertyName=expGive)
VariableLinks(1)=(ExpectedType=class’SeqVar_Float’,bWriteable = true, LinkDesc=”result”,PropertyName=result)
}

Now let me explain what we did. For those of you who read my previous post you will undoubtedly recognize how we got our PlayerController and called the modifyEXP(float) function. Now I will explain all the bits of new code:

var() float expGive;
var float result;

We initialize two variables one called expGive which will hold the amount of experience we would like to give the player. The other is called result and it will be used to hold the total amount of experience the player has after the change.

If you look closely you will notice that one is initialized as var and the other as var(). When we add () to a variable it basically allows us to edit this variable inside the properties box of the object within UDK itself.

For now, save the script and launch the UDK, open up the Kismet editor and place a DH_SeqAct_GiveExp node. If you click on it and dig through its property box you will notice that we can directly input the value of expGive there. This is handy for certain situations. You will also notice that result does not appear there because we initialized it as var and not var(). Refer to the image bellow for clarification:

expGive appears in the properties box

expGive appears in the properties box

Now close the UDK and get back to your code. To explain why we allowed for both expGive to be passed and set think of the following scenarios. Let’s say you simply want to reward the player a static amount of exp when he goes somewhere. You don’t have to hookup a kismet variable, all you would need to do is set the value inside the properties box. Now let’s imagine we want to reward the player experience based on how many kills he has so far or how quickly he did something. In this scenario our exp value would change based on some sort of mathematical function so ultimately we would create a kismet variable that will store the calculated exp value and then pass it to our giveExp node.

Note: if you have a variable connected, that takes priority over the value you set inside the property box.

Now let us check out the activated event:


/**
* When activated this node triggers the DH_PlayerController's modifyExp()
**/
event Activated()
{
local DH_PlayerController PC;

PC = DH_PlayerController(GetWorldInfo().GetALocalPlayerController());
PC.modifyExp(expGive);
result = PC.currentEXP;
}

There is only one line that should seem unfamiliar and that is:

result = PC.currentEXP;

This little bit simply sets the result variable to that of the PC’s currentEXP.

The rest of the code is exactly like my previous post. We initialize a local PC variable, call the modifyExp(float) function with our passed expGive variable.

Note: you might want to run a few checks on the PC to make sure that all is on the up and up, but I won’t include that here for simplicity’s sake.

Finally, all that is left is the defaultproperties code block and it has a few new topics:


defaultproperties
{
ObjName="Reward Exp"
ObjCategory="DH_PlayerController"

VariableLinks.Empty;
VariableLinks(0)=(ExpectedType=class’SeqVar_Float’,bWriteable = false, LinkDesc=”expGive”,PropertyName=expGive)
VariableLinks(1)=(ExpectedType=class’SeqVar_Float’,bWriteable = true, LinkDesc=”result”,PropertyName=result)
}

We’ve already gone through what the first two lines so let us skip over them and focus on the last three.


VariableLinks.Empty;
VariableLinks(0)=(ExpectedType=class'SeqVar_Float',bWriteable = false, LinkDesc="expGive",PropertyName=expGive)
VariableLinks(1)=(ExpectedType=class'SeqVar_Float',bWriteable = true, LinkDesc="result",PropertyName=result)

The first thing I usually do is empty the VariableLinks in this case it won’t make much of a difference but it would come in handy if you try to do something a little advanced with your Kismet nodes so I thought it good to mention it.

Now the other two lines might seem a little intimidating to someone unfamiliar with programming but they are pretty straight forward. All we do here is tell UnrealScript how many Variable Links we want our Kismet Node to have and more importantly we set the properties for each.

So, when we were designing our node we figured we would need one input link that would take the value that we would like to modify the player’s experience by. We decided to take it a step further and have an output link that would then, after adding the value, get the value of the PC’s currentExp variable. This is handy because our node now functions both as a getter and a setter.

VariableLinks(0)=(ExpectedType=class'SeqVar_Float',bWriteable = false, LinkDesc="expGive",PropertyName=expGive)

We tell UnrealScript that in our first Variable Link we expect to see a Kismet Float Variable (the proper class name is: SeqVar_Float). In the next bit we simply set the writeable property to false because we do not intend to write anything into this variable. Finally we give this link a description and in PropertyName we pass the name of the variable we intend to hold the value of this Variable Link.

VariableLinks(1)=(ExpectedType=class'SeqVar_Float',bWriteable = true, LinkDesc="result",PropertyName=result)

Now in our second link the only change is the fact that this time we want this link to be writeable and we make this happen by setting bWriteable = true. We also pass the name of the variable that has the value we would like to write into whatever is connected to this output link. Now save, compile, open up the UDK, and test your new node.

Final Node

How your node should look like and how to use it

So there you have it, you should now be pretty comfortable with creating Kismet Nodes with simple Variable Links. That is it for this week’s tutorial posts. I’m not sure what I’ll go over next week, might be some more introductory topics or I might dive into some advanced topics. Time will tell, until then stay tuned. 🙂

Important Links:

Notes:

If you are writing a multiplayer game or are unsure about whether or not your game will have multiplayer, you can get the player controller using the following method:


event Activated()
{
local WorldInfo wInf;
local DH_PlayerController PC;

wInf = class’WorldInfo’.static.GetWorldInfo();

if (wInf != None)
{
ForEach WI.AllControllers(class’DH_PlayerController’, PC)
{
//Now for each occurrence of DH_PlayerController in your game this section of code will run
PC.something();
…etc
}
}
}

I’ve made a game!

For the past year I’ve formed a small game studio called Cwerki Studios and we’ve been hard at work on our debut game, Min: A Space Adventure! Min built using UDK and was approved by Apple and will become available worldwide on June 18th! Check out our launch trailer!

Click here to download Min for Free from the App Store!

Make sure you like our video and share it with your friends!

It doesn’t end there, Min would not have been possible without the help and support of our community, we have huge, huge plans for Min but more importantly we want to include our community in this future. Head over to our Facebook page and like us to take part in polls and discussions we’ll be orchestrating to decide on Min’s future.

 
6 Comments

Posted by on 17/04/2011 in Kismet Nodes, Tutorials, UnrealScript

 

Tags: , , , , , , , , , , , , , , ,