[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

Crimson Wizard

Quote from: Gurok on Wed 12/03/2014 13:40:48
I have a feeling that we won't get any feedback about the new scripting stuff until someone finds a bug.
Lol, you need to have patience, such things are usually revealed 1 week before final release :D.

monkey0506

Quote from: Gurok on Wed 12/03/2014 12:59:21I'm too used to writing it the "proper" way ( while(i-- > 0) )

Hmm, that's funny. I've never heard anyone refer to the postfix operator as being "proper" (even if it is an aggregate type in a language with no prefix operator). :cool:

Quote from: Crimson Wizard on Wed 12/03/2014 13:44:46
Quote from: Gurok on Wed 12/03/2014 13:40:48
I have a feeling that we won't get any feedback about the new scripting stuff until someone finds a bug.
Lol, you need to have patience, such things are usually revealed 1 week before final release :D.

Or a week after release.

Ryan Timothy B

Code: ags
Game.AudioClips[n]

In all honesty, it should've been  audio[n]  to keep with AGS's standard (ie object[n], character[n] etc), but this is the better choice. But since I've brought it up, it would've been nice to have things grouped in a more organized and intuitive convention like: Audio.Clips[n]   or something of that sort.


Has anyone thought of adding a do while loop? Not that it's an important addition (neither was the for loop though), it would just be nice to have.

Anyway nice additions everyone!

Gurok

Quote from: monkey_05_06 on Wed 12/03/2014 14:58:33
Quote from: Gurok on Wed 12/03/2014 12:59:21I'm too used to writing it the "proper" way ( while(i-- > 0) )

Hmm, that's funny. I've never heard anyone refer to the postfix operator as being "proper" (even if it is an aggregate type in a language with no prefix operator). :cool:


Hrm... not sure what you mean. Are you saying this because when a postfix operator is used with an aggregate type, it means creating a temporary copy? For the case of ints, --i and i-- generate identical opcodes, just in a different order as far as I know. So for that case, there's no reason to consider the i-- operator as being bad. I primarily use the postfix operator because I am lazy, hence the quotes around the term proper. In C and Javascript (which is my day job), you can get away with: while(i--) which saves keystrokes.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Radiant

The difference is that i++ returns the value of i and then increments it, whereas ++i increments i and then returns the value. This is only relevant if you write wonky code like "j = ++i" or the like.

Gurok

Quote from: Ryan Timoothy on Wed 12/03/2014 20:32:05
Has anyone thought of adding a do while loop? Not that it's an important addition (neither was the for loop though), it would just be nice to have.

That's on my list after switch...case and passing structs as params.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Radiant

#26
Quote from: Gurok on Wed 12/03/2014 23:16:05
That's on my list after switch...case and passing structs as params.
Cool, I would like to have do{}while as well.

Considering we already have +=, would it be a big deal to add *= /= &= |= ^= >>= and <<= ? I'm used to C++ coding and tend to reflexively type those before realizing they don't actually work. Yes, I actually use bitfields in AGS :D

(edit) sorry if that sounds like a lot, I figured they're all pretty much the same in terms of opcodes.

Dualnames

Provided the static extender works properly, this is quite fantastic!! And useful, wonderful job there, Gurok. +1 For several of these to be integrated into the main build.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Radiant

Quote from: Gurok on Wed 12/03/2014 13:40:48I 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 :).

I'd be happy to give you feedback. I've got some rather complicated C++ code that I can try to compile in AGS, and if that works then it's pretty strong evidence that for/break/continue work properly. I'd probably have time for that in a couple of weeks. But the code also uses do{}while and some of the *= type operators, so I'd either have to wait for those to be added, or rewrite the code. Either way, it should be a nice test.

tzachs

Quote from: Gurok on Wed 12/03/2014 13:40:48
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 :).

I tried the new version and it ran a for loop fine.
Well done!

Crosco

