RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Element Immunities

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Element Immunities
Version: 1.0
Author: modern algebra
Date: October 10, 2008

Version History


  • <Version 1.0> 10.10.2008 Original Release

Description


This script allows you to make it so that only weapons, skills, or items with a certain element can target an enemy, as denoted by you. So, if you want to make a flying enemy that can only be hit by ranged weapons, then you can set it so that only weapons with the element 'Ranged' can hit that enemy.

Features

  • Allows you to restrict what weapons, etc... can be used to target an enemy
  • Easy customizability by setting element vulnerabilites in the Notes section of the Enemy

Instructions

See inside the header of the script.

Script


Code: [Select]
#==============================================================================
#  Element Immunities
#  Version: 1.0
#  Author: modern algebra (rmrk.net)
#  Date: October 9, 2008
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#    Place this script above Main and below Materials in the Script Editor.
#
#    To restrict what elements can harm the enemy, place into the notes section
#   of the Enemy this code:
#
#     \ELEM_VULN[element_ID]
#   
#    You can put as many of them as you like, and that will mean that only
#   those elements can harm the enemy. If you do not put any, then it will
#   assume that the monster is vulnerable to all elements.
#
#    EXAMPLE:
#     If this were in the Notes Box of a given enemy:
#
#      \ELEM_VULN[4]
#      \ELEM_VULN[5]
#
#    Then any item, weapon, or skill without either element 4 or 5 will not be
#   able to hurt this enemy.
#==============================================================================
# ** Game_Temp
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new accessor instance variable - active_battler
#==============================================================================

class Game_Temp
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variable
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :active_battler # Holds current battler
end

#==============================================================================
# ** Game_Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - element_vulnerable?
#==============================================================================

class Game_Enemy
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Element Vulnerable?
  #    attack_array : an array of the objects used to attack the enemy
  #``````````````````````````````````````````````````````````````````````````
  #  Checks if the actor can hurt the enemy with the elements being used
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def element_vulnerable? (attack_array)
    # Retrieve note
    note = $data_enemies[@enemy_id].note.dup
    test = false
    while note.slice! (/\\ELEM_VULN\[(\d+)\]/i) != nil
      attack_array.each { |i| return true if i.element_set.include? ($1.to_i) }
      test = true
    end
    return !test
  end
end

#==============================================================================
# ** Window_TargetEnemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    overwritten super method - refresh
#==============================================================================

class Window_TargetEnemy < Window_Command
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Refresh
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def refresh
    self.contents.clear
    # Initialize enabled array
    @enabled_commands = [] if @enabled_commands.nil?
    @enabled_commands.clear
    for i in 0...@item_max
      # Get what is being used to attack the enemy
      tools = case $game_temp.active_battler.action.kind
      when 0 then $game_temp.active_battler.weapons # Basic; Target => Attack
      when 1 then [$data_skills[$game_temp.active_battler.action.skill_id]] # Skill
      when 2 then [$data_items[$game_temp.active_battler.action.item_id]]   # Item
      end
      enabled = @enemies[i].element_vulnerable? (tools.compact)
      @enabled_commands.push (enabled)
      draw_item(i, enabled)
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Enabled?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def enabled?
    return @enabled_commands[self.index]
  end
end

#==============================================================================
# ** Scene_Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - start_target_enemy_selection,
#                    update_target_enemy_selection
#==============================================================================

class Scene_Battle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Start Target Enemy Selection
  #``````````````````````````````````````````````````````````````````````````
  #  This saves the active battler into $game_temp for use in Target Window
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_strt_enmy_slect_dnte_actor_83b5 start_target_enemy_selection
  def start_target_enemy_selection
    $game_temp.active_battler = @active_battler
    # Run Original Method
    modalg_strt_enmy_slect_dnte_actor_83b5
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Target Enemy Selection
  #``````````````````````````````````````````````````````````````````````````
  #  This method forbids a disabled enemy from being targeted
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_enmy_elmnt_invuln_test_update_trgt update_target_enemy_selection
  def update_target_enemy_selection
    # If selected, then check if disabled
    if Input.trigger?(Input::C) && !@target_enemy_window.enabled?
      Sound.play_buzzer
      return
    end
    # Run original method
    ma_enmy_elmnt_invuln_test_update_trgt
  end
end

Credit


  • modern algebra

Thanks

  • Razielboy, for the request

Support


Just post here with any concerns.

Known Compatibility Issues

<If you know of any compatibility issues (like will not work with RTAB), post them here. Also, if you've done some compatibility fixes>

Demo


No Demo necessary


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
« Last Edit: July 06, 2010, 11:47:00 AM by modern algebra »


**
Rep:
Level 88
This is pretty useful for people who haven't rewritten the stupid ONLY MOST EFFECTIVE ELEMENT WORKS part of Game_Battler. Good work!

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
I'm glad you guys like it, though I'm not entirely sure what you're talking about Craze :P

And no problem Razielboy - it was fun enough to make.

****
Rep:
Level 84
3...2...1...
Would this work with Vlad's Requiem ABS?


***
Rep:
Level 77
RMRK Junior
Problem:
When I attempt to just attack an enemy the game crashes because normal attacks don't have any element. is there a fix for this, or do I need to rewrite the standard attacks system somehow?

Taking it Elsewhere!
« Last Edit: July 06, 2010, 11:30:07 AM by Wiimeiser »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Normal attacks do have elements though, because weapons have elements :/

There might be an error if there is nothing equipped though, which might be what you meant?

Try changing this line:
Code: [Select]

      enabled = @enemies[i].element_vulnerable? (tools)

to:

Code: [Select]

      enabled = @enemies[i].element_vulnerable? (tools.compact)

***
Rep:
Level 77
RMRK Junior
Yes, that's what I meant.