RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

Savepoint

Started by Rune, May 20, 2007, 11:57:09 AM

0 Members and 1 Guest are viewing this topic.

Rune

Here's us a nice little script I put together :D

[spoiler=Script + Instructions]
Insert this above main and call it Scene_Savepoint

#+++++++++++++++++++++++++++++++#
#                        Savepoint Ver 1                            #
#                             By Rune                                  #
#+++++++++++++++++++++++++++++++#

# Window_Savepoint #

class Window_Savepoint < Window_Base
 def initialize
   super(0, 0, 320, 64)
   self.contents = Bitmap.new(width - 32, height - 32)
   refresh
 end
 def refresh
   self.contents.clear
   self.contents.font.name = "Tahoma"
   self.contents.font.size = 22
   self.contents.font.color = Color.new(0, 255, 0)
   self.contents.draw_text(100, 0, 96, 32, "Savepoint")
 end
end

# Window_Base edit #

class Window_Base
 def draw_actor_graphic(actor, x, y)
   bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
   cw = bitmap.width / 4
   ch = bitmap.height / 4
   src_rect = Rect.new(0, 0, cw, ch)
   self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
 end
 def draw_actor_name(actor, x, y)
   self.contents.font.color = crisis_color
   self.contents.draw_text(x, y, 120, 32, actor.name)
 end
 def draw_actor_class(actor, x, y)
   self.contents.font.color = Color.new(0, 255, 0)
   self.contents.draw_text(x, y, 236, 32, actor.class_name)
 end
 def draw_actor_level(actor, x, y)
   self.contents.font.color = system_color
   self.contents.draw_text(x, y, 32, 32, "Level")
   self.contents.font.color = normal_color
   self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)
 end
 def make_battler_state_text(battler, width, need_normal)
   brackets_width = self.contents.text_size("[]").width
   text = ""
   for i in battler.states
     if $data_states[i].rating >= 1
       if text == ""
         text = $data_states[i].name
       else
         new_text = text + "/" + $data_states[i].name
         text_width = self.contents.text_size(new_text).width
         if text_width > width - brackets_width
           break
         end
         text = new_text
       end
     end
   end
   if text == ""
     if need_normal
       text = "[Normal]"
     end
   else
     text = "[" + text + "]"
   end
   return text
 end
 def draw_actor_state(actor, x, y, width = 120)
   text = make_battler_state_text(actor, width, true)
   self.contents.font.color = actor.hp == 0 ? knockout_color : crisis_color
   self.contents.draw_text(x, y, width, 32, text)
 end
 def draw_actor_exp(actor, x, y)
   self.contents.font.color = system_color
   self.contents.draw_text(x - 16, y - 8, 24, 32, "Exp")
   self.contents.font.color = normal_color
   self.contents.draw_text(x - 64, y + 16, 84, 32, actor.exp_s, 2)
   self.contents.draw_text(x + 24, y + 16, 12, 32, "/", 1)
   self.contents.draw_text(x + 36, y + 16, 84, 32, actor.next_exp_s)
 end
 def draw_actor_hp(actor, x, y, width = 144)
   self.contents.font.color = system_color
   self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
   if width - 32 >= 108
     hp_x = x + width - 108
     flag = true
   elsif width - 32 >= 48
     hp_x = x + width - 48
     flag = false
   end
   self.contents.font.color = actor.hp == 0 ? knockout_color :
     actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
   self.contents.draw_text(hp_x - 44, y + 16, 48, 32, actor.hp.to_s, 2)
   if flag
     self.contents.font.color = normal_color
     self.contents.draw_text(hp_x + 4, y + 16, 12, 32, "/", 1)
     self.contents.draw_text(hp_x + 16, y + 16, 48, 32, actor.maxhp.to_s)
   end
 end
 def draw_actor_sp(actor, x, y, width = 144)
   self.contents.font.color = system_color
   self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
   if width - 32 >= 108
     sp_x = x + width - 108
     flag = true
   elsif width - 32 >= 48
     sp_x = x + width - 48
     flag = false
   end
   self.contents.font.color = actor.sp == 0 ? knockout_color :
     actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
   self.contents.draw_text(sp_x - 44, y + 16, 48, 32, actor.sp.to_s, 2)
   if flag
     self.contents.font.color = normal_color
     self.contents.draw_text(sp_x + 4, y + 16, 12, 32, "/", 1)
     self.contents.draw_text(sp_x + 16, y + 16, 48, 32, actor.maxsp.to_s)
   end
 end
end

# Window_MenuStatus edit #

