Nullify Element State - Scripting Help

So I just got into RMVXA recently after a wave of inspiration washed over me to give it a shot. I've been spending the past couple days tinkering around and getting to know the program and decided to learn how to script for this program. I wanted to start with a fairly simple custom state that will nullify the damage of one elemental attack of a particular element, but I can't seem to get it to work. Based off my three-day knowledge of both Ruby and RPG Maker-specific scripting, this is what I've come up with.

module Null_Element  ATTACK_ELEMENT = ()  NULL_ELEMENT = ()  NULL_STATE_ID = ()endclass RPG::State < RPG::BaseItem  if @note =~ /<null (.*)>/i    $1.to_i    NULL_ELEMENT = $1    NULL_STATE_ID = RPG::State.id  endend#~ class Game_BattlerBase#~   def element_null#~       ATTACK_ELEMENT = user.atk_elements#~   end#~ endclass Game_Battler < Game_BattlerBase  ATTACK_ELEMENT = user.atk_elements  if NULL_ELEMENT == ATTACK_ELEMENT    alias null_damage_value :make_damage_value    def make_damage_value(user, item)      @result.make_damage(0, item)      self.remove_state(NULL_STATE_ID)    end  endendI am able to embue a target with the State I want through a skill no problem, and it shows that the state is put on the target. However, it doesn't seem to show that the state is active, nor does it prevent any damage or dissappear after an appropriate elemental attack has been used. Where am I going wrong? Am I calling the right variables to get the appropriate information?

EDIT: I should probably mention that I'm using GBTS. I tinkered with it a little and tested the state on the normal system and it works fine for whatever reason (though it still won't disappear after they're hit with the attack :\) but it doesn't work at all in the GBTS battle.
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.
I think

ATTACK_ELEMENT = user.atk_elements

if NULL_ELEMENT == ATTACK_ELEMENT

is only checked when the instance is made... and during that time, user.atk_elements does not exist yet so it will always be false

Plus the way ur using NULL_ELEMENT is wrong, assuming you want to be using NULL_ELEMENT from the module, it should be

Null_Element::NULL_ELEMENT

Also, I think fullcaps is constant, meaning you cannot change the value, so

ATTACK_ELEMENT = user.atk_elements won't proceed...

I suggest doing this instead:

class Game_Battler < Game_BattlerBase alias null_damage_value :make_damage_value def make_damage_value(user, item) return unless user.atk_elements.include?(Null_Element::NULL_ELEMENT) and user.state?(Null_Element::NULL_STATE_ID) @result.make_damage(0, item) self.remove_state(NULL_STATE_ID) end endendyou could also opt to use the damage formula for this...if b.state?(state_id);b.remove_state(state_id);return 0;else;return damage_formula;end
I figured out the element resist function immediately after posting this. For some reason it fails to make any impact on the damage calculation when doing a GTBS battle, though it works perfectly in my normal test (which doesn't make any sense...).

When/where should I set the variable so it picks up the element of the attack after user.atk_elements has been set? Part of my problem is that I'm having trouble understanding the structure that underlies battle processes.
I edited my post, reread... hopefully that would work


I really think you should familiarize yourself first with how the basic syntax goes...
I saw your edit and I'm going to give it a shot. I appreciate the help!

Yeah I'm going to read up on Ruby syntax a little more; I'm used to Java, which has different rules for how classes and variables interact, so I'm a little lost when it comes to some of the basics.

EDIT: I see what I did; I made the variables from the module constants instead of global variables, so they wouldn't have updated anyways. It's always the little things.
well for variables inside modules, you do MODULE_NAME::VARIABLE_NAME


And variable types (local,class,instance,global etc) are dependent on how you write them, so look those up...


like


@variable => instance variable


@@variable => class variable


$variable => global variable


There are basic ruby tuts around the net, just look them up... then you can also read the Help file of Ace for some Ace things

Original thread: https://forums.rpgmakerweb.com/threads/nullify-element-state-scripting-help.22113/