Emoticon Script

Started by Scorpius, May 05, 2013, 08:17:49 pm

Previous topic - Next topic

Scorpius

May 05, 2013, 08:17:49 pm Last Edit: May 05, 2013, 08:19:05 pm by Scorpius
Hey again everyone! So I found this script by Ánemus, and I'm running into trouble with it and I wanted to see if anyone could trouble shoot it for me!

Script and needed image are below!
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>SCRIPT<<<<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
#                                                               #
#                        Emotions Script                        #
#                by Ánemus (www.arcadiumrpg.net)                #
#                                                               #
#  This script shows emotions over the player or over the other #
#                     characters of the map.                    #
#                                                               #
#                  $scene.emotion(id,ev,image)                  #
#                                                               #
#           For any comments: anemus@arcadiumrpg.net            #
#                                                               #
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>SETTINGS<<<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
#                                                               #
# Number of Repetitions or LOOP:                                #
# That's the number of times the animation of the emotion will  #
# repeat. I recomend 1, because bigger numbers are just way to  #
# repetitive.                                                   #
LOOP = 1
#                                                               #
# Delay:                                                        #
# That's the slowness of the animation. I recomend 3 or 4,      #
# smaller numbers are like flashes, so they aren't really       #
# useful.                                                       #
DELAY = 4
#                                                               #
# Deafult file for emotions:                                    #
# This is a tool to make it easier to use, this way you just    #
# write the id of the animation and the event where you want to #
# show it.
DEFAULTFILE = "balloon"
#                                                               #
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>INSTRUCTIONS<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
#                                                               #
# Whenever you want to use it just use Call Script command      #
# then write:                                                   #
# $scene.emotion(id, ev, image)                                 #
# Being id the number of the emotion in the file (the top one is#
# the 0 and the lowest one the 9), ev the event over which you  #
# are showing the emotion (being -1 for the player and any      #
# other number for events, and image, that is the image file    #
# that you are using for the emotions. This file is to be placed#
# on Pictures folder and should be 256x320 px.                  #
#                                                               #
# Some tips:                                                    #
# If you are using the emotion file specified in DEFAULTFILE    #
# you dont need to include it in the sentence.                  #
# $scene.emotion(id, ev)                                        #
# Now if you are using the default file and also placing the    #
# emotion on the main character, the sentence is reduced to:    #
# $scene.emotion(id)                                            #
#                                                               #
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>END<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#

#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>CODE<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<#
#===============================================================#
class Sprite_Character < RPG::Sprite
 alias :old_updateEmo :update
 def update
   old_updateEmo
   if @frames != nil
     @pic.x = (@character.screen_x + 5)
     @pic.y = (@character.screen_y - @ph - @ch.to_i+2)
     if @frames > (1 + LOOP*7)*DELAY
       @pic.zoom_x = 0.6
       @pic.zoom_y = 0.6
       @pic.opacity = 100
       @frames -= 1
       return
     elsif @frames > (LOOP*7)*DELAY
       @pic.zoom_x = 1
       @pic.zoom_y = 1
       @pic.opacity = 255
       @frames -= 1
       @iframe = 1
       @gota = 0
       return
     elsif @frames == 0
       @frames = nil
       @pic.bitmap.dispose
       @pic.dispose
       @picid = nil
       return
     else
       @pic.bitmap.clear
       @pic.bitmap.blt(0,0,RPG::Cache.picture(@picig),Rect.new(@iframe*32, @picid*32, 32, 32))
       @pic.zoom_x = 1
       @pic.zoom_y = 1
       @pic.opacity = 255
       @frames -= 1
       if @gota == DELAY
         @iframe += 1
         if @iframe > 7
           @iframe = 1
         end
         @gota = 0
       end
       @gota +=1
     end
   end
 end
 def emotion (id,ig="balloon",wt=false)
   if !FileTest.exist?("Graphics/Pictures/"+ig+".png")
     return 0
   end
   @frames = (2 + LOOP*7)*DELAY
   @picid = id > 9 ? 9 : id
   @picig = ig
   @pic = Sprite.new
   @pic.bitmap = Bitmap.new(32,32)
   @pic.bitmap.blt(0, 0, RPG::Cache.picture(@picig), Rect.new(0,32*@picid,32,32))
   @pic.ox = @pic.bitmap.width / 2
   @pic.oy = @ph = @pic.bitmap.height / 2
   @pic.z = 100
   if wt
     return @frames
   else
     return 0
   end
 end
 def dispose
   super
   if @pic != nil
     @pic.bitmap.dispose
     @pic.dispose
   end
 end
