Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: random generic responses  (Read 3786 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
random generic responses
« on: June 17, 2004, 10:37:48 AM »

Hi all,
       Is there a way that you can create 5 animations that are randomly picked when the player does a BAD click on somthing.

Example: - The player tries to click and item from his/her inventory onto a scene
                The player tries to clcik an item onto an item in inventory to merge, build a new item.

The response is 1 of 5 animations showing the character srugging, shaking head etc.

Any GOOD clicking overrides the random responses for specific ones that are coded for. (eg. using the right key on a door lock etc)



Thanks.


Steve
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: random generic responses
« Reply #1 on: June 17, 2004, 10:52:52 AM »

Ok, there are two possibilities:

1) the player uses an item on the scene (*not* on any interactive object within the scene). By default that makes the character to walk to that point. IMHO you should keep this behavior, because it's more comfortable for the player.

2) the player uses the item on some interactive object (including other items). In that case a "default-use" event is triggered in the actor (the default scripts handle this).

So all you need to do is to edit the script attached to your actor and add the following handler:

Code: [Select]
on "default-use"
{
  switch(Random(1, 5))
  {
    case 1: actor.PlayAnim("bad_use_1.sprite"); break;
    case 2: actor.PlayAnim("bad_use_2.sprite"); break;
    // etc.
  }
}


In case of using the right combination, you can either incorporate the animation directly into the code which handles this combination or (if you want to play the animation everytime) you'd have to modify the standard game.script.
There is the following piece of code in game.script in the "LeftClick" handler:

Code: [Select]
    else if(Game.SelectedItem != null && Game.SelectedItem!=ActObj)
    {
      var Item = Game.SelectedItem;
      if(ActObj.CanHandleEvent(Item.Name)) ActObj.ApplyEvent(Item.Name);
      else if(Item.CanHandleEvent("default-use")) Item.ApplyEvent("default-use");
      else if(ActObj.CanHandleEvent("default-use")) ActObj.ApplyEvent("default-use");
      else actor.Talk("I can't use these things together.");
    }


You'd have to change it to something like:


Code: [Select]
    else if(Game.SelectedItem != null && Game.SelectedItem!=ActObj)
    {
      var Item = Game.SelectedItem;
      if(ActObj.CanHandleEvent(Item.Name))
      {
        // *******
        // add some special code when the combination is possible
        actor.PlayAnim("whatever.sprite");
        // *******
       
        ActObj.ApplyEvent(Item.Name);
      }
      else if(Item.CanHandleEvent("default-use")) Item.ApplyEvent("default-use");
      else if(ActObj.CanHandleEvent("default-use")) ActObj.ApplyEvent("default-use");
      else actor.Talk("I can't use these things together.");
    }
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: random generic responses
« Reply #2 on: June 17, 2004, 11:06:03 AM »

As always you deliver.

Many thanks for this Mnemonic will let you know the outcome.


Regards



Steve


Ps. Do not want to be the Lead programmer on my Commercial game using this engine do you??


Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re: random generic responses
« Reply #3 on: June 17, 2004, 02:26:41 PM »

Ps. Do not want to be the Lead programmer on my Commercial game using this engine do you??

Alternative you can search for team members here http://forum.dead-code.org/index.php?board=7.0  ;)
Logged
fl*p

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: random generic responses
« Reply #4 on: June 18, 2004, 08:29:39 AM »

Ps. Do not want to be the Lead programmer on my Commercial game using this engine do you??

Heh :) Thanks, but no thanks. My time is already very limited and I'm not intending to participate in any more projects.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.127 seconds with 21 queries.