Is it possible to create such skills?

Need help to create skills by using formula box or snippet.

Soul Eater - skill deals damage to one enemy and if the enemy dies by this skill, you gain some HP.

Lightning Strike - hit one selected enemy for some damage then the damage split by half to besides targets (left and right of the selected target). Eg. Slame A, B, C appear. You use Lightning Strike on B for 1,000 damage first then Slame A and C also take 500 damage. If your Lightning Strike hits Slame A or C then only B will take the split damage.

Thanks!
Theoretically everything is possible - but your ideas are a bit tricky.


The first one would require either a lot of complex eventing or a script specifically for it.


The second idea absolutely requires scripting as it would need a different targeting and damage distribution effect.
Check out the battle engine yanfly hosts over at: https://github.com/Archeia/YEARepo . The Lunatic battle stuff in particular can very easily alter skills to do what you want the first one to do, the second requires a bit more work to really accomplish.  I don't know of a battle system off the top of my head that accounts for exact enemy placements.  At best, you'd spread to Enemy A and C regardless of location (EG: one is set up behind the others, it would still get hit by a lunatic multi-enemy attack).

either way, you definitely need some RGSS knowledge to really step into the world of feature ridden skills like that.  Best to Keep it simple if you're not looking to delve into all that complex stuff.
class Scene_Battle < Scene_Base

  attr_accessor :log_window

end

 

class Game_Battler < Game_BattlerBase

 

def manual_make_damage_value(value, subject, item)

    value *= item_element_rate(subject, item)

    value *= mdr

    value = apply_critical(value) if @result.critical

    value = apply_variance(value, item.damage.variance)

    value = apply_guard(value)

    @result.make_damage(value.to_i, item)

  end

  

  def custom_formula_lightningstrike(a, b )

    log_window = SceneManager.scene.log_window

    targets =

    targets = targets |= [$game_troop.alive_members[[b.index-1, 0].max]]

    targets = targets |= [$game_troop.alive_members[[b.index+1, $game_troop.alive_members.size-1].min]]

    item = a.current_action.item

    targets.each_with_index { |target, index|

      standard_formula = 200 + a.mat * 2 - target.mdf * 2

      target.result.clear

      target.result.used = item_test(a, item)

      target.result.missed = (target.result.used && rand >= item_hit(a, item))

      target.result.evaded = (!target.result.missed && rand < item_eva(a, item))

      if target.result.hit?

        unless item.damage.none?

          target.result.critical = (rand < item_cri(a, item))

          value = standard_formula - (0.5 * standard_formula)

          target.manual_make_damage_value(value, a, item)

          target.execute_damage(a)

          log_window.clear

          log_window.add_text("The lightning jumps!") if index > 0

          log_window.display_action_results(target, item)

        end

      end

    }

    b.result.clear

    return 0

  end

  

  def custom_formula_souleater(a, b )

    log_window = SceneManager.scene.log_window

    standard_formula = a.atk * 4 - b.def * 2

    item = a.current_action.item

    b.result.clear

    b.result.used = item_test(a, item)

    b.result.missed = (b.result.used && rand >= item_hit(a, item))

    b.result.evaded = (!b.result.missed && rand < item_eva(a, item))

    if b.result.hit?

      unless item.damage.none?

        b.result.critical = (rand < item_cri(a, item))

        b.manual_make_damage_value(standard_formula, a, item)

        damage = b.result.hp_damage

        b.execute_damage(a)

        log_window.display_action_results(b, item)

      end

    end

    if b.hp <= 0 && a.hp < a.mhp

      heal = [(-damage * 0.4), -(a.mhp - a.hp)].max.to_i

      a.manual_make_damage_value(heal, a, item)

      a.execute_damage(a)

      log_window.clear

      log_window.add_text(sprintf("%s is healed for %d HP by the strike!", a.name, heal.abs))

      log_window.display_action_results(a, item)

    end

    b.result.clear

    return 0

  end

end

 

