[Resolved] Emotions Script and Saving, Incompatible?

Started by Zangetsu, July 11, 2015, 04:38:34 am

Previous topic - Next topic

Zangetsu

July 11, 2015, 04:38:34 am Last Edit: July 11, 2015, 02:46:39 pm by Zangetsu
Hi, I'm using RPG Maker XP! I ran into a problem today that I hope to solve soon. :) I'll will put all the detail that I can.

So in my game I ran a parallel process, and this process uses the emotions script. I will post below, in spoilers in case this code is too large.

Spoiler: ShowHide
#===============================================================#
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>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 = 5
#                                                               #
# 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)
   @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


So I ran the parallel process with two set move routes for the two NPCs, so that they have emotions above their head as if they're arguing. I use parallel process as to not conflict with autoruns (if I put in an autorun and write "Wait for Completion", the move route will never finish, because it set on repeats).

But when I save and try to load my save file I get an error. Also below, an image, in spoilers:
Spoiler: ShowHide


EDIT: Seems the image does not work. Here is the direct link: http://sta.sh/0266wvtem63e

So when I load the save I get this error... it's because the engine doesn't recognise the "emotion" script that I added? It is an unfamiliar process? In any case please help me solve this! Thank you very much if you can. :)

I'm sorry if my English isn't great! I haven't had good practice for a while now. I'm a little rusty jaja :D
My name is Kitsuki.

KK20

From what you provided, I can only assume that somewhere in your scripts, you probably have a $scene.emotion lying somewhere. But there's no way I can really check.
You should just make a demo.

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!

Zangetsu

I do have a $scene.emotion, and it will be all right if I delete that and save without it, but I do want to keep this emotion scene...

Never mind actually! I've fixed this by simply adding in some wait frames at the beginning, to give the game some time before it runs that parallel process... I guess because "emotions" doesn't exist in the Scene_Load? So I make it wait for 10 frames, then it works!

But for some reason, the new project file that I started had no problems to load the script in the parallel process for emotions.

I have solved this and will be changing the title to mark it as resolved. :) Thank you for trying to help, though!
My name is Kitsuki.

KK20

Oh yeah, I remember someone having a similar problem like that before. The explanation is this:

When you load a game, $game_map is called to update BEFORE $scene is set to Scene_Map (currently, $scene = Scene_Load). The Game_Map update method will update any events on the map that may need it. For example, a treasure chest that has already been opened should look opened when the player enters the map. If you don't call the Game_Map update method BEFORE transitioning to the map, the treasure chest will appear closed, the game fades in, and then suddenly the chest pops open.

All map events are checked in this case, so your parallel process will execute immediately. Of course, your map event probably had a script event command $scene.emotion, and, since $scene is not Scene_Map yet, it will error.

Events will process as much of your event commands as it possibly can in this one frame. A Wait command will pause its execution for some X number of frames. As long as it's a one frame pause, you effectively stop it from running $scene.emotion and allow the game to make $scene = Scene_Map (and no more errors!).

In actuality, you can make the Wait be 0 frames long and that will be enough to stop the parallel process from executing the rest of your map event's commands.

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!