Damage Sequence

Damage Sequence 1.1


Lecode


Introduction


This script allows you to synchronize skills and items' damage with their animations.


To put it simply, the player can now deal damage during an animation.


Thus, you can decide to make real multiple-hits skills or to deal damage at a specific frame.


Screenshot

Spoiler
Spoiler



Qdsdpt1.png



Instructions


Version 1.0

Spoiler
Spoiler




<dmg_sequence: a,b,c,d...>


Specify the frame(s) where damages are dealt.
Example: <dmg_sequence: 6,12>
 



<effects_sequence: a,b,c,d...>


Specify the frame(s) where effects are applied.


By default, they are applied on the last hit.
 



<effects_each_hit>


This tag allows the skill/item to apply effects on each hit.



Version 1.1


(Don't bother with that version if you want a simple script/configuration)

Spoiler
Spoiler




<damage sequence>[frame,formula,effects?,crit?,never_miss?][frame,formula,effects?,crit?,never_miss?]ect...</damage sequence>


Specify the frames where damages are dealt.
You can also specify if you allow the skill/item to:
- Apply effects (effects?)
- Try to crit (crit?)
- Certain hit (nerver_miss?)
Also, you can set a custom damage formula for that specific frame.
Replace "formula" with "" or nil to use the default formula.



Demo + Script


Here.


Notes


The script is compatible with the default battle system and with Yanfly's battle engine.


Let me know if you face some compatibility issues. Perhaps I will solve them.
amazing. I've been looking for something like this for a long time 😀
Oooh, a pretty nice idea.
If I bring a ring to your house will you marry me?
Cool script, and it actually might work for something I planned to do long time ago! *-*


Now to add a possibility to make a separate damage formula for each hit performed... Am I asking too much? 😀
If I bring a ring to your house will you marry me?
I'm not ready for that, lol.

Now to add a possibility to make a separate damage formula for each hit performed... Am I asking too much? 😀
Hey, why not ? 🙂

I will think about that.

Thanks, everyone.
That will be easy to add now that he has this IMHO...
I do have a question about this: How does the script handle accuracy? Is each frame counted as a separate accuracy roll, or is it "full move hits / full move misses." 

It may also be a good idea to add an option to configure this, if it's not well integrated in already
This is pretty cool.

A separate damage formula (and/or different elemental) for each hit would be...amazing.
I do have a question about this: How does the script handle accuracy? Is each frame counted as a separate accuracy roll, or is it "full move hits / full move misses."
Accuracy / Crit / Evade / Cover, ect... are handled on each hit.

It's because I use the default way to deal damages. For compatibility sake.

It may also be a good idea to add an option to configure this, if it's not well integrated in already
Added to the todo-list.
Amazing, it's centuries i've been waiting for it!
This adds a lot of realism to the game; I really wanted something like this since a while, thank you very much!!! 😀
Updated.

Code:
# Versions:#   1.0   - Initial release#   1.1   - Add the possibility to control critical#           and guaranted hits, and formula. Also, merge all tags into#           a unique one.
Maybe it's a script compatibility but I'll ask anyways. Is it supposed to hit the player as well? I'm using the first version of the script, because I don't really need all the other features, just the real time damage sequence, and when I used it with a skill that hit's all enemies, it hits the player as well. Is this normal?
No, it isn't normal at all :'o

What battle system are you using ?
I've been mainly using this for a while: http://www.rpgmakervxace.net/topic/26983-cardgame-inspired-skill-and-battle-system/

Your script seems to be one of a kind, since I can''t find anything else that does the same thing (Real time damage with animations). 

Everything else seems to work just fine but the skill hitting the player is the only odd problem I've run into.
Nice script.

I'm sure many people in the community will make very good use of it.

...now to take another look at my skill list lol
I received a compatibility report between this script and DoubleX RMVXA Confusion Edit.

The cause is that the battler instance variable @leds_sprite is a sprite, which has an instance variable @leds_battler, which is that battler.

Whenever a deep copy is to be made for such battlers via Marshal(usually Marshal.load(Marshal.dump)), crashes will come as sprites can't be serialized and Marshal will crash whenever it tries to copy an unserializable object.

As I've solved an extremely similar compatibility issue with my scripts before, I realized yours will also be incompatible with these scripts:

Yanfly Engine Ace - Victory Aftermath

Yami Engine Symphony - Equipment Learning

Theolized Sideview Battle System

Victor Engine - Custom Slip Effect

And I've come up with this fix:

Spoiler
if $imported[:TSBS]alias ledmgseq_copy copydef copy(obj, &argb) # Added to store then clear all battler's unserializables if is_battler = obj.is_a?(Game_Battler) unserializables = obj.ledmg_unserializables obj.clear_ledmg_unserializables end # clone = ledmgseq_copy(obj, &argb) # Rewritten # Added to restore all battler and his/her/its clone's unserializables if is_battler obj.restore_ledmg_unserializables(unserializables) clone.restore_ledmg_unserializables(unserializables) end clone #end # copyend # if $imported[:TSBS]if $imported["YEA-VictoryAftermath"] || $imported["YES-EquipmentLearning"]class << BattleManager # Edit alias ledmgseq_process_victory process_victory def process_victory(*argv, &argb) # Added to store then clear all party members' unserializables unserializables = {} $game_party.all_members.each { |mem| unserializables[mem] = mem.ledmg_unserializables mem.clear_ledmg_unserializables } ledmgseq_process_victory(*argv, &argb) # Added to restore all party members' unserializables $game_party.all_members.each { |mem| mem.restore_ledmg_unserializables(unserializables[mem]) } # end # process_victoryend # BattleManagerend # if $imported["YEA-VictoryAftermath"] || $imported["YES-EquipmentLearning"]if $imported["DoubleX RMVXA Confusion Edit"]class Game_Action # Edit def evaluate_item_with_target(target) # Rewrite target.result.clear # Added to store then clear all unserializables from subject and target subject_unserializables = subject.ledmg_unserializables target_unserializables = target.ledmg_unserializables subject.clear_ledmg_unserializables target.clear_ledmg_unserializables # eval_target = Marshal.load( Marshal.dump(target) ) eval_subject = Marshal.load( Marshal.dump(subject) ) # Added to restore all unserializables for subject, target and their clones subject.restore_ledmg_unserializables(subject_unserializables) eval_subject.restore_ledmg_unserializables(subject_unserializables) target.restore_ledmg_unserializables(target_unserializables) eval_target.restore_ledmg_unserializables(target_unserializables) # eval_target.make_damage_value(eval_subject, item) if item.for_opponent? return eval_target.result.hp_damage.to_f / [eval_target.hp, 1].max end recovery = [-eval_target.result.hp_damage, eval_target.mhp - eval_target.hp].min.to_f / eval_target.mhp end # evaluate_item_with_targetend # Game_Actionend # if $imported["DoubleX RMVXA Confusion Edit"]class Game_Battler # Edit def ledmg_unserializables # New unserializables = { leds_sprite: @leds_sprite } unserializables[:item_in_use] = @item_in_use if $imported[:TSBS] if $imported[:ve_custom_slip_effect] unserializables[:state_user] = @state_user end unserializables end # ledmg_unserializables def clear_ledmg_unserializables # New @leds_sprite = nil @item_in_use = nil if $imported[:TSBS] @state_user = {} if $imported[:ve_custom_slip_effect] end # clear_ledmg_unserializables def restore_ledmg_unserializables(unserializables) # New @leds_sprite = unserializables[:leds_sprite] @item_in_use = unserializables[:item_in_use] if $imported[:TSBS] return unless $imported[:ve_custom_slip_effect] @state_user = unserializables[:state_user] || {} end # restore_ledmg_unserializablesend # Game_Battler
I wanted to solve the compatibility issue with yours on my side(as DoubleX RMVXA Confusion Edit Compatibiltiy Fix), but as I failed to find any way to detect yours' presence(like using $imported[:script_name]), I think it's better to give you the fix and let you decide(you don't have to credit nor even mention me if you decided to use this fix on your side) 🙂
I see. Thanks for reporting this issue 🙂

I'll look at your fix.
Almost forgot that your script will also crash, due to the same reason, when an actor tries to access his/her/its equips in the equip window:

Spoiler
def update_help super if @actor && @status_window temp_actor = Marshal.load(Marshal.dump(@actor)) temp_actor.force_change_equip(@slot_id, item) @status_window.set_temp_actor(temp_actor) end end
So the fix should address this part as well:

Spoiler
if $imported[:TSBS]alias ledmgseq_copy copydef copy(obj, &argb) # Added to store then clear all battler's unserializables if is_battler = obj.is_a?(Game_Battler) unserializables = obj.ledmg_unserializables obj.clear_ledmg_unserializables end # clone = ledmgseq_copy(obj, &argb) # Rewritten # Added to restore all battler and his/her/its clone's unserializables if is_battler obj.restore_ledmg_unserializables(unserializables) clone.restore_ledmg_unserializables(unserializables) end clone #end # copyend # if $imported[:TSBS]if $imported["YEA-VictoryAftermath"] || $imported["YES-EquipmentLearning"]class << BattleManager # Edit alias ledmgseq_process_victory process_victory def process_victory(*argv, &argb) # Added to store then clear all party members' unserializables unserializables = {} $game_party.all_members.each { |mem| unserializables[mem] = mem.ledmg_unserializables mem.clear_ledmg_unserializables } ledmgseq_process_victory(*argv, &argb) # Added to restore all party members' unserializables $game_party.all_members.each { |mem| mem.restore_ledmg_unserializables(unserializables[mem]) } # end # process_victoryend # BattleManagerend # if $imported["YEA-VictoryAftermath"] || $imported["YES-EquipmentLearning"]if $imported["DoubleX RMVXA Confusion Edit"]class Game_Action # Edit def evaluate_item_with_target(target) # Rewrite target.result.clear # Added to store then clear all unserializables from subject and target subject_unserializables = subject.ledmg_unserializables target_unserializables = target.ledmg_unserializables subject.clear_ledmg_unserializables target.clear_ledmg_unserializables # eval_target = Marshal.load( Marshal.dump(target) ) eval_subject = Marshal.load( Marshal.dump(subject) ) # Added to restore all unserializables for subject, target and their clones subject.restore_ledmg_unserializables(subject_unserializables) eval_subject.restore_ledmg_unserializables(subject_unserializables) target.restore_ledmg_unserializables(target_unserializables) eval_target.restore_ledmg_unserializables(target_unserializables) # eval_target.make_damage_value(eval_subject, item) if item.for_opponent? return eval_target.result.hp_damage.to_f / [eval_target.hp, 1].max end recovery = [-eval_target.result.hp_damage, eval_target.mhp - eval_target.hp].min.to_f / eval_target.mhp end # evaluate_item_with_targetend # Game_Actionend # if $imported["DoubleX RMVXA Confusion Edit"]class Game_Battler # Edit def ledmg_unserializables # New unserializables = { leds_sprite: @leds_sprite } unserializables[:item_in_use] = @item_in_use if $imported[:TSBS] if $imported[:ve_custom_slip_effect] unserializables[:state_user] = @state_user end unserializables end # ledmg_unserializables def clear_ledmg_unserializables # New @leds_sprite = nil @item_in_use = nil if $imported[:TSBS] @state_user = {} if $imported[:ve_custom_slip_effect] end # clear_ledmg_unserializables def restore_ledmg_unserializables(unserializables) # New @leds_sprite = unserializables[:leds_sprite] @item_in_use = unserializables[:item_in_use] if $imported[:TSBS] return unless $imported[:ve_custom_slip_effect] @state_user = unserializables[:state_user] || {} end # restore_ledmg_unserializablesend # Game_Battlerclass Window_EquipItem < Window_ItemList # Edit alias ledmgseq_update_help update_help def update_help(*argv, &argb) # Added if @actor unserializables = @actor.ledmg_unserializables @actor.clear_ledmg_unserializables end # ledmgseq_update_help(*argv, &argb) @actor.restore_ledmg_unserializables(unserializables) if @actor # Added end # update_helpend # Window_EquipItem
If this compatibility fix will have to be placed above Yanfly Engine Ace - Ace Equip Engine, the below separate snippet will have to be placed below that script as well:

Spoiler
class Window_EquipItem < Window_ItemList # Edit alias ledmgseq_update_help_compatibility update_help def update_help(*argv, &argb) # Added if @actor unserializables = @actor.ledmg_unserializables @actor.clear_ledmg_unserializables end # ledmgseq_update_help_compatibility(*argv, &argb) @actor.restore_ledmg_unserializables(unserializables) if @actor # Added end # update_helpend # Window_EquipItem
It's because of the below part of that script:

Spoiler
Code:
  #--------------------------------------------------------------------------  # overwrite method: update_help  #--------------------------------------------------------------------------  def update_help    super    return if @actor.nil?    return if @status_window.nil?    return if @last_item == item    @last_item = item    temp_actor = Marshal.load(Marshal.dump(@actor))    temp_actor.force_change_equip(@slot_id, item)    @status_window.set_temp_actor(temp_actor)  end

Original thread: https://forums.rpgmakerweb.com/threads/damage-sequence.44434/