Adding item.params to Kread-Ex's Rune Enchantments

Hero_Claive

(Phoenix Ember)
Veteran
Joined
Jan 5, 2016
Messages
149
Reaction score
88
First Language
English
Primarily Uses
RMVXA
After a few days trying to work this out, I've pretty much run out of ideas. First, here's the title script I'm referencing:

https://github.com/Archeia/Kread-Ex...Scripts/Gameplay Scripts/Runic_Enchantment.rb

Anyways, there's a snippet that Kread-Ex adds which aliases "feature_objects," a method in Game_Actor that gathers all of the traits from their equipment ("equips"). The snippet can be found at line 198:
Code:
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● Returns the list of traits
  #--------------------------------------------------------------------------
  alias_method(:krx_sandal_ga_fo, :feature_objects)
  def feature_objects
    runes = []
    equips.compact.each do |equip|
      container = equip.is_a?(RPG::Weapon) ? $game_party.enchants_w :
      $game_party.enchants_a
      next if container[equip.id].nil?
      ids = container[equip.id]
      ids.each do |id|
        next if id.nil?
        runes.push($data_armors[id])
      end
    end
    krx_sandal_ga_fo + runes.compact
  end
end
What the script does essentially is allowing your characters to equip "Runes" (notetagged armors) to their weapons. Then, the traits on those runes are applied to the actor using the above method. What it doesn't do is add the parameters from those armors onto the character. That makes sense because this isn't what "feature_objects" does; it only stores the actor's "traits" in an array. The method for adding equipment parameters is found in Game_Actor, on line 377:
Code:
  #--------------------------------------------------------------------------
  # * Get Added Value of Parameter
  #--------------------------------------------------------------------------
  def param_plus(param_id)
    equips.compact.inject(super) {|r, item| r += item.params[param_id] }
  end
This is where things get confusing. I'm trying to make it so that equipped runes have their parameters added to their respective actor via the above method. But this is proving extremely complicated for me because I'm not very keen on method values, which is what "equips" and "param_plus" return basically. I don't know how to access or edit the equips hash. I also don't understand what inject(super) means... Is that just injecting the following hash into the superclass method "param_plus"?

Any and all help is much appreciated. I'm trying to solve as many things on my own as I can, but this problem in particular is very difficult and an explanation on how to achieve what I want would be great.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
First though, I'm gonna explain how inject works.
Code:
[1,2,2,3,4,5].inject(0) {|r, i| r += i}
Means, it start from 0. Iterating it so that the code becomes 0+1+2+2+3+4+5

The keyword "super" is to use to call super class' method. Game_Actor has Game_BattlerBase as superclass. It also has this method.
Code:
  def param_plus(param_id)
    @param_plus[param_id]
  end
Which mean, in your Game_Actor class, the method is 'equal' as
Code:
  def param_plus(param_id)
   equips.compact.inject(@param_plus[param_id]) {|r, item| r += item.params[param_id] }
  end
Again, it's a starting number. @param_plus is an additional bonus parameter added when you use an event to increase stat permanently. Since you don't want your actor to miss that while calculating the equipment parameter, hence it's written that way.

And here is the breakdown how it works
> equips = fetch equips from your actor. Both empty slot and used slot (array)
> dot compact = removes nil. From [weapon1, nil, body armor, nil, leg armor] into [weapon1, body armor, leg armor]
> dot inject (perform calculation)
> param_plus (initial value) + weapon stat + armor 1 stat + armor 2 stat

You don't really have to know what is 'equips' method (unless you really want to break it down and learn everything from default script). All it does is to return something like this
> [$data_weapons[1], $data_armors[1], $data_armors[2]]

Now back to original question. I'm neither know how rune enchantment works in Dragon's Age (the script intro ain't help), nor how they wrote their script. So I'm not gonna research it. But if you want to add more calculation on parameters, the template would be like this.
Code:
  def param_plus(param_id)
    stat = equips.compact.inject(super) {|r, item| r += item.params[param_id] }
    stat += <put additional formula here>
    return stat
  end
 

Hero_Claive

(Phoenix Ember)
Veteran
Joined
Jan 5, 2016
Messages
149
Reaction score
88
First Language
English
Primarily Uses
RMVXA
That's alright, I don't expect you to get to know this script as well as I have in the past two days lol.

Learning methods like .inject definitely helps. I've been working at it all day and still nothing works though. I have absolutely no idea how to access the array of currently equipped runes in this script. The runes are equipped to weapons rather than the actors themselves (since Kread-Ex's script doesn't alter slots). But no matter where I look, I can't find how to access the params of the runes which are currently affecting the given actor (actor which has weapon equipped, which has rune equipped).

That "feature_objects" method baffles me, though. Through all the local variables used, I can't even imagine how he was able to access the traits which currently affect the actor. I've tried copying and pasting that method, and replacing $data_armors[equip.id] with $data_armors[equip.id].params[param_id], but that doesn't work either. I'm pretty much just blowing off steam at this point. This defeats a huge function of my game if I can't access the array of runes affecting the player.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
This is a wild guess. Take it with a grain of salt. Or did you already do it?
Code:
class Game_Actor
  def param_plus(param_id)
    runes = []
    equips.compact.each do |equip|
      container = equip.is_a?(RPG::Weapon) ? $game_party.enchants_w :
      $game_party.enchants_a
      next if container[equip.id].nil?
      ids = container[equip.id]
      ids.each do |id|
        next if id.nil?
        runes.push($data_armors[id])
      end
    end
    stat = equips.compact.inject(super) {|r, item| r += item.params[param_id] }
    stat += runes.inject(0) {|r, item| r += item.params[param_id] }
    return stat
  end
end
 

Hero_Claive

(Phoenix Ember)
Veteran
Joined
Jan 5, 2016
Messages
149
Reaction score
88
First Language
English
Primarily Uses
RMVXA
That is actually exactly what I did, except I mixed up $game_party.enchants_w with $game_party.enchants_a. I'm only using weapon enchantments (hence the array "enchants_w" refers to those) but for whatever reason I thought "enchants_a" referred to the runes (armors). But yeah, this actually works! So that's a huge relief.

Thanks a ton, also let me know if you need any design/GUI work done or anything. You've been a huge help to my project so far!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,975
Members
137,563
Latest member
cexojow
Top