Showing posts with label event tutorial. Show all posts
Showing posts with label event tutorial. Show all posts

Tuesday, April 21, 2015

Introducing how event are written 4: References

As I said in the previous post, I would make a tutorial for using the references in event creation.

Okay, let's start with two simple events:

<Event Name="work_in_bar">
  <SetText>!$trainee worked at the bar.</SetText>
  <AddBody>Wear ++ Worked in bar</AddBody>
  <AddBody>Clean - Worked in bar</AddBody>
  <AddMind>Wear + Workd in bar</AddMind>
  <AddMoney>
    <Reason>Worked in bar</Reason>
    <Amount>[MinimumWage] * 1.2</Amount>
  </AddMoney>
</Event>

<Event Name="work_in_bar_2">
  <SetText>While working at the bar !$trainee fell. OUCHIE!</SetText>
  <AddBody>Wear + !$trainee fell down</AddBody>
  <AddBody>Wear ++ Worked in bar</AddBody>
  <AddBody>Clean - Worked in bar</AddBody>
  <AddMind>Wear + Workd in bar</AddMind>
  <AddMoney>
    <Reason>Worked in bar</Reason>
    <Amount>[MinimumWage] * 1.2</Amount>
  </AddMoney>
</Event>

Both events are about the slave working at the bar, but one event is slightly different from the other.
There's a part that it's identical in the two events, which is the "result" for working at the bar. The result is whathever the slave gained by working there, in this case money, fatigue and dirtiness.

Well, I don't know you but I don't like repetitions...
Well, I don't know you but I don't like repetitions...

Whops...
Anyway thanks to the cutting edge technology that are event reference we can rewrite the two event like this:


<Event Name="work_in_bar">
  <SetText>!$trainee worked at the bar.</SetText>
  <DirectReference>default_reward</DirectReference>
</Event>

<Event Name="work_in_bar_2">
  <SetText>While working at the bar !$trainee fell. OUCHIE!</SetText>
  <AddBody>Wear + !$trainee fell down</AddBody>
  <DirectReference>default_reward</DirectReference>
</Event>

<Event Name="default_reward">
  <AddBody>Wear ++ Worked in bar</AddBody>
  <AddBody>Clean - Worked in bar</AddBody>
  <AddMind>Wear + Workd in bar</AddMind>
  <AddMoney>
    <Reason>Worked in bar</Reason>
    <Amount>[MinimumWage] * 1.2</Amount>
  </AddMoney>
</Event>

So why is this better?

Well, now when I'll addd "work_in_bar_3" I just have to reference the "default_reward" event instead of copying it and pasting as I have done in the first example.

And speaking of copy & paste, look! Have you noticed the mistake I have done?

  <AddMind>Wear + Workd in bar</AddMind>

should be

  <AddMind>Wear + Worked in bar</AddMind>

Well, in the first example I made the mistake twice since I just copied paste the whole event.
For each copy paste I have now to correct the error. In this case (just a small spelling error) it might be fine. But think about more complex error or text that has been copied 5-6 times, the problem is harder to solve, you will start to miss some place, expecially if the text is copied past on different files.



The reference you have seen is valid only for events whitin the same file. For referencing an event in another file you use this:

<DirectReference>pathToYourFile;eventName</DirectReference>

for example

<DirectReference>Events/Common.xml;strip_all</DirectReference>

That reference is one you will see in the event file since it's an event that strips all the clothes of the slave.


I hope I've explained it in a compresible manner.
See you next tutorial!

Sunday, March 22, 2015

Introducing how event are written 3: Expressions and parameters

Hello,

this time we are going to write another simple events where I'll introduce the expressions and parameters.

Let's say I want to have a more dinamic event (relatively to the previous two we have seen). For example I want that the player need to pay a fee to enter a building.

We are looking for an event written like this:

If player doesn't have enough money
     Kick him out
else
     play the main event

To have something like this we need 2 things that we haven't still seen:

  • An if event step
  • A way to check player money
