function to assign formula to HRG

● ARCHIVED · READ-ONLY
Started by Countyoungblood 15 posts View original ↗
  1. Shouldnt the damage formula be able to pass a formula inside a function and assign the result to health regeneration of the skill target? I dont know enough ruby to say myself but it seems to me like itd be accessable and writable..id think the bigger problem would be reassigning normal hrg after the debuff wears off.
  2. Well, I guess you can call a script that can manipulate variables and set things up instead of a formula, but yes you might got a point.
  3. Countyoungblood said:
    the bigger problem would be reassigning normal hrg after the debuff wears off
    This is why, in my opinion, you should do it using a state instead of doing it using damage formula. What I mean is that you actually CAN do it using damage formula but I'd still apply a "flag" state, just to know when to remove it. Once you do that you can remove that said HRG whenever the state is not applied.

    Another option would be creating multiple HRG states and applying the correct one based on the amount of health you want to regenerate. That would be much easier to handle. If you do it in a smart way you don't even need to call it manually.

    Let's say you create your HRG states starting from state 81 to state 85 (so you have state 81, 82, 83, 84, 85) and HRG for those states increases as state id grows up, you can then apply state (80 + x) where x is your buff strength in a scale from 1 to 5. Do you want a heal to apply a HRG state that heals target over time based on the amount of initial heal? Just use it like this
    Code:
    heal_amount = your_formula; x = 80 + (5 * max_heal_amount / your_formula); b.add_state(x); your_formula

    This one applies HRG based on your current skill strength. Of course you have to set an amount as max_heal_amount. You can do something like calculating it dynamically but then it requires more coding and it is better to use a script to do it. I doubt it fits in your formula box.
  4. I always go with the hardcode approach.
    Code:
    class Game_Battler
      def regenerate_hp
        if <any condition goes here>
          damage = <your formula>
        else
          damage = -(mhp * hrg).to_i # <-- Default formula
        end
        perform_map_damage_effect if $game_party.in_battle && damage > 0
        @result.hp_damage = [damage, max_slip_damage].min
        self.hp -= @result.hp_damage
      end
    end
  5. regenerate_hp gets called at the end of every turn right? can i still use b.state? or could i use self.state?
  6. Regen HP called every turns in all battlers for theirself. So, no. No b.state formula. Use self.state?
  7. what if i added another function to regenerate_all which checked for states and assigned stats.. like for example if a berserk status was found then attack += attack + (mhp - hp) what would happen after the battle?
  8. Countyoungblood said:
    what if i added another function to regenerate_all which checked for states and assigned stats.. like for example if a berserk status was found then attack += attack + (mhp - hp) what would happen after the battle?
    Instead of guessing what would happen, I'd ask what you actually want to do?
  9. TheoAllen said:
    Instead of guessing what would happen, I'd ask what you actually want to do?

    specifically nothing just looking to learn
  10. Countyoungblood said:
    specifically nothing just looking to learn
    Then i dont understand what you were asking. What is this "attack" you're talking about. This "attack" variable would just a meaningless variable that would just disappear. Which is why i was asking what you want to do an what you expect to happen so i could correct it. Or just go try to learn some ruby script.
  11. TheoAllen said:
    Then i dont understand what you were asking. What is this "attack" you're talking about. This "attack" variable would just a meaningless variable that would just disappear. Which is why i was asking what you want to do an what you expect to happen so i could correct it. Or just go try to learn some ruby script.

    well ive been reading ruby tutorials and reading the scripts and as of right now im using rpgmaker to learn more ruby by looking to make functions to be called by the attack formula. specifically i dont care what i end up with since its all just for learning but particularly right now im trying to give anyone with a berserk state more attack power dependant on their health remaining at the end of each turn. I know the basics of ruby and conditional branches and such but im trying to grasp the more abstract ideas like why things are formatted the way they are.. why one function calls another just to do what could of been done without a function.. its really just about learning more ruby since reading only takes you so far.
  12. In the light of the further clarification, I think this might be better in 'Learning Ruby and RGSSx'. That way you will get more theoretical help. Ace Support is more for getting help on specific things that you are actually trying to do in game.

    [mod]I am, therefore, moving this to Learning Ruby and RGSSx[/mod]
  13. Welp, since it's been moved into Learning RGSSx, we gonna have more freedom to talk about this.

    Countyoungblood said:
    im trying to give anyone with a berserk state more attack power dependant on their health remaining at the end of each turn
    Then using regenerate_hp / regenerate_all was not the right place. You want to directly modify the attack stat by doing
    Code:
    class Game_Battler
      def atk
        param(2) + <your own attack stat formula>
      end
    end
    But anyway, I already wrote the custom stat overhaul tutorial, not sure if anyone is interested or if they even understand lol
    https://forums.rpgmakerweb.com/index.php?threads/ace-custom-stats-overhaul-scripting.97084/

    Countyoungblood said:
    but im trying to grasp the more abstract ideas like why things are formatted the way they are.. why one function calls another just to do what could of been done without a function.. its really just about learning more ruby since reading only takes you so far.
    Back in RMXP days, the script was quite a mess that one method contains hell lot of lines. Breaking them down into methods helps about the compatibility a lot. Especially Ruby has aliasing. You don't want to overwrite a whole function just to add one or two. This leads into incompatibility where two different script would just overwrite the same method then both scripts are incompatible with each other.

    Breaking them down into methods also helps you to organize your code. Of course, if it's only you that work on your game, feel free to just write a long lines of code without need to break them down into a function, that's if you later when you were away from the code and come back, you won't get confused with your own code. It's also the reason for team project, some people hate to read unorganized code, so they couldn't work on it with efficiency. Mostly, these kind of practice been taught in the software engineering course in a college.
  14. TheoAllen said:
    Welp, since it's been moved into Learning RGSSx, we gonna have more freedom to talk about this.


    Then using regenerate_hp / regenerate_all was not the right place. You want to directly modify the attack stat by doing
    Code:
    class Game_Battler
      def atk
        param(2) + <your own attack stat formula>
      end
    end
    But anyway, I already wrote the custom stat overhaul tutorial, not sure if anyone is interested or if they even understand lol
    https://forums.rpgmakerweb.com/index.php?threads/ace-custom-stats-overhaul-scripting.97084/


    Back in RMXP days, the script was quite a mess that one method contains hell lot of lines. Breaking them down into methods helps about the compatibility a lot. Especially Ruby has aliasing. You don't want to overwrite a whole function just to add one or two. This leads into incompatibility where two different script would just overwrite the same method then both scripts are incompatible with each other.

    Breaking them down into methods also helps you to organize your code. Of course, if it's only you that work on your game, feel free to just write a long lines of code without need to break them down into a function, that's if you later when you were away from the code and come back, you won't get confused with your own code. It's also the reason for team project, some people hate to read unorganized code, so they couldn't work on it with efficiency. Mostly, these kind of practice been taught in the software engineering course in a college.

    fantastic I will go through the tutorial but are you saying you could run a state check inside the atk method?

    edit: it did work but the other snippet you made is behaving odd in conjunction.

    Code:
      def combo_attack(a,b)
      #--------------------------------------------
      # State ID to check => State ID to add
      # Edit here:
      #--------------------------------------------
      states = {
        14 => 15,
        15 => 16,
        16 => 16,
      }
      #--------------------------------------------
      states.keys.each do |state_id|
        if a.state?(state_id)
          a.remove_state(state_id)
          a.add_state(states[state_id])
          return
        end
      end
      # Else
      a.add_state(14) # <-- Also here
      return  # <-- Also here
    end

    did i fill this out wrong? my berserk state is 13 and if the user is berserk it attacks 3 times. by the end its somehow applied state 16 which was supposed to be the end of a combo ramp
  15. Countyoungblood said:
    fantastic I will go through the tutorial but are you saying you could run a state check inside the atk method?
    Yes, but the check is continuous. If you somehow want the attack to be altered by the end of the turn, it will be a slight different. You will need a new variable that is either reduced / increased on the end of the turn, then add it to the attack stat formula.

    Countyoungblood said:
    did i fill this out wrong? my berserk state is 13 and if the user is berserk it attacks 3 times. by the end its somehow applied state 16 which was supposed to be the end of a combo ramp
    It didn't behave wrong, it really did like that. Since it's "damage formula", it will be called everytime you deal damage. You deal 3 times damage, it will be checked 3 times, which brings to state 16 right away. If you wish to change the behavior, you gonna need to move the state check somewhere else. The flow goes like this:
    • The attack will apply a dummy state, invisible one
    • Then at the end of action / turn, check if the dummy state is present
    • If it's present, by the end of action / turn, mutate the state into other state. That way it won't go straight to state 16 by triple attacks.