Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: inventory items  (Read 6815 times)

0 Members and 1 Guest are viewing this topic.

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
inventory items
« on: October 11, 2004, 01:46:33 PM »

Hi all,
       Is it possible to click on an item in your inventory and show it as a closeup image.
Let me explain: - You have a bottle of wine in your inventory.
you click on it with right mouse button - player menu appears. you select option EXAMINE.

The player then sees a large closeup view of the wine bottle and can read the label etc. clicking on a back button would send you back to the normal view.


In practice I think the closeup would be a scene with an entity/region for the back button.


But how would I code this? any ideas or test code I can try out.

I know how to do the scene and click on the back region to go back to the scene you looked at the item from. But how would I implement clicking on an item in inventory or is this catered for like clicking on an object in a scene?



Many thanks



 >:D




Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: inventory items
« Reply #1 on: October 11, 2004, 02:00:10 PM »

Quote
or is this catered for like clicking on an object in a scene?
Yes, it works exactly the same way. In your item's script there would be something like:

on "LookAt" // or whatever verb you are using for examining objects
{
  Game.ChangeScene("path\some.scene");
}


And that given scene would have to set actor.Active = false; in scene_init and call something like this after the back button is clicked:

Game.ChangeScene(Game.PrevSceneFilename);

...to return back to the calling scene.

The only tricky part is, that by reloading the original scene you'll lose the original actor's position. You'd have to handle this for example in the scene_init scripts of your scenes, to only setup actor's position/direction if the previous scene isn't one of those item close-ups.
For this reason, I'd recommend making the item close-up not a separate scene but rather a .window, which is placed over the original scene.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Jerrot

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
Re: inventory items
« Reply #2 on: October 11, 2004, 02:02:41 PM »

Is it possible to click on an item in your inventory and show it as a closeup image.

Good, good... you are developing good ideas on how to do things, good progress. :)
You don't need to create the close-up into a new scene though. The GUI windows can contain entities as well, so you could - for example - create a (full-sized) window containing your close-up as entity. And your "Back" Button would simply close the window and return to the game.

Darn, Mnemonic was faster again, aaargh. :)
Logged
Mooh!

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Re: inventory items
« Reply #3 on: October 11, 2004, 02:45:24 PM »

Many thanks guys. I think the window is the way to go.

 >:D
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Re: inventory items
« Reply #4 on: October 15, 2004, 12:31:04 PM »

ok I need to know how to combine items.

1. Items combined in inventory to make a new item.
 
Example: I have an empty bottle and a cork. I pick up the cork (left click) from inventory and place it on the cork in inventory and (left click) - result = cork item in inventory gone, bottle item with mouse pointer gone, item in inventory is now bottle with cork.



2. Items combined from inventory into a scene.

Example: I have an empty bottle and in the scene is a fountain. I pick up the empty bottle (left clcik) from inventory and place it on the scene on the fountain (entity in scene) the empty bottle changes to bottle of water against my mouse pointer. (left click) puts bottle of water in inventory.


3. Item combined with NPC

Example: I have a bottle of water and in the scene is an old man. I pick up the bottle of water (left click) from inventory and place it on the NPC (in the scene) and left click. The bottle of water disappears and the NPC animates a response.


Can I have some sample code to reflect these examples please.


Many thanks.
 
>:D
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

organican

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 74
    • View Profile
Re: inventory items
« Reply #5 on: October 16, 2004, 02:21:06 AM »

:) Ok, I'll try this as best as I can...

>ok I need to know how to combine items.
>1. Items combined in inventory to make a new item.
>Example: I have an empty bottle and a cork. I pick up the cork (left click) from inventory and place >it on the cork in inventory and (left click) - result = cork item in inventory gone, bottle item with
>mouse pointer gone, item in inventory is now bottle with cork.

In the bottle's script, make an event called <on "cork"> (if that's the name of the cork)
and then write a little code, like:

on "cork"
{ Game.DropItem("cork");
Game.TakeItem("cork_bottle");
actor.Talk("Here I am supposed to say something interesting.");
}

So now the actor dropped the bottle and instead you got the new bottle with the cork (you should make this bottle separately, it's easier to script and keep track of.

Just a note about the "on" thing: it seems really backwards-intuitive.
If you use the cork on the bottle you might think that it's the cork that should have on "bottle"
instead of the other way around. But it's the object you're using things on that has the "on something" in it.
And also, you don't have to declare the on "cork" or anything, it's automatic when you use an object on another. So whenever you have a new item, like an apple, you can just write in some object's script: on "apple" {here's what happens}.

>2. Items combined from inventory into a scene.

>Example: I have an empty bottle and in the scene is a fountain. I pick up the empty bottle (left >clcik) from inventory and place it on the scene on the fountain (entity in scene) the empty bottle >changes to bottle of water against my mouse pointer. (left click) puts bottle of water in inventory.

Ok. This is more tricky. The bottle have to have two different sprites or pictures for this.
And then you need a variable to keep track of the bottle's state (empty, full, etc...)
You have two ways to do this, you can either have different bottles, or the same bottle and change it's pictures dynamically.
(the second one is a bit more tricky and requires more scripting)

[... lots of code goes to waste]

