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

New Stat for Armor

Recommended Posts

I need a new stat that I can use with armor. I can already make stats that increase with level up, but I need one that doesn't do that. I already have everything set up for it to be in the battle system, and I don't need anything to edit the status screen or equipment menu. I say this because I have a script that does this, but messes with so many things that is was impossible for me to use the way I want to.

 

edit:

In other words, I have 7 stats, and I need an 8th. A stat that doesn't increase when the player levels up, but does when they equip certain equipment. it will be called "LUK" short for luck, obviously. I have a script that adds a stat to that increases on level up, and combines it with another stat so it can be used with armor, but I can't do that with this one since I don't have any stats left to combine it with.

This is the script I'm using, if it helps:

 

# HIT stat
    module STATS
     Hit = {
       1 => { :scaler => 0.9525, :base => 4 },#actor_id => { ...
       2 => { :scaler => 0.9865, :base => 9 },
       3 => { :scaler => 0.9785, :base => 6 },
       4 => { :scaler => 0.9640, :base => 5 },
       5 => { :scaler => 0.9435, :base => 3 },
       6 => { :scaler => 1.0060, :base => 10 },
       7 => { :scaler => 0.9470, :base => 4 },
       }
 
    end
     
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #  Game_Actor
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    class Game_Actor < Game_Battler
     
     alias hit_setup setup
     
     attr_accessor :bob_hit
     
     def setup(actor_id)
       @base_hit = 0
       @hit_bonus = 0
       @thisActor = actor_id
       hit_setup(actor_id)
       @hit = 0
     end
     
      def base_hit
       @base_hit = (level * STATS::Hit[@thisActor][:scaler] + STATS::Hit[@thisActor][:base]).round
     end
     
     def base_pdef
        weapon = $data_weapons[@weapon_id]
        armor1 = $data_armors[@armor1_id]
        armor2 = $data_armors[@armor2_id]
        armor3 = $data_armors[@armor3_id]
        armor4 = $data_armors[@armor4_id]
        pdef1 = weapon != nil ? weapon.pdef : 0
        pdef2 = armor1 != nil ? armor1.pdef : 0
        pdef3 = armor2 != nil ? armor2.pdef : 0
        pdef4 = armor3 != nil ? armor3.pdef : 0
        pdef5 = armor4 != nil ? armor4.pdef : 0
        return pdef1 + pdef2 + pdef3 + pdef4 + pdef5 + base_hit
      end
    end

It's called HIT and is combined with PDEF, because I used the DEX stat as Defense and called it DEF, but needed a way to make HIT increase on level up, since I was using PDEF as HIT.

But I don't want critical hits to have anything to do with DEX and AGI like in the default battle system (called HIT and SPD in my game)

So I'm using LUK, which is the critical hit percentage, so it would be crazy to have it increase on level up.

Edited by Bob423

Share this post


Link to post
Share on other sites

The luck stat doesn't exist in RMXP, you need a script for that to happen.

Share this post


Link to post
Share on other sites

okay that's cool that you know how to quote :huh2: , so should we move this to script request? And I'll try to think of a script by Friday.

Share this post


Link to post
Share on other sites

Wait...I think I can use the EVA stat since it already has a max of 100, which is what I want.

I'll see if I can find a way to do that. If anyone knows, feel free to let me know.

 

Never mind, can't do that. I didn't see it in the battle system at first, but looks like I kept it in there.

Here's a script that adds an actor only stat. I combined it with the pdef stat (I renamed a lot of things, so PDEF is actually HIT and DEX is DEF, it's kinda confusing, but works)

I have a feeling I just need to set how much everything increases it by, but I don't know how to do that.

