[RMXP]Auto Regenrate Health

Started by Jek, March 26, 2010, 04:26:09 pm

Previous topic - Next topic

Jek

What I am trying to do is to regenerate health based on the characters level. So, every minute, your health regenerates by 1 if you are level 1. Once you are level 2, you regenerate 2 health. How might I go about doing this when there is no conditional branch for it? Im guessing it would involve the script option in the conditional branch?

G_G

Okay 20 frames = 1 second.
1200 frames = 1 minute. The example below is for 30 seconds though.
The example also includes healing the entire party.

Spoiler: ShowHide


Tell me if this is what you wanted.

Jek

What I wanted was to have the amount of health regenerated be more for each level. An example would be:
Level 1 - 100 health generated per minute
Level 2 - 110 health generated per minute
Level 3 - 120 health generated per minute
In the Conditional Branch, there is no way to check for the heros level.

Wizered67

you can check with variables.......

G_G

Okay this does what you wanted.

Spoiler: ShowHide


level 1: 100
level 2: 110

It does it for the entire party according to the actor's level.
Change 600 frames to 1200 frames. However you may need to use multiple wait commands for that.

Jek


Tyril132

March 27, 2010, 07:09:21 am #6 Last Edit: March 27, 2010, 08:13:00 am by Tyril132
Don't mind me, since I'm not much of a scripter (yet) myself, but it seems like you could stand to improve it by tying it to a simple counting loop instead of sequenced /wait commands, as well.

What I mean is, consider structuring your event like this:

Spoiler: ShowHide
@>Loop
    @>Conditional Branch: Variable [XXXX: Time] == 60
         @>Script: $game_party.actors.each {|i| i.hp += i.level}
         @>Control Variables: [XXXX: Time] = 0
         @>Wait: 20 frame(s)
    Else
         @>Wait: 20 frame(s)
         @>Control Variables: [XXXX: Time] += 1
   : Branch End
@>
: Repeat Above
@>


Doing this would serve two pretty useful purposes:


  • You could very easily change the number for testing/balancing purposes if you decide that a minute is too short/not long enough.

  • It sounds like you may be using this in tandem with other scripts you may want to control with a timer (such as if you're using it with an ABS.) Doing so lets you use one variable for multiple purposes.

Lv. 7 Writer | Lv. 7 Composer | Lv. 7 Mapper | Lv. 4 Eventer | Lv. 0 Scripter | Lv. 1 Spriter
DSC Project Soundtrack
Personality Index:: ShowHide

G_G

It would work, but my way is shorter. Making it only 2 or three lines depending on how long you want the regeneration.

Fantasist

You know, one could make a "Time-based slip-damage" script, so that effects like poison act based on time rather than steps taken. Then add the regeneration effect to the gallery. *hint to G_G (would be awesome for Tons of Addons)*
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Tyril132

Quote from: Hellfire's G_G on March 27, 2010, 07:38:43 am
It would work, but my way is shorter. Making it only 2 or three lines depending on how long you want the regeneration.


Simpler usually is better, true.
Lv. 7 Writer | Lv. 7 Composer | Lv. 7 Mapper | Lv. 4 Eventer | Lv. 0 Scripter | Lv. 1 Spriter
DSC Project Soundtrack
Personality Index:: ShowHide

G_G

Quote from: Mad Scientist Fantasist on March 27, 2010, 07:46:10 am
You know, one could make a "Time-based slip-damage" script, so that effects like poison act based on time rather than steps taken. Then add the regeneration effect to the gallery. *hint to G_G (would be awesome for Tons of Addons)*


Maybe I will. :D

(Hexamin)

Only issue is how does the event proc when you reenter a map?  If you're only on a map for 45 seconds, you'll miss out on the hp heal.  Using the loop would at least make it so you hold on to the seconds you've waited for the heal.

? Just a thought ?

I could be wrong.
Max 1111101000; characters remaining: 1110111000

Tyril132

Being brand new to ruby, I'm trying to error-proof as many of my scripts/events as I can.

That's why I like using game variables for stuff like this... you can easily quantify them while testing through F9 and it's easy to control or modify them for reasons exactly like the one you bring up. lol
Lv. 7 Writer | Lv. 7 Composer | Lv. 7 Mapper | Lv. 4 Eventer | Lv. 0 Scripter | Lv. 1 Spriter
DSC Project Soundtrack
Personality Index:: ShowHide

G_G

Quote from: (Hexamin) on March 27, 2010, 08:51:05 am
Only issue is how does the event proc when you reenter a map?  If you're only on a map for 45 seconds, you'll miss out on the hp heal.  Using the loop would at least make it so you hold on to the seconds you've waited for the heal.

? Just a thought ?

I could be wrong.


If its setup in a common event on a parallel process it'll still work.

(Hexamin)

Will common events continued to process through menus too?  Provided they're set up on PP?
Max 1111101000; characters remaining: 1110111000

G_G

No common events wont work unless the menu is updating the interpreter.