The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Winterfell on November 26, 2011, 07:51:34 PM

Title: Help for a mini script construction
Post by: Winterfell on November 26, 2011, 07:51:34 PM
Hello and excuse for my bad english !

I try to make a little script in order to add some parameters to actors and enemies. I use a script because i want some custom parameters in the hit ratio or the damage formula. So, i made this :

 
[spoiler] class Game_Actor
 
 
  attr_accessor :combat, :tir, :artmilitaire, :athletisme, :connaissance, :duperie, :endurance, :ingeniosite, :langue, :persuasion, :soins, :statut, :survie, :vigilance, :volonte, :dressage
 
  alias caracteristique_initialize initialize
  def initialize(*args)
    @combat = 0
    @tir= 0
    @artmilitaire = 0
    @connaissance = 0
    @duperie = 0
    @endurance = 0
    @ingeniosite = 0
    @langue = 0
    @persuasion = 0
    @soins = 0
    @statut = 0
    @survie = 0
    @vigilance = 0
    @volonte = 0
    @dressage = 0
    caracteristique_initialize(*args)
  end
end

module RPG
  class Enemy
   
    def combat
      if @combat.nil?
        txt = Jet.check_tag_number(self, /<(?:combat)[ ]*(\d+)>/i)
        @combat = txt.nil? ? 0 : txt.to_i
      end
      return @combat
    end
   
    def tir
      if @tir.nil?
        txt = Jet.check_tag_number(self, /<(?:tir)[ ]*(\d+)>/i)
        @tir = txt.nil? ? 0 : txt.to_i
      end
      return @tir
    end
   
    def artmilitaire
      if @artmilitaire.nil?
        txt = Jet.check_tag_number(self, /<(?:artmilitaire)[ ]*(\d+)>/i)
        @artmilitaire = txt.nil? ? 0 : txt.to_i
      end
      return @artmilitaire
    end
   
    def connaissance
      if @connaissance.nil?
        txt = Jet.check_tag_number(self, /<(?:connaissance)[ ]*(\d+)>/i)
        @connaissance = txt.nil? ? 0 : txt.to_i
      end
      return @connaissance
    end
   
    def duperie
      if @duperie.nil?
        txt = Jet.check_tag_number(self, /<(?:duperie)[ ]*(\d+)>/i)
        @duperie = txt.nil? ? 0 : txt.to_i
      end
      return @duperie
   end
   
    def endurance
      if @endurance.nil?
        txt = Jet.check_tag_number(self, /<(?:endurance)[ ]*(\d+)>/i)
        @endurance = txt.nil? ? 0 : txt.to_i
      end
      return @endurance
   end
 
    def ingeniosite
      if @ingeniosite.nil?
        txt = Jet.check_tag_number(self, /<(?:ingeniosite)[ ]*(\d+)>/i)
        @ingeniosite = txt.nil? ? 0 : txt.to_i
      end
      return @ingeniosite
end
 
  def langue
      if @langue.nil?
        txt = Jet.check_tag_number(self, /<(?:langue)[ ]*(\d+)>/i)
        @langue = txt.nil? ? 0 : txt.to_i
      end
      return @langue
    end

  def persuasion
      if @persuasion.nil?
        txt = Jet.check_tag_number(self, /<(?:persuasion)[ ]*(\d+)>/i)
        @persuasion = txt.nil? ? 0 : txt.to_i
      end
      return @persuasion
  end

  def soins
      if @soins .nil?
        txt = Jet.check_tag_number(self, /<(?:soins)[ ]*(\d+)>/i)
        @soins  = txt.nil? ? 0 : txt.to_i
      end
      return @soins
    end
 
      def statut
      if @statut .nil?
        txt = Jet.check_tag_number(self, /<(?:statut )[ ]*(\d+)>/i)
        @ingeniosite = txt.nil? ? 0 : txt.to_i
      end
      return @statut
    end

 
      def survie
      if @survie.nil?
        txt = Jet.check_tag_number(self, /<(?:survie)[ ]*(\d+)>/i)
        @survie = txt.nil? ? 0 : txt.to_i
      end
      return @survie
    end
 
   def vigilance
      if @vigilance.nil?
        txt = Jet.check_tag_number(self, /<(?:vigilance)[ ]*(\d+)>/i)
        @vigilance = txt.nil? ? 0 : txt.to_i
      end
      return @vigilance
    end
 
 
   def volonte
      if @survie.nil?
        txt = Jet.check_tag_number(self, /<(?:volonte)[ ]*(\d+)>/i)
        @volonte = txt.nil? ? 0 : txt.to_i
      end
      return @volonte
