Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: Calintz on January 31, 2009, 10:36:09 pm

Title: [RESOLVED]Idle Animation...
Post by: Calintz on January 31, 2009, 10:36:09 pm
I was wondering if someone could make a script that will add animation to characters when you aren't moving them.

EX.
- Hair blowing in the wind
- Blinking
Title: Re: Idle Animation...
Post by: Landith on January 31, 2009, 10:57:36 pm
I'll give this a shot  :^_^':
Title: Re: Idle Animation...
Post by: Calintz on January 31, 2009, 11:00:23 pm
Thank you Landith!
Title: Re: Idle Animation...
Post by: Landith on January 31, 2009, 11:17:26 pm
Okay, this is what I have so far...
It doesn't work though.

Spoiler: ShowHide
class Game_Player
 
  attr_accessor :character_name_org
  attr_accessor :character_name
  def initialize
    super
    @character_name_org = @character_name
  end
  def update
    unless self.moving?
      @character_name = @character_name_org + '_idl'
      update_idle
    end
  end
  def update_idle
    if self.moving?
      @character_name = @character_name_org
      update
    end
  end
end


Someone can take over because I thought it would be easy but i was wrong...  :<_<:
Sorry Calintz...
Title: Re: Idle Animation...
Post by: winkio on January 31, 2009, 11:20:30 pm
wait, isn't this a built-in function of rmxp?  I'm pretty sure... lemme check...

EDIT: Yes, ok, I think I found it.  Setting a character's step_anime property to true should give it idle animation.  Hence, you code would look something like:

@character_name.step_anime = true

Yes, that should be it...
Title: Re: Idle Animation...
Post by: Landith on January 31, 2009, 11:23:07 pm
Are you talking about idle sprites?

Idle sprites aren't a built in RMXP Function, although it would have been nice to have...

@Calintz: I think you can use Blizz-ABS with it being compatible with your side-view system and use the sprite handling it uses without configuring anything else. I'm not sure though...
Title: Re: Idle Animation...
Post by: winkio on January 31, 2009, 11:25:42 pm
I edited my earlier post with it.

And... yes, they are built in.  Unless we are talking about two different types of idle sprites...

Oh, I get it.  you want to switch between two different sprites, am i correct?  One for idle, and one for movement?  Yeah, that's not built in...  I just thought you were talking about animating a sprite in place. :stupid:
Title: Re: Idle Animation...
Post by: Calintz on January 31, 2009, 11:33:59 pm
Yeah...switch between two separate sprites...

I didn't think it would be that hard actually...I thought it would just consist of something like if player is moving, then it would use one, but if no buttons are being pressed it would search the specified folder for a certain image and animate it...

I guess I was wrong, Lol...
Thanks anyway Landith!
Title: Re: Idle Animation...
Post by: Blizzard on February 01, 2009, 01:55:02 pm
Just check out how I did it in Blizz-ABS. It's all in BlizzABS::Controller and Map_Battler.
Title: Re: Idle Animation...
Post by: Calintz on February 01, 2009, 02:03:17 pm
I don't know ANYTHING about scripting sadly...
Title: Re: Idle Animation...
Post by: Blizzard on February 01, 2009, 02:21:19 pm
I meant winkio and Landith. xD
Title: Re: Idle Animation...
Post by: winkio on February 01, 2009, 02:21:58 pm
oh, fine, ill do it...  Give me a few minutes...
Title: Re: Idle Animation...
Post by: Calintz on February 01, 2009, 02:33:52 pm
Lol, you don't have to!!

- This IS a REQUEST!! I'm not picky, Lol
Title: Re: Idle Animation...
Post by: winkio on February 01, 2009, 02:55:38 pm
lol 48 lines!  It goes below defaults, above main, and just name your idle sprites the same as the character sprite with _idl on the end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  With idle sprites.  name the idle sprites the same as their normal ones
#  except with '_idl' on the end (before the extension)
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :character_name_org       # original character file name
  attr_reader   :current_sprite           # current sprite suffix
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias initialize_idlesprites_before initialize
  def initialize
    initialize_idlesprites_before
    # set original character name
    @character_name_org = @character_name
    # set current sprite
    @current_sprite = ""
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_idlesprites_before update
  def update
    update_idlesprites_before
    if @character_name != ""
      if moving?
        if @current_sprite != ''
          @step_anime = false
          @character_name = @character_name_org
          @current_sprite = ''
        end
      else
        if @current_sprite != '_idl'
          @character_name_org = @character_name
          @step_anime = true
          @character_name += '_idl'
          @current_sprite = '_idl'
        end
      end
    end
  end