So let's start with the former and write a basic event


    <SetText>Bouncer: Halt!</SetText>
    <SetText>Bouncer: You need to pay the standard fee to enter.</SetText>
    <SetText>Bouncer: 50!$$</SetText>

    <If Expression="true">
        <SetText>!$player: I think I left my money in the other pants.</SetText>
        <SetText>The bouncer kick your butt making you fly outside of the place.</SetText>
        <End/>
    </If>

    <SetText>!$player: Here you are sir.</SetText>
    <AddMoney>
        <Reason>Expensive place entrance fee</Reason>
        <Amount>-50</Amount>
    </AddMoney>

    <!--The rest of the event here-->

As you can see the If event step is pretty simple. It has a Expression attribute where you write an expression that will be evaluated at runtime.
If the expression return true the event steps inside the If are played otherwise not.
In this case the expression is "true" which, DUN DUN DUN, always evaluate to true.
So in our basic event we always get kicked out.

Another thing to notice is the <End/> event step, which, as its name suggest, will end the event.

Sidenote: At the moment I'm not sure there will ever be an If Else event step because I'm not sure I             can achieve a clean way to write it in XML, but anyway an if else behaviour can be simulated             using a Switch that has both true and false cases.


Okay, having a bouncer that will always kick your butt, is not that great. So, how can we check player money?
Other than using normal mathematical construct the expression can evaluate information called parameters. Parameters are specified inside [] brackets.
In our case we need the [Money] parameter. This return a number that represent the current player money.

So, knowing this we can now write:

    <SetText>Bouncer: Halt!</SetText>
    <SetText>Bouncer: You need to pay the standard fee to enter.</SetText>
    <SetText>Bouncer: 50!$$</SetText>

    <If Expression="[Money] &lt; 50">
        <SetText>You only have !$expr{[Money]}</SetText>
        <SetText>!$player: I think I left my money in the other pants.</SetText>
        <SetText>The bouncer kick your butt making you fly outside of the place.</SetText>
        <End/>
    </If>

    <SetText>!$player: Here you are sir.</SetText>
    <AddMoney>
        <Reason>Expensive place entrance fee</Reason>
        <Amount>-50</Amount>
    </AddMoney>

    <!--The rest of the event here-->

We have, unfortunately, to use the &lt; entity instead of < since in XML you can't write the < character blindly.
Anyway as you can see our expression is now [Money] < 50 and so we will enter in that if only if player money are less than 50.
Another interesting thing to notice is that you can use expression in text using !$expr{} writing your expression inside the brackets.
This way we can give feedback on how many money does the player have.

Now our event will work correctly. If we have less than 50$ we will get kicked out, we will enjoy the full event if we have 50 or more.


Sidenote: The expression used by the game are evaluated using NCalc. On their site you can find the         documentation, the sintax and some example.

When I'll make the first release the game will contain the documentation where all the available parameters are described.

Okay, that's it for this time.
Bye bye!





Monday, March 16, 2015

Introducing how events are written 2: let's go working!

Hi,

here's the second lessons on how the events are written.
Today let's see how to put up a simple working event. This way we can see some new event steps.


So, how a slave in a fantasy hentai world could make money?
What did you say? By being an astronaut? Well, thats... unexpected.

Anyway okay.
So we start with something basic:

<Event Name="work_as_astronaut">
        <SetTitle>To infinity... and beyond!</SetTitle>
        <SetText>!$trainee worked as an astronaut! WIIII!</SetText>
</Event>

Yeah, very basic...
Anyway here there's already something new.
Have you spotted it?
It's the !$trainee. Okay le'ts start by saying that when you see something that starts with !$ it's called an Alias and inside the game will be replaced with something more meaningfull. For example our !$trainee will be substituted with the name of your slave.


Now, during events your slave stats improve/degrade as a consequence of what she do.

    <Event Name="work_as_astronaut">
        <SetTitle>To infinity... and beyond!</SetTitle>
        <AddBody>Wear +++++ Being in space is tiring</AddBody>
        <AddBody>Fitness ----- There's no way to train in space</AddBody>
        <AddMind>Wear +++++ Being in space is tiring</AddMind>
        <AddMind>Happiness +++ Being in space is a wonderful experience</AddMind>
        <SetText>!$trainee worked as an astronaut! WIIII!</SetText>
    </Event>

There are 2 kind of stats: body stats and mind stats.
The body stats represent phisical trait of the girl while mind stats represent mental traits.
Anyway <AddBody> is used to modify body stats while <AddMind> is used to modify mind stats.
A stat that is common to both is Wear. The higher it is the more fatigued the girl is, phisically and mentally.