He, the new built-in enum CharacterDirection is very interesting.
When I started to use AGS I began with a game template from Maniac Mansion Mania (http://www.maniac-mansion-mania.com). In this template they defined such an enum: eDirection. They used it at a Character extending function FaceDirection( this Character*, eDirection dir ).

So, maybe a function FaceDirection( CharacterDirection direction, optional BlockingStyle ) is a useful extension to the FaceCharacter, -Object, ... functions and should make it into AGS?


GrogGames

#31
very nice!!! ;-D

When i was a "kid", i learn programation with AGS, with the proskito's templates,
and i remember, thah i was very surprised with the "while-int i=0-i++" conjunction, i tought "oh, what a clever use of while" (i had no-idea of "for", or something like it).
I think, if "for" existed in AGS in that moment, then that no was happen. That was a great moment of my adolescence.

But, yes, is very, very useful for me (now more adult), the "for" sentence. At overall, for better understanding of the code.

I am studing "Informatic Enginering", and i no have idea of "continue" existence . That is very useful too. And i learn something new :)

And, obviulsy, "break" is useful, always that will be used with responsability.

in conclusion, very interesting propose!

Gurok

I'm hoping this is not considered presumptuous, but I'd like to bump the build number and the version numbers in the repository and release what we have as "3.3.1 alpha 1". If CrimsonWizard obliges, I'd be happy to update this thread with the changelog. Or if you prefer, CrimsonWizard, you can start a new thread for 3.3.1 alpha 1. What do you think?

Among the changes since this test build are better screen resolution selection, fixed building after moving script folders around and extra operators in scripting (e.g. *=, /=).
[img]http://7d4iqnx.gif;rWRLUuw.gi

Crimson Wizard

#33
Sure, please do. I am sort of distracted from AGS lately.
Two months ago I asked JJS to give you contributor rights in the ags repository, but JJS hadn't been on forums since February :(. I am not sure if I may do this myself, I haven't found a way to do this yet (github UI is confusing).

I don't remember if I mentioned this before. We are using odd build numbers for development versions (e.g. 1163, 1165 etc) and even numbers for release versions (e.g. 1162, 1164 etc).

Gurok

Okay, I've updated the first post.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Crimson Wizard

#35
I think you should make a notice which features are from 3.3.0 update, to prevent possible confusion.

