Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: Inventory item highlight  (Read 6032 times)

0 Members and 1 Guest are viewing this topic.

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Inventory item highlight
« on: March 08, 2011, 11:21:16 PM »

When clicking on an inventory item, the item is selected using

Code: WME Script
  1. Game.SelectedItem = ActObj;
  2.  

Then, when the cursor moves around and hovers over entities and actors, we see the CURSOR_HOVER icon, defined in the items.items file.

What I am trying to do is for some particular entities/actors to show a different hover image. I could not find the code in any script that is responsible for this behaviour so I assume it is built in.

Is there a way around it?
Logged

Mihulik

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Inventory item highlight
« Reply #1 on: March 09, 2011, 11:53:43 AM »

What about setting the particular hovered image of an entity as the sprite of the entity? :)
Logged

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: Inventory item highlight
« Reply #2 on: March 09, 2011, 04:54:04 PM »

Thanks Mihulik for your response but unfortunately I don't understand what you are trying to say  ::slug Could you please be a bit more thorough?

One solution is to set for every entity the MouseEnter event and change the cursor there. But this would be too much work and I am bound to miss something. I need something more dynamic like:

Code: WME Script
  1. if(!entity.CanHandleEvent(item.Name)){
  2.   //set mouse cursor to custom
  3. }
  4.  

Of course that could cause problems when the user moves the cursor away from the entity, where the cursor should be set back to the CURSOR image, as defined in items.items.

An important question is whether this is a built in function or if there is editable code for this. If there is indeed editable code that handles the cursor for inventory items, tweaking that code would easily solve my problem.
Logged

Mihulik

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Inventory item highlight
« Reply #3 on: March 10, 2011, 08:35:16 AM »

Oh, I misunderstood your question. I though you wanted something different. Forget my answer :)
Logged

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: Inventory item highlight
« Reply #4 on: March 14, 2011, 07:39:07 PM »

Not solved.

Come on guys more than 100 people saw this. Noone knows?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Inventory item highlight
« Reply #5 on: March 22, 2011, 10:06:31 AM »

I can't think of a better way than the MouseEntry approach.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: Inventory item highlight
« Reply #6 on: March 25, 2011, 04:25:56 PM »

Thanks Mnemonic. I have already achieved this using MouseEntry and MouseLeave events. We are building our game having in mind that we do not want those annoying "I cannot do that" or "You cannot use these things together" words from the game, which our team has learned to despise in even many great adventure games. The "different hover image" I have mentioned is to show to the players that using the item is not possible, in order to prevent them from doing the good old "try all items with all hotspots", which in my opinion reduces some of the atmosphere and realism of the game.

If anyone is interested in such approach check out the code below:

Code: WME Script
  1. on "MouseEntry"
  2. {
  3.         var item = Game.SelectedItem;
  4.         if(item != null && !this.CanHandleEvent(item.Name)){
  5.                 var defaultSprite = item.GetSprite();
  6.                 item.SetHoverCursor(defaultSprite + "_d.bmp");
  7.         }
  8. }
  9.  
  10. on "MouseLeave"
  11. {
  12.         var item = Game.SelectedItem;
  13.         if(item != null){
  14.                 var defaultSprite = item.GetSprite();
  15.                 item.SetHoverCursor(defaultSprite + "_h.bmp");
  16.         }
  17. }
  18.  

You need to have an extra icon for the item which is the "cannot make action" item. I named it the same as the normal icon with extra extension _d, similar to _h for the hover icon. It is simple but the only drawback is that you have to add this code to every actor and hotspot in the game.
Logged
 

Page created in 0.042 seconds with 25 queries.