Simulating a Skill Formula oustide of battle?

Discussion in 'RGSSx Script Support' started by Hero_Claive, Jul 2, 2019.

  1. Hero_Claive

    Hero_Claive (Phoenix Ember) Veteran

    Messages:
    148
    Likes Received:
    81
    First Language:
    English
    Primarily Uses:
    RMVXA
    Been experimenting trying to create a window in Scene_Skill that shows hypothetical damage output of a given skill. This is easier said than done, however, as I'm having an increasing amount of trouble getting the program to return a numeric value from the skill's formula outside of battle. I'm doing this by simulating an @actor argument in the Window class and $data_enemies[999] which is just a dummy with 0 Defense. All I did after that was use @skill.damage.formula, then @actor.send(formula), but that returns an error even when the exact method is defined under Game_Battler.

    I can give more examples/actual code if needed, but I'm curious if anyone knows an immediate solution to return a value for a given skill outside of battle using a hypothetical enemy. I found the precise method "make_damage_value(user, item)" but not only does it straight up return 0, it also calculates a lot of things I don't want (I only want to simulate the formula, without variance or crit).

    If anyone has any idea on how to do this, I'd be more than appreciative.
     
    #1
  2. Another Fen

    Another Fen Veteran Veteran

    Messages:
    512
    Likes Received:
    232
    First Language:
    German
    Hey there,

    You were on the right track, the evaluation of the damage formula is shown in the first line of that method:
    item.damage.eval(user, self, $game_variables)

    However, $data_enemies[X] is probably incompatible with most formulas. The easiest way to get a target dummy would be to use $game_actors[X] with an unused actor instead. ($data_enemies and $data_actors only contain your database settings and have a different layout than actual battlers.)
     
    #2
    Hero_Claive likes this.
  3. Hero_Claive

    Hero_Claive (Phoenix Ember) Veteran

    Messages:
    148
    Likes Received:
    81
    First Language:
    English
    Primarily Uses:
    RMVXA
    Great catch! I did try that method but like a numbskull, still tried to use $data_enemies. I created a dummy actor as you instructed and it works beautifully. Thanks a ton!
     
    #3

Share This Page