Using inventory on inventory crashes the game every time

Started by WanderingWizard, Mon 25/10/2021 01:43:43

Previous topic - Next topic

WanderingWizard

Hi all. I've just published a game for ScreamJam on itch.io, made in ten days. I seem to have gotten everything working before the deadline, except one little problem with a character animation, but that's not why I'm here... The main problem is one really big game-crashing error that takes place every time an inventory item is used on another inventory item... and on very rare occasions, clicking randomly in the inventory box will crash it as well. I originally scripted it from scratch, but I have copypasted a template version of the inventory handler in and it's still crashing any time you use an item on another item. It doesn't make the game unwinnable... just annoying.

The crash error is this:

Quote---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occurred in ACWIN.EXE at EIP = 0x0054C057; program pointer is +379, ACI version 3.5.1.10, gtags (1,1)

AGS cannot continue, this exception was fatal.

in "GlobalScript.asc", line 2148

(This line corresponds to whatever line the item interaction is on, and changes depending on which item you use on which item... there's nothing wrong with any of them as far as I can tell).

---------------------------------------------------------

I don't mind making the game code available to anyone, since I'm offering it for free anyway. Here's the source files (which includes the infodump for the error):
https://drive.google.com/file/d/1dKMRXhHRpv9RbKtRcb2ufWYcAW_WoVZN/view?usp=sharing

While you're checking that out, there are two more little issues I'm having which I haven't been able to solve yet, but are extremely minor in comparison...
-The "pointer" mouse mode keeps getting called even when I don't ask it to, particularly in the inventory screen. It should always be defaulting to Interact.
-In room 6, starting on code line 165 to the end, is the script for the climactic moment of the game. Thus, let me put this one in a spoiler tag:
Spoiler
A character starts running toward you, but gets shot before they can reach you. Not only does the character refuse to have their run animation play, but after they are shot, they keep having their 'getting shot' animation play as they glide back to their starting position.
[close]
I've messed with that code over and over, including adding a bunch of superfluous LockView and StopMoving commands, but to no avail. I know the code in there now is wrong, and probably full of spaghett, but it's only that way because I've been finagling with it for so long.
EDIT: I also just remembered one more issue: In one scene that I'm definitely aware of (maybe more), Wait() doesn't seem to work, and the numerical parameter for FadeIn and FadeOut are also not doing anything... no matter how high I set them, FadeOut(), Wait(), and FadeIn() gives me a quick fade to black and then an immediate fade back in. This takes place in GlabalScript.asc lines 1689 to 1709.

Any assistance would be greatly appreciated!


Crimson Wizard

I do not have a spare time to reply to your scripting problems right now, but the crash you depicted seems an error in the engine, and I definitely would like to check that out.

WanderingWizard

Whenever you get a chance, it doesn't matter... I can't upload a new version until the voting period for the jam ends in a week anyway. I still would obviously like to get a working version up since the game is part of a series, but I'm under no time constraints.

Thanks for your quick reply, and I'll be quite grateful for any help you may be able to offer (at your leisure!).

Khris

I took a look and found out it's not so much using an inventory item on another but simply the player saying anything while the inventory GUI is visible.
When I changed  player.Say("I fail to see what good that will do!");  to use  Display()  instead it didn't crash.
Next I tried
Code: ags
  gInventory.Visible = false;
  player.Say("I fail to see what good that will do!");
  gInventory.Visible = true;

This time the crash didn't happen before the speech was visible but immediately after I clicked it away.

I played around some more and apparently the crash is caused by AGS trying to grey out the inventory GUI's controls. If I set the game option (Visual / When player interface is disabled, GUIs should) to any other value, the crash doesn't happen.
Interestingly, like I said, Display didn't cause the crash and it turns out that despite Display being a blocking command, AGS doesn't grey out the controls while the Textbox is displayed.

Finally I made the character perform a blocking walk while the inventory GUI is displayed and the game crashed again. With the inventory not visible, the two other GUIs greyed out fine though.

TL; DR:
The inventory GUI's close button has two non-existent sprite numbers assigned to its normal and pushed images; resetting them to zero fixed the crash.

WanderingWizard

Wow. I wish I'd seen this before the forums went down. I've been losing my mind thinking not only would I never figure it out, but I'd never be able to get back here to see if anybody else did. That was harrowing!

Thanks so much, Khris, and for Crimson Wizard for your quick reply. I really love this community, and I'm glad to be back.

SMF spam blocked by CleanTalk