No scrap that, I tried it out and came to the conclusion that it's easier to have separate bottles for full, empty, blood, wine, whatever.
So then in the fountains script you just say:
on "fullbottle" {...}
on "emptybottle" {...}
and so on, where fullbottle and emptybottle is different items.
so in your case you say:
(in the fountains script)

on "fullbottle"
{ actor.Talk("But it's already full of water."; }

on "emptybottle"
{ Game.TakeItem("fullbottle", "emptybottle");
Game.DropItem("emptybottle");
Game.SelectedItem = "fullbottle";
actor.Talk("Here, finally I say something cool...";
}

the "emptybottle" in
Game.TakeItem("fullbottle", "emptybottle");
is which object you're to insert it after in the inventory (this is optional, works with just "Game.TakeItem("fullbottle");").
then you just remove the old bottle with
Game.DropItem("emptybottle");
and then you make the new bottle selected from the inventory with
Game.SelectedItem = "fullbottle";
and then finally the actor says something cool.

the bad thing about this is that you have to have four differen bottles if
you can use the cork on each of them.

>3. Item combined with NPC

>Example: I have a bottle of water and in the scene is an old man. I pick up the bottle of water (left >click) from inventory and place it on the NPC (in the scene) and left click. The bottle of water >disappears and the NPC animates a response.

in the old man's script:

on "emptybottle"
{ Game.Interactive=false;
this.Talk("This bottle is empty.");
actor.Talk("I can see that..");
this.Talk("What would I want an empty bottle with?");
actor.Talk("Drink it??...");
this.Talk("OK.");
this.Talk("I now drink this bottle and give it back to you... the player that is...");
actor.Talk("Was it any good?");
this.Talk("Perfect. But I'm still thirsty. And I won't give you the apple until I get my dose of H2O.");
actor.Talk("Ok.");
Game.Interactive=true;
}

on "fullbottle"
{ Game.Interactive=false;
Game.DropItem("fullbottle");
this.Talk("Hey, thanx!");
actor.Talk("Glad you liked it.");
this.Talk("Here, have an apple. It's still fresh...");
actor.Talk("This is it!! Now I can finally solve the Wilhelm tell puzzle, where he's supposed to shoot an arrow throught my head but misses...");
Game.TakeItem("apple");
Game.Interactive=true;
}

The Game.Interactive=false is just so you can't go somewhere or do other things while they're talking. The "this.Talk" means that whoever this script's attached to talks.

Hope this helps..

(edit: I wrote actor.DropItem two times here... changed it to Game.Drop... (I use actor.TakeItem in  my game myself... both works, but Game.TakeItem and Game.DropItem, and so on, is standard)
« Last Edit: October 17, 2004, 10:51:34 PM by organican »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: inventory items
« Reply #6 on: October 16, 2004, 03:18:38 PM »

Thanks, organican. I will only add that you can also use DeleteItem instead of DropItem to permanently remove the item from game. In that case, make sure DeleteItem is the last command, since it deletes the script with it and so any other subsequent command won't be executed.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

organican

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 74
    • View Profile
Re: inventory items
« Reply #7 on: October 17, 2004, 10:58:29 PM »

Yes.
Since others have helped me here I wanted to return the favor.

I was in SBOVIS position not too long ago, not knowing how to do thing I wanted to do.
Just wanted to be the one who helps others for a change.
 :D
« Last Edit: October 17, 2004, 11:02:12 PM by organican »
Logged

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Re: inventory items
« Reply #8 on: October 18, 2004, 09:30:01 AM »

Many thanks Orgaincan and Mnemonic will give these a bash and let you know how I do.


Thanks.
 >:D
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Re: inventory items
« Reply #9 on: October 18, 2004, 11:37:32 AM »

ok I have items combined with items in Inventory, items combined with scene.

Items combined with NPC works too.

All I have left to look at where item management is concerned is the following:-


1. Item used on NPC, an animation then interupts, sprite animation or move to a new scene that is the animation and then back again to the original scene. If True then an object is created and is in the scene.

EXAMPLE: use spell potion on NPC, npc drinks and then disolves to skeleton, bones left to pick up in scene.

2. Item used on scene, sprite animation interupts, this causes something to happen in another scene where an item is left behind.

EXAMPLE: burn rope in scene A, rope burns animation, this opens a secret hole in the wall of scene B


Also if the player wants to talk to an NPC, use player option on player menu, can another scene be set up for a closeup animation of the dialougue and NPC and main actor etc and then after it has finished it automatically goes back to the scene you were in.



Any ideas on scripting these examples?? many thanks, I am getting the hang of this. Honest!! hahahaha

 >:D

 




Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: inventory items
« Reply #10 on: October 18, 2004, 02:35:43 PM »

You need to use a global variables for that. When some of the actions happens, set the variable to true. Then, the scene_init of a given scene should check the variable and setup the scene appropriately. So, when you re-enter the scene, the previous action will trigger some scene change via the variable. I believe you've done all of that before.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Re: inventory items
« Reply #11 on: October 18, 2004, 03:57:32 PM »

OK thanks thought that was the case, but did not know if there was any special way regarding items.


 >:D
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS
 

Page created in 0.06 seconds with 21 queries.