Yanfly's Lunatic States with the addon Punishment Package has some neat abilities, such as inflicting a Drain state that heals the caster whenever ANYONE damages the target. That Drain state can be applied via skills or weapons.
I'd like to expand upon this concept by setting a caster's entire party as the state origin, as opposed to only the caster themself. So the caster could inflict a special kind of Drain State that heals their entire party when the target is damaged.
I've already set up the special state in the Punishment Package, here:
#---------------------------------------------------------------------- # Punish Effect No.9: Party Drain HP # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Best used with shock effect. Whenever user takes HP damage, the # caster's party will heal HP based on HP damage dealt. # # Recommended notetag: # <shock effect: drain hp x%> #---------------------------------------------------------------------- when /PDRAIN HP[ ](\d+)([%%])/i return unless @result.hp_damage > 0 dmg = (@result.hp_damage * $1.to_i * 0.01).to_i if $imported["YEA-BattleEngine"] && dmg > 0 Sound.play_recovery end text = sprintf(YEA::BATTLE:😛OPUP_SETTINGS[:hp_heal], dmg.group) state_origin.create_popup(text, "HP_HEAL") state_origin.hp += dmg state_origin.animation_id = 360That lets me notetag a state with <shock effect: pdrain hp 15%> as opposed to the normal variation <shock effect: drain hp 15%>. Now that we have the pdrain state, we need to define the entire party as the source, instead of just the caster. For that, I'm looking at the Lunatic States Script itself, at these lines:
#-------------------------------------------------------------------------- # new method: change_state_origin #-------------------------------------------------------------------------- def change_state_origin(state_id, type = :apply) return unless $game_party.in_battle return if state_id == death_state_id if :apply && SceneManager.scene_is?(Scene_Battle) subject = SceneManager.scene.subject clear_state_origins if @state_origins.nil? if subject.nil? @state_origins[state_id] = [:actor, self.id] if self.actor? @state_origins[state_id] = [:enemy, self.index] unless self.actor? elsif subject.actor? @state_origins[state_id] = [:actor, subject.id] else @state_origins[state_id] = [:enemy, subject.index] end else # :erase @state_origins[state_id] = nil end end #-------------------------------------------------------------------------- # new method: state_origin? #-------------------------------------------------------------------------- def state_origin?(state_id) return self unless $game_party.in_battle return self if @state_origins[state_id].nil? team = @state_origins[state_id][0] subject = @state_origins[state_id][1] if team == :actor return $game_actors[subject] else # :enemy return $game_troop.members[subject] end endAnd this is the part I don't know anything about. I think I need to adjust this part to allow for the entire party to be the source of a state? (without breaking the existing functionality, of course). Or do I just need to adjust the line at the end of the pdrain itself? I did try various random attempts like:
state_origin_party.create_popup(text, "HP_HEAL")
state_origin_party.hp += dmg
state_origin_party.animation_id = 360
and misc other similar coding shenanigans, but none of them would affect the caster's party. If the solution is here in this part I don't know what it could be. Does anyone have any ideas?
I'd like to expand upon this concept by setting a caster's entire party as the state origin, as opposed to only the caster themself. So the caster could inflict a special kind of Drain State that heals their entire party when the target is damaged.
I've already set up the special state in the Punishment Package, here:
#---------------------------------------------------------------------- # Punish Effect No.9: Party Drain HP # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Best used with shock effect. Whenever user takes HP damage, the # caster's party will heal HP based on HP damage dealt. # # Recommended notetag: # <shock effect: drain hp x%> #---------------------------------------------------------------------- when /PDRAIN HP[ ](\d+)([%%])/i return unless @result.hp_damage > 0 dmg = (@result.hp_damage * $1.to_i * 0.01).to_i if $imported["YEA-BattleEngine"] && dmg > 0 Sound.play_recovery end text = sprintf(YEA::BATTLE:😛OPUP_SETTINGS[:hp_heal], dmg.group) state_origin.create_popup(text, "HP_HEAL") state_origin.hp += dmg state_origin.animation_id = 360That lets me notetag a state with <shock effect: pdrain hp 15%> as opposed to the normal variation <shock effect: drain hp 15%>. Now that we have the pdrain state, we need to define the entire party as the source, instead of just the caster. For that, I'm looking at the Lunatic States Script itself, at these lines:
#-------------------------------------------------------------------------- # new method: change_state_origin #-------------------------------------------------------------------------- def change_state_origin(state_id, type = :apply) return unless $game_party.in_battle return if state_id == death_state_id if :apply && SceneManager.scene_is?(Scene_Battle) subject = SceneManager.scene.subject clear_state_origins if @state_origins.nil? if subject.nil? @state_origins[state_id] = [:actor, self.id] if self.actor? @state_origins[state_id] = [:enemy, self.index] unless self.actor? elsif subject.actor? @state_origins[state_id] = [:actor, subject.id] else @state_origins[state_id] = [:enemy, subject.index] end else # :erase @state_origins[state_id] = nil end end #-------------------------------------------------------------------------- # new method: state_origin? #-------------------------------------------------------------------------- def state_origin?(state_id) return self unless $game_party.in_battle return self if @state_origins[state_id].nil? team = @state_origins[state_id][0] subject = @state_origins[state_id][1] if team == :actor return $game_actors[subject] else # :enemy return $game_troop.members[subject] end endAnd this is the part I don't know anything about. I think I need to adjust this part to allow for the entire party to be the source of a state? (without breaking the existing functionality, of course). Or do I just need to adjust the line at the end of the pdrain itself? I did try various random attempts like:
state_origin_party.create_popup(text, "HP_HEAL")
state_origin_party.hp += dmg
state_origin_party.animation_id = 360
and misc other similar coding shenanigans, but none of them would affect the caster's party. If the solution is here in this part I don't know what it could be. Does anyone have any ideas?