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.

Elemental Status Effects

I just thought of something I think is kinda clever, and since my scripting is about as good as my skill at rocket science and brain surgery, I pretty much figured I had to ask around the Community for help.

I'm wondering if there's anyway to make status effects that change your elemental efficiency. What I mean-- and I hope I explain this right-- is that, instead of making you stronger or faster or upping defense, a buffing spell or technique that adds an elemental charge to your attacks.

Like suppose you're facing a bevy of fire monsters, and you've rather stupidly let your black mage kick it without having a Fenix Down in reserve. No fenix down, no black mage; no black mage, no ice mage, no killing the angry fire monsters, right?

But what if your green mage- or blue, or white, or vermillion, or whatever colour scheme you're running with-- had a spell called Frost Touch, or something like that, that gave your Fighter character's sword a temporary Ice-effect to use on the fire monsters? It would work like a regular buff spell, it would only last a few turns, and it would only have a boosted damage effect on monsters of the opposite element.

I figure if nothing else, it will at least make the Green Mage type characters more useful--how many monsters are weak to silence, anyways?

Well, that's my idea. If anyone has any ideas or suggestions on how to make it happen, or if I'm just spinning my wheels, or whatever, then feel free to let me know. There's gotta be a dozen people out there who wouldn't mind something like this
 
I would use it in my game. It must be possible, and I know the ccoa (an old member) did wonders with scripting status aliments. Someone must know how to do this. ;) I would keep posted on this one, cause its a great idea.
 
I'm currently working on a Junction script for VX which does exactly what you want. But the script is way to huge for only adding elemental attack/defense with a status... It's fairly simple to do. You need to play a bit with the element_set method in Game_Actor.
Basically, what you want to do is, first of all, check for the current actor's states.
Then, take only those you want to have special elemental attack and finally add the elemental attack to the actor's element set.

I would start by making an Hash which would hold the status and its related element.
Something like that
Code:
Elemental_Attack = {
                    2 => 2,
                    3 => 2
                   }
The syntax here is State_ID => Element_ID
By doing this, you will associate an element to a state.

Then when you will edit the element_set method (I strongly recommend to alias your method), simply use a for loop to cycle through every state like that
Code:
new_elements = []
for state_id in @states
  new_elements.push(Elemental_Attack[state_id])
end
You now have an array containing every extra elemental attacks. Now you just need to add this array to the element_set array.
I guess it would require about 20-25 lines of code.
 
Hmmm...okay, first of all, thank you so much for responding. I really need some help with this, and I appreciate any you can offer.

Secondly, I'm afraid you'll have to explain to me a few things, namely hashes, aliasing my method and arrays, since my scripting ability is...well hell, I have no scripting ability. I think I get some of what your trying to say, but I'm afraid I'm a terminal newb at scripts.
 
Arrays and hashes are similar. The biggest difference between these two objects is that the array is 'index based' and the hash is 'key based'
An index is always a number. A key can be a number or a string. It can probably be more but I'm not sure.

here's an example of an array:
Code:
Friends = [ "Mike", "Stef", "Jim" ]

Friends[2] # => "Jim"
Friends[0] # => "Mike"
Friends[1] # => "Stef"

here's an example of an hash:
Code:
Age = { "Mike" => 20, "Stef> => 18, "Jim" => 16 }

Age["Mike"] # => 20
Age["Stef"] # => 18
Age["Jim"]  # => 16

Note the difference; in the hash, you must specify the key and its value like that: Hash = { key => value }
It's also possible with an array but the method differs a bit; Array[index] = value

Alias is a Ruby keyword used to create a new name for an existing method. One of the greatest advantages of the alias is that you can modify an existing method without having to overwrite it. Usually, overridden methods are the source of compatibility issues, bugs, etc.
I'll give you an example. Here's the original element_set method in Game_Actor:
Code:
#--------------------------------------------------------------------------
  # * Get Normal Attack Element
  #--------------------------------------------------------------------------
  def element_set
    weapon = $data_weapons[@weapon_id]
    return weapon != nil ? weapon.element_set : []
  end
And Here's what it would look like if I overwrite it.
Code:
#--------------------------------------------------------------------------
  # * Get Normal Attack Element
  #--------------------------------------------------------------------------
  def element_set
    new_elements = []
    for state_id in @states
      new_elements.push(Elemental_Attack[state_id])
    end
    weapon = $data_weapons[@weapon_id]
    return weapon != nil ? weapon.element_set + new_elements: [] + new_elements
  end

In your case, this method would probably work just fine, unless you have a bunch of custom scripts.
Now here's what it would look like if I use an alias.
alias new_element_set element_set
  #--------------------------------------------------------------------------
  # * Get Normal Attack Element
  #--------------------------------------------------------------------------
  def element_set
    # Create new elements array
    new_elements = []
    for state_id in @states
      # Add elements to the array
      new_elements.push(Elemental_Attack[state_id])
    end
    # Combine the last method with the element array
    return new_element_set + new_elements
  end

The name in green is the new method name and the name in blue is the original method name.
The variable in red is our array which will contain every extra element ID.
In the last line, the aliased original method (in green) is executed and we are adding our array of new elements.
 
Okay, I think that makes a bit more sense. Thank you for that.


EDIT: Hmm....apparently I don't understand as well as I thought I had. If you could just clarify one thing for me...I'm a bit uncertain as to what to do with the lines,
   
    new_elements.push(Elemental_Attack[state_id])
    end
    # Combine the last method with the element array
    return new_element_set + new_elements
 
Code:
new_elements = []
This is the array in which new elements will be stored

Code:
for state_id in @states
  (code...)
end
In this part, the script cycles through each states in the @states array

Code:
new_elements.push(Elemental_Attack[state_id])
This adds the new elemental attack to the new_elements array.

Code:
Elemental_Attack
This is a constant variable (more precisely, an Hash) we have defined in a previous example.

So new_elements.push(Elemental_Attack[1]) means that we are adding the Elemental Attack of State #1 to the new_elements array.

Code:
return new_element_set + new_elements
That means that when the process is done, the method will return the value of the previously aliased method (new_element_set) plus the result of the new lines we have added (new_elements).
 

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