[ACE] Creating and returning skill notetag array data?

Discussion in 'RGSSx Script Support' started by Arsist, Aug 6, 2016.

  1. Arsist

    Arsist Veteran Veteran

    Messages:
    140
    Likes Received:
    10
    So, I have managed to use text from skill notetags as data before (see below), using examples from scriptors.


    But this data has always been based on numerical digits and not arrays, and I'm not really experienced with or can comprehend enough of Regexp processes to figure this out myself.


    #Tag items and skills with <armor ignore: x>
    #A value of 50 means that an opponent's armor rating will only be
    half as effective.
    #Do not include the percentage symbol.
    module TH
      module Armor_Ignores
        
        Regex = /<armor[-_ ]ignore:\s*(\d+)>/i
      end
    end
    #===============================================================================
    # ** Rest of script
    #===============================================================================
    module RPG
     class UsableItem < BaseItem
        def armor_ignore
          return @armor_ignore unless @armor_ignore.nil?
          load_notetag_armor_ignore
          return @armor_ignore
        end
        
        def load_notetag_armor_ignore
          res = self.note.match(TH::Armor_Ignores::Regex)
          @armor_ignore = res ? res[1].to_i : 0
        end
      end
    end


    With this script tidbit example I just posted, I could use in a formula 'item.armor_ignore' for additional processes.


    I know that the adjustment to be made would have to be at the

    part.


    I would like to be able to tag in a skill notetag <secondary effects: [data]>


    So if I were to use 'item.secondary_effects' in a formula, it would return the [data] array in the skill's notetag.


    An example of an application of this would be for me to make [data] into, say,


    [["Poison", 0.3, [1,2], physical, true], ["Burn", 0.15, [1,2], magical, false]]


    "Poison" would be the display name for the secondary effect in the battle log, '0.3' would be the base chance of the ailment, [1,2] would be the stat influences of Attack and Luck respectively (meaning that the ATK stat would be normally influential in the effect chance, and the LUK stat would be twice as influential in the effect chance), 'physical' would mean that the chance would be multiplied by the target's Physical damage rate, and 'true' would dictate that the chance would be increased if the skill ended up being critical.
     
    Last edited by a moderator: Aug 6, 2016
    #1
  2. Shaz

    Shaz Veteran Veteran

    Messages:
    37,720
    Likes Received:
    11,430
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    I haven't tested this and am just making the suggestion based on something I THINK I had working in my game at some point, but if you try the following, does it give you want you want?

    Code:
    regex = /<secondary effects:\s*(\.*)>/i
      
    module RPG
      class UsableItem < BaseItem
        def load_notetag_armor_secondary_effects
          res = self.note.match(regex)
          @secondary_effects = res ? exec(res[1]) : nil
        end
      end
    end


    I know a lot of people don't like using exec, but I've found it really handy for turning strings into the appropriate kinds of variables based on their contents.
     
    #2
  3. Arsist

    Arsist Veteran Veteran

    Messages:
    140
    Likes Received:
    10
    I tried pasting that script tidbit and then putting 


    <secondary effect: [[1,2], [2,1]]>


    in the basic attack's notebox and made the damage formula 


    puts "#{a.current_action.secondary_effects}"; 10


    to test it out, but it just made the damage nil out, saying it dealt no damage and displaying no text on the console beforehand. I know there's nothing wrong with the current_action process, because


    puts "#{a.current_action}"; 10


    works as intended.
     
    #3
  4. Shaz

    Shaz Veteran Veteran

    Messages:
    37,720
    Likes Received:
    11,430
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    you've spelled the word incorrectly in the note tag.
     
    #4
  5. Arsist

    Arsist Veteran Veteran

    Messages:
    140
    Likes Received:
    10
    Sorry, I just quoted my own notetag wrong, hehe. In my test, I did spell it 'effects' and not 'effect'.


    But even when spelled correctly, it doesn't work for me.
     
    Last edited by a moderator: Aug 7, 2016
    #5

Share This Page