Both <AddMind> and <AddBody> have the same sintax:
<AddMind>Wear(1) ++++(2) Being inbla bla(3)</AddMind>

  1. The first part is the name of the stat being modified.
  2. The second part is the amount the stat will be modified. +++++ mean it will increase a lot, using less plus will increase it but less. ----- will decrease the stat a lot and using less minus will still decrease it but less.
  3. The third part is the reason the stat changed. This will be displayed to the player.
Now let's add another event step.


    <Event Name="work_as_astronaut">
        <SetTitle>To infinity... and beyond!</SetTitle>
        <AddBody>Wear +++++ Being in space is tiring</AddBody>
        <AddMind>Wear +++++ Being in space is tiring</AddMind>
        <AddMind>Happiness +++ Being in space is a wonderful experience</AddMind>
        <AddMoney>
            <Reason>Worked as astronaut</Reason>
            <Amount>2000</Amount>
        </AddMoney>
        <SetText>!$trainee worked as an astronaut! WIIII!</SetText>
    </Event>

Guess, what <AddMoney> do?
Exactly, it make the game crash.
No, I mean it add a given amount to the player money.
The <Amount> is how many money will be added (or removed if it's negative) from the player finance.
The <Reason> is the same as the reason for <AddMind> and it is used to display info to the player.



Now let's fire this bad boy, shall we?


As you can see:
  •  !$trainee is changed and is now Jeane
  • The money are added to player finance as can be seen in the screen.
  • You can't see the stats but I assure you they had been added to trainee stats (I would have shown you the stat panel too but currently it doesn't display the reason so let's wait a little)

Okay, hope I have been clear enough.



Monday, March 2, 2015

Introducing how events are written: Hello world!

NOTE: technical post meant for whoever is interested on how the game events works.

I think I never explained how events for the game are written (other than saying they're written in XML)

So I'll start make some post where I show you some simple event and I'll explain what's it means.
So let's see the programmer basic, the hello world example.
We start by creating a new .xml file and put it in the events directory of the game. We call the f

ile MyFirstEvent.xml
and in the file we write:

<Events>
   <Event Name="hello_world">
      <SetText>Hello world</SetText>
   </Event>
</Events>

What all this mean?

<Events> is our root, all event defined in this file will be inside it.

<Event> is the definition of an Event and must contain in his attribute a Name. Having a name is necessary for the event to be referenced by the game or by other events.

Finally inside the event we have a <SetText>, I already said something about event step. Well this is the most basic one.
When the game see this event step, the given text is displayed to the user and the game will wait until the player click continue to go to the next event step.
Not all the event steps wait for the user input for example the <SetTitle> event step will be executed and will continue immediately to the next event step.

So for example we can do this:

<Events>
   <Event Name="hello_world">
      <SetTitle>My first event</SetTitle>
      <SetText>Hello world</SetText>
   </Event>
</Events>

When the event fire the title (the big text on the screen, you can see it in the figure on the bottom) will be setted to My first event and immediately the SetText will be fired setting the event text to hello world.

In order to play the event there's stilll one thing to do. The game doesn't know which event should be playable so you have to tell him.
For that you have to create an activity.
The game work in weeks, every week you decide what to do for the next, then all the event planned are played.
Activities are what the player can do during the week. For example things like: work at bar, rest, take a walk are all valid activities.
For our example we need to create a new activity (at the moment I can't say where you will have to write the activity bit since it'll change in the future.)
The activity is written like this:

     <Activity>
        <Name>Hello world activity</Name>
        <Duration>1</Duration>
        <EventReference>
            <DirectReference>
                <Path>Events/MyFirstEvent.xml</Path>
                <Name>hello_world</Name>
            </DirectReference>
        </EventReference>
    </Activity>

Let's see all the bits:

<Name>  This is the display name the user will see for that activity.
<Duration> How much in days the event is long. The maximum is 7. Note that things like 0.5 are valid numbers. (But atm all the basic events are 1 days long)
<EventReference> Is what event the activity will play. As you can see it contains a <DirectReference> that is an element you can use inside events too that contain the relative path of the file containing the event and the name of the event.

After adding your activity you will see it in game, you can select it and play it.
The result are shown here:


Note that the screen are going to change and are just for demostrative purpose