Variance damage on weapons?

Started by Seox, March 30, 2009, 06:33:41 pm

Previous topic - Next topic

Seox

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 ^_^
... (<<<<<<<<<<<<<<< TEH DOTS OF DOOM. Hey, kinda catchy. :naughty:)

shdwlink1993

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.
Stuff I've made:




"Never think you're perfect or else you'll stop improving yourself."

"Some people say the glass is half full... some half empty... I just wanna know who's been drinking my beer."

Kujo

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)

shdwlink1993

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.
Stuff I've made:




"Never think you're perfect or else you'll stop improving yourself."

"Some people say the glass is half full... some half empty... I just wanna know who's been drinking my beer."

Kujo

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.  :^_^':

shdwlink1993

Oh, yea. This is a variance of 5%. And yes, the script is inserted above main, just as usual.
Stuff I've made:




"Never think you're perfect or else you'll stop improving yourself."

"Some people say the glass is half full... some half empty... I just wanna know who's been drinking my beer."

Kujo

Thanks, brother!
You've been a huge help  :D

Cid

I was actually after something like this myself. Good stuff.

MeVII

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

Sacred Nym

That sounds about right. If the variance here is the same as skills then default variance should be 15.
Quote昨日の自分に「さようなら」
Say "Goodbye" to who you were yesterday.

MeVII

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!

G_G

Look for the [Level++] or [Level--] under the level count

MeVII

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