Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Grim on Fri 07/12/2007 20:40:23

Title: After changing player character inventory items don't respond normally.(SOLVED)
Post by: Grim on Fri 07/12/2007 20:40:23
Hi
I'm using AGS 2.61 version. It's based on Left and Right Click Open Source Template (ALARCOST) made by Daniel Hanley.
The problem I encountered is that at a certain point in the game player character is changed to different character. That works fine but I just discovered that every item that character picks up is undetectable in the inventory! Items upear in the inventory bar when picked up but when I click on them cursor doesn't change into these items' graphic and nothing happens therefore not allowing me to i.e. combine items or use them on hotspots. Look interaction( which here is under right mouse button) works okay.
  So why is that happening? So far I never had a problem like this and I hate it when things that are supposed to happen just don't happen....
This must be something to do with changing player character..but why? And how to fix it?
Please help me if you can guys!
Title: Re: After changing player character inventory items don't respond normally.
Post by: Khris on Fri 07/12/2007 20:53:43
Each character has its own inventory. If you want a common inventory, you'll have to either
a) add inventory items to the same character throughout the game
b) move every item to the new char upon changing the playable one, then update the inventory GUI window accordingly. (It has a property holding which character's inventory it's supposed to display).

You'll have to look up the old commands yourself though, sorry.
Title: Re: After changing player character inventory items don't respond normally.
Post by: Grim on Fri 07/12/2007 21:17:00
Thanks, but that is not the issue here. I don't want the common inventory. Inventory obviously changed  to that second character's inv because it's empty after the change. The problem is that all the new items this second character picks up cannot be used. And I just don't understand why....

i.e. character picks up a blanket. It appears in the inventory bar on top of the screen as it should. Then when I left-click on it it should change cursor into the blanket's picture from the inventory and I should be able to move it onto the hotspots or other inventory items...but that doesn't happen. The problem is that nothing happens when I click on it. Until I solve this I can't move on with my game!
Title: Re: After changing player character inventory items don't respond normally.
Post by: auriond on Sat 08/12/2007 02:30:21
So your first character has no problems with inventory and interaction, am I right? If you start the new character having an inventory item, is he able to use it? Or does it just happen with new inventory items that he picks up?
Title: Re: After changing player character inventory items don't respond normally.
Post by: Grim on Sat 08/12/2007 06:29:50
First playable character has no problems with inventory at all. The second one starts with empty inventory. At the swap I gave him one of the items that previous char was using just to check if it is the problem with the sprite of the new item being too big or something but that one also doesn't react to left-clicking.... So I wander if it's something to do with the template I'm building game on not being prepared for the multiple-character game?...Please help!
Title: Re: After changing player character inventory items don't respond normally.
Post by: auriond on Sun 09/12/2007 01:41:48
I can't find a working version of AGS 2.61, so I couldn't duplicate your problem. But looking at the scripting for the module, it looks like your problem might lie here:

else if (button == 5) {   // use selected inventory
      if (character[ GetPlayerCharacter() ].activeinv >= 0)
        SetCursorMode(4);
    }


Try duplicating the code, but specifying both your characters, and see if it works?

I haven't tried it out, but usually from there I would try:

