ENGINE PLUGIN: AGSteam v3.4 (Windows; Linux; Mac OS X)

Started by monkey0506, Thu 27/10/2011 05:05:47

Previous topic - Next topic

JSH

Is there a way to detect if the steam overlay is open? I'd like to pause the game when that happens, since right now the game responds to mouse clicks and keyboard input when I chat with a friend using the overlay.

My first idea was just to simply intercept the shift+tab key combination in AGS but apparently the shortcut can be rebound in the steam settings...

*edit Not to mention, the overlay can be disabled altogether in the game options in steam too.

Dave Gilbert

The Steam overlay has been one of our biggest issues so far (third only to save game compatibility on updates and the inability to change resolution from within the game). AGS games react in really unpredictable ways when the overlay is activated. The game freezes, or dialog zooms by really fast, or any number of things. My theory, and it's only a theory, is that you are running the game natively in a very small resolution? The overlay is in a higher resolution, so displaying both at the same time tends to have unpredictable results. I've noticed that the higher resolution I run a game in (using the "max nearest neighbor filter" in the later versions of AGS) the fewer problems there are.

As for pausing the game when the overlay is active, I am unsure! It pauses fine when I use the overlay, but as I said the results tend to be unpredictable.

monkey0506

As far as the Steam overlay goes, the latest version of the Steam plugin uses the following code (released as part of the open-source stub):

AGSteamMain.cpp:162
Code: cpp
int AGS_EngineOnEvent(int event, int data)
{
    if (event == AGSE_FINALSCREENDRAW)
    {
        // use this as main_game_loop
        // the screen is drawn every actual game loop anyway
        AGSteam::Stub::GetAGSteam()->Update();
    }
    else if (event == AGSE_KEYPRESS)
    {
        typedef int (*IsKeyPressed_t)(int);
        IsKeyPressed_t IsKeyPressed = reinterpret_cast<IsKeyPressed_t>(engine->GetScriptFunctionAddress("IsKeyPressed"));
        bool isShift = ((data == 403) || (data == 404)); // is pressed key shift
        bool isTab = (data == 9); // is pressed key tab
        bool isShiftTab = ((data == 0x00001111) || // shift+tab as a single key
            ((isShift) && (IsKeyPressed(9) != 0)) || // key is shift and tab is held
            ((isTab) && ((IsKeyPressed(403) != 0) || (IsKeyPressed(404) != 0)))); // key is tab and shift is held
        return isShiftTab; // Claim (Shift+Tab), ignore other keys
    }
    return 0;
}


I added this when working on Al Emmo. I don't recall if Chris said this definitely fixed everything, but it attempts to force the engine to ignore the Steam overlay being opened and closed. As I recall, that seemed to be enough to stop AGS from going crazy in the background. If not, then I might consider having the plugin keep track of whether the overlay is open, but I was afraid of that somehow getting out of sync and causing worse problems. Just to be sure, you are using the latest version of the plugin linked in the first post?

P.S. As you obviously are a Steam developer, I could give you access to the full source code of the plugin if needed.

FNGames

My adventure game, Absent, was released on Steam recently!
http://store.steampowered.com/app/398450

Any chance you could add that one to the list on the front page?

I've updated the games' credits and put you in there for designing the plugin too. :)

JSH

Quote from: monkey0506 on Tue 15/09/2015 22:56:56
P.S. As you obviously are a Steam developer, I could give you access to the full source code of the plugin if needed.

Thanks a ton for the source code, it has saved so much time on my end! :)

Neo_One

If i understood, i don't have to write nothing in the code of my game only copy and paste the .dll library in the main proyect folder, ¿that's correct?.

m0ds

I am hearing of new issues with our game, in places where it has worked fine previously on Linux - is it possible the .so files are out of date compared to latest versions of Linux? Not knowing how Linux stuff really goes, thats the best I can come up with..

monkey0506

Sorry for the unresponsiveness folks. Latest binaries are up with some significant changes. AGSteam now supports unified builds by default (agsteam.dll). If you want to continue using the Steam-specific struct name of "AGSteam" in your game scripts, feel free to use the "disjoint" plugin (agsteam-disjoint.dll) instead. All this really changes is how you call the Steam functions, but the two versions (unified and disjoint) generally shouldn't be used together (theoretically they won't conflict, but there's just no reason to have both since they do the same thing).

@Neo_One: You don't have to even initialize the Steam API to release a game on Steam. A lot of Steam games don't use Steamworks, have no achievements, etc. You only need to use this plugin if you have achievements, and as such, you do have to tell the plugin when the achievements (etc.) should be set. You do this with some simple function calls, such as:

Code: ags
AGS2Client.SetAchievementAchieved("ACHIEVEMENT_01");


Where "ACHIEVEMENT_01" is the API name of your achievement (as set up on the Steamworks backend website). This is how Steam knows that the achievement has been unlocked. You would call this function whenever the player triggers the action that unlocks the achievement.

@Mark: Not sure, I'll look into it. I know Linux has been an on-going issue for you. I will contact you.

Dualnames

Script link failed: Runtime error: unrersolved import 'ASG2Client::SetAchievementAchieved^1'

Some of my users (others have no problems) get this, being unable to run the game at all. I'm using the AGSSteam Plugin only (Windows), any thoughts? It's driving me crazy.

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)

Dualnames

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)

Dualnames

Forgot to say that, the users having the problem are all on Windows, some even have the same exact Windows I'm using, and the issue happens regardless of whether Steam is up and running, or even installed at all. I run the game perfectly fine with Steam closed.
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)

