Monday, March 30, 2015

Validator for events

Hello,

in these days I made a great improvement in event creation that should make event creation a little simpler for me and for anyone that in the future might like to try and create one.

I made a validator that can tell you major errors.
What errors can it find at the moment:
It find undefined EventStep for example <SetText> is defined while <SetTxt> or <ABCD> is not. This should prevent mistakes in writing event steps names.

  • It find undefined EventStep for example <SetText> is defined while <SetTxt> or <ABCD> is not. This should prevent mistakes in writing event steps names.
  • It tells whether an event step is formed correctly, for example event steps that require attributes or inner elements will fail validation if they're not defined. And will fail too if they have attributes that are not used.
  • It tells if a given quest id exist or not.
  • Most important it will validate expressions (hopefully if there are not bug on that side :3) for example an expression like [Trainee.Mind.Happiness.VeryHaRpy] will fail since that parameter does not exist, while the correct one [Trainee.Mind.Happiness.VeryHappy] will pass the validation. In part it even check for correct types if an expression require a bool as a return and the expression return a number it will fail validation.
I'd like to add in the future:
  • Check whether a <DirectReference> point to a correct file/event
  • Check whether a quest is started somewhere or is unused.
  • And maybe whehter events themself are used (not sure I could do this at the moment)
  • Other that at the moment don't come to mind.
Anyway for every error that find it gives the file and line where the error could be finded.
This should reduce a lot event testing (unfortunately it will never be smart enough to tell grammar error but for that there's the button to report typos)

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 9, 2015

New dress: cc2

Hello small update here.

There's a new dress ready. It's a simplified version of cc2 top.
For who doesn't know CC2 is a character in the game Hyperdimension Neptunia something something.

Here it is:


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