Chaos Project

RPG Maker => General Discussion => Troubleshooting / Help => Topic started by: Seox on March 30, 2009, 06:33:41 pm

Title: Variance damage on weapons?
Post by: Seox on March 30, 2009, 06:33:41 pm
How do I make it so that certain weapons have a chance to do really good or really bad damage, like axes in several RPGs?

IE

Sword damage= 50-60
Axe damage = 10-180

Get what I'm saying?

Please and thank you ^_^
Title: Re: Variance damage on weapons?
Post by: shdwlink1993 on March 30, 2009, 06:35:53 pm
In the database, go to the weapon and mess with the value Variance. The more you have, the more varied the resulting damage can be.
Title: Re: Variance damage on weapons?
Post by: Kujo on August 14, 2009, 04:55:53 pm
I hate to necropost here (especially since it's my first :shy:), but I too would like to know how to add a variance to weapon damage, but there is no "option" to do so under the Weapons tab in XP.

I hope the OP wasn't asking about VX.  :o

If there's a script floating about, I have failed to find it anywhere.  I've been through pages upon pages of google searches trying to find an answer. 
Rather then go and request a script, I was hoping someone might know of one already available.

Any help appreciated!!
Thanks  8)
Title: Re: Variance damage on weapons?
Post by: shdwlink1993 on August 14, 2009, 05:38:37 pm
Oh wow... I feel rather dumb for posting the answer above, considering that no modern version of RM has a Weapon Variance option with it... I was thinking of items. :(

OK, as for the actual question, Lemme see if I can't not get something coded up here...

Solution?: ShowHide
Code: Weapon Variance
module SL93
 
  def self.weaponVariance(weapon_id)
    case weapon_id
    when 1 then return 5
    when 2 then return 18
    else
      return 15
    end
  end
 
end

class Game_Battler
 
  #--------------------------------------------------------------------------
  # * Applying Normal Attack Effects
  #     attacker : battler
  #--------------------------------------------------------------------------
  def attack_effect(attacker)
    # Clear critical flag
    self.critical = false
    # First hit detection
    hit_result = (rand(100) < attacker.hit)
    # If hit occurs
    if hit_result == true
      # Calculate basic damage
      atk = [attacker.atk - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.str) / 20
      # Element correction
      self.damage *= elements_correct(attacker.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Critical correction
        if rand(100) < 4 * attacker.dex / self.agi
          self.damage *= 2
          self.critical = true
        end
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end
      # Dispersion
      if self.damage.abs > 0
        if attacker.is_a?(Game_Actor)
          amp = [self.damage.abs * SL93::weaponVariance(attacker.weapon_id) / 100, 1].max
        else
          amp = [self.damage.abs * 15 / 100, 1].max
        end
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # Second hit detection
      eva = 8 * self.agi / attacker.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
    end
    # If hit occurs
    if hit_result == true
      # State Removed by Shock
      remove_states_shock
      # Substract damage from HP
      self.hp -= self.damage
      # State change
      @state_changed = false
      states_plus(attacker.plus_state_set)
      states_minus(attacker.minus_state_set)
    # When missing
    else
      # Set damage to "Miss"
      self.damage = 'Miss'
      # Clear critical flag
      self.critical = false
    end
    # End Method
    return true
  end
 
end


I have not tested this, but I'm about 100% it works. If there's an error, then let me know and I'll fix it up.
Title: Re: Variance damage on weapons?
Post by: Kujo on August 14, 2009, 07:03:25 pm
Awesome! Thanks a bunch  :D

Now that I'm looking at it tho...I realize that I actually don't have that much knowledge on how 'Variance' actually works.  :(
Does the variance figure represent actual numbers, or percentage?
And...are they plus/minus?

For instance: Weapon (ID) 1 has an ATK of 10 and a variance of 5. 
Will the damage vary between plus/minus 5 damage, or plus/minus 5% damage?

Also, I assume this script gets inserted above Main, as usual.  :^_^':
Title: Re: Variance damage on weapons?
Post by: shdwlink1993 on August 14, 2009, 08:38:56 pm
Oh, yea. This is a variance of 5%. And yes, the script is inserted above main, just as usual.
Title: Re: Variance damage on weapons?
Post by: Kujo on August 15, 2009, 10:31:26 am
Thanks, brother!
You've been a huge help  :D
Title: Re: Variance damage on weapons?
Post by: Cid on August 16, 2009, 04:21:35 am
I was actually after something like this myself. Good stuff.
Title: Quick Confirmation
Post by: MeVII on January 27, 2010, 12:01:50 pm
Hello, I have a very low confidence with scripts. So I just want a thumbs up if Im reading this correctly.

  def self.weaponVariance(weapon_id)
    case weapon_id
    when 1 then return 5
    when 2 then return 18
    else
      return 15


That is saying when calculating (weapon ID "X" then vary the damage by "Y")
and give all other weapons a variance of 15.

So, to customize you would add "when 3,4,5,6 etc..." for any/all weapons you want to have a variance, and if you want zero variance to be the default, you would change "return 15" to " return 0".

Is all this correct?

If not, naturally, please correct me. :)

Thanks!

                                                                                                                MeVII
Title: Re: Variance damage on weapons?
Post by: Sacred Nym on January 27, 2010, 04:50:35 pm
That sounds about right. If the variance here is the same as skills then default variance should be 15.
Title: Re: Variance damage on weapons?
Post by: MeVII on January 27, 2010, 06:32:41 pm
Thanks for the confirmation! I appreciate it.

What is that powersup thing, who can do it, and how is it done?

Its better off I dont know. :<_<:  Id be very liberal with it.  ;)

I think anyone that takes the time to polity and intelligently respond accurately to any question regarding the programs should get one. :)

Thanks again!
Title: Re: Variance damage on weapons?
Post by: G_G on January 27, 2010, 06:54:50 pm
Look for the [Level++] or [Level--] under the level count
Title: Re: Variance damage on weapons?
Post by: MeVII on February 02, 2010, 04:37:28 pm
My my, and there it is, in plain sight.

My first use of it will be to reduce my power by one for being a dolt and not seeing that myself.  :huh:

                                                                                                          Me VII