monkey0506

I think it's probably this problem. Unfortunately there's no way for the plugin to know which version(s) of the Visual C++ Runtime any given user may have installed, though the engine itself does currently rely on the VC++2008 32-bit Runtime, so that probably would be the safest bet. I will take a look at recompiling all 6 plugins (AGSteam, AGSteamStub, AGSGalaxy, plus the "disjoint" builds of each) later today (hopefully) with VS2008 instead of VS2015.

proximity

Hi. Are Steam Achievements one time thing or do i need to supply them with extra variables to ensure that they are triggered only once ?

For example :

Code: ags
function repeatedly_execute_always() {
    int doitonce=0;
    if (score == 100) {
        if (doitonce == 0) {
            doitonce=1;
            AGS2Client.SetAchievementAchieved("ACHIEVEMENT_01");
        }
    }
}


or is this just enough ? :

Code: ags
function repeatedly_execute_always() {
    if (score == 100) {
        AGS2Client.SetAchievementAchieved("ACHIEVEMENT_01");
    }
}

Proximity Entertainment

monkey0506

Well a function-local variable would always be reset every time the function is called anyway. :P

However, Steam doesn't have any issues with you "setting" an already set achievement, so there's no harm in calling the function more than once. If you're worried about the unnecessary callbacks, you could try to cache the results in-game, but that could easily get out of sync. A more efficient solution might be to use the engine's built-in scoring system, using game.score and GiveScore. You could then have something like:

Code: ags
function on_event(EventType event, int data)
{
  if (event == eEventGotScore)
  {
    if ((game.score >= 100) && (Game.DoOnceOnly("ACHIEVEMENT_01")))
    {
      AGS2Client.SetAchievementAchieved("ACHIEVEMENT_01");
    }
  }
}


Then whenever you call GiveScore and the score exceeds or equals 100, the achievement is set, without having to poll for it every single game loop.

proximity

Quote from: monkey0506 on Sun 20/03/2016 07:03:47
Well a function-local variable would always be reset every time the function is called anyway. :P

However, Steam doesn't have any issues with you "setting" an already set achievement, so there's no harm in calling the function more than once. If you're worried about the unnecessary callbacks, you could try to cache the results in-game, but that could easily get out of sync. A more efficient solution might be to use the engine's built-in scoring system, using game.score and GiveScore. You could then have something like:

Code: ags
function on_event(EventType event, int data)
{
  if (event == eEventGotScore)
  {
    if ((game.score >= 100) && (Game.DoOnceOnly("ACHIEVEMENT_01")))
    {
      AGS2Client.SetAchievementAchieved("ACHIEVEMENT_01");
    }
  }
}


Then whenever you call GiveScore and the score exceeds or equals 100, the achievement is set, without having to poll for it every single game loop.

:grin::grin::grin: No no no :cheesy: I just gave an example to specify what doitonce is. In fact, I was planning to use global variables for that which are easy to use and recognised by all scripts. Additionally, I'm using a bit different scoring system; floats keep track of characters' stats in percent form. So, if calling an unlocked achievement causes no trouble to game-play, i can easily make this :

Code: ags
function repeatedly_execute_always() {
   if (charstat > 99.99) {
     AGS2Client.SetAchievementAchieved("ACHIEVEMENT_01");
   }
}


Thanks for the help monkey0506. That will save me from creating unnecessary variables. I have already tons of them and i wouldn't want to add any if it isn't absolutely necessary.
Proximity Entertainment

Neo_One

At last i'll use the plugin to insert achievement. But i have a question. Wich plugin of the list i  have to download to use it?.

shaun9991

RESOLVED - I MANAGED TO WORK THIS OUT. I missed a checkbox when setting the game up on Steamworks.

I've just released A Date on the Park on Steam, using this plugin. Quite a lot of users are reporting that the game doesn't run - please see this pic for the error report -



Any help is much appreciated! I've looked through the forum and seen that it could be an issue with DLL conflicts or Visual C++ Redistributable for Visual Studio 2015. Do you know if this is the case?

Many thanks,
Shaun
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

Crimson Wizard

#57
shaun9991, the error itself means that the AGS2Client plugin was not able to load (hence the game cannot use its script commands).

The question is why it happened. I would try to find out whether this plugin has any dependencies, like particular VisualC redistributable package has to be installed.

EDIT: Well, I could not find such information anywhere in this thread, or AGSClient thread (although maybe I missed it, a lot of text there).
However, since you know which plugin dll you are using, you can use dependency walker utility to find out which libraries it requires. Or tell us where we may download the plugin DLL, so that we could investigate.

Dualnames

From personal tests, it's the redistributables. I had my game installed on various OS and when i managed to replicate the problem, it was solved by installing VC libraries.
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)

shaun9991

Hi guys, thanks for your messages.

When I initally released the game on Steam, I had overlooked the fact that I needed to include VC redistributables. When I fixed this it solved 90% of the problems, however, some people are still reporting the same error, and a couple have reported this error: "The program can't start because api-ms-win-crt-runtime-|1-1-0.dll is missing from your computer. Try Reinstalling the program to fix this Problem"

I've packaged the game to automatically download VC2015 and 2008, as well as the latest .NET framework. Is there some other redistributables I should be including here?

Here's a link to the agssteam.dll file the game uses: https://www.dropbox.com/s/3wfys2vpp4j0e8j/AGSteam.dll?dl=0

I ran it through the Dependency checker but I'm not too sure what I'm doing... any help much appreciated!

Thanks
Shaun
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

SMF spam blocked by CleanTalk