Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> HP/SP Recovery on Level Up
kowbrainz
post Nov 3 2011, 06:41 AM
Post #1


Level 1
Group Icon

Group: Member
Posts: 11
Type: Developer
RM Skill: Intermediate




Hi,

I'm fairly new to scripting, so this was just a basic thing to start off with. I'd just like to alter the default game script so that every time an actor levels up, their SP and HP are recovered fully.

Here's the part of the Actor class which deals with a change in level - anyone able to help with what I need to add to this (or whether I need to do anything else different) in order to get this to work? Thanks

CODE
  #--------------------------------------------------------------------------
  # * Change Level
  #     level : new level
  #--------------------------------------------------------------------------
  def level=(level)
    # Check up and down limits
    level = [[level, $data_actors[@actor_id].final_level].min, 1].max
    # Change EXP
    self.exp = @exp_list[level]

   #insert HP and SP recovery code here

   end
Go to the top of the page
 
+Quote Post
   
Tsukihime
post Nov 3 2011, 07:08 AM
Post #2


Level 25
Group Icon

Group: Revolutionary
Posts: 565
Type: None
RM Skill: Undisclosed
Rev Points: 25




You will have to change two functions.

The one you copied is when you run the "change level" command in an event.

The second is just above it, where you "change exp".
You can add do something like

CODE
def exp=(exp)
    @exp = [[exp, 9999999].min, 0].max
    # Level up
    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
        @level += 1
        # Learn skill
        for j in $data_classes[@class_id].learnings
            if j.level == @level
                learn_skill(j.skill_id)
            end
        end
        @hp = self.maxhp
        @sp = self.maxsp
    end
    # Level down
    while @exp < @exp_list[@level]
        @level -= 1
    end
    # Correction if exceeding current max HP and max SP
    @hp = [@hp, self.maxhp].min
    @sp = [@sp, self.maxsp].min
end


And similarly add those two new lines to the other function as well.

You may want to keep the "correction" cause it handles cases where hp/sp goes down upon exp change, such as negative HP/SP curve per level up.


__________________________
My Scripts
Go to the top of the page
 
+Quote Post
   
kowbrainz
post Nov 3 2011, 10:42 AM
Post #3


Level 1
Group Icon

Group: Member
Posts: 11
Type: Developer
RM Skill: Intermediate




Ah right, I see. Thanks! biggrin.gif
Go to the top of the page
 
+Quote Post
   
lilcooldude69
post Nov 3 2011, 11:11 AM
Post #4


The pro-est eventer u know ;D
Group Icon

Group: Revolutionary
Posts: 297
Type: Event Designer
RM Skill: Masterful




cant u event this as well...?


__________________________

My Userbars


Rated pg-13 part of signiture
Scientist A: "A single sperm has 37.5MB of DNA information in it. That means a normal ejaculation represents a data transfer of 1,587.5TB."
Scientist B: Too bad ejaculate has terrible packet loss
Scientist C:but the transfer does have a lot of redundancy

Go to the top of the page
 
+Quote Post
   
Tsukihime
post Nov 3 2011, 11:54 AM
Post #5


Level 25
Group Icon

Group: Revolutionary
Posts: 565
Type: None
RM Skill: Undisclosed
Rev Points: 25




Probably.
But would it have to be done on every map?


__________________________
My Scripts
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 08:59 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker