MV Yanfly StatAllocation add a stat via JS script ?

Hello,

I have added the YEP_StatAllocation script on my project, and i would like to add some Critical damage to a player when
he talk to a npc, or when he use an item in the menu.

I would like to call a script like this.actor.gaincri(20)... but i'm too noob to understand the code and the right syntax...

Maybe anyone can help me ?

Thanks to all of you in advance.
YEP_StatAllocation works by storing the number of allocations per stat. Each stat has a specified allocationBonus value determined via the Plugin Manager. The bonus for a given stat equals the number of allocations multiplied by the corresponding bonus value.

To manually increase the number of allocations for a particular Ex-param (like CRI), try this:
JavaScript:
var actor = $gameParty.members()[0];
var paramId = 2;
var allocations = 5;
actor.gainXParamAllocateTimes(paramId, allocations);
Explanation:
  • $gameParty.members()[0] is the party leader. Swap 0 for 1 to reference party member 2, etc. Alternatively you can refer to the actor by their ID, e.g. $gameActors.actor(1) (actor ID 1).

  • paramId = 2 - here are parameter IDs as used by this plugin:
    Spoiler: paramId values
    • Basic params:
      Code:
       0    1    2    3    4    5    6    7
      mhp  mmp  atk  def  mat  mdf  agi  luk
    • Ex-params:
      Code:
       0    1    2    3    4    5    6    7    8    9
      hit  eva  cri  cev  mev  mrf  cnt  hrg  mrg  trg
    • Sp-params:
      Code:
       0    1    2    3    4    5    6    7    8    9
      tgr  grd  rec  pha  mcr  tcr  pdr  mdr  fdr  exr

  • allocations = 5 - the number of allocations to add to this actor for this param.

  • gainXParamAllocateTimes is for Ex-params (like CRI).
    • For basic params use gainParamAllocateTimes instead.
    • For Sp-params use gainSParamAllocateTimes instead.
😮‍💨
didn't know, only the plugin name, I will save this as well, in case of need 🙂
Thank you so much caethyril ! It worked fine !
I played around with this a bit, and discovered there is a potential downside to this solution in that if you leave the plugin's Revert command enabled, the allocations added through the script call will be lost along with all normal allocations, and no Allocation Points will be returned for the allocations added through the script, so there is potential for players to permanently lose the intended bonus.

If you disable the revert command in your project this is not an issue, but if you do plan to provide this option to players, you should be able to achieve the same CRI bonus effect using a passive state plugin (like Yanfly's) without the risk of unintentionally removing the bonus.
I'll use it in a skill tree menu so I don't think there will be a problem.
we'll see that in the future.
Yea, I just assumed you wanted to tie it into the stat allocation system... 😅

In case it's helpful: YEP_ExtraParamFormula (not free) has a script call for this, e.g.
JavaScript:
$gameActors.actor(1).addCri(0.2);
This typically acts like the default Change Parameter command, except for ex-params (CRI in this case).

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-statallocation-add-a-stat-via-js-script.128213/