Add this as a new script above main, then in your skill formula put either a.custom_formula_lightningstrike(a, b ) or a.custom_formula_souleater(a, b ). Remember to replace the standard_formula with whatever calculation you're using.
class Scene_Battle < Scene_Base

attr_accessor :log_window

end

class Game_Battler < Game_BattlerBase

def manual_make_damage_value(value, subject, item)

value *= item_element_rate(subject, item)

value *= mdr

value = apply_critical(value) if @result.critical

value = apply_variance(value, item.damage.variance)

value = apply_guard(value)

@result.make_damage(value.to_i, item)

end

def custom_formula_lightningstrike(a, b )

log_window = SceneManager.scene.log_window

targets =

targets = targets |= [$game_troop.alive_members[[b.index-1, 0].max]]

targets = targets |= [$game_troop.alive_members[[b.index+1, $game_troop.alive_members.size-1].min]]

item = a.current_action.item

targets.each_with_index { |target, index|

standard_formula = 200 + a.mat * 2 - target.mdf * 2

target.result.clear

target.result.used = item_test(a, item)

target.result.missed = (target.result.used && rand >= item_hit(a, item))

target.result.evaded = (!target.result.missed && rand < item_eva(a, item))

if target.result.hit?

unless item.damage.none?

target.result.critical = (rand < item_cri(a, item))

value = standard_formula - (0.5 * standard_formula)

target.manual_make_damage_value(value, a, item)

target.execute_damage(a)

log_window.clear

log_window.add_text("The lightning jumps!") if index > 0

log_window.display_action_results(target, item)

end

end

}

b.result.clear

return 0

end

def custom_formula_souleater(a, b )

log_window = SceneManager.scene.log_window

standard_formula = a.atk * 4 - b.def * 2

item = a.current_action.item

b.result.clear

b.result.used = item_test(a, item)

b.result.missed = (b.result.used && rand >= item_hit(a, item))

b.result.evaded = (!b.result.missed && rand < item_eva(a, item))

if b.result.hit?

unless item.damage.none?

b.result.critical = (rand < item_cri(a, item))

b.manual_make_damage_value(standard_formula, a, item)

damage = b.result.hp_damage

b.execute_damage(a)

log_window.display_action_results(b, item)

end

end

if b.hp <= 0 && a.hp < a.mhp

heal = [(-damage * 0.4), -(a.mhp - a.hp)].max.to_i

a.manual_make_damage_value(heal, a, item)

a.execute_damage(a)

log_window.clear

log_window.add_text(sprintf("%s is healed for %d HP by the strike!", a.name, heal.abs))

log_window.display_action_results(a, item)

end

b.result.clear

return 0

end

end

Add this as a new script above main, then in your skill formula put either a.custom_formula_lightningstrike(a, b ) or a.custom_formula_souleater(a, b ). Remember to replace the standard_formula with whatever calculation you're using.
This looks amazing! Need to do some settings for skill damage and try whether the skills work.

Anyway, thank you for your scripts Trihan.
If you have any issues let me know.
Soul Eater - skill deals damage to one enemy and if the enemy dies by this skill, you gain some HP.
You can also try this damage formula with variance set as 0:

dmg = apply_guard(apply_variance(original_damage_formula, var)); dmg = apply_critical(dmg) if b.result.critical; a.hp += some_hp if b.hp - dmg <= 0 && !b.state_resist?(death_state_id); dmgYou may want to try this simpler form instead:

dmg = original_damage_formula * (1 - var + rand(var) * 2) / 2 / b.grd; dmg *= 3 if b.result.critical; a.hp += some_hp if b.hp - dmg <= 0 && !b.state_resist?(death_state_id); dmgUnfortunately, even the simpler form will still likely be too long lol
I don't think that fits in the box and it also won't show a message with the HP gained, though I guess if you're using something like Yanfly's battle engine that's a moot point.

Good point that I didn't factor in enemies immune to the death state, though.

Original thread: https://forums.rpgmakerweb.com/threads/is-it-possible-to-create-such-skills.39775/