Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Crimson Wizard

#681
If this is about having many items to check in a single "if", like in Khris's example:
Code: ags
if (player.HasInventory(iRope) && player.HasInventory(iHook) && player.HasInventory(iInsurancePolicy)) {

Then what you may use instead is a list of required items, which you would iterate in a loop and test whether each of these items exist. Such list could be created in various ways, even as a comma-separated list in String, for example. The only issue would be to convert a textual name into inventory item's pointer or ID.

Simply hypothetically, it could look like this:
Code: ags
if (TestAllItems("iRope, iHook, iInsurancePolicy")) {
}
where TestAllItems would parse the string and check for all the items there.

But I am currently speculating, as I do not see your real code, so I don't know which kinds of cases you are trying to work on.
#682
Quote from: Stranga on Mon 26/12/2022 23:54:33It was only to check if the player had certain items then the other character would respond without having to type long lines with "if" and "else" statements.

I guess I could run a loop check to check all items in the game and use their ID in a switch statement that way but wasn't sure if it was exactly possible to do so?

I honestly do not see how having a switch inside a loop over all items would help you to achieve what you want in the above case (simplier code).

What exactly do you want to make simpler? Do you have a response per item, or a response per a combination of items?
#683
I do not understand full situation here, but may mention this article about order of game events and script callbacks:
https://adventuregamestudio.github.io/ags-manual/GameEventsOrder.html

Perhaps it will help to know when to do, after you find out what to do.
#684
Quote from: jumpjack on Mon 26/12/2022 16:52:44My character apparently has .z and .Baseline values constantly = 0 while it moves around the room (I put their values into a label in global script, together with x and y). Should I enable anything to get them updated?

Additionally, "z" looks more like a "real world" value rather than an "engine value", as if I manually increment .z, the character raises, but if I increment .Baseline, character does not move, but it gets drawn behind some objects with different baslines...

When Baseline reports 0 that means that Character's Y is used instead. If you set Baseline to something besides 0 that would use that fixed value regardless of character's location.
https://adventuregamestudio.github.io/ags-manual/Character.html#characterbaseline

Character's "z" is a special graphical offset by Y axis, which does not affect sorting at all. It's mostly a historical feature, used to simulate "levitating" while keeping same y position in the room.
https://adventuregamestudio.github.io/ags-manual/Character.html#characterz
#685
So, room background is always behind everything, so whatever you draw there will always be behind.

Characters, room objects and walk-behinds have Baseline property, that determines their sorting on screen. By default character's and object's baseline is automatically bound to their Y position. Setting Baseline to any custom value will override it, and let you sort these objects differently.

Since AGS 3.6.0 Overlays use ZOrder property, but that's essentially the same (it was called to match the GUI's property of same name). If you create overlays on the room layer, their ZOrder will sort among other room elements' baselines.

EDIT: Oh, right, Overlays have their ZOrder set to some very low negative value by default, this is for backwards compatibility with older versions of AGS, where they were always drawn behind GUIs. Possibly this was a design mistake to keep exact behavior for room overlays, but it is like that right now.

EDIT2: So, if you like to have Overlays sorted by the same rule as Characters and Room Objects, you need to set their ZOrder to their bottom Y position.
#686
The documentation for Overlay.CreateGraphical also sais this:
Quoteif the Overlay variable goes out of scope, the overlay will be removed. Hence, if you want the overlay to last on-screen outside of the script function where it was created, the Overlay* variable declaration needs to be at the top of the script and outside any script functions.

If you want overlay to remain after the function is finished, you need a global variable (declared outside of the function).
The creation of overlay remains inside a function (as AGS script does not support calling functions in the global scope).

For example:
Code: ags
Overlay *myOverlay;

function Room_AfterFadeIn()
{
    myOverlay = Overlay.CreateGraphical(100, 100, 300);
}
#687
@vga256,

The documentation appears to be wrong where it sais that "Ghost GUI" works with everything.

The reason why "Ghost GUI" does not work for GUI & controls is quite simple. With "Ghost" GUI/Overlay the module must draw the dragged object on that GUI/Overlay. With characters and objects this is straightforward: you draw their current sprite (or animation frame). But with GUI it's not easy: there's no way to ask AGS to draw a GUI or control on a drawing surface or a dynamic sprite, so I would have to reimplement virtually whole GUI drawing in script! Naturally, I decided to not do that.

One may speculate that this could be worked around using a screenshot feature, but this approach will be additionally complicated by other screen elements which would have to be hidden (and that's not reliably possible to script in the module, I think).

Another workaround would be to only support controls which are drawn using sprites:
* Empty GUIs with background image and nothing else;
* Buttons which have a graphic assigned to them.

With the current module though, you would have to resort to scripting a custom drag-drop mode. The easiest method may be to replicate "Ghost GUI" or "Ghost Overlay", but let it set any image instead of knowing what AGS object you're dragging. You may follow examples in documentation, or use either demo game or DragDropCommon module as an example.
#688
Updated to RC4 (3.6.0.39)
(use download links in the first post)

Editor:
- Fixed project tree items not updated when changing item ID.

Engine:
- Various performance optimizations for both raw drawing and texture updates (Direct3D/OpenGL). (This will be mostly noticeable in high-resolution games.)
- Fixed software renderer may have an unpainted black line at the bottom, if there's a GUI or Overlay positioned partially offscreen.
- Fixed Parser.Said() could lead to a program crash in case there are space-separated words following the comma (e.g. "climb,get in bed").


Reported issues remaining:
* GUI controls incorrectly blend (mix colors) with the parent GUI if parent's transparency is anything but 0. Unfortunately this takes longer than expected to fix, because some of the new feature should be rewritten. This is related to the rendering performance optimization, which proved to be too significant to drop.
* Direct3D is said to still be not fully stable when alt+tabbing in exclusive fullscreen mode: https://www.adventuregamestudio.co.uk/forums/ags-engine-editor-releases/ags-3-6-0-release-candidate-rc1/msg636650995/#msg636650995
* Linux port cannot load a AGSSteam plugin. There's a workaround mentioned right above this post.
#689
Quote from: Snarky on Wed 21/12/2022 17:13:04Did you perhaps mean to use Character.ActiveInventory? In that case, you could do something like:

AFAIK in AGS you can also use Character.ActiveInventory directly in a switch, and compare to item script names:
Code: ags
switch(player.ActiveInventory)
{
case iKey:
case iBlueCup:
}
#690
@Stranga, please clarify, what are you trying to achieve with this, what this code is for? The answer will depend on that.
#691
There's a sudden problem found, that 3.6.0 seem to not able to load a Steam plugin correctly on Linux.
According to the log output, it finds and tries to load `libagsteam.so`, but then fails to load a `libsteam-api.so`, which is a dependency of `libagsteam.so`. The reported error is "No such file or directory", although the file is right there in the same dir.

Other plugins load fine, which makes me think this problem manifests when the plugin itself requires a second library.

I've been testing older builds of 3.6.0, but none work so far, including versions which are year and more old.

Have anyone else tried using 3.6.0 on linux with the steam plugin yet?


EDIT

So, this looks like not an engine's own problem, but the engine's build / setup issue. I still do not know what exactly did change in 3.6.0, but now it may require a different launch script on linux to make it work with the steam plugin. Namely add "LD_LIBRARY_PATH" option.

Something like:
Code: sh
if [ "$(uname -m)" = "x86_64" ]; then
    LD_LIBRARY_PATH="$scriptdir/data/lib64" "$scriptdir/data/ags64" "$@" "$scriptdir/data/"
else
    LD_LIBRARY_PATH="$scriptdir/data/lib32" "$scriptdir/data/ags32" "$@" "$scriptdir/data/"
fi

Alternatively:
Code: sh
if [ "$(uname -m)" = "x86_64" ]; then
    export LD_LIBRARY_PATH="$scriptdir/data/lib64":$LD_LIBRARY_PATH
    "$scriptdir/data/ags64" "$@" "$scriptdir/data/"
else
    export LD_LIBRARY_PATH="$scriptdir/data/lib32":$LD_LIBRARY_PATH
    "$scriptdir/data/ags32" "$@" "$scriptdir/data/"
fi

We'd need to adjust the Editor to generate a launch script with this addition.
#692
Quote from: lapsking on Sun 18/12/2022 11:23:29Thanks a lot Crimson, you guys are so helpful and kind. I already had AGS 3.6 beta, opened the game with it and problem is solved. But is it safe to use AGS 3.6 beta? I'm asking because it seems it's not officially released.

More or less, and some people are already making games with it. But there are couple of known bugs, which we are trying to resolve at the moment. There's a chance that you won't notice them, depends on what do you have in your game.

These known problems are mentioned in the end of this post:
https://www.adventuregamestudio.co.uk/forums/index.php?topic=60323.0

#693
This is a known issue with how AGS draws some fonts historically.

I believe this should be fixed in 3.6.0, where it calculates font sizes better.
Also, since AGS 3.6.0 there's a setting called "TTF font adjustment", that lets fix fonts that were previously drawn too low. It should normally be set to "Do nothing".

If you're using a previous version, like 3.5.1, there are few possible workarounds:
* try adjusting font's Vertical Offset (but this may lead to upper part cut, if you're unlucky);
* try finding another font;
* script custom speech / display text, where you create a textual overlay yourself, instead of relying on AGS calculations.
* upgrading to 3.6.0, if you like.
#694
From what I understand, newer editors do not provide any means to edit the Global messages.
The relevant article in the manual:
https://adventuregamestudio.github.io/ags-manual/UpgradeTo30.html