end


I tested it and it worked fine.  An example of naming would be:
moving sprite: MainDude.png
idle sprite:     MainDude_idl.png
Title: Re: Idle Animation...
Post by: Calintz on February 01, 2009, 03:22:42 pm
Your a beast...
I will test it now =)

I know this is a small scriplet type thing, but you should make a quick demo and add it to the scripts section.

*powers up*
Title: Re: Idle Animation...
Post by: Blizzard on February 01, 2009, 04:01:50 pm
I think it has a bug - the same bug mine had when I made the first version.
The short moment where you are fully standing on a map square, even though you are pressing a movement button, would display the idl sprite for one short moment. I fixed this by adding "&& Input.dir4 == 0" (actually it was Input.dir8, lol) to the "moving?" condition. You should try out the script if it works normally. If it does, then this fix is unecessary.
Title: Re: Idle Animation...
Post by: Calintz on February 01, 2009, 04:24:10 pm
I will look for that bug now...
Title: Re: Idle Animation...
Post by: Landith on February 01, 2009, 04:27:06 pm
Good job Winkio!

*Powers Up*

I wish I could script...  :(
Title: Re: Idle Animation...
Post by: Calintz on February 01, 2009, 04:29:55 pm
Well...it's not working the way I wanted...

The sprite is idle, but just doing a moving animation. I have created a quick sprite alter that makes the character blink, but he isn't blinking, he is just moving in place...
Title: Re: Idle Animation...
Post by: winkio on February 01, 2009, 05:21:04 pm
Err, mine works fine.  Here, I'll put up a demo in a bit.

@Blizz: thanks for that.  I didn't test with a drastically different sprite so i didn't notice :).

Ok, here's the demo.  The idle animations are stupid, but that's all i could come up with in about 15 seconds.

http://www.sendspace.com/file/u8lbfo (http://www.sendspace.com/file/u8lbfo)

recopy the slightly-fixed version out of there.

ignore the other random left-over stuff in the demo.
Title: Re: Idle Animation...
Post by: Calintz on February 01, 2009, 05:27:51 pm
I don't know...it doesn't work for me :\
Title: Re: Idle Animation...
Post by: winkio on February 01, 2009, 05:32:30 pm
wait, the demo itself doesn't work?  Is anybody else having this problem?  I'm certainly not...

So am I correct in saying, Calintz, that when you run the demo, when the guy is standing in place, his arms/head don't move around?
Title: Re: Idle Animation...
Post by: Aqua on February 01, 2009, 05:34:06 pm
wink, the demo works for me.

Calintz, check your other scripts; one of them might be conflicting.
Title: Re: Idle Animation...
Post by: winkio on February 01, 2009, 05:34:58 pm
the thing is, that this one small 48-line script is THE ONLY CUSTOM SCRIPT IN THE DEMO.  So... wait, are you using PKE or some other version of RMXP?
Title: Re: Idle Animation...
Post by: Shadonking on February 01, 2009, 05:40:35 pm
i like this script i just wish i could had a good idle pose to have.

p.s im haveing no problems yet with it
Title: Re: Idle Animation...
Post by: Calintz on February 01, 2009, 07:21:38 pm
No!! The DEMO works perfectly, but the script is not running correctly in my game...
It is probably conflicting somewhere, but I don't know enough about scripting to check...

Besides, this wasn't a key feature of the game, soI can live without it, but I kinda wanted it.
Title: Re: Idle Animation...
Post by: winkio on February 01, 2009, 08:12:20 pm
tell me what scripts you are using, and I'll tell you the conflict, I might be able to help fix it...
Title: Re: Idle Animation...
Post by: Calintz on February 01, 2009, 09:03:58 pm
I am using these scripts...



That's it...
I can't really see why there is a confliction here...

Maybe with the WorldMap as it resizes the charaset and what not...
Title: Re: Idle Animation...
Post by: winkio on February 01, 2009, 09:08:23 pm
its either Worldmap, or Tons.  Most probably Worldmap if it resizes, and the lazy coder guy decreased its compatibility.  Send it to me, and I'll see if I can make it compatible

EDIT: better yet, upload your scripts.rxdata
Title: Re: Idle Animation...
Post by: Calintz on February 01, 2009, 09:25:40 pm
Like send it through like Sendspace or something??
Title: Re: Idle Animation...
Post by: winkio on February 01, 2009, 09:28:42 pm
sure
Title: Re: Idle Animation...
Post by: Calintz on February 01, 2009, 09:30:27 pm
I sent the link in the Shoutbox...
Title: Re: Idle Animation...
Post by: winkio on February 01, 2009, 09:40:31 pm
ok the conflict is with Tons part 1.  The caterpillar is doing it.  Let me see what i can do...

