Advertisement
Double_X

DoubleX RMMV Action Times v100c

Oct 28th, 2015 (edited)
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*============================================================================
  2.  *    ## Plugin Info                                                          
  3.  *----------------------------------------------------------------------------
  4.  *    # Plugin Name                                                          
  5.  *      DoubleX RMMV Action Times                                            
  6.  *----------------------------------------------------------------------------
  7.  *    # Terms Of Use                                                          
  8.  *      You shall keep this plugin's Plugin Info part's contents intact      
  9.  *      You shalln't claim that this plugin's written by anyone other than    
  10.  *      DoubleX or his aliases                                                
  11.  *      None of the above applies to DoubleX or his aliases                  
  12.  *----------------------------------------------------------------------------
  13.  *    # Prerequisites                                                        
  14.  *      Nothing special                                                      
  15.  *----------------------------------------------------------------------------
  16.  *    # Links                                                                
  17.  *      This plugin:                                                          
  18.  *      1. http://pastebin.com/tX0C3AR2                                      
  19.  *      Mentioned Patreon Supporters:
  20.  *      https://www.patreon.com/posts/71738797
  21.  *----------------------------------------------------------------------------
  22.  *    # Author                                                                
  23.  *      DoubleX                                                              
  24.  *----------------------------------------------------------------------------
  25.  *    # Changelog                                                            
  26.  *      v1.00c(GMT 1300 27-1-2016):                                          
  27.  *      1. Fixed using 0 instead of 1 as the initial action times value      
  28.  *      v1.00b(GMT 0900 11-11-2015):                                          
  29.  *      1. Added descriptions that will be shown in the plugin manager        
  30.  *      2. Fixed some syntax errors                                          
  31.  *      v1.00a(GMT 1400 28-10-2015):                                          
  32.  *      1. 1st version of this plugin finished                                
  33.  *============================================================================*/
  34. /*:
  35.  * @plugindesc Changes the Action Times traits from being each of them
  36.  *             calculated independently to be added together before calculating
  37.  *             that sum at once
  38.  * @author DoubleX
  39.  * @help
  40.  * Under the default RMMV setting, if p = p1 + p2 + p3 + ... + pn, where pi is
  41.  * the value of an Action Times trait, then the probability distribution on the
  42.  * final action times will be:
  43.  * P(0 or smaller) = 0
  44.  * P(1) = (1 - x1)(1 - x2)(1 - x3)...(1 - xn)
  45.  * P(2) = x1(1 - x2)(1 - x3)(1 - x4)...(1 - xn) + x2(1 - x1)(1 - x3)(1 - x4)...
  46.  * (1 - xn) + x3(1 - x1)(1 - x2)(1 - x4)...(1 - xn) + ... + xn(1 - x1)(1 - x2)
  47.  * (1 - x3)...(1 - x(n - 1))
  48.  * P(3) = x1x2(1 - x3)(1 - x4)(1 - x5)...(1 - xn) + x1x3(1 - x1)(1 - x4)(1 - x5)
  49.  * ...(1 - xn) + x1x4(1 - x2)(1 - x3)(1 - x5)...(1 - xn) + ... + x(n - 1)xn
  50.  * (1 - x1)(1 - x2)(1 - x3)...(1 - x(n-2))
  51.  * ...
  52.  * P(n + 1) = x1x2x3...xn
  53.  * P(n + 2 or larger) = 0
  54.  * With this plugin's used, if a = the integer part of a p and r = the decimal
  55.  * part of p, then the probability distribution on the final action times will
  56.  * be:
  57.  * P(a - 1 or smaller) = 0
  58.  * P(a) = 1 - r
  59.  * P(a + 1) = r
  60.  * P(a + 2 or larger) = 0
  61.  */
  62.  
  63. "use strict";
  64. var DoubleX_RMMV = DoubleX_RMMV || {};
  65. DoubleX_RMMV["Act_Times"] = "v1.00c";
  66.  
  67. /*============================================================================
  68.  *    ## Plugin Implementations                                              
  69.  *       You need not edit this part as it's about how this plugin works      
  70.  *----------------------------------------------------------------------------
  71.  *    # Plugin Support Info:                                                  
  72.  *      1. Prerequisites                                                      
  73.  *         - Little Javascript coding proficiency to fully comprehend this    
  74.  *           plugin                                                          
  75.  *      2. Function documentation                                            
  76.  *         - The 1st part describes why this function's rewritten/extended for
  77.  *           rewritten/extended functions or what the function does for new  
  78.  *           functions                                                        
  79.  *         - The 2nd part describes what the arguments of the function are    
  80.  *         - The 3rd part informs which version rewritten, extended or created
  81.  *           this function                                                    
  82.  *         - The 4th part informs whether the function's rewritten or new    
  83.  *         - The 5th part informs whether the function's a real or potential  
  84.  *           hotspot                                                          
  85.  *         - The 6th part describes how this function works for new functions
  86.  *           only, and describes the parts added, removed or rewritten for    
  87.  *           rewritten or extended functions only                            
  88.  *         Example:                                                          
  89.  * /*----------------------------------------------------------------------
  90.  *  * Why rewrite/extended/What this function does                        
  91.  *  *----------------------------------------------------------------------*/
  92. /* // arguments: What these arguments are                                    
  93.  * function function_name(arguments) // Version X+; Rewrite/New; Hotspot      
  94.  *     // Added/Removed/Rewritten to do something/How this function works    
  95.  *     function_name_code                                                    
  96.  *     //                                                                    
  97.  * end // function_name                                                      
  98.  *----------------------------------------------------------------------------*/
  99.  
  100. Game_Battler.prototype.makeActionTimes = function() { // Rewrite
  101.     // Rewritten to use the sum of all action times at once instead
  102.     var actPercent = this.actionPlusSet().reduce(function(r, p) {
  103.         return r + p;
  104.     }, 1);
  105.     var actTimes = Math.floor(actPercent);
  106.     return Math.random() < actPercent - actTimes ? actTimes + 1 : actTimes;
  107.     //
  108. }; // Game_Battler.prototype.makeActionTimes
  109.  
  110. /*============================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement