$D13x - States :: Damage Over Time

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,330
First Language
Binary
Primarily Uses
RMMV
$D13x - States :: Damage Over Time
Dekita


Introduction

This script allows states to be given a portion of code to eval during the 'refresh state turns' method.

What this means is, you can create various hp / mp / tp moddifying states. You could also attach variables onto your state turns.
Obviously, as you can code the formula, this opens a whole range of possibilities. Such as using various stats to determine the hp/mp loss, Using element resistance to determine TP gain,  Using variables to determine the HP lost...
There are many uses for this kind of feature, so dont be scared to think 'outside of the box'.

Features
- Run Custom Code When State Turns Are Refreshed.

Screenshots

Runs in the background - no Screenshots required.

How to Use

Place under materials and above main.

Full instruction within the script.

Demo

Nope

Script

LINK

FAQ

None

Credit and Thanks
- Dekita / Dekita-RPG

Author's Notes
None.
 

Arsist

Veteran
Veteran
Joined
May 16, 2014
Messages
140
Reaction score
10
Primarily Uses
Assuming this allows you to have degenerative HP loss while standing still on the map (instead of it being step-based), if my DoT data was say

DoT_Data[2] = "self.hp -= 10"how many frames/seconds would it take to lose 10 HP?
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,330
First Language
Binary
Primarily Uses
RMMV
Hey there,

What your asking should work. I dont see any reason why it wouldnt but I only tested within the battle scene.

The degeneration of HP would  occur each time the states turns are checked. For the map, that would happen as often as the damage occurs when you walk on floor that hurts you. The floor hurts you every 20 steps.

Hope that helps somewhat ^_^
 
Last edited by a moderator:

Arsist

Veteran
Veteran
Joined
May 16, 2014
Messages
140
Reaction score
10
Primarily Uses
Oh, I realized what I'm looking for is MMO Regen.

But you didn't post it here.

 

For example, let’s say 28 seconds in game time is an hour, and it takes 3 hours to lose 650 HP, the default level 5 Max HP, aka the HP of a normal human being villager. So I would want it to take 84 seconds to lose 650 HP.

 

Let’s say your script updates the DoT at a rate of every 3 seconds (180 frames).

 

So that’s 650 / 84 / 3 which equals 2.57936…

normally for your DoT script I would have the formula be 

DOT Data[3] = “self.hp -= “if rand(100000) <= 57936 then 3 else 2 end”but since this is MMO Regen, I tried

def self.hp_degen(actor) sum = 0 if actor.state?(26) if rand(100000) <= 57936 sum += 3 else sum += 2 end end sum += (actor.mhp/100) if Keys.press?(Keys::Key[Regen_Key]) actor.hp -= sum.to_i end

and made the following adjustment

def do_deki_regen return if @last_regen == Time.now.sec return if !Regen_Per_Sec unless Keys.press?(Keys::Key[Regen_Key]) @last_regen = Time.now.sec $game_party.battle_members.each do |actor| next if actor.hp <= 0 MMO_Regen.hp_regen(actor) MMO_Regen.hp_degen(actor) MMO_Regen.mp_regen(actor) MMO_Regen.tp_regen(actor) if Keys.press?(Keys::Key[Regen_Key]) anim = Animation $game_player.animation_id = anim $game_player.followers.each do |char| next unless char.actor != nil char.animation_id = anim end end end 
How many frames/seconds does MMO Regen take to update HP/MP/TP?

if it updates every 60 frames then it'd be

650 / 84 which is 7.73809... which I think would be

def self.hp_degen(actor) sum = 0 if actor.state?(26) if rand(100000) <= 73809 sum += 8 else sum += 7 end end sum += (actor.mhp/100) if Keys.press?(Keys::Key[Regen_Key]) actor.hp -= sum.to_i end 
Update:

Yes, it does update every 60 frames. Wow, at the speed it's going, a degen rate like that would have to be for like minimap movement. 

What's unfortunate is that means if I want to tweak regen or degen rates for skills I'd always have to edit within the script editor which often times makes previous save files unplayable.

But what if I wanted to have it so that it updates every, say, 5 seconds and not 1? So I could have it so that Bleeding reduces HP by (3 x 5) to (4 x 5) aka 15 to 20 every 5 seconds, so that if there's something like bandages or clothing or abilities that reduce bleeding damage in the form of an element rate, there's a big difference between halving 3 and halving 15, because you won't get as exact using small numbers.

(If I'm making sense)

I guess then I could do

def self.hp_degen(actor) sum = 0 if actor.state?(26) && rand(100) <= 20 if rand(100000) <= 86904 sum += 20 * actor.element_rate(25) else sum += 15 * actor.element_rate(25) end end sum += (actor.mhp/100) if Keys.press?(Keys::Key[Regen_Key]) actor.hp -= sum.to_i end 
to achieve that. Sorry for answering my own questions XD

But I would think that having multiple characters all with their HP/MP/TP regenerating and degenerating and updating every second, added with other things running, would cause a lot of lag, right?
 
Last edited by a moderator:

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,330
First Language
Binary
Primarily Uses
RMMV
lol no problem.

Also, to neaten that last code up a little, you could do this...

  def self.hp_degen(actor) sum = 0    sum = degen_state_26(actor) if actor.state?(26) && (rand(100) <= 5)    sum = (actor.mhp/100)       if Keys.press?(Keys::Key[Regen_Key])    actor.hp -= sum.to_i  end   def do_degen_state_26(actor)    return 20 * actor.element_rate(25) if rand(100000) <= 86904    return 15 * actor.element_rate(25)  end Also, just an FYI. the rand() method will NEVER return the max number you enter. eg. rand(100) will never return 100. At most it will return 99 :)
 
