After changing player character inventory items don't respond normally.(SOLVED)

Started by Grim, Fri 07/12/2007 20:40:23

Previous topic - Next topic

Grim

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!

Khris

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.

Grim

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!

auriond

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?

Grim

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!

auriond

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:

Code: ags
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:

Code: ags
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.

Scorpiorus

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?

Grim

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:



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:)




Scorpiorus

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?

Grim

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?

Scorpiorus

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

Ashen

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:
Code: ags

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:
Code: ags

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.
I know what you're thinking ... Don't think that.

Scorpiorus

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.

Grim

Cheers Ashen!:)
It works fine now!! I'm happy again:)Yoo hoo!!


SMF spam blocked by CleanTalk