Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[VX]Some specific skill commands I need. Should be fairly easy to implement.

Alright, for the game I am working on, I need 3(!!) skill types implemented, and I am told these would be easy to do.

These are for RPG Maker VX.

1- Heal over Time:
Adds a buff to an ally(or allies) that heals them for X health each turn. X would be a number based on standard healing numbers, but it needs to only heal while the buff is on the person.

Example:
Mending Wind: Heals for ~10 health each turn. Applies Mending Wind to target ally.

2- Delayed Heal + Delayed Damage:
A way to cause a healing effect on an ally/allies to happen after X turns pass, or deal damage to an enemy/enemies after X turns pass.

Example:
Nature's Boon: After 3 turns pass, target ally is healed for ~1000 health.

3- Removal of ailments/buff effect:
Admittedly, possibly the most complicated one. An effect that causes another skill to be used if something happens.

Here's a couple examples of what I mean:
Venomous Revenge: Remove a poison effect from an ally. If a poison effect is removed, (this activates another skill in the database, which would have 0MP cost) you poison all foes.

Mending Sacrifice: Attempts to remove "Mending Wind" from an ally. If Mending Wind is removed, you heal that ally for ~250 health.

Shatter Mind: Attempts to remove "Mind Wrack" from a foe. If Mind Wrack is removed, you deal ~250 damage to that foe.

etc etc.

Basically, these skills will remove a status effect from a foe/ally, and if the status effect (need to be able to write the #'s of all the status effects possible) is removed, it calls another skill to be used.

*Attempt to remove a status ailment (this can be done from the skill database) from a foe or ally.
*Checks to see if a status ailment was removed or not. If no: do nothing. If so: continue.
*If so: calls a skill. There needs to be a way to allow it to target any ally/foe, or all allies/foes, and specifically a way to force the skill to target the ally/foe who you removed the status ailment from.

All I ask is that these are simple to use, and if possible, use the notes system in VX to call these effects and set them up.

If there's anything else you need specified, feel free to ask. I do ask that you make these scripts public, as I think many other users could profit from it.

I'm using the DBS.
 

poccil

Sponsor

The following script implements "healing over time".  Put it in the Materials section of the script editor. 
For each state that includes this healing effect, add the note "[HealingState: X]" where X is the amount of HP that the state recovers each turn.  (Don't include the quotation marks.  Example: [HealingState: 40])  X can also be a percentage, for example: [HealingState: 15%] .
Code:
class Game_Battler
  def setHPDamage(amount)
    @missed=false
    @hp_damage=amount
    @mp_damage=0
    @absorbed=false
    execute_damage(nil)
  end
end

class Scene_Battle
  alias :petero_healingStates_turn_end  :turn_end
  @@_HealingStates=nil
  @@_DamageOverTime=nil
  def turn_end
    if @@_HealingStates==nil
      @@_DamageOverTime={}
      @@_HealingStates={}
      for dataState in $data_states
        next if !dataState
        dataState.note.gsub!(/\[HealingState\:\s*(\d+)\]/i){
          @@_HealingStates[dataState.id]=$1.to_i; next ""
        }
        dataState.note.gsub!(/\[HealingState\:\s*(\d+)%\]/i){
          @@_HealingStates[dataState.id]=-($1.to_i); next ""
        }
        dataState.note.gsub!(/\[DamageOverTime\:\s*(\d+)\]/i){
          @@_DamageOverTime[dataState.id]=$1.to_i; next ""
        }
        dataState.note.gsub!(/\[DamageOverTime\:\s*(\d+)%\]/i){
          @@_DamageOverTime[dataState.id]=-($1.to_i); next ""
        }
      end
    end
    for battler in $game_party.members + $game_troop.members
      damage=0
      for state in @@_HealingStates.keys
        if battler.state?(state)
          amt=@@_HealingStates[state]
          if amt<0
            damage-=battler.maxhp*(-amt)/100
          else
            damage-=amt
          end
        end
      end
      if damage!=0
        battler.setHPDamage(damage)
        display_damage(battler)
        display_state_changes(battler)
        wait(25)
      end
      damage=0
      for state in @@_DamageOverTime.keys
        if battler.state?(state)
          amt=@@_DamageOverTime[state]
          if amt<0
            damage+=battler.maxhp*(-amt)/100
          else
            damage+=amt
          end
        end
      end
      if damage!=0
        battler.setHPDamage(damage)
        display_damage(battler)
        display_state_changes(battler)
        wait(25)
      end
    end
    petero_healingStates_turn_end
  end
end

EDIT:  Made improvements and fixed a bug.

EDIT:  Added a new feature, "damage over time".  Similar to "healing over time", but reduces HP instead.  Each state that has this ability should have the note [DamageOverTime: X] where X is the amount of HP to subtract and can be a number or a percentage.
 

poccil

Sponsor

Here's a similar script that implements "delayed damage" and "delayed healing".  Like the script above, add a note containing [DelayedDamageState: X] or [DelayedHealState: X], respectively, where X can be either a number or a percentage.  The damage or healing effect triggers as soon as the state is removed naturally, and not when the state is removed from an effect. The code is below.

Code:
class Game_Battler
  def setHPDamage(amount)
    @missed=false
    @hp_damage=amount
    @mp_damage=0
    @absorbed=false
    execute_damage(nil)
  end
end

class Scene_Battle
  alias :petero_delayedHeal_remove_states_auto  :remove_states_auto
  @@_DelayedHealStates=nil
  @@_DelayedDamageStates=nil
  def remove_states_auto
    petero_delayedHeal_remove_states_auto
    if @@_DelayedHealStates==nil
      @@_DelayedHealStates={}
      @@_DelayedDamageStates={}
      for dataState in $data_states
        next if !dataState
        dataState.note.gsub!(/\[DelayedHealState\:\s*(\d+)\]/i){
          @@_DelayedHealStates[dataState.id]=$1.to_i; next ""
        }
        dataState.note.gsub!(/\[DelayedHealState\:\s*(\d+)%\]/i){
          @@_DelayedHealStates[dataState.id]=-($1.to_i); next ""
        }
        dataState.note.gsub!(/\[DelayedDamageState\:\s*(\d+)\]/i){
          @@_DelayedDamageStates[dataState.id]=$1.to_i; next ""
        }
        dataState.note.gsub!(/\[DelayedDamageState\:\s*(\d+)%\]/i){
          @@_DelayedDamageStates[dataState.id]=-($1.to_i); next ""
        }
      end
    end
    damage=0
    for state in @@_DelayedHealStates.keys
        if @active_battler.removed_states.include?($data_states[state])
          amt=@@_DelayedHealStates[state]
          if amt<0
            damage-=@active_battler.maxhp*(-amt)/100
          else
            damage-=amt
          end
        end
    end
    if damage!=0
      @active_battler.setHPDamage(damage)
      display_damage(@active_battler)
      display_state_changes(@active_battler)
      wait(25)
    end
    damage=0
    for state in @@_DelayedDamageStates.keys
        if @active_battler.removed_states.include?($data_states[state])
          amt=@@_DelayedDamageStates[state]
          if amt<0
            damage+=@active_battler.maxhp*(-amt)/100
          else
            damage+=amt
          end
        end
    end
    if damage!=0
      @active_battler.setHPDamage(damage)
      display_damage(@active_battler)
      display_state_changes(@active_battler)
      wait(25)
    end
  end
end
 

poccil

Sponsor

I think I've implemented your last request.  The code is below.  To use it, add the following note to the skill: [CallSkillIfRemoved: X] where X is the skill to use.  If the skill has the same target, use this note instead: [CallSkillIfRemovedSameTarget: X] where X is the skill to use.

EDIT: The tag must be applied to the skill that removes the state, not to skills that add the state or to states that the skill removes.  I had to emphasize this.

Code:
class Game_BattleAction
 attr_accessor :specificTarget
 alias :petero_callskill_make_targets :make_targets
 def make_targets
  if @specificTarget
   return @specificTarget.is_a?(Array) ? @specificTarget : [@specificTarget]
  end
  return petero_callskill_make_targets
 end
end

class Game_Battler
 attr_accessor :action
 def setSkillAction(skillID)
  @action=Game_BattleAction.new(self)
  @action.kind=1
  @action.forcing=false
  @action.skill_id=skillID
 end
end

class Scene_Battle
 alias :petero_callskill_display_action_effects :display_action_effects
 @@_CallSkillIfRemoved=nil
 def display_action_effects(target,skill=nil)
  if @@_CallSkillIfRemoved==nil
    @@_CallSkillIfRemoved={}
    for dataState in $data_skills
     next if !dataState
     dataState.note.gsub!(/\[CallSkillIfRemoved\:\s*(\d+)\]/i){
      @@_CallSkillIfRemoved[dataState.id]=$1.to_i; next ""
     }
     dataState.note.gsub!(/\[CallSkillIfRemovedSameTarget\:\s*(\d+)\]/i){
      @@_CallSkillIfRemoved[dataState.id]=-$1.to_i; next ""
     }
    end
  end
  petero_callskill_display_action_effects(target,skill)
  if skill && skill.is_a?(RPG::Skill)
   stateRemoved=false
   for state in skill.minus_state_set
    stateRemoved=true if target.removed_states.include?($data_states[state])
   end
   if stateRemoved && @@_CallSkillIfRemoved[skill.id]
    sameTarget=(@@_CallSkillIfRemoved[skill.id])<0
    newSkillID=@@_CallSkillIfRemoved[skill.id].abs
    if newSkillID!=skill.id # to prevent infinite recursion
     oldAction=@active_battler.action
     @active_battler.setSkillAction(newSkillID)
     if sameTarget
       @active_battler.action.specificTarget=[target]
     end
     execute_action_skill
     @active_battler.action=oldAction
    end
   end
  end  
 end
end
 
Hey guy, you're awesome, but there's an error. When I try to access my skill list it crashes with the following error:
Script 'Window_Skill' line 57: ArgumentError
wrong number of arguments (4 for 3)

Line 57:
      draw_item_name(skill, rect.x, rect.y, enabled)

EDIT: But I'm not sure if its your scripts causing it or not, gonna investigate.

All I need now is a modified version of the HoT for damage, and I'm golden. Either way, I'll try to forward you some cash when I get some, later on.

EDIT EDIT:
Yep, not your script, it was another one.

EDIT EDIT EDIT:
Yo dude, maybe it's because I'm dumb, but I can't seem to get the following exchange to work:

Mending Wind (skill): Applies Mending Wind to an ally.
^this works, I get Mending Wind and am healed 10 HP each turn.

Mending Wind (state): Has the following notes:
[HealingState: 10]
[CallSkillIfRemovedSameTarget: 996]

Nature's Burst (skill) Removes Mending Wind from an ally.
^this works, Mending Wind is removed.

Mending Burst (skill 996): Heals for ~300. Is not called. The hero doesn't know this skill, obviously.

Is it because I'm not allowed to have both notes or what?? I really want this to work but my guy doesn't get healed. :/
 

poccil

Sponsor

The tag "CallSkillIfRemoved" and "CallSkillIfRemovedSameTarget" must be applied to skills, not to states.  Such skills must have an effect that removes at least one state.
 

poccil

Sponsor

I have received a private message saying that the topic was resolved.  The script needed to be placed after all others.  From "handsome lamb":
omg dude

it works

thanks a TON man.

you rock SO HARD.

do you have a way to modify the HoT script to have a damage version as well? That way I can create Poison effects that are outside the standard poison values.

To respond, I've just done so, see my first post on this thread.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top