else if (button == 5) {   // use selected inventory
      if (character[Ego].activeinv >= 0)
        SetCursorMode(4);
    else if (character[NewCharacter].activeinv >= 0
        SetCursorMode(4);


It might help to narrow down the problem.
Title: Re: After changing player character inventory items don't respond normally.
Post by: Scorpiorus on Sun 09/12/2007 11:01:35
Quote from: Grim Reaper on Fri 07/12/2007 20:40:23Items upear in the inventory bar when picked up...

Hmm, what do mean by "inventory bar" exactly?

As I see, the template in question comes with the built-in inventory dialog (invoked with the AGS' InventoryScreen( ) command) with its inventory item clicks handled by AGS automatically. So it should therefore work for any player character.

Or maybe you use your own custom inventory GUI?

Or are you indeed referring to that ICONBAR menu (Sierra-style) at the top of the screen with one of its buttons showing the currently selected inventory item, as we've been assuming so far?
Title: Re: After changing player character inventory items don't respond normally.
Post by: Grim on Sun 09/12/2007 15:44:42
Auriond- I'll check this out tommorow(got to go to work again now)but thanks, I hope it's gonna do the trick.

Scorpiorus- when I say inventory bar I mean this:

(http://i116.photobucket.com/albums/o27/kurwakurwakurwa/onthestairs.jpg)

That's what it looks like on this template. I hope this screenshot will shed some new light on what I'm talking about...It's just difficult to explain:)



Title: Re: After changing player character inventory items don't respond normally.
Post by: Scorpiorus on Sun 09/12/2007 18:43:07
Hmm, do you mean that inventory bar comes with the template, or did you add it yourself? I just can't seem to find anything like that in the ALARCOST template, could you tell us where you downloaded it from?

By the way, the problem may be with the way inventory clicks are handled in on_mouse_click, could you post the contents of that function?
Title: Re: After changing player character inventory items don't respond normally.
Post by: Grim on Sun 09/12/2007 19:47:21
I have to apologize for misinforming you at first- this template turns out to be a Broken Sword template, not LR Click...I got really confused 'cos I used to try LR Click first and...Oh nevermind. The point is:
-It's definetely a Broken Sword template
-Inventory bar came with it and I didn't alter it

I just found topic in Beginners Technical Questions relating to the same problem I experienced and it was solved then, but unfortunatelly behind closed door... Look at the link  http://www.adventuregamestudio.co.uk/yabb/index.php?topic=28592.0   
There it is described exactly like what I see when trying to use inventory. What should I do next? Contact those people and ask for solution? Or maybe it'll make you know what is wrong?
Title: Re: After changing player character inventory items don't respond normally.
Post by: Scorpiorus on Sun 09/12/2007 20:11:06
Ah ok so it is not ALARCOST :)

But which one exactly are you using? There is no anything with "Broken Sword" as a name:

http://www.americangirlscouts.org/agsresources/Templates.html
Title: Re: After changing player character inventory items don't respond normally.
Post by: Ashen on Sun 09/12/2007 22:23:00
It's on the skimbleshanks page. Scorpiorus.

Grim Reaper, now that we're looking at the right template ;):

There's a line in repeatedly_execute - it's line 88 in a new game, but if you've added code before that, I can't give an exact  number - that looks like this:

got_inv = character[EGO].activeinv;


I can't be bothered reading through the whole thing to figure out the sense of it, but it seems to change out of cursor mode 4 (UseInv) if got_inv is -1 (which should be the normal behaviour - like I said, can't be bothered working out the whole thing). When you don't have EGO as the player character, it doesn't update properly and you can't be in mode 4. (To me, it looks like the cursor changes to the Item for a split second then changes back - which would support this idea.)
Changing that line to:

got_inv = character[GetPlayerCharacter()].activeinv;


Works for me.

EDIT:
On a related note, it uses player.activeinv in unhandled_event. IIRR, the player pointer didn't update to when you change the player character before V2.7, so you might need to replace that with character[GetPlayerCharacter()].activeinv as well.
Title: Re: After changing player character inventory items don't respond normally.
Post by: Scorpiorus on Sun 09/12/2007 22:35:39
Ah hehe, I in fact tried one link to go there but it led me to a 404 page so I assumed the site is down.
I now found the right one though: http://www.freewebs.com/skimbleshanks/ :)

And yeah the problem is surely in having "EGO" instead of referencing the current player character with the GetPlayerCharacter() command.
Title: Re: After changing player character inventory items don't respond normally.
Post by: Grim on Mon 10/12/2007 10:54:26
Cheers Ashen!:)
It works fine now!! I'm happy again:)Yoo hoo!!