Last edited by a moderator:

Arsist

Veteran
Veteran
Joined
May 16, 2014
Messages
140
Reaction score
10
Primarily Uses
Thanks.

Do you think that MMO Regen is prone to causing lag?

Also, MMO Regen occurs even when you're talking to someone. How would you have otherwise?

So that the only time it would update is during normal gameplay times where you're able to access the map or walk around a whim?
 
Last edited by a moderator:

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,330
First Language
Binary
Primarily Uses
RMMV
ahh thats an easy one. I actually took out that feature (it used to automatically do that)

Simply add this into the beginning of the method...

    return if $game_map.interpreter.running?like this...

  def self.hp_degen(actor)    return if $game_map.interpreter.running?    sum = 0    sum = degen_state_26(actor) if actor.state?(26) && (rand(100) <= 5)    sum = (actor.mhp/100)       if Keys.press?(Keys::Key[Regen_Key])    actor.hp -= sum.to_i  endEdit:

Also, I was concerned about lag caused from the MMO Regen script and done rather extensive tests on it. It turns out that the part of the regen that causes the biggest lag is the single line actor.hp -= value.

This is because when an actors HP is changed the actors data is refreshed.

Just to give you an idea how little performance this actually uses...

If you are in battle and use a skill that hits all enemies and regenerates your hp (for example) that calculation (battler.hp -= value) would be used on EVERY single battler without causing a drop in FPS.

^_^
 
Last edited by a moderator:

Arsist

Veteran
Veteran
Joined
May 16, 2014
Messages
140
Reaction score
10
Primarily Uses
Does that mean if the map interpreter isn't running, there will be no HP change at all? Not += 0 or -= 0 or anything?
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,330
First Language
Binary
Primarily Uses
RMMV
yep, pretty much. The interpreter only runs when events are running though - when text is playing for example.
 

Arsist

Veteran
Veteran
Joined
May 16, 2014
Messages
140
Reaction score
10
Primarily Uses
This script doesn't cause much lag or skip on its own, but when I put it into my project, it does (I've been testing it on a fresh project).

That's because it's constantly updating, so any script that runs when the battlerbase is updated with like HP/MP/TP changes will run.

So it decreased the frame count by 2 and makes it so that every 2 seconds, on the map, it skips.

Adding this

return if (Time.now.sec - @last_regen) <= 5 would be fine, right? To this, I mean

#-------------------------------------------------------------------------- # Do The MMO Style Regen #-------------------------------------------------------------------------- def do_deki_regen return if @last_regen == Time.now.sec return if (Time.now.sec - @last_regen) <= 5 return if !Regen_Per_Sec unless Keys.press?(Keys::Key[Regen_Key]) @last_regen = Time.now.sec $game_party.battle_members.each do |actor| next if actor.hp <= 0 MMO_Regen.hp_regen(actor) MMO_Regen.hp_degen(actor) MMO_Regen.tp_regen(actor) if Keys.press?(Keys::Key[Regen_Key]) anim = Animation $game_player.animation_id = anim $game_player.followers.each do |char| next unless char.actor != nil char.animation_id = anim end end end if SceneManager.scene_is?(Scene_Battle) $game_troop.members.each do |actor| next if actor.hp <= 0 break unless Enemy_Can_Regen MMO_Regen.hp_regen(actor) MMO_Regen.mp_regen(actor) MMO_Regen.tp_regen(actor) end @status_window.refresh if @status_window end endend 
In order to have it so that it updates every 5 seconds, and then I multiply my formulas by 5.
 
Last edited by a moderator:

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,330
First Language
Binary
Primarily Uses
RMMV
Nah, that wouldnt do it..

When i seen that method, I decided it was far too inefficient to not be fixed, so I just updated the MMO Regen script and added the feature of 'waiting frames to pass before regen instead of every second'.

If you want it to happen every 5 seconds, you would want 300 frames.
 

Arsist

Veteran
Veteran
Joined
May 16, 2014
Messages
140
Reaction score
10
Primarily Uses
*slaps you in the face and calls you a dragonite* 

Yay, it works  :)
 

tale

Volunteer
Veteran
Joined
Dec 16, 2016
Messages
544
Reaction score
883
First Language
English
Primarily Uses
N/A
If anyone's looking for this script, it's on pastebin-
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

This community is awesome. They helped me get my eventing processes to work. I love you all.
suspended on twitter for calling an ahole an ahole & appealing the tweet; furious at myself for being even slightly upset with my suspension: oh no, you've been temporarily banned from hell. GET OVER IT, me.
how can you download the tiles from a forum post here? HELP
That moment when you post the wrong download link to your game and wonder why it got so few downloads... :mad:
Trying to make it so my map is cleared of "random" events after the player leaves the map... to little success >.< I think I might need to ask help for this.

Forum statistics

Threads
94,247
Messages
919,373
Members
123,960
Latest member
crayonchan
Top