Are you using caterpillar?
Title: Re: Idle Animation...
Post by: Calintz on February 01, 2009, 09:48:50 pm
no I am not using the caterpillar effect...
Title: Re: Idle Animation...
Post by: winkio on February 01, 2009, 09:51:18 pm
ok, I was going to have you take it out, but I have a better solution:

go to line 2677 in Tons part 1 (DEAD_DISPLAY = 1) and change the value from 1 to 0.  Then you are done! (lol)
Title: Re: Idle Animation...
Post by: Calintz on February 01, 2009, 09:53:00 pm
Wait...are you serious, Lol??
Will that allow me to have full function ability of both scripts??
Title: Re: Idle Animation...
Post by: winkio on February 01, 2009, 09:54:35 pm
yes, it just wont show ghosts in caterpillar anymore, but I don't think that will be a problem :)
Title: Re: Idle Animation...
Post by: Calintz on February 01, 2009, 09:56:30 pm
Haha, not at all!!
Thank you very much, this is working perfectly now!!
Title: Re: Idle Animation...
Post by: winkio on February 01, 2009, 09:59:22 pm
Final version of the script, for anyone who wants it:
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  With idle sprites.  name the idle sprites the same as their normal ones
#  except with '_idl' on the end (before the extension)
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :character_name_org       # original character file name
  attr_reader   :current_sprite           # current sprite suffix
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias initialize_idlesprites_before initialize
  def initialize
    initialize_idlesprites_before
    # set original character name
    @character_name_org = @character_name
    # set current sprite
    @current_sprite = ""
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_idlesprites_before update
  def update
    update_idlesprites_before
    if @character_name != ""
      if moving?
        if @current_sprite != ''
          @step_anime = false
          @character_name = @character_name_org
          @current_sprite = ''
        end
      elsif Input.dir4 == 0
        if @current_sprite != '_idl'
          @character_name_org = @character_name
          @step_anime = true
          @character_name += '_idl'
          @current_sprite = '_idl'
        end
      end
    end
  end
end
Title: Re: Idle Animation...
Post by: Calintz on February 01, 2009, 10:00:06 pm
This is the same version as the one used in your DEMO, correct??
Title: Re: Idle Animation...
Post by: winkio on February 01, 2009, 10:00:47 pm
yes, just so that people don't have to download the demo if they don't want to.
Title: Re: Idle Animation...
Post by: Calintz on February 01, 2009, 10:01:29 pm
Good choice, and you will be added to my projects special thanks and script credits in 2.5secs...

Thank you Winkio...
Title: Re: Idle Animation...
Post by: Starrodkirby86 on February 01, 2009, 11:12:51 pm
So does that mean this topic is finally resolved? If so, Calintz you should add a [Resolved] Tag. :P

Why am I not doing it? Because I know you're a big boy Derek. :)

This script is extremely useful to have, I know that for a fact. Though I also know someone evented something like this...but hey, scripts are cool. :x
Title: Re: Idle Animation...
Post by: Calintz on February 02, 2009, 12:13:50 am
Haha, I forgot to add the resolved...I'm sorry StarrodKirby!! Right now =)
Title: Re: [RESOLVED]Idle Animation...
Post by: Fantasist on February 02, 2009, 09:18:27 am
I for some reason never touched this feature. *powers up winkio*

@winkio: You should post this in the scripts section or request Bliz to add it to Tons. Good job :)
Title: Re: [RESOLVED]Idle Animation...
Post by: Calintz on February 02, 2009, 04:25:38 pm
Ton, tons, tons!!
That would be great, because then maybe Blizzard would make it 100%compatible with the caterpillar script!! =)
Title: Re: [RESOLVED]Idle Animation...
Post by: winkio on February 02, 2009, 05:45:44 pm
Ugh, I don't want to go through all that trouble for 48 lines right now.  Especially when I'm desperately trying to finish the intro of my game, since I got behind schedule over the weekend :(.  I will sometime soon, though.
Title: Re: [RESOLVED]Idle Animation...
Post by: Calintz on February 02, 2009, 07:08:43 pm
Haha, okay ;)
Title: Re: [RESOLVED]Idle Animation...
Post by: winkio on June 26, 2021, 11:59:50 am
This is a massive gravedig, but someone messaged me on discord about fixing this script to be compatible with caterpillar ghosts.  I updated the script and put it in it's own thread here: https://forum.chaos-project.com/index.php/topic,16211.0.html