Also, I completely forgot, I had to add a fix to extended WFN renderer which lets to load incorrect WFN fonts (already used in Scavenger's "Heatwave", for example). I might do that soon.

monkey0506

I made a combined build of the new 3.3.1 alpha with the Linux compilation. Hope you don't mind me piggybacking this onto your release. (roll)

https://bitbucket.org/monkey0506/ags/downloads/3.3.1%2Blinux.rar

Radiant

Quote from: Gurok on Sun 04/05/2014 11:20:38
I'm hoping this is not considered presumptuous, but I'd like to bump the build number and the version numbers in the repository and release what we have as "3.3.1 alpha 1". If CrimsonWizard obliges, I'd be happy to update this thread with the changelog. Or if you prefer, CrimsonWizard, you can start a new thread for 3.3.1 alpha 1. What do you think?

Among the changes since this test build are better screen resolution selection, fixed building after moving script folders around and extra operators in scripting (e.g. *=, /=).

Very good news! Thank you Gurok!

Gurok

#38
Quote from: Crimson Wizard on Sun 04/05/2014 17:32:46
I think you should make a notice which features are from 3.3.0 update, to prevent possible confusion.

You're absolutely right. For now, to avoid confusion, I've completely removed the sections about upscaling and resolution selection. Are there any other 3.3.0 features I've listed by mistake? I didn't realise upscaling was already present in 3.3.0. I just went through all the commit logs in order. Sorry!

Quote from: monkey_05_06 on Sun 04/05/2014 20:44:25
I made a combined build of the new 3.3.1 alpha with the Linux compilation. Hope you don't mind me piggybacking this onto your release. (roll)

https://bitbucket.org/monkey0506/ags/downloads/3.3.1%2Blinux.rar

I have included a link to this in the main post. I don't see why this couldn't be part of 3.3.1 alpha 2. I saw your thread and branch about this feature and was wondering why there wasn't a pull request yet.

I can't test how the builds work because I don't run Linux. They certainly seem like they're being built though! I guess I could try it out in a VM at some point.

The "linux" directory, however, does feel wrong to me somehow. I know that the directory structure of an AGS game isn't great to start with, but it would be nice to organise the directories like so:

Compiled\Windows\
Compiled\Linux\

And then, of course, if "automatically build for all available ports" is unchecked, revert to the old behaviour of dumping the Windows .exe directly into compiled:

Compiled\

But I don't know... would that kind of reorganisation break anything? We might need to update the editor "delete all" code so that it recursively deletes directories inside Compiled\. Having this kind of hierarchy would also ensure Linux files are deleted when the editor rebuilds for Windows only.

Edit: Oh gosh, sorry monkey_05_06, I probably should have posted this in your test thread.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Crimson Wizard

Quote from: Gurok on Mon 05/05/2014 07:23:59
Quote from: monkey_05_06 on Sun 04/05/2014 20:44:25
I made a combined build of the new 3.3.1 alpha with the Linux compilation. Hope you don't mind me piggybacking this onto your release. (roll)

https://bitbucket.org/monkey0506/ags/downloads/3.3.1%2Blinux.rar

I have included a link to this in the main post. I don't see why this couldn't be part of 3.3.1 alpha 2. I saw your thread and branch about this feature and was wondering why there wasn't a pull request yet.

Maybe people will look at this first and tell if that's ok the way it's done? Just to be sure that it is made conveniently. Just suggesting.

Also, Gurok raised good point about directory structure.

monkey0506

Quote from: Crimson Wizard on Mon 05/05/2014 08:08:24
Quote from: Gurok on Mon 05/05/2014 07:23:59I saw your thread and branch about this feature and was wondering why there wasn't a pull request yet.

Maybe people will look at this first and tell if that's ok the way it's done? Just to be sure that it is made conveniently. Just suggesting.

Also, Gurok raised good point about directory structure.

Yes, this is the reason there's not a pull request yet. (Well that, and I have several intermediary commits that don't need to be part of the main repo's history. Once I get a build that everyone's generally happy with then I'll dump it all into a single "initial" commit and pull that in instead.) ;) Agreed about the points you raised, and yes, to prevent clogging this thread up let's continue discussion about it in this thread. A few items were brought up there that I will be working on.

Calin Leafshade

Quote from: monkey_05_06 on Mon 05/05/2014 17:24:47
Once I get a build that everyone's generally happy with then I'll dump it all into a single "initial" commit and pull that in instead.) ;)

Look up "rebasing"

Crimson Wizard

Quote from: monkey_05_06 on Mon 05/05/2014 17:24:47
Once I get a build that everyone's generally happy with then I'll dump it all into a single "initial" commit and pull that in instead.) ;)

Quote from: Crimson Wizard on Sun 16/02/2014 15:50:35
It is strongly suggested to not put all the changes you make into one commit without consideration. When reviewing the history of changes it is very important to understand what has changed and why. Also, sometimes when looking for a source of bug we may walk down the history of commits, looking for the one which introduced the error: in this case it really helps when every commit has only task- and thematically related changes.
http://www.adventuregamestudio.co.uk/forums/index.php?topic=50001.msg636481384#msg636481384
;)

Gurok

#43
Hello all,

AGS 3.3.1 Alpha 2 is out. You can download it here:

Download 3.3.1 alpha 2 as a .zip archive



Changes from 3.3.1 Alpha 1:



Engine

Bug Fixes

  • 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

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.

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.



Editor

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.



This build also includes everything in AGS 3.3.0 Hotfix 3 (including the updated templates).
[img]http://7d4iqnx.gif;rWRLUuw.gi

Crimson Wizard