end
class Spriteset_Map
 def emotion (id,ev=-1,ig=DEFAULTFILE,wt=false)
   if ev.to_i > -1
     @frames = @character_sprites[ev].emotion (id,ig,wt)
   else
     @frames = @character_sprites[@character_sprites.size - 1].emotion(id,ig,wt)
   end
   return @frames
 end
end
class Scene_Map
 def emotion (id,ev=-1,ig=DEFAULTFILE,wt=false)
   $game_system.map_interpreter.wait_count = @spriteset.emotion (id,ev,ig,wt)
 end
end
class Interpreter
 def wait_count=(frames)
   @wait_count = frames.to_i
 end
end


Save image in Picture Folder as balloon.png!


It's giving me an error from line 143. (below)
      @frames = @character_sprites[@character_sprites.size - 1].emotion(id,ig,wt)


I made Common Events for each one and I know I did the call script commands properly. So I don't know what the issue is and I figured I'd give it a shot. Sorry for such ridiculousness!  :-* Thanks a head of time!  :^_^':

KK20

What is the exact error (let me guess... undefined method 'emotion' for nil class)? Any other scripts you have, and, if so, what is the order? You are using XP?

And, if all else fails, you don't need a script to pull this effect off.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Scorpius



And in Order my scripts are

UMS (Ccoa's)
This Emoticon script

Blizz ABS add ons

Blizz ABS
Blizz ABS fixes
Blizz EXP Bar

Modified Adv. Weather

and finally

Location Name Menu

Thank you for your help! I truly appreciate it! I hope to get back into the swing of things!


KK20

Spoiler: ShowHide
class Control_Sprite_Character < RPG::Sprite
  alias :old_updateEmo :update
  def update
    old_updateEmo
    if @frames != nil
      @pic.x = (@character.screen_x + 5)
      @pic.y = (@character.screen_y - @ph - @ch.to_i+2)
      if @frames > (1 + LOOP*7)*DELAY
        @pic.zoom_x = 0.6
        @pic.zoom_y = 0.6
        @pic.opacity = 100
        @frames -= 1
        return
      elsif @frames > (LOOP*7)*DELAY
        @pic.zoom_x = 1
        @pic.zoom_y = 1
        @pic.opacity = 255
        @frames -= 1
        @iframe = 1
        @gota = 0
        return
      elsif @frames == 0
        @frames = nil
        @pic.bitmap.dispose
        @pic.dispose
        @picid = nil
        return
      else
        @pic.bitmap.clear
        @pic.bitmap.blt(0,0,RPG::Cache.picture(@picig),Rect.new(@iframe*32, @picid*32, 32, 32))
        @pic.zoom_x = 1
        @pic.zoom_y = 1
        @pic.opacity = 255
        @frames -= 1
        if @gota == DELAY
          @iframe += 1
          if @iframe > 7
            @iframe = 1
          end
          @gota = 0
        end
        @gota +=1
      end
    end
  end
  def emotion (id,ig="balloon",wt=false)
    if !FileTest.exist?("Graphics/Pictures/"+ig+".png")
      return 0
    end
    @frames = (2 + LOOP*7)*DELAY
    @picid = id > 9 ? 9 : id
    @picig = ig
    @pic = Sprite.new
    @pic.bitmap = Bitmap.new(32,32)
    @pic.bitmap.blt(0, 0, RPG::Cache.picture(@picig), Rect.new(0,32*@picid,32,32))
    @pic.ox = @pic.bitmap.width / 2
    @pic.oy = @ph = @pic.bitmap.height / 2
    @pic.z = 100
    if wt
      return @frames
    else
      return 0
    end
  end
  alias dispose_emote dispose
  def dispose
    if @pic != nil
      @pic.bitmap.dispose
      @pic.dispose
    end
    dispose_emote
  end
end
Try this, pasted below the BlizzABS scripts. Not tested.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Scorpius

Still have the same error.  :shy:

KK20

In my post, delete the '< RPG::Sprite' part. It was working in my project.

Now I have to warn you that BlizzABS creates new characters all the time to the map. If you shoot a projectile and use the $scene.emotion(id) call while the projectile is still on the map, the emotion bubble will play over the projectile.

So basically, in other words, this script is not highly compatible with BlizzABS.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Scorpius

Thank you! It worked!  :^_^': Again thank you for your swift help as usual!