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.

Skill with Status, but.....

I try to explin this as best as I can

I have a skill lets call it Shield Poison that does Damage and cause a status effect like Poison, BUT!! the Poison only takes effect when the enemy has cast Protect on himself. If the enemy never cast Protect on himself and I cast Shield Poison, I'll do Damage, but I can never ever Poison the enemy.

it kinda like a conditional Branch Cant' poison unless the enemy has Protect Status
 
You can try to modify the skill_effect methode in Game_Battler, I added two lines (in blue) but I am not sure if it would work correctly, I don't have rmxp on this computer so I can't test it right now.

Code:
class Game_Battler
  def skill_effect(user, skill)
    self.critical = false
    if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
       ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
      return false
    end
    effective = false
    effective |= skill.common_event_id > 0
    hit = skill.hit
    if skill.atk_f > 0
      hit *= user.hit / 100
    end
    hit_result = (rand(100) < hit)
    effective |= hit < 100
    if hit_result == true
      power = skill.power + user.atk * skill.atk_f / 100
      if power > 0
        power -= self.pdef * skill.pdef_f / 200
        power -= self.mdef * skill.mdef_f / 200
        power = [power, 0].max
      end
      rate = 20
      rate += (user.str * skill.str_f / 100)
      rate += (user.dex * skill.dex_f / 100)
      rate += (user.agi * skill.agi_f / 100)
      rate += (user.int * skill.int_f / 100)
      self.damage = power * rate / 20
      self.damage *= elements_correct(skill.element_set)
      self.damage /= 100
      if self.damage > 0
         if self.guarding?
          self.damage /= 2
        end
      end
      if self.damage.abs > 0
        amp = [self.damage.abs * skill.variance / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      eva = 8 * self.agi / user.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
      effective |= hit < 100
    end
    if hit_result == true
      if skill.power != 0 and skill.atk_f > 0
        remove_states_shock
        effective = true
      end
      last_hp = self.hp
      self.hp -= self.damage
      effective |= self.hp != last_hp
      @state_changed = false
      [COLOR=blue]if skill.id == ID && self.state?(STATE_ID)[/COLOR]
        self.add_state(state_id)
      [COLOR=blue]else[/COLOR]
        effective |= states_plus(skill.plus_state_set)
        effective |= states_minus(skill.minus_state_set)
      [COLOR=blue]end[/COLOR]
      if skill.power == 0
        self.damage = ""
        unless @state_changed
          self.damage = "Miss"
        end
      end
    else
      self.damage = "Miss"
    end
    unless $game_temp.in_battle
      self.damage = nil
    end
    return effective
  end
end

The problem here is that the skill will only add a state only if the skill id is specified in "if" statement.

EDIT: I modified it a lil' bit, it should work now. on if skill.id == ID && self.state?(STATE_ID), change ID for your skill id. STATE_ID is the state the battlet must have if you want the skill to add another state.
You can add more conditions by adding elsif
if skill.id == ID && self.state?(STATE_ID) but, personally, i think it's an ugly way to make it lol
 
you can do some elsif statements like this:
Code:
if skill.id == ID && self.state?(STATE_ID)
...
elsif skill.id == ID && self.state?(STATE_ID)
...
elsif skill.id == ID && self.state?(STATE_ID)
...
etc.
 

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