Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: Jragyn on August 24, 2009, 09:20:43 pm

Title: [XP] Elemental Reflector
Post by: Jragyn on August 24, 2009, 09:20:43 pm
Elemental Reflector v1.3
Authors: Hima?
Version: 1.3
Type: Battle Add-on Script
Key Term: Battle Add-on



Introduction

This is a script that allows magic and skills to be reflected by element, rather than 'magic' or not.


Features




Screenshots
Rather difficult to take screen shots, but here are 2 anyways.

Spoiler: ShowHide
(http://i46.photobucket.com/albums/f150/Jragyn/E_Reflect1.png)

Spoiler: ShowHide
(http://i46.photobucket.com/albums/f150/Jragyn/E_Reflect2.png)



Demo

http://www.sendspace.com/file/4pnfbo


Script

A good place to put this is probably above MAIN and below the default scripts.
If your using a CBS, if it is to work at all, it'd likely have to be below that.

Spoiler: ShowHide

=begin
#==============================================================================# 
    Hima's Elemental Reflect v. 1.3
#==============================================================================# 

  Using this script will allow a character or enemy to reflect skills by
  element.
 
  ---Version History:

  1.0 -  First Released
  1.1 -  Fixed infinite reflect problem
  1.2 -  More features added
          a.) You can now choose to reflect any physical or magical skill.
          b.) Physical reflect will also reflect any basic attack.
          c.) Basic attack with element will also be reflected from elemental reflector.
  1.3 -  Fixed some bugs that occur when you don't put all the ELEMENTS you defined into the database.
#==============================================================================#
    Of course, all credits of this script go to HIMA, the presumable
    lady who made this script.
   
  contact : ninomiya_mako@hotmail.com
#==============================================================================# 
=end
module HIMA_REFLECT

#=====================================#
#  This is the part you should read.  #
#=====================================#
=begin

The structure:

          ELEMENTS = {"ELEM_REFLECT_ID" => ID_TO_REFLECT}

  "ELEM_REFLECT_ID" = The ID of the element you want to check or raise to 'A'.
                      This can effectively be named whatever you want,
                      though you should probably relate it to the proper element.
                      It must be within the quotes, though.
 
   ID_TO_REFLECT    = This is the ID of the element that will be reflected.

   
   So lets say this is an example:
   
          ELEMENTS = {"Fire Reflector" => 1}

  In this instance, the name of the element that will be reflecting is called:
  "Fire Reflector", when this element is checked (on armor or accessories) or
  raised to 'A' resistance (on enemies) then the element in ID 1 will be
  reflected.
#==============================================================================# 
  SPECIAL ELEMENT WORDS:
 
  "Physical" - using this term in place of the ID_TO_REFLECT will reflect all
               skills with an ATK-Force > 0 and even normal attacks.
           
  "Magical"  - Using this term in place of ID_TO_REFLECT will reflect all types
               of skills with an INT-Force > 0, regardless of element.

Lastly:
   
    WORD  - This is the string that will pop up when a skill is reflected.

Oh, and on a final note:
  If you have cast an element on an enemy, ie, Ice, and both you and the
  enemy reflects the ice element, it will just say "Block".
 
  You can also edit that word if you want to, just CTRL+F "Block", and change
  each one to whatever you want. :)
________________________________________________________________________________
=end
#========================================#
#  This is the tiny part you customize.  #
#========================================#

    ELEMENTS = {"Fire Reflector" => 1,
                "Ice Repel" => 2,
                "Deflection" => "Physical",
                "Reflection" => "Magical"}
    WORD = "Reflected!"
#========================================#
end

module RPG
    class Skill
        def type_of_skill
            if @int_f > 0
                return "Magical"
            elsif @atk_f > 0
                return "Physical"
            else
                return nil
            end
        end
    end
end

class Game_Battler
  attr_accessor :reflect                   # Reflect Flag
    alias hima_reflect_init initialize
    def initialize
        @reflect = 0    #0 = no reflect, 1 = basic_attack, 2 = skill_effect
    hima_reflect_init
    end
   
    alias hima_reflect_attack_effect attack_effect
    def attack_effect(attacker)
        # Check for reflect basic attack
        element_to_reflect = HIMA_REFLECT::ELEMENTS.index("Physical")
        reflect_id = $data_system.elements.index(element_to_reflect)
        if reflect_id != nil
            if self.element_reflect(reflect_id) == 1
                if attacker.element_reflect(reflect_id) == 1
                    self.damage = "Block"
                    self.reflect = 0
                else
                    self.damage = HIMA_REFLECT::WORD
                    self.reflect = 1
                end
                return false
            end
        end
        # End of reflect basic attack
       
        # Check for reflect element of basic attack
        for q in 0...attacker.element_set.size
            element_id = attacker.element_set[q]
            element_to_reflect = HIMA_REFLECT::ELEMENTS.index(element_id)
            if element_to_reflect != nil
                reflect_id = $data_system.elements.index(element_to_reflect)
                if self.element_reflect(reflect_id) == 1
          if attacker.element_reflect(reflect_id) == 1
              self.damage = "Block"
              self.reflect = 0
          else
              self.damage = HIMA_REFLECT::WORD
              self.reflect = 1
          end
          return false
                end
            end
        end #end for       
        # End of reflect element of basic attack
        hima_reflect_attack_effect(attacker)
    end
   
    alias hima_reflect_skill_effect skill_effect
  def skill_effect(user, skill)
        # Reflect physical or magic skill
        if skill.type_of_skill != nil
            element_id = skill.type_of_skill
            element_to_reflect = HIMA_REFLECT::ELEMENTS.index(element_id)
            if element_to_reflect != nil
                reflect_id = $data_system.elements.index(element_to_reflect)
                if reflect_id != nil
                    if self.element_reflect(reflect_id) == 1
                        if user.element_reflect(reflect_id) == 1
                                self.damage = "Block"
                                self.reflect = 0
                        else
                                self.damage = HIMA_REFLECT::WORD
                                self.reflect = 2
                        end
                        return false
                    end
                end
            end
        end
       
        # Reflect specific element
        for q in 0...skill.element_set.size
            element_id = skill.element_set[q]
            element_to_reflect = HIMA_REFLECT::ELEMENTS.index(element_id)
            if element_to_reflect != nil
                reflect_id = $data_system.elements.index(element_to_reflect)
                if reflect_id != nil
                    if self.element_reflect(reflect_id) == 1
                        if user.element_reflect(reflect_id) == 1
                                self.damage = "Block"
                                self.reflect = 0
                        else
                                self.damage = HIMA_REFLECT::WORD
                                self.reflect = 2
                        end
                        return false
                    end
                end
            end
        end #end for
        hima_reflect_skill_effect(user,skill)
  end
   
    def element_reflect(element_id)
        if self.is_a?(Game_Actor)
        result = $data_classes[self.class_id].element_ranks[element_id]

            for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
                armor = $data_armors[i]
                if armor != nil and armor.guard_element_set.include?(element_id)
                    result = 1
                end
            end
   
            for i in @states
                if $data_states[i].guard_element_set.include?(element_id)
                    result = 1
                end
            end
        else
            result = $data_enemies[self.enemy_id].element_ranks[element_id]
            for i in @states
                if $data_states[i].guard_element_set.include?(element_id)
                    result = 1
                end
            end
        end
    # Method end
    return result
  end
end

class Game_Enemy < Game_Battler
    attr_accessor        :enemy_id
end

class Scene_Battle
    alias hima_update_phase4_step5 update_phase4_step5
  def update_phase4_step5
        hima_update_phase4_step5
    reflect = 0
        for target in @target_battlers
          if target.reflect != 0
                reflect = target.reflect
                target.reflect = 0
      end
    end
        if reflect > 0
      @target_battlers = []
            @target_battlers.push(@active_battler)
            case reflect
                when 1
                    @active_battler.attack_effect(@active_battler)
                when 2
                    @active_battler.skill_effect(@active_battler,@skill)
            end #case
            @phase4_step = 4
        else
      @phase4_step = 6
    end
  end
end



Instructions

I hid instructions at the top of the script.
Feel free to download to the demo for demonstration and such.


Compatibility

I don't believe it works with Cogwheel's RTAB.
I haven't tested it with anything else, but it probably doesn't work well with things outside of the DBS.
It does however, work with Ryexander's Asan'Tear Battle System, as its what I use. :]


Credits and Thanks




Author's Notes
No special words of advice. Just use and enjoy.
Title: Re: [XP] Elemental Reflector
Post by: Jragyn on October 16, 2009, 03:25:20 pm
So uhh...
is anyone putting this to wonderful use?
Or is this rendered useless thanks to Blizzard's own Reflection system?
Title: Re: [XP] Elemental Reflector
Post by: xeilmach on July 10, 2011, 08:29:50 pm
I know this topic is pretty old, but since it's in the script database, it should be addressed for those who come here from it.

I set up the script and everything database item right and when I used it in the DBS, nothing seems to happen (yes, it is above "Main"). Has anyone gotten this to work before?

Thanks.
Title: Re: [XP] Elemental Reflector
Post by: Jragyn on July 13, 2011, 07:45:23 pm
I'm in the process of re-writing this script (and a bundle of others) to be re-released.

To answer the question though, I myself have functioned it.
What exactly is the issue?

Perhaps linking a copy of a naked project with this script in it how you think it needs to be setup, yet not working, would help me troubleshoot any issues you have.


--J
Title: Re: [XP] Elemental Reflector
Post by: xeilmach on July 14, 2011, 12:34:00 am
Okay, here it is:

http://www.megaupload.com/?d=5IWW6AIS (http://www.megaupload.com/?d=5IWW6AIS).
Title: Re: [XP] Elemental Reflector
Post by: Jragyn on July 23, 2011, 02:36:45 pm
:\ Looking at project, you failed to setup the database at all.
This project is an example of how it should be setup.
Also, you could've downloaded the demo for explanation too, if it wasn't working.

Your Demo Project~ (http://db.tt/ZqFUhSN)

--J
Title: Re: [XP] Elemental Reflector
Post by: Diamond Star on November 01, 2011, 08:30:29 am
This is good script ,I need it
but I nees to be able to specify the actor or enemy who will reflect not all
I want to make askill make its target reflect attacks on attacker or one of attacker party or all members........
Is this possible by modifying this script