class Window_MenuStatus
 def initialize
   super(0, 0, 640, 240)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.contents.font.name = $defaultfonttype
   self.contents.font.size = $defaultfontsize
   refresh
   self.active = false
   self.index = -1
 end
 def refresh
   self.contents.clear
   @item_max = $game_party.actors.size
   for i in 0...$game_party.actors.size
     x = i * 160
     y = 116
     actor = $game_party.actors[i]
     draw_actor_graphic(actor, x + 16, y - 60)
     draw_actor_name(actor, x + 32, y - 120)
     draw_actor_class(actor, x + 32, y - 80)
     draw_actor_level(actor, x + 32, y - 100)
     draw_actor_state(actor, x + 16, y - 60)
     draw_actor_exp(actor, x + 16, y + 50)
     draw_actor_hp(actor, x, y - 40)
     draw_actor_sp(actor, x, y)
   end
 end
 def update_cursor_rect
   if @index < 0
     self.cursor_rect.empty
   else
     self.cursor_rect.set(@index * 160, 0, 128, self.height - 32)
   end
 end
end

# Window_HealCost #

class Window_HealCost < Window_Base
 def initialize
   super(0, 0, 160, 96)
   self.contents = Bitmap.new(width - 32, height - 32)
   refresh
 end
 def refresh
   @price = $game_variables[!!!!]
   self.contents.clear
   self.contents.font.name = "Tahoma"
   self.contents.font.color = system_color
   self.contents.font.size = 22
   self.contents.draw_text(0, 0, 128, 32, "Heal Cost:  ")
   self.contents.font.color = normal_color
   self.contents.draw_text(0, 32, 128, 32, @price.to_s, 1)
   self.contents.font.color = system_color
   self.contents.draw_text(86, 32, 128, 32, $data_system.words.gold)
 end
end

#    Actual Scene    #
# Scene_Savepoint #

class Scene_Savepoint
 def initialize(sav_index = 0)
   @sav_index = sav_index
   @price = $game_variables[!!!!]
 end
 def main
   @spriteset = Spriteset_Map.new
   s1 = "Cancel"
   s2 = "Save"
   s3 = "Heal"
   @command_window = Window_Command.new(320, [s1, s2, s3], 3)
   @command_window.index = @sav_index
   @command_window.x = 160
   @command_window.y = 176
   if $game_party.actors.size == 0
     @command_window.disable_item(1)
     @command_window.disable_item(2)
   end
   @steps_window = Window_Steps.new
   @steps_window.x = 480
   @steps_window.y = 144
   @status_window = Window_MenuStatus.new
   @status_window.x = 0
   @status_window.y = 240
   @gold_window = Window_Gold.new
   @gold_window.x = 480
   @gold_window.y = 0
   @heal_window = Window_HealCost.new
   @heal_window.x = 0
   @heal_window.y = 144
   @savpnt_window = Window_Savepoint.new
   @savpnt_window.x = 160
   @savpnt_window.y = 112
   Graphics.transition
   loop do
     Graphics.update
     Input.update
     update
     if $scene != self
       break
     end
   end
   Graphics.freeze
   @spriteset.dispose
   @command_window.dispose
   @steps_window.dispose
   @status_window.dispose
   @gold_window.dispose
   @heal_window.dispose
   @savpnt_window.dispose
 end
 def refresh_options
   if @price > $game_party.gold
     @command_window.disable_item(2)
   end
 end
 def update
   @spriteset.update
   @command_window.update
   @steps_window.update
   @status_window.update
   @gold_window.update
   @heal_window.update
   @savpnt_window.update
   if @command_window.active
     update_command
     return
   end
   if @status_window.active
     update_status
     return
   end
 end
 def update_command
   if Input.trigger?(Input::B)
     $game_system.se_play($data_system.cancel_se)
     $scene = Scene_Menu.new(4)
     return
   end
   if Input.trigger?(Input::C)
     if $game_party.actors.size == 0 and @command_window.index < 4
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     case @command_window.index
     when 0
       $game_system.se_play($data_system.cancel_se)
       $scene = Scene_Menu.new(4)
     when 1
       $game_system.se_play($data_system.decision_se)
       $scene = Scene_Save.new
     when 2
       if @price > $game_party.gold
         $game_system.se_play($data_system.buzzer_se)
         return
       end
       Audio.se_play("Audio/SE/107-Heal03")
       $game_party.lose_gold($game_variables[!!!!])
       refresh_options
       @status_window.refresh
       @status_window.update
       for actor in $game_party.actors
         actor.recover_all
       end
     end
   end
 end
end


Instructions:
   Make a variable and call it Heal Cost or something similar... you can change the value of this at different points in the game if you like
   Ctrl + f to find !!!!
   Change !!!! to the number of whatever variable you set as your heal cost...
   Have fun ;8
[EDIT]
   To call, use this in a call script event.
$scene = Scene_Savepoint.new

[/spoiler]

[spoiler=Screeny]
[/spoiler]

This script goes well with this script
Sincerely,
Your conscience.

Kokowam

Wow, that seems pretty cool! Also, there's 3 "!!!!"s so... don't forget the other two and reply with "it's not working" or something. XP

Rune

Thanks ;8
If anyone has any queries i'm right here ;8
Sincerely,
Your conscience.

Esmeralda

Can you make the Savepoint text another color?
:taco: :taco: :taco:

Falcon