end

 
   def dressage
      if @dressage.nil?
        txt = Jet.check_tag_number(self, /<(?:dressage)[ ]*(\d+)>/i)
        @survie = txt.nil? ? 0 : txt.to_i
      end
      return @dressage
    end
 
end   
end


class Window_Base
  def draw_actor_parameter(actor, x, y, type)
    case type
    when 0
      parameter_name = Vocab::atk
      parameter_value = actor.atk
    when 1
      parameter_name = Vocab::def #AC
      parameter_value = actor.def
    when 2
      parameter_name = Vocab::spi
      parameter_value = actor.spi
    when 3
      parameter_name = Vocab::agi
      parameter_value = actor.agi
    when 4
      parameter_name = "Combat"
      parameter_value = actor.combat
      param_mod = ((parameter_value-10)/2)
    when 5
      parameter_name = "Tir"
      parameter_value = actor.tir 
     
    when 6
      parameter_name = "Art militaire"
      parameter_value = actor.artmilitaire
     
    when 7
      parameter_name = "Connaissance"
      parameter_value = actor.connaissance
     
    when 8
      parameter_name = "Duperie"
      parameter_value = actor.duperie 
     
    when 9 
      parameter_name = "Endurance"
      parameter_value = actor.endurance
     
    when 10 
      parameter_name = "Ingeniosité"
      parameter_value = actor.ingeniosite
    when 11
      parameter_name = "Langue"
      parameter_value = actor.langue
    when 12 
      parameter_name = "Persuasion"
      parameter_value = actor.persuasion
   
        when 13 
      parameter_name = "Soins"
      parameter_value = actor.soins
   
        when 14 
      parameter_name = "Statut"
      parameter_value = actor.statut
   
       when 15
      parameter_name = "Survie"
      parameter_value = actor.survie
     
    when 16
      parameter_name = "Vigilance"
      parameter_value = actor.vigilance
   
    when 17 
      parameter_name = "Volonté"
      parameter_value = actor.volonte
    end

      if type < 4
        self.contents.font.color = system_color
      elsif type >= 4 and type < 6
        self.contents.font.color = Color.new(255, 0, 0, 255)
      elsif type >=6 and type < 8
        self.contents.font.color = Color.new(173, 255, 47, 255)
      elsif type >= 10
        self.contents.font.color = system_color
      else
        self.contents.font.color = Color.new(218, 112, 214, 255)
      end
    self.contents.draw_text(x, y-24, 120, WLH, parameter_name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 80, y-24, 36, WLH, parameter_value, 2)
   
  end
end

class Window_Status < Window_Base
  alias xstats_draw_parameters draw_parameters
  def draw_parameters(x, y)
    xstats_draw_parameters(x, y)
    draw_actor_parameter(@actor, x, y + WLH * 4, 4)
    draw_actor_parameter(@actor, x, y + WLH * 5, 5)
    draw_actor_parameter(@actor, x, y + WLH * 6, 6)
    draw_actor_parameter(@actor, x, y + WLH * 7, 7)
    draw_actor_parameter(@actor, x, y + WLH * 8, 8)
    draw_actor_parameter(@actor, x, y + WLH * 9, 9)
    draw_actor_parameter(@actor, x, y + WLH * 10, 10)
    draw_actor_parameter(@actor, x, y + WLH * 11, 11)

end
end
[/spoiler]

The featuring

I just want some new parameters and play with them. But i don't know how i can use these parameters with a script call in the software. For exemple, if Ralph have 6 in Endurance, so X. BUT the enemies also have these parameters who can interfere in the battle results. 
Title: Re: Help for a mini script construction
Post by: Mr_Wiggles on November 27, 2011, 05:47:06 AM
Sooo, you want to know how to have these new attributes affect battles?

If you wrote this you should be able to do it easily, look at the Game Battle class and look at the deal_damage part. (i dont have VX installed currently but i use XP and they're sorta alike.)

Then looking at how it uses the default attributes like strength and dexterity, you should be able to weave in some new checks.

That was what you wanted right? Sorta a point to what direction you needed to go?