RMMV Yanfly StatAllocation add a stat via JS script ?

Sektor

Villager
Member
Joined
Dec 29, 2018
Messages
19
Reaction score
1
First Language
French
Primarily Uses
RMMV
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.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,043
Reaction score
1,474
First Language
EN
Primarily Uses
RMMZ
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:
    • 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.
:kaophew:
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,799
Reaction score
983
First Language
Dutch
Primarily Uses
RMMV
didn't know, only the plugin name, I will save this as well, in case of need :)
 

Matrien

Villager
Member
Joined
Aug 23, 2020
Messages
7
Reaction score
1
First Language
English
Primarily Uses
RMMV
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.
 

Sektor

Villager
Member
Joined
Dec 29, 2018
Messages
19
Reaction score
1
First Language
French
Primarily Uses
RMMV
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.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,043
Reaction score
1,474
First Language
EN
Primarily Uses
RMMZ
Yea, I just assumed you wanted to tie it into the stat allocation system... :kaoswt:

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).
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Pootscooter wrote on Pharonix's profile.
Hey @Pharonix, just wondering what you're up to lately and if you've had an opportunity to check out the LTBS thread in the past few days...(a couple of us could really use your expertise). Hope you are well and Happy Thanksgiving!
Anyone know the best size image to put in signature?
Well, the local collections agency is hiring... bleh. I'm not rude enough for them to hire me. Even the people they collect FOR don't like dealing with them. >.>
EA: "Kids are buying currency, not using money to gamble. It shouldn't be illegal!"
Me: "So... kids should be allowed into casinos to buy poker chips and not spend them at the blackjack table? Pretty sure, even buying currency used to gamble is illegal for children."
Been hard at work in photoshop working with MOG scripts for main menu & victory result screens, might do all my maps and Npc chatter this week too!

Forum statistics

Threads
105,500
Messages
1,014,214
Members
137,155
Latest member
diegodevin
Top