Cool, but kind of useless since you don't need a script to make a savepoint.

Esmeralda

But you could use it as a special savepoint. I think of a hospital.
:taco: :taco: :taco:

Falcon

Ferenn, edit the line in bold to change the savepoint color:

  def refresh
    self.contents.clear
    self.contents.font.name = "Tahoma"
    self.contents.font.size = 22
    self.contents.font.color = Color.new(0, 255, 0)
    self.contents.draw_text(100, 0, 96, 32, "Savepoint")
  end
end

Just edit the variables in the () to change the color. Additionally, if you have Trickster's MACL, you could use Color.red, etc.

Esmeralda

Ah, thanks.  ;8

Though it was a detail, I'm glad for the help.
:taco: :taco: :taco:

Rune

Quote from: Falcon on May 20, 2007, 12:38:36 PM
Cool, but kind of useless since you don't need a script to make a savepoint.

Some people like fancy savepoints :P
Sincerely,
Your conscience.

Esmeralda

How do I call it?  :tpg:
:taco: :taco: :taco:

Rune

#10
Argh! >.< I knew there was someting I was forgetting...

Use this
$scene = Scene_Savepoint.new

[EDIT]
First post edited
Sincerely,
Your conscience.

Esmeralda

I get an error saying

Script 'RuneSave' line 199: Argument Error Occured

wrong number of arguments(3 for 2)

:tpg:
:taco: :taco: :taco:

Rune

#12
RuneSave?
Sincerely,
Your conscience.

Esmeralda

That's the script name. ;8
:taco: :taco: :taco:

Rune

Put this before the Scene itself...
[spoiler]
class Window_Command < Window_Selectable
  def initialize(width, commands, column_max = 1, style = 0, inf_scroll = 1)
    super(0, 0, width, (commands.size * 1.0 / column_max).ceil * 32 + 32)
    @inf_scroll = inf_scroll
    @item_max = commands.size
    @commands = commands
    @column_max = column_max
    @style = style
    self.contents = Bitmap.new(width - 32, (@item_max * 1.0 / @column_max).ceil * 32)
    self.contents.font.name = "Tahoma"
    self.contents.font.size = 22
    refresh
    self.index = 0
  end
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(index%@column_max * (self.width / @column_max) + 4, 32 * (index/@column_max), self.width / @column_max - 40, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index], @style)
  end
  def disable_item(index)
    draw_item(index, disabled_color)
  end
  def update_help
    @help_window.set_actor($game_party.actors[$scene.actor_index])
  end
end
[/spoiler]

That scriptlet's in the script mentioned in my first post
Quote from: Rune on May 20, 2007, 11:57:09 AM
This script goes well with this script
So either add that scriptlet or get the mentioned script
Sincerely,
Your conscience.

:)

Watch out for: HaloOfTheSun

Esmeralda

Now it's working  ;8
:taco: :taco: :taco:

Rune

Quote from: Nouman on May 20, 2007, 01:33:00 PM
Me likely. :D

:tpg: Thanks :tpg:
Script Database ahoy!! ;8

Quote from: Ferenn on May 20, 2007, 01:36:05 PM
Now it's working  ;8

Glad to be of assistanceing... ness... whatever ;8
Sincerely,
Your conscience.

Rune

Thought this might need a little bump...

[spoiler]If this wasn't needed, shoot me[/spoiler]
Sincerely,
Your conscience.

Falcon

Why would you bump a topic that's been inactive for not even a week? On top of that it's in the database. You don't see all the other scripters bumping our topics.

Rune

True...
Seems like ages since I posted this though...
Sincerely,
Your conscience.

hero_kenshi

dude nice script... im learning c#
anywho....
umm is there a way i can take out the heal party and just have the save,  but when you save it auto heals? 

P.s gotta love the bean  :bean:

Rune

Um... hold on... haven't touched scripting in ages...

Right!

Take outs3 = "Heal"
And then take out the s3 in the line beneath it and change the end 3 to a 2.

Take outwhen 2
        if @price > $game_party.gold
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        Audio.se_play("Audio/SE/107-Heal03")
        $game_party.lose_gold($game_variables[!!!!])
        refresh_options
        @status_window.refresh
        @status_window.update
        for actor in $game_party.actors
          actor.recover_all
        end


After where it says$scene = Scene_Save.new
add        for actor in $game_party.actors
          actor.recover_all
        end


This hasn't been tested yet, so say if you have any problems ;)
Sincerely,
Your conscience.

Demonic Blade

#23
 ??? Is it possible to not heal at all (It'd be cheating in most games to just exit and enter again to heal yourself...)?
I wonder how many of my-reps are there for a reason, and not just because some jackass wanted to show off in front of some other jackasses...?
Probably a lot of them - and those people sure as hell don't deserve my pity, let alone my disgust.
That's right, let's see some more -Rep'ing! BOOYEAH!!

modern algebra

Umm, he explains that in the post above. Take out everything he says and then don't add anything.