[ABANDONED] AGS 3.3.1 Alpha 2 Turbo

Started by Gurok, Tue 11/03/2014 11:25:53

Previous topic - Next topic

Gurok

Hello all,

I invite you to try...

AGS 3.3.1 Alpha 2

Download 3.3.1 alpha 2 as a .zip archive

Previous alphas:
Spoiler

ACHTUNG!
This is an early version of AGS 3.3.1.
Use at your own risk. Please back up any games before opening them in this version of AGS.
New settings in this version may make your project files unusable in 3.3.0 after saving with this version.

Last updated: 1st of August, 2014



Engine

Full Screen VSync for Direct3D

This feature was previously available (but always on) in Draconian editions of AGS. With AGS 3.3.1, it has been integrated into the mainline builds. It's now possible to toggle VSync using the "Vertical sync" checkbox in Winsetup.exe. If it's checked, the game starts with vertical sync turned ON. In DirectX 5 mode, you can still toggle this by setting System.VSync to true/false. In DirectX 9 mode, the System.VSync property is now read-only (as opposed to being useless previously).

Bug Fixes

  • The engine now moves the portrait with the speaking character when using BasedOnCharacterPosition if the speaking character moves between calls to Say
  • Fixed internal handling of defaults when they can't be read from the config file
  • Fixed precision loss when getting/setting a transparency value, e.g. player.Transparency
  • Fixed occasional pathfinding failure on straight lines with complex walkable areas (reported here)
  • Printing [ no longer consumes all of the backslashes before it (e.g. "\\[" should now print \[ as expected)



Scripting

For statement

In addition to a while loop, you can now use a for loop in AGS script. The syntax is:
Code: ags
for([initialisation];[condition];[increment])
{
    [loop body]
}

Example:
Code: ags
for(player.x = 0; player.x < 100; player.x++)
    Wait(1);

Important: You cannot declare a variable inside a for loop's initialisation section. For instance, "for(x = 0; ..." is fine, but "for(int x = 0; ..." is not valid. It might be valid someday.

Break statement

You can now break out of loops using the break statement. For example:
Code: ags
i = length - 1;
while(i >= 0)
{
    if(page[i] == target)
        break;
    i--;
}

Will halt the loop when a match is found or leave i as -1 if there was no match.

Continue statement

You can now continue to the next iteration of a loop using the continue statement. For example:
Code: ags
for(x = 0; x < 100; x++)
{
    if(x % 2 == 0)
        continue;
    Display("%d", x);
}

Will display only odd numbers between 0 and 100.

Do...While loops

The Do...While loop construct is now supported. For example:
Code: ags
x = 1;
do
{
    x++;
    Display("%d", x);
} while(x < 1);

Unlike While, Do...While runs the loop iteration *before* evaluating the condition. The loop above will run once.

Dynamic Arrays in Structs

Dynamic arrays are now permitted inside structs. You can declare a struct like so:
Code: ags

struct DieRoll
{
    int BaseModifier;
    int DieCount;
    int Dice[ ];
    import function GetTotalValueOfRoll();
};

function PrepareDice()
{
    DieRoll a;

    a.DieCount = 3;
    a.Dice = new int[a.DieCount];
    a.Dice[0] = 6; // d6
    a.Dice[1] = 6; // d6
    a.Dice[2] = 8; // d8
    ...
}

And the dynamic array "Dice" can be initialised and used like any other dynamic array.

Managed User Structs

In AGS parlance, a managed struct is a struct that can be created dynamically. You must use pointers to refer to them (similar to built-in types like Region or Hotspot). You declare them with the keyword "managed" and construct new instances with "new", like so:
Code: ags

managed struct Point
{
    int X;
    int Y;
};

Point *GetPosition()
{
    Point *result;

    result = new Point;
    result.X = 30;
    result.Y = 40;

    return result;
}

Important: Managed structs are currently VERY limited in that they can't contain pointers (including dynamic arrays). It is hoped that this restriction will be lifted in the future.

#define Improvements

#define can now refer to other #define'd constants. Like VC++, #define symbol expansion only needs to make sense at the time of reference. Also like VC++, the order of previously defined constants isn't important, making stuff like this possible:
Code: ags

#define RED    GREEN
#define BLUE   456
#define GREEN  BLUE
Display("%d", RED); // Prints 456
#undef BLUE
#define BLUE  123
Display("%d", RED); // Prints 123

Note: To prevent circular references, a #define cannot refer to itself or anything previously used to expand the #define symbol.

Static extender functions

You can now declare the first parameter of a function as a static identifier that corresponds to a struct, e.g.
Code: ags
function AbsInt(static Maths, int value)
{
    if(value < 0)
        value = 0 - value;
     
    return(value);
}

This works in the same way as the normal extender method syntax (e.g. this Character *) but for static methods. The above code will define a new method in the static Maths called AbsInt. You can then import it in a header:
Code: ags
import function AbsInt(static Maths, int value);

And then use it elsewhere in your code just like it were a built-in Maths function:
Code: ags
int x = Maths.AbsInt(-3);


Extra Assignment Operators

The following C-style assignment operators are now supported:
*=   (Multiply by and assign)
/=   (Divide by and assign)
&=   (Bitwise AND and assign)
|=   (Bitwise OR and assign)
^=   (Bitwise XOR and assign)
<<=  (Bitshift left and assign)
>>=  (Bitshift right and assign)

Direction parameter for Character.ChangeRoom

This feature was previously available Draconian editions of AGS. The Character.ChangeRoom function now looks like this:
Code: ags
Character.ChangeRoom(int room, optional int x, optional int y, optional CharacterDirection direction)

Where CharacterDirection is a new built-in enum defined for facings (eDirectionUp, eDirectionUpLeft and so forth).

Character.DestinationX and Character.DestinationY

Two new read-only properties that can be used to determine where a character is currently heading (via a Walk command). If the character is currently stationary, these values are the same as Character.x and Character.y, respectively.

IsInteractionAvailable() for Other Types

This is another feature from Draconian editions of AGS. The IsInteractionAvailable() method can now be called on Hotspots, Objects and Characters.

Audio Clips API

There are two new properties for dealing with audio clips in this version.
Code: ags
Game.AudioClipCount

Retrieves the number of clips and
Code: ags
Game.AudioClips[n]

Allows you to access a particular audio clip.

Plugin API

There is now a new function that can be used to detect whether a plugin has been loaded:
Code: ags
Game.IsPluginLoaded(const string name)

Where name is the filename of the plugin

Dialog Options

The highlight colour for dialog options (default rendering) is no longer hard coded as yellow (14). You can use:
Code: ags
game.dialog_options_highlight_color = xxx;

And set the dialog options highlight colour to whatever you like. The default is 14.

Code Regions

This was previously available in Draconian editions of AGS. You can define an arbitrary region for code folding in your script like so:
Code: ags
#region MyRegion
do stuff;
do stuff;
do stuff;
#endregion MyRegion

The AGS editor will allow you to fold and unfold this region as though it were a code block. This has no effect on compiled code.

Bug Fixes



Common

Extended WFN Font Support

Support was added for extended characters in WFN fonts (those with codes 128 - 255).



Editor

Padding for Text GUI Windows

Text GUI windows now have a padding property which lets you control how much space appears between the border and the text inside a text GUI window. Previously, this value was hardcoded as 3 pixels. It now defaults to 3 pixels.


Clickable for Objects

The Clickable property of objects is now exposed in the editor so that you can set it at design time. Previously, this value was embedded in the room file format but only toggleable via scripting.


Bug Fixes

  • Undo history will no longer be deleted when a tab changes its docked state
  • Fixed crashes under certain circumstances when a script editor is closed
  • Fixed crash if selecting a character without a normal view in the room designer
  • Ctrl+Tabbing now works the first time when cycling through open editor tabs
  • Go to Line... now goes to the correct line and doesn't select it
  • The project is now completely rebuilt whenever Enable Debug Mode in General Settings differs from the setting used for the last build
  • The sprite editor now highlights drop targets when you drag sprites around
  • Moving folders of scripts around in the Explore Project pane no longer screws up compilation



Please enjoy this build and use responsibly.

Contributors
Crimson Wizard
Tzachs
monkey_05_06
salty-horse
Me
[img]http://7d4iqnx.gif;rWRLUuw.gi

Joseph DiPerla

Joseph DiPerla--- http://www.adventurestockpile.com
Play my Star Wars MMORPG: http://sw-bfs.com
See my Fiverr page for translation and other services: https://www.fiverr.com/josephdiperla
Google Plus Adventure Community: https://plus.google.com/communities/116504865864458899575

Crimson Wizard

Quote from: Gurok on Tue 11/03/2014 11:25:53
  • More settings will now have sensible defaults when they can't be read from the config file (hope I got this right, CW)
No, that just fixed how internal function works. Default values should stay the same.

Gurok

[img]http://7d4iqnx.gif;rWRLUuw.gi

Snarky

Nice! Look forward to trying this out!

Problem

Great, these are some valuable additions to the scripting language! I'll try it out soon :)

Dropped Monocle Games

I'm not very good with coding, being more into graphics so a lot of this has gone over my head.. but hell yes to VSync!!! I spend alot of time on the art and then seeing the screen tearing brokes my little heart hehe, nice work! :)

Radiant

Thanks, this is a breakthrough that I've been expecting for awhile; please continue your work on this :grin:

Gilbert

It's not particularly important for me with for loops adding back as it's been removed for like a decade. It's of course nice to have it back.

But:
Quote from: Gurok on Tue 11/03/2014 11:25:53
Audio Clips API
Sold! :=

monkey0506

Quote from: Iceboty V7000a on Tue 11/03/2014 14:08:29
Quote from: Gurok on Tue 11/03/2014 11:25:53Audio Clips API
Sold! :=

I tried a couple times to implement something like this, but I kept over-complicating things (introducing new data types and such) to the point where I felt I couldn't justify all the changes. This is much more elegant and simple, and is a very welcome change. :)

tzachs

Running with this version and can confirm the text window padding works. :)

Re the audio clips API: Can you guys explain why you find those additions useful? One use I can maybe see is for playing random sound effects, but other than that, I'm drawing a blank. Is there another reason that got you sold, Iceboty?

Gilbert

It's tremendously useful. In fact I'm all for referring to every thing with numbers, rather than stupid object names. For example, I abuse the sprite numbers heavily for putting in the correct tiles to draw in a tiled engine.

Often times, there are occasions where a certain piece of asset is chosen by means of a formula.
For example (just some randomly made up junk, so don't mind whether this is really practical here), I have an interface with some piano keys(say, for simplicity, 8 keys, or, think the interface of LOOM) and a different sound clip will be played when a different key is clicked. If the clips are numbered #100 to #107, it's easy to code the game to play clip #100 + piano_key, than to assign a different clip by name to each key.

I haven't checked it yet, but will the numbering be changed if a sound file is removed from the project? In that case it's only half-done in the current situation. Ideally we should be able to change manually what number each sound file is assigned to, just like what we have for sprites.

Gurok

Re: Audio Clips API

I can't say terribly much about this because I don't have much experience with audio clips. It returns a flattened version of the audio clips tree. That's as much as I know. I would hazard a guess that there's no special numbering going on, but maybe Crimson Wizard can chime in as he'll know more.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Ghost

Very interested in testing this, I especially like the loops. Can't say how often I've wished for those. Well played, Gurok!

Radiant

Quote from: tzachs on Tue 11/03/2014 20:06:01Re the audio clips API: Can you guys explain why you find those additions useful?
The old (AGS 2) music/sound system let you address everything by number, but it doesn't work with the new (AGS 3) volume controls; so this should do both. This lets you pull tricks like setting a variable cur_music for each room, then playing music[cur_music] if it's daytime, music[cur_music + 1] if it's night, without having to set up an array of pointers.

DoorKnobHandle

Quote from: Gurok on Tue 11/03/2014 11:25:53
Break statement

You can now break out of loops using the break statement. For example:
Code: ags
i = length - 1;
while(i > 0)
{
    if(page[i] == target)
        break;
    i--;
}

Will halt the loop when a match is found or leave i as -1 if there was no match.

This is really nitpicking but I think there's an error in this example. It halts the loop when a match is found (but it doesn't check the first element in the page[] array) or end up with i being 0 (not -1) if there was no match, right? What you probably wanted is >= instead of > in the second line.

Good work though, can't wait to try this! The for/break/continue stuff is neat but the audio clips are really useful to me as well!

Snarky

It's better written as a for-loop anyway. :-D

Gurok

#17
Quote from: DoorKnobHandle on Wed 12/03/2014 12:21:31
This is really nitpicking but I think there's an error in this example. It halts the loop when a match is found (but it doesn't check the first element in the page[] array) or end up with i being 0 (not -1) if there was no match, right? What you probably wanted is >= instead of > in the second line.

Good work though, can't wait to try this! The for/break/continue stuff is neat but the audio clips are really useful to me as well!

Yes, you're right. I'm too used to writing it the "proper" way ( while(i-- > 0) ) which AGS doesn't support yet. I'll update the example. Sorry about that! :-[
[img]http://7d4iqnx.gif;rWRLUuw.gi

Adeel

Nice going, sir. It's a very fine start. I especially like having the power to manually configure 'padding for Text GUI Windows.' :)

Gurok

Umm... I just want to stress that this is still a collaborative effort. I appreciate the thanks and kind words from people, but Crimson Wizard and Tzachs have been contributing for a lot longer than me and are also contributing to this release. Audio Clips and some of the Draconian porting is CW's work. The undo history + editor crash fixes are Tzachs'.

I have a feeling that we won't get any feedback about the new scripting stuff until someone finds a bug. Regardless, it would be nice to read a "I tried the new version and it ran a for loop fine" from someone so I know that I didn't completely mess things up :).
[img]http://7d4iqnx.gif;rWRLUuw.gi

SMF spam blocked by CleanTalk