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.

% based weapons states rates

Normally you can add any combination of states for weapons,
but you dont have any other control. With this you can use any state based on %. It functions like old rpgmakers ones.

You can ask for bugs, suggerences, compatibilitzations and any other things.

You can get the code in this simple web. Im going to use it on now because it saves alot of time updating posts and other things.

http://usuarios.multimania.es/kisap/english_list.html
Code:
#==============================================================================

# % based weapons states rates

# By gerkrt/gerrtunk

# Version: 1.0

# License: GPL, credits

# Date: 23/12/2010

# IMPORTANT NOTE: to acces the more actualitzed or corrected version of this 

# script check here: [url=http://usuarios.multimania.es/kisap/english_list.html]http://usuarios.multimania.es/kisap/english_list.html[/url]

#==============================================================================

 

=begin

 

--------Introduction-----------

 

Normally you can add any combination of states for weapons,

but you dont have any other control. With this you can use any state based on %.

 

You can ask for bugs, suggerences, compatibilitzations and any other things.

 

-------In the future------------

 

Im going to add complete armors suport, and also, a elements equivalent.

 

------Instructions-------------

 

The % means the posibilities that have the state to impact the enemy. After that

impact, the traditional formula(versus random+abdce) is applied. It works like

old rpgmakers state affliction.

 

 

weapon_id=>[[state_id1, posibility], [state_id2, posibility]]

 

Weap_state_rates = {3=>[[2, 100], [4,100]], 11=>[[2, 100], [4,100]] }

 

You can add any number of states for weapon, and weapons, just add a , before these.

and respect the {}.

 

---------Syntax notes--------------

 

You can divide long linges like this:

 

Weap_state_rates = {3=>[[2, 100], [4,100]], 

11=>[[2, 100], [4,100]] ,

15=>[[2, 100], [4,100]] }

 

See that the new line have to be after a , and that the final one dont put a

final ,.

 

=end

 

 

module Wep

    Weap_state_rates = {3=>[[2, 100], [4,100]], 11=>[[2, 100], [4,100]] }

end

  

class Game_Battler

  #--------------------------------------------------------------------------

  # * Applying Normal Attack Effects

  #     attacker : battler

  #     moded to use unique states rates 

  #--------------------------------------------------------------------------

  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

        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

      # Check to add unique states for weapons

      if attacker.is_a? Game_Actor and Wep::Weap_state_rates[attacker.weapon_id] != nil

        state_list = []

        # Loop over state rates and check the posibiltys. Create a state list.

        for state_rate in Wep::Weap_state_rates[attacker.weapon_id]

            if rand(100) < state_rate[1]

              state_list.push(state_rate[0])

            end

        end

        states_plus(state_list)  

      else

        states_plus(attacker.plus_state_set)

        states_minus(attacker.minus_state_set)

      end

    # When missing

    else

      # Set damage to "Miss"

      self.damage = "Miss"

      # Clear critical flag

      self.critical = false

    end

    # End Method

    return true

  end

 

  

end

 
 

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