[RMXP] How I edit data_states? (creating a second HP)

Discussion in 'RGSSx Script Support' started by Kavaline, Nov 30, 2018.

  1. Kavaline

    Kavaline GameDev Member

    Messages:
    9
    Likes Received:
    0
    First Language:
    Português
    Primarily Uses:
    RMXP
    Hi guys,
    In my project using RPG Maker XP, I wat use 2 HP counters; the HP, and other, called EP. I search all functions for HP, and duplicate, just renaming for EP, and scripting the battle for decide when remove from each counter. The enemies can have just one counter, but for less headache (aka less knowledge), I duplicate too, but take just from HP counter, the EP counter is useless for enemies. But I get an error on Game_Actor;
    #--------------------------------------------------------------------------
    # * Get Maximum EP
    #--------------------------------------------------------------------------
    def maxep
    n = [[base_maxep + @maxep_plus, 1].max, 9999].min
    for i in @states
    n *= $data_states[ i ].maxep_rate / 100.0
    end
    n = [[Integer(n), 1].max, 9999].min
    return n
    end

    In line "n *= $data_states[ i ].maxep_rate / 100.0", I dont have this attribute, and I cant find where I can add or how I can edit the class State. I tried to understand how use this script, to use other solution/code that replace this without problem, but I dont know what I can do. I get the error during the battle. I can replace this with other code, or create a manual array (with what kind of data exactly?), or edit this class?
    Thanks for reading
     
    #1
  2. DerVVulfman

    DerVVulfman Resident Werewolf Veteran

    Messages:
    275
    Likes Received:
    137
    First Language:
    English
    Primarily Uses:
    RMXP
    Okay. Let me first get this straight.

    You are looking to add a new statistic to your Actors, a statistic being something akin to HP, SP, STR, DEX, AGI or INT. And of this, you are hoping to be able to make a progression chart (like that for the above stats), so the actors can increase this statistic based on their earned level. However, this new statistic is not to be available for the Enemies.

    I have had a hand in making something towards adding statistics to game characters, this script called Kitsune's Extra Statistics which isn't all that plug-n-play. However, I have used it to add Charisma and Constitution statistics that work for both Actor and Enemy. Take a look.... take some time. It's not all that 'EASY' to add a stat into the system, especially one that might be influenced by actor levels and such.

    But you also have to recognize that stats used in-game must be available for both Actors and Enemies alike, even if you don't see it available. Sure, you can set your enemies to have this stat be 0, but it does exist somehow.... even if hidden away.
     
    #2
  3. Kavaline

    Kavaline GameDev Member

    Messages:
    9
    Likes Received:
    0
    First Language:
    Português
    Primarily Uses:
    RMXP
    Ok, I will take a long read in this script, but one thing about the EP custom statistic: it don't increase with level progression, don't follow any chart like these attributes. The formula of this value is actor INT * 2, with some bonus of equips/acessories, and consumable that increase this value permanently. The level dont affect directly (also, leveling will increase INT, and will increase the EP). I dont know if I used the best choice duplicating all HP occurrence, after solve this "bug" (code fail), I need test is REALLY works like I want (looks like that works, in battle I can take damage in this alternative HP, but I mind if have a better way of do that).
    The main motive to dont work for enemies, is because they will fight only in your combat style, the players will fight in both styles, using HP and EP. Because of this, I just mirrored the HP value, and coded that if is enemy taking damage, will decrease only the HP, because the EP dont bring game over/death, and code this case only for an enemy is harder than mirror and take only the HP. They have EP too, but dont use for anything, just to make the code works.
    (In advance, my english isn't very good, like you can notice ^^")
     
    #3
  4. DerVVulfman

    DerVVulfman Resident Werewolf Veteran

    Messages:
    275
    Likes Received:
    137
    First Language:
    English
    Primarily Uses:
    RMXP
    Sounds like you're gonna need to work with the three damage producing methods in Game_Battler 3 to reduce actor EP stats when applicable (attack_effect, skill_effect and item_effect). That is, running the test 'if self.is_a?(Game_Actor)' to see if the subject is an actor or enemy, and then running another to see if it is HP or EP damage for the actor alone.

    I guess you already surmised this.
     
    #4
  5. Kavaline

    Kavaline GameDev Member

    Messages:
    9
    Likes Received:
    0
    First Language:
    Português
    Primarily Uses:
    RMXP
    Exact, I use if self.is_a?(Game_Actor) to detect if is enemy taking damage, to reduce only the HP, and one variable to detect if is HP or EP fight, in scene_battle 1, using when enemy detection is false. This part works fine, after solve this, I will edit the "Change EP" in Game_Battler 1, to code what happens in specific cases. For now, my problem is that code, and I dont know how I can fix or substitute him.
    I read your script, he adds character attributes (enemy and palyer) that have leveling curve for players, and can be boosted with equips. I dont want this curve, this attribute is directly related with INT, but the item bonus gave me some ideas of what I can do. And I did wish read it before search how I add this status in windows menu, status, battle, etc.
    Your script is really nice and usefull, used to make a game with offline table RPG style (maybe D&D). But in this error that I get, I dont find something that can help me =/
     
    #5
  6. Kavaline

    Kavaline GameDev Member

    Messages:
    9
    Likes Received:
    0
    First Language:
    Português
    Primarily Uses:
    RMXP
    Alright, solved:
    Reading your script again, I noticed something: you add the code in a separated block, reading all the original code, and adding what you want. This make me find the solution, because I know the original code of my error (thanks to documentation). So, I just added a custom code, that read the original code and added what I want, like you did.
    I created script before Main called "custom", with this lines:

    Code:
    class State
      alias state_init initialize
      def initialize
        state_init
        @maxep_rate = 100
      end
      attr_accessor :maxep_rate
    end
    Now it works. And stopping here, I just could change the maxep_rate for 100 manually in Game_Actor, instead use this attribute... I told that have an easier solution for this -_-"
    But ok, this new knowledge will help me a lots. Thanks @DerVVulfman
     
    #6
  7. DerVVulfman

    DerVVulfman Resident Werewolf Veteran

    Messages:
    275
    Likes Received:
    137
    First Language:
    English
    Primarily Uses:
    RMXP
    No problem. I follow a basic standard in coding which DEMANDS that coders add helpful and informative comments throughout, so others coders can adapt and learn.

    Good to go. Glad I could help.
     
    #7

Share This Page