QuoteGlobal Messages

Global Messages are no longer supported and should be considered obsolete -- there's really no need for them now that the interaction editor has gone. Any global messages that you had will be retained and will still work, however the AGS 3 editor provides no way to edit them.

So, they simply stay in data, and may be edited by hand in Game.agf (if you're careful, but it is simply an XML). They may also be completely removed using "File -> Remove Global messages" command. Unfortunately, Editor also does not let automatically copy these messages over to some supported form, like into a script, or Global Variables, which is a shame, and clearly an oversight in the upgrade process.

Strangely, Room Messages can still be accessed (from the room properties), and seem to retain all the old options.


EDIT: I opened a ticket regarding this, but it's probably going to be low priority for the dev team.
#695
Quote from: Dave Gilbert on Fri 09/12/2022 14:40:16I feel like if it there was a memory leak, the crash would happen at random spots. But my my case it consistently happens at the same point.

Both situations are possible. If in your case it happens exactly at the same spot, that, in my opinion, might mean one of a few things:
1) In that spot you do some actions that allocate lots of memory at once. For example, create dynamic sprites or dynamic arrays in a loop.
2) Your game constantly requires a lot of memory, but in that particular case it allocates bit more and crosses the limit.
3) There's some bug in the engine, and you do something that triggers it, which in turn leads to engine allocating abnormal amount of memory.

How exact is the "point"? Is it certain interaction, a dialog, a cutscene?

EDIT: On a side note, I might remind again, that Windows version of the engine is still distributed as 32-bit, limiting the RAM usage to around 2 GB (iirc). If your game requires more memory under normal circumstance (if that is not a mistake), then it might need a 64-bit version of the engine.
#696
The problem with the "out of mem" error, is that when it happens nothing is safe anymore. The state of the program objects may be invalid, and any tiny extra allocation may fail in these circumstances.

Looking at the code now, it seems that I'd have to rewrite all the code related to getting the script location again, because at the moment it also allocates memory for the strings which store function call lists, etc.

But then, asking scripts about their current locations may also not be reliable and lead to a program crash, because "out of mem" could have happened while script was being created, or was allocating something during its run.

EDIT: I guess, theoretically this may be done by having a global preallocated buffer, and store this information there, updating as the game and scripts run... Then such buffer may be used when reporting error.
#697
Quote from: Dave Gilbert on Thu 08/12/2022 17:44:03Is it possible for these error messages to spit out where in the script the crash happened?

I think it may be possible to print the last known script location, but that won't necessarily help, as the "out of memory error" may occur virtually anytime, such as during game update or render, and not the script execution. Also, some actions in AGS are scheduled and postponed until after current script finishes.

For instance, PP=379 is in the middle of GUI redraw.

#698
Quote from: Snarky on Tue 06/12/2022 10:30:03I'm curious why you decided to make the acceleration multiplicative, @Crimson Wizard? It's not physically accurate, as now the actual acceleration is dependent on the speed (contrary to Newton's second law).

Maybe I began to forget these things. I'll change to addition.
#699
Added some code example above.
#700
You need to store Velocity in a variable, and increase velocity over time too.

So each game update you:
* increase Velocity by acceleration;
* change coordinates by velocity.

An example, using floats for more precision (smoother movement):
(this code assumes blocking animation, if you need non-blocking, then it should be updated inside repeatedly_execute instead)
Code: ags
float Accel = 0.2;
float Velocity = 1.0;
float YPos = IntToFloat(oRocket.Y); // current position of a rocket object
float YTop = SOME_NUMBER_YOU_WANT;

while (YPos > YTop)
{
    YPos -= Velocity;
    Velocity += Accel;
    oRocket.Y = FloatToInt(YPos, eRoundNearest);
    Wait(1); // let the game update and redraw
}
SMF spam blocked by CleanTalk