Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Bob423

[RGSS] Random syntax error

Question

So I've been editing the battle fomulas, and have set up a series of if statements to determine the strength of skills.

the problem is, no matter what i do, as long as it's not the default, i always get a syntax error on the first else, elsif, or end of my if statements.

 

 

I know it's not he battle system or anything because it does the same thing in a blank project.

the part i'm having trouble with starts where it says "# Calculate basic skill damage #"

and ignore the fact that the stats are rearranged. that's not the problem.

class Game_Battler
  include N01
  #--------------------------------------------------------------------------
  # * Apply Skill Effects
  #     user  : the one using skills (battler)
  #     skill : skill
  #--------------------------------------------------------------------------
  def skill_effect(user, skill)
    # Clear critical flag
    self.critical = false
    # If skill scope is for ally with 1 or more HP, and your own HP = 0,
    # or skill scope is for ally with 0, and your own HP = 1 or more
    if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
       ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
      # End Method
      return false
    end
    # Clear effective flag
    effective = false
    # Set effective flag if common ID is effective
    effective |= skill.common_event_id > 0
    # First hit detection
    hit = skill.hit
    if skill.atk_f > 0
      hit *= user.hit / 100
    end
    hit_result = (rand(100) < hit)
    # Set effective flag if skill is uncertain
    effective |= hit < 100
    # If hit occurs
    if hit_result == true
#==============================================================================#
# Calculate basic skill damage #
#==============================#
      if skill.str_f > 0 and skill.power > 0 # if skill uses STR (ATK)
        attack = (((user.str * 4) + (skill.power * ((user.atk / 2) / 100))
        self.damage = attack - (self.dex / 2)
      end
      if skill.int_f > 0 and skill.power > 0 # skill uses INT
        attack = (((user.int * 4) + (skill.power * ((user.atk / 2) / 100))
        self.damage = attack - (self.mdef / 2)
      end
      if skill.pdef_f > 0 and skill.power > 0 # skill uses PDEF (HIT)
        attack = (((user.pdef * 4) + (skill.power * ((user.atk / 2) / 100))
        self.damage = attack - (self.agi / 2)
      end
      if skill.power < 0 # if skill is a healing spell
        attack = (((user.int * 4) + ((skill.power * -1) * ((user.atk / 2) / 100))
        self.damage = (attack * -1)
      end
      if skill.power == 0
        self.damage = 0
      end
#==============================================================================#
      # Element correction
      self.damage *= elements_correct(skill.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end
      # Dispersion
      if skill.variance > 0 and self.damage.abs > 0
        amp = [self.damage.abs * skill.variance / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # Second hit detection
      eva = 8 * self.agi / user.pdef + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
      # Set effective flag if skill is uncertain
      effective |= hit < 100
    end
    # If hit occurs
    if hit_result == true
      # If physical attack has power other than 0
      if skill.power != 0 and skill.atk_f > 0
        # State Removed by Shock
        remove_states_shock
        # Set to effective flag
        effective = true
      end
      # Substract damage from HP
      last_hp = self.hp
      self.hp -= self.damage
      effective |= self.hp != last_hp
      # State change
      @state_changed = false
      effective |= states_plus(skill.plus_state_set)
      effective |= states_minus(skill.minus_state_set)
      # If power is 0
      if skill.power == 0
        # Set damage to an empty string
        self.damage = ""
        # If state is unchanged
        unless @state_changed
          # Set damage to "Miss"
          self.damage = "Miss"
        end
      end
    # If miss occurs
    else
      # Set damage to "Miss"
      self.damage = "Miss"
    end
    # If not in battle
    unless $game_temp.in_battle
      # Set damage to nil
      self.damage = nil
    end
    # End Method
    return effective
  end
end
Edited by Bob423

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Your parenthesis are wrong. You've got "attack = ( ( ( user.str * ) + skill.power * ( ( user.atk / ) / 100 ) ) ". There are two extra paranthesis in front of user.str. The same is true of the rest of your lines in that section. When I've got syntax errors those are the first thing I check cause it's what I typically screw up.

Share this post


Link to post
Share on other sites
  • 0

I use so many parenthesis because i want to make sure the PEMDAS stuff is correct. I guess I could check it on a calculator instead though. Thanks.

Share this post


Link to post
Share on other sites
  • 0

as far as i can tell you have 1 too many parenthesis in the front of the equation. and since the last part skill.power * ( ( user.atk / ) / 100 ) ) is all multiply and divide you don't actually need parenthesis between them, only addition and subtraction need the order of operations indicated. (( user.str * 4 ) + ( skill.power * user.atk / 200 )) should work fine and since you can combine the division of two non variables like 2 and 100 = 200.

 

But I didn't test it so you might have another problem.

Share this post


Link to post
Share on other sites
  • 0

I already fixed it thanks to Mobius, thanks.

 

Oh I was pretty sure he did, i was just letting you know you don't need to worry about parenthesis too much as long as you use them properly like in traditional math.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...