#44
Gurok, I just found a compiler bug: it does not restrict dynamic arrays in managed structs (although that's too a pointer).
Guess I forgot to check that particular case.


E: elaborating to users: it actually will work, but will cause memory leaks in program (which may result in various problems).

Gurok

Quote from: Crimson Wizard on Thu 31/07/2014 15:12:36
Gurok, I just found a compiler bug: it does not restrict dynamic arrays in managed structs (although that's too a pointer).
Guess I forgot to check that particular case.

Sorry! I quickly patched it locally and updated the link (a bit cowboy, I know). Should be better now. I will make a pull request for the extra compiler warning soon (tomorrow).
[img]http://7d4iqnx.gif;rWRLUuw.gi

Crimson Wizard

Quote from: Gurok on Thu 31/07/2014 15:32:02
Sorry! I quickly patched it locally and updated the link (a bit cowboy, I know). Should be better now. I will make a pull request for the extra compiler warning soon (tomorrow).
You may simply send me a patch and I'll apply it right into main branch.

Sslaxx

This isn't exactly a major feature request, but allowing "... } do" at the end of a while loop (to provide syntactic symmetry with the "do while" loop) would be nice.
Stuart "Sslaxx" Moore.

Crimson Wizard

#48
Post deleted :tongue:, sry nevermind.

Alberth

But the "do" is a prefix for the statements ("do x = 1;" rather than "x = 1; do"), just like "while" a prefix is for the condition. (Technically the "while" is thus not at the end of the "do while" since the condition follows).

The only somewhat feasible alternative is probably "while ... do { ... }", like Pascal had. The parentheses around the condition after the "while" make the "do" unneeded in this case.

In all cases, the syntax would be different from what the zillion C/C++/Java programmers are used to, which seems to be a major source of inspiration for the AGS language. That makes it highly unlikely to happen.

Calin Leafshade

agreed. while() {} do; is not correct form basically everywhere.

deltamatrix

Wow great job!

One thing I'd like to ask for. I noticed ages ago that when you assign the function names for interactions (i.e: for Hotspots), you were limited to use only functions in the room script and not global script functions - this caused for me a lot of duplicated code across the room scripts.
BAD WOLF - TORCHWOOD - MR SAXON - THE BEES ARE DISAPPEARING - PANDORICA - RIVER SONG

Crimson Wizard

#52
Quote from: deltamatrix on Sun 10/08/2014 17:38:11
One thing I'd like to ask for. I noticed ages ago that when you assign the function names for interactions (i.e: for Hotspots), you were limited to use only functions in the room script and not global script functions - this caused for me a lot of duplicated code across the room scripts.
Not that I am principally against this suggestion, but there are numerous ways to reduce code duplication, such as intercepting mouse clicks on hotspot in global script, or calling other, "generic", functions from room event handlers.
It is even possible to not having a room script at all.
Perhaps if you'd give some example of duplicated code you have, we could find a solution for you.

deltamatrix

Thats very true. I envision good programming practice within AGS using jQuery-like event detection (lambda expressions/Closures 4 AGS?? :cheesy::cheesy::cheesy:)

The example was Look at Bush which calls a global function with random descriptions. This game was Hero6 which had a lot of forest screens each with bush hotspots. Therefore the duplication was in the repeated calling of the global function in each room.
BAD WOLF - TORCHWOOD - MR SAXON - THE BEES ARE DISAPPEARING - PANDORICA - RIVER SONG

Crimson Wizard

#54
Quote from: deltamatrix on Mon 11/08/2014 14:06:57
The example was Look at Bush which calls a global function with random descriptions. This game was Hero6 which had a lot of forest screens each with bush hotspots. Therefore the duplication was in the repeated calling of the global function in each room.

Code: ags

function on_mouse_click(MouseButton button)
{
    if (GetLocationType(mouse.x, mouse.y) == eLocationHotspot &&
        Game.GetLocationName(mouse.x, mouse.y) == "bush")
    {
        ProcessBushInteraction(mouse.Mode);
    }
}


:=

EDIT: You could use "unhandled_event" function, that would be more logical, but it won't work properly if interaction was triggered not by mouse.
Code: ags

function unhandled_event(int what, int type)
{
   if (what == 1 && type == 1) // look at hotspot
   {
       if (Game.GetLocationName(mouse.x, mouse.y) == "bush")
       {
           LookAtRandomBush();
       }
   }
}

Billbis

#55
Great works!
I'm a bit late, but I would like to make a couple of comments about the new CharacterDirection enum.
- It would be nice to have a build-in FaceDirection function. Sure, it is easy to code with some AGSscript, but the very first things I'm doing in every AGS project I start is recode it, because I found it so useful. I should probably be able to implement it myself, if only I knew how to compile a C++ program on Windows platform. :-D
- Would it make some sense to have a eDirectionNone in the enum? That way you can make some functions that use it as an optional parameter:
Code: ags
// header
import void Use(this Character*, CharacterDirection = eDirectionNone);

// script
void Use(this Character*, CharacterDirection Dir)
{
    int view;
    if (this == cEgo) {
        view = 10; //La view Utilise de Ego
    } else if (this == cRoger) {
        view = 15; //La view Utilise de Roger
    } else {
        return;
    }
    this.FaceDirection(Dir, eBlock);
    this.LockView(view);
    this.Animate(this.Loop, 5, eOnce, eBlock);
    this.UnlockView();
}

But maybe I'm missing something. It seems I can't set my optional parameters to null (compiling error), so a eDirectionNone would be (relatively) useful.

Crimson Wizard

Quote from: Billbis on Mon 11/08/2014 19:21:59
I should probably be able to implement it myself, if only I knew how to compile a C++ program on Windows platform.
If you may build it on Linux, for instance, you could do that too, because both versions share nearly same code.

Crimson Wizard

Any plans on checking out why AGS does not allow to put non-managed structs into structs?
I don't think it needs any breaking changes, it's just inserting nested data chunk; in engine memory it will be just the seamless array of data, just like any simple struct.
Probably compiler is not taught to track nested offsets.

Gurok

#58
I haven't thought about it, but I'll put it on my list of things to investigate.

Current priorities are:
-- Investigate destruction of stack struct variables that contain pointers to user objects (something seemed weird about the way they were cleaned up)
-- Modify the script format to support writing out parts of the symbol table for RTTI
-- Implement switch...case
-- Function pointers, type coercion for floats<->ints, etc (these are more things I'd like to put up for discussion before even attempting)

Quote from: Billbis on Mon 11/08/2014 19:21:59
eDirectionNone would be (relatively) useful.

I meant to comment on this a while ago. I think both this and the FaceDirection suggestion are worthy of inclusion in the standard library, but I don't know how others feel. I also implement this in most projects. I tend to call it "eDirectionUnknown" because you aren't facing none, you're just not specifying the direction faced. Right now, I think all the directions in the direction enumeration have a 1:1 mapping with loops. Not sure if we need to consider that when adding eDirectionNone.

Also, regarding the standard library of functions, there's one that seems peculiar to me:

Code: ags
GetRoomProperty(const string property);


No idea why this is a global function and not a static function on the room (like Room.GetTextProperty). Would anyone object to tidying that up?
[img]http://7d4iqnx.gif;rWRLUuw.gi

Crimson Wizard

Quote from: Gurok on Fri 22/08/2014 18:06:51
I meant to comment on this a while ago. I think both this and the FaceDirection suggestion are worthy of inclusion in the standard library, but I don't know how others feel. I also implement this in most projects.
We already have optional direction argument to Character.ChangeRoom, so I don't see a reason not to.

Quote from: Gurok on Fri 22/08/2014 18:06:51
I tend to call it "eDirectionUnknown" because you aren't facing none, you're just not specifying the direction faced.
Hmm, I'd rather vote for "eDirectionNone" to comply with other similar constants (e.g. eKeyNone).
Its value should probably be "SCR_NO_VALUE".

Quote from: Gurok on Fri 22/08/2014 18:06:51
No idea why this is a global function and not a static function on the room (like Room.GetTextProperty). Would anyone object to tidying that up?
Its global because 100% of old AGS script API was global. OO-style was introduced around 2.7, and still not complete.
Just leave existing one under #ifndef STRICT for backwards compatibility (there are many examples around the header).

Gurok

Quote from: Crimson Wizard on Fri 22/08/2014 18:32:52
Hmm, I'd rather vote for "eDirectionNone" to comply with other similar constants (e.g. eKeyNone).
Its value should probably be "SCR_NO_VALUE".

Of course! I'm totally on board with that and the other comments you made. I just wanted to check that I wasn't randomly adding features when these possibly show up as pull requests in the future.
[img]http://7d4iqnx.gif;rWRLUuw.gi

SMF spam blocked by CleanTalk