# HIT stat
    module STATS
     Hit = {
       1 => { :scaler => 0.9525, :base => 4 },#actor_id => { ...
       2 => { :scaler => 0.9865, :base => 9 },
       3 => { :scaler => 0.9785, :base => 6 },
       4 => { :scaler => 0.9640, :base => 5 },
       5 => { :scaler => 0.9435, :base => 3 },
       6 => { :scaler => 1.0060, :base => 10 },
       7 => { :scaler => 0.9470, :base => 4 },
       }
 
    end
     
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #  Game_Actor
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    class Game_Actor < Game_Battler
     
     alias hit_setup setup
     
     attr_accessor :bob_hit
     
     def setup(actor_id)
       @base_hit = 0
       @hit_bonus = 0
       @thisActor = actor_id
       hit_setup(actor_id)
       @hit = 0
     end
     
      def base_hit
       @base_hit = (level * STATS::Hit[@thisActor][:scaler] + STATS::Hit[@thisActor][:base]).round
     end
     
     def base_pdef
        weapon = $data_weapons[@weapon_id]
        armor1 = $data_armors[@armor1_id]
        armor2 = $data_armors[@armor2_id]
        armor3 = $data_armors[@armor3_id]
        armor4 = $data_armors[@armor4_id]
        pdef1 = weapon != nil ? weapon.pdef : 0
        pdef2 = armor1 != nil ? armor1.pdef : 0
        pdef3 = armor2 != nil ? armor2.pdef : 0
        pdef4 = armor3 != nil ? armor3.pdef : 0
        pdef5 = armor4 != nil ? armor4.pdef : 0
        return pdef1 + pdef2 + pdef3 + pdef4 + pdef5 + base_hit
      end
    end
Edited by Bob423

Share this post


Link to post
Share on other sites

hi, looking at the formula the script is using,

all you need is to set :scaler to 0, for your new stat:

 

LUK = {
       1 => { :scaler => 0, :base => 4 },#actor_id => { ...
       2 => { :scaler => 0, :base => 9 },
       3 => { :scaler => 0, :base => 6 },
       4 => { :scaler => 0, :base => 5 },
       5 => { :scaler => 0, :base => 3 },
       6 => { :scaler => 0, :base => 10 },
       7 => { :scaler => 0, :base => 4 },
       }

 

then, the level will not affect the LUK stat at all. it will always be equal to the :base value.

Share this post


Link to post
Share on other sites

That's not at all what I want. I know how to do THAT, I just need it to go up with equipment. That's the part I can't do.

Share this post


Link to post
Share on other sites

ok, If i got you right

> HIT is a new stat for actors

> you add Hit values for each actor, in the script itself.

> you have a script that shows your "Hit" value in menus, by replacing pDef.

> Hit stat is working fine, you only mention it cause you wanna add 'LUK' to it.

> LUK is a new stat for each armor/weapon, it's a set value.

> you wanna set LUK in the script, cause there are no more "database" stats you can use for it

 

>> you wanna change actor's "Hit" stat to be:

actor's HIT + LUK from any equipment it has on

 

so.. which part is giving you trouble? setting LUK in the database? making RMXP use it to calculate Hit?

making it show in menus?

Edited by Metaclaw

Share this post


Link to post
Share on other sites

Almost right. HIT is unrelated. It's just in there to show that I have a script that adds a stat, because I was hoping it could be easily modified.

 

Hope this helps:

 

mV87H38.png

 

I just realized I might've made it worse by saying "Critical HIT" Ignore the fact that Hit is in all caps. It's supposed to be Critical hit...

And I know it's confusing, but it doesn't matter. All you need to worry about is making the LUK stat and having a way for me to easily assign LUK values to equipment and enemies. the base LUK value for actors is 0 of course.

WARNING! Unrelated tangent!

 

adding another reason to never fight without a weapon (not only do you not get the ATK boost from it, but your PWR is reduced to 0, making your normal attacks and all skills weaker, you can't use critical hits AND the damage you do is cut in half.) One minute you're doing 100-115 damage per normal attack, but then you unequip your sword, and now you're doing like 20-30 damage. maybe less.

Maybe I should do this unrelated tangent thing more often, since I tend to go off on a tangent when talking about something, making what I'm saying more confusing because now people are thinking about a slightly different subject. I still feel the need to say useless information because I feel like it's important when it's really not. I could write a really big book about every thought I've had about my game trilogy. Like...a HUGE book with like 10000 pages, I'm not even exaggerating...

 

 

Back on topic...

 

And I also have Foxkit working on it, but he's busy with other stuff and doesn't have a whole lot of time, so if you get it done before him and/or yours is better than his, I'll use it. Thanks :D

 

Protip: Open the image in a new tab if the text is too small.

Edited by Bob423

Share this post


Link to post
Share on other sites

ok, this script lets you add luk to weapon/armor/enemy.

to get the luk value , you can now use enemy.luk / weapon.luk / armor.luk

before I post the script USE this luk value, just making sure:

luk is the chance for a critical hit, in percents? (so 0=never, 100=always) ?

and.. if you're using a custom battle system, I'll need you to search the word 'critical' in it, to see where it handles critical hits. if you find nothing, I have a script all ready& tested for you. if you find any, post that part of the script, I'll modify it.

 

* I added a method to add luck value INSIDE item/enemy names.

I find this method way better, then you have the luk values visible on the database window, with all the other stats.

also, if you delete or add an enemy/weapon/armor in the middle of the list, it'll change the numbers of other enemy/weapon/armor below it, so you have to fix the table often. with names, you don't have such problems.

 

 

>>

#=============================================================================#
#  HIT stat for equipment / Enemy                                             #
#                                                                             #
#  > there are 2 ways to set luk values                                       #
#    first, is editing the table below                                        #
#    second is adding the luck in weapon/armor/enemy name in the database.    #
#     should be something like: IronSword #luk=100                            #
#=============================================================================#


#=============================================================================#
class RPG::Weapon
  
  GET_LUK_FROM_NAME = true    # do you wish to add LUK in a weapon's name
  DEF_LUK = 0                 # default LUK
                              # preventing game-crashing bugs, should
                              # you forget to set LUK for one weapon, etc
# --------------------------------------------------------------------------- #                              
# set your LUK stats for Weapons here.
#    weapon number => LUK stat
  LUK = {  1=>10, 
           2=>20,
           3=>30
           # add more lines as needed
        }
# --------------------------------------------------------------------------- #  
  def luk
    # if using weapon names for luk values
    if GET_LUK_FROM_NAME
      return get_luk_from_name
    end
    # if using the table above
    luck = LUK[self.id]
    # if you forgot to set luk for a certain weapon
    return DEF_LUK if luck.nil?
    # if all is ok
    return luck
  end
  
  # new option: set luk in the weapon's name:
  def get_luk_from_name
    if !GET_LUK_FROM_NAME
      return DEF_LUK
    end
    nm = @name
    if nm.index('=').nil?
      # no luk value is set in weapon's name.
      # use the table to get luk value
      luck = LUK[self.id]
      luck = DEF_LUK if luck.nil?
      return luck
    end
    i = nm.index('=') + 1
    j = nm.size - 1
    luck_txt = nm[i..j]
    luck = luck_txt.to_i
    # test luck is a legal number before using it
    if luck==0 && luck_txt != '0'
      # luck value isn't set correctly, use default
      luck = DEF_LUK 
    end
    return luck
  end
  
  # make RMXP ignore the: #luck=x part of the name
  def name
    nm = @name
    i = nm.index('#')
    return  @name unless GET_LUK_FROM_NAME
    return (@name) if i.nil?
    j = nm.size - 1
    luck_data = nm[i..j]
    nm.delete!(luck_data)
    return nm
  end
  
end


#=============================================================================#
class RPG::Armor
   
  GET_LUK_FROM_NAME = true    # do you wish to add LUK in an armor's name
  DEF_LUK = 0                 # default LUK
                              # preventing game-crashing bugs, should
                              # you forget to set LUK for one weapon, etc
# --------------------------------------------------------------------------- #                              
# set your LUK stats for Armors here.
#    weapon number => LUK stat
  LUK = {  1=>10, 
           2=>20,
           3=>30
           # add more lines as needed
        }
# --------------------------------------------------------------------------- #  
  def luk
    # if using weapon names for luk values
    if GET_LUK_FROM_NAME
      return get_luk_from_name
    end
    # if using the table above
    luck = LUK[self.id]
    # if you forgot to set luk for a certain weapon
    return DEF_LUK if luck.nil?
    # if all is ok
    return luck
  end
  
  # new option: set luk in the weapon's name:
  def get_luk_from_name
    if !GET_LUK_FROM_NAME
      return DEF_LUK
    end
    nm = @name
    if nm.index('=').nil?
      # no luk value is set in weapon's name.
      # use the table to get luk value
      luck = LUK[self.id]
      luck = DEF_LUK if luck.nil?
      return luck
    end
    i = nm.index('=') + 1
    j = nm.size - 1
    luck_txt = nm[i..j]
    luck = luck_txt.to_i
    # test luck is a legal number before using it
    if luck==0 && luck_txt != '0'
      # luck value isn't set correctly, use default
      luck = DEF_LUK 
    end
    return luck
  end
  
  # make RMXP ignore the: #luck=x part of the name
  def name
    nm = @name
    i = nm.index('#')
    return  @name unless GET_LUK_FROM_NAME
    return (@name) if i.nil?
    j = nm.size - 1
    luck_data = nm[i..j]
    nm.delete!(luck_data)
    return nm
  end
  
end


#=============================================================================#
class RPG::Enemy
  
  GET_LUK_FROM_NAME = true    # do you wish to add LUK in an emeny name
  DEF_LUK = 0                 # default LUK
                              # preventing game-crashing bugs, should
                              # you forget to set LUK for one weapon, etc
# --------------------------------------------------------------------------- #                              
# set your LUK stats for Weapons here.
#    weapon number => LUK stat
  LUK = {  1=>10, 
           2=>20,
           3=>30
           # add more lines as needed
        }
# --------------------------------------------------------------------------- #  
  def luk
    # if using weapon names for luk values
    if GET_LUK_FROM_NAME
      return get_luk_from_name
    end
    # if using the table above
    luck = LUK[self.id]
    # if you forgot to set luk for a certain weapon
    return DEF_LUK if luck.nil?
    # if all is ok
    return luck
  end
  
  # new option: set luk in the weapon's name:
  def get_luk_from_name
    if !GET_LUK_FROM_NAME
      return DEF_LUK
    end
    nm = @name
    if nm.index('=').nil?
      # no luk value is set in weapon's name.
      # use the table to get luk value
      luck = LUK[self.id]
      luck = DEF_LUK if luck.nil?
      return luck
    end
    i = nm.index('=') + 1
    j = nm.size - 1
    luck_txt = nm[i..j]
    luck = luck_txt.to_i
    # test luck is a legal number before using it
    if luck==0 && luck_txt != '0'
      # luck value isn't set correctly, use default
      luck = DEF_LUK 
    end
    return luck
  end
  
  # make RMXP ignore the: #luck=x part of the name
  def name
    nm = @name
    i = nm.index('#')
    return  @name unless GET_LUK_FROM_NAME
    return (@name) if i.nil?
    j = nm.size - 1
    luck_data = nm[i..j]
    nm.delete!(luck_data)
    return nm
  end
  
end
Edited by Metaclaw

Share this post


Link to post
Share on other sites

Ok, another problem.

I already have it set up in the battle system and menus. All I need, other than the ability to assign it to equipment and enemies, is to be able to use actor.luk, self.luk, and attacker.luk in the script where they're needed. self and attacker being in the battle system, and actor being for the menus. I already have a place for everything. I made my own menus and damage formula :P

 

Also, I don't understand what you mean by "add luck value INSIDE item/enemy names" All of that part makes no sense.

 

The rest of the script, though looks fine. I'll just go

LUK = {1=>7,  # Lion Blade
       2=>5,  # Iron Sword
       3=>10, # Revolver
       4=>5,  # Iron Spear
       5=>7,  # Short Bow
       6=>3,  # Wooden Staff
      }

for the first 6 weapons. That's easy enough

Edited by Bob423

Share this post


Link to post
Share on other sites

forget about adding luk inside names, then.

just fill the tables. I see you already filled the weapons table.

 

here's the newer script.

> lets you use actor.luk / enemy.luk / attacker.luk / weapon.luk / armor.luk 

> defines an actor's luk. it'll be: weapon.luk + armor1.luk + armor2.luk + armor3.luk +  armor4.luk

> actor's luk will always be between 0 and 100

#=============================================================================#
#  HIT stat for equipment / Enemy                                                   #
#  
#  made by : Metaclaw (also known as silverwind)
#  v.2
#=============================================================================#

class Game_System
  
  DEF_LUK = 0                 # default LUK. 
                              # it will be used for any weapon/armor/enemy
                              # that is not listed in the 3 tables below.
                              # this prevents game-crashing bugs
                              # if you forget to set LUK for one weapon, etc
end

#=============================================================================#
class RPG::Weapon
  
# --------------------------------------------------------------------------- #                         
# set your LUK stats for Weapons here.
#    weapon number => LUK stat
# --------------------------------------------------------------------------- #
  LUK = {  1=>10, 
           2=>20,
           3=>30
           # add more lines as needed
        }
  
  def luk
    luck = LUK[self.id]
    return Game_System::DEF_LUK if luck.nil?
    return luck
  end
  
end


class RPG::Armor
   
# --------------------------------------------------------------------------- #                         
# set your LUK stats for Armors here.
#    armor number => LUK stat
# --------------------------------------------------------------------------- #
  LUK = {  1=>10, 
           2=>20,
           3=>30
           # add more lines as needed
        }
  
  def luk
    # if using the table above
    luck = LUK[self.id]
    return Game_System::DEF_LUK if luck.nil?
    return luck
  end
  
end


class RPG::Enemy
  
# --------------------------------------------------------------------------- #                         
# set your LUK stats for Enemies here.
#    enemy number => LUK stat
# --------------------------------------------------------------------------- # 
  LUK = {  1=>10, 
           2=>20,
           3=>30
           # add more lines as needed
        }
 
  def luk
    luck = LUK[self.id]
    return Game_System::DEF_LUK if luck.nil?
    return luck
  end

end


class Game_Enemy < Game_Battler
  
  def luk
    $data_enemies[@enemy_id].luk
  end
  
end

class Game_Actor < Game_Battler
  def luk
    n = 0
    weapon = $data_weapons[@weapon_id]
    armor1 = $data_armors[@armor1_id]
    armor2 = $data_armors[@armor2_id]
    armor3 = $data_armors[@armor3_id]
    armor4 = $data_armors[@armor4_id]
    n += weapon != nil ? weapon.luk : 0
    n += armor1 != nil ? armor1.luk : 0
    n += armor2 != nil ? armor2.luk : 0
    n += armor3 != nil ? armor3.luk : 0
    n += armor4 != nil ? armor4.luk : 0
    return [[n, 0].max, 100].min
  end
end

now, you say you have scripts that use luk already.

how is that possible, if your game doesn't have luk stat yet?

anyway, this script makes RMXP use the luk value as chance to critical hit. (0=never 100=always)

use it if you need.

class Game_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
# ------- edit: use luk ---------------------------------------------#
        # Critical correction
        #if rand(100) < 4 * attacker.dex / self.agi  # << old code
        if rand(100) < attacker.luk
          self.damage *= 2
          self.critical = true
        end
# -------------------------------------------------------------------#
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end
      # Dispersion
      if self.damage.abs > 0
        amp = [self.damage.abs * 15 / 100, 1].max
        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
Edited by Metaclaw

Share this post


Link to post
Share on other sites

Awesome, thanks! :D

 

What I meant by, i already have it set up, is i dont need you to give me anything to add the stat to any scripts, i already have the code for adding the stat to the menus and stuff, i just need to uncomment it. if it wasnt commented, the game would crash because the stat doesnt exist. same goes for the battle system. that second script is completely unnecessary.

 

I haven't tried it yet, but I'll let you know how it goes when I have the time.

 

edit: it works fine, thanks :D

Edited by Bob423

Share this post


Link to post
Share on other sites

>.> Beat me too it Metaclaw... oh well... such is the world of capitalism. You also put together a much nicer script than I could have, props ^^.

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...