Advertisement
nio_kasgami

Game_AIJS

Dec 18th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*:
  2. //==============================================================================
  3. // ■ Emoji Engine MV - Origin "AI Core"
  4. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  5.   @plugindesc Dev Script who permit to have interactive basic AI for your scene.
  6.  
  7.   id: EMMV::AI_Core
  8.   @author Nio Kasgami.
  9.   @Data : 2015/10/05
  10.   @Version : 1.0.0
  11.   @Require : NA
  12. //==============================================================================
  13.  
  14. //==============================================================================
  15. // History
  16. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  17. // 2015/10/05 - Begin of the conversion Ruby -> JS {Beta}.
  18. //==============================================================================
  19.  
  20. //==============================================================================
  21. // Introduction
  22. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  23. //
  24. //==============================================================================
  25.  
  26.  
  27. //==============================================================================
  28. // Plugin Parameter
  29. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  30. // this section handle the plugin parameter. Please do not edit unless you
  31. // want to add extra plugin command.
  32. //------------------------------------------------------------------------------
  33.  * @param tests
  34.  * @desc test
  35.  * @default it's work
  36. //==============================================================================
  37.  
  38. //==============================================================================
  39. // ■ Help File
  40. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  41. // This section serve for input the help file in the engine don't touch this
  42. // unless you want to input more information
  43. //------------------------------------------------------------------------------
  44.    * @help
  45.    * Due the nature of this plugin and the tons of arguments in the call,
  46.    * this plugin do not use plugin command and only script calls.
  47.    *
  48.    * ==========================================================================
  49.    *  ■ Script Call
  50.    * ==========================================================================
  51.    * this.setup_AIShop(aiID,EnableHaggle); :
  52.    * due is nature MV AI shop have to be setup before you call shop process.
  53.    *
  54.    * this.scene_ai(scene,aiID); : Permit to call your scene with a specific
  55.    * AI personality. Only works on scene who got programmed for.
  56.    * --------------------------------------------------------------------------
  57.    *
  58.    * ==========================================================================
  59.    *  ■ Internal Method call
  60.    * ==========================================================================
  61.    * /varname/ = $gamePersonalities.get_personality(ai_id); :
  62.    * Permit to set the ai_id and to get the method in your scene.
  63.    * /varname/.interaction('interaction_type'); : call the interaction method
  64.    * for permit a AI to react.
  65.    * /varname/.curtain_interaction(curtaintype); : call the method for the AI
  66.    * to quit or enter.
  67.    *
  68.    * this.changeExpression(expres); : change the AI expression.
  69.    * this.callDialogue(text); : make the AI speaking.
  70.    * this.callVoice(file,volume,pitch,pan) : call a SE for the AI.
  71.    * this.callEffect(effectype,time,speed); : call a effect on the AI.
  72.    * -------------------------------------------------------------------------
  73.    *
  74.    * ==========================================================================
  75.    *  ■ JSON Structure {AI_Personality}
  76.    * ==========================================================================
  77.    * the structure for setup AI_Personality is setup in the datafile. it's
  78.    * name "AI.JSON" can be opened via a normal text editor so accessible for
  79.    * the user to edit. The structure make them possible to have unlimited
  80.    * personality and dialogue.
  81.    * here a example of a JSON structure.
  82.    * {
  83.    * "1" :{
  84.    *     "Bitmap" : "",
  85.    *     "Greeting" : "Hellow!"
  86.    *   },
  87.    *
  88.    * "2" :{
  89.    *    "Greeting" : "hi..."
  90.    *  }
  91.    * }
  92.    * So in simple you input a id and after a content inside of it.
  93.    * They don't have restriction of wich content you want in it you can remove
  94.    * or add some like you want.
  95.    * the only "mandatory" content you have to add are :
  96.    * -"Bitmap" : "content"
  97.    * -"x" : value
  98.    * -"y" : value
  99.    * If you don't add them this will throw a error.
  100.    * for get the the JSON material create a new one in the method by using.
  101.    * this.varname = this._personality."thenameofthecontent".
  102.    *
  103. */
  104.  
  105. //==============================================================================
  106. // ■ Emoji_Engine
  107. //------------------------------------------------------------------------------
  108. // the class who handle all the base of my plugins. Can be access via $emoji.
  109. //==============================================================================
  110. (function(){
  111. //----------------------------------------------------------------------------
  112. // ○ alias function: get_pluginname
  113. //----------------------------------------------------------------------------
  114. var ai_name = Emoji_Engine.prototype.get_pluginname;
  115. Emoji_Engine.prototype.get_pluginname = function() {
  116.     ai_name.call(this);
  117.     this.aiParams = this.set_PluginID('EEMV::AICore');
  118. };
  119.  
  120. //----------------------------------------------------------------------------
  121. // ● alias function: get_params
  122. //----------------------------------------------------------------------------
  123. var ai_parameters = Emoji_Engine.prototype.get_params;
  124. Emoji_Engine.prototype.get_params = function() {
  125.     ai_parameters.call(this);
  126. // Get Emoji System parameters
  127.     this.enableShopAI   = this.setBoolean(this.aiParams,'Enable Shop AI');
  128.     this.aiFolder       = this.setString(this.aiParams,'AI folder');
  129.     this.allowhaggle    = this.setBoolean(this.aiParams,'Enable Shop Haggle');
  130.     this.allowMood      = this.setBoolean(this.aiParams, 'Enable AI Mood');
  131. };
  132. })();
  133.  
  134. //===============================================================================
  135. // => END : Emoji_Engine
  136. //===============================================================================
  137.  
  138. //==============================================================================
  139. // ■ Game_AI
  140. //------------------------------------------------------------------------------
  141. // This class handles ai actions. It used within the Game_Personalities class
  142. // ($game_personalities).
  143. //==============================================================================
  144.  
  145. function Game_AI() { this.initialize.apply(this,arguments); }
  146.   Game_AI.prototype.constructor = Game_AI;
  147.  
  148. //==============================================================================
  149. // ■ Game_AI {Core}
  150. //------------------------------------------------------------------------------
  151.  // This section is the place where I initialize everything's and permit to
  152.  // retrieve the whole AI_Personality[id] informations. It's also inits the
  153.  // firts actions made by the system.
  154.  // {exclude sprite configurations}
  155. //==============================================================================
  156.  
  157. //----------------------------------------------------------------------------
  158. // ○ new function: initialize
  159. //----------------------------------------------------------------------------
  160. Game_AI.prototype.initialize = function(ai_id) {
  161.     this._id = ai_id;
  162.     this._personality = $dataAI[this._id];
  163.  
  164.     this.retrieveData();
  165.     this.checkMessageType();
  166.     this.createContents
  167. //  this.curtain_interactions("entering");
  168. };
  169.  
  170. Game_AI.prototype.retrieveData = function() {
  171.     this.greeting = this._personality.Greeting;
  172.     this.byeBye   = this._personality.Farewell;
  173. };
  174.  
  175. //----------------------------------------------------------------------------
  176. // ○ new function: checkMessageType
  177. //----------------------------------------------------------------------------
  178. // * Method who permit to setup the Message system for the AI. Without that,
  179. // * the AI would not being able to speak to you.
  180. // * Nothing stop you from inputing more disponible message system to the AI.
  181. // * As long the method is acessible via a global this should works.
  182. // * They have 3 default method in this method :
  183. // * 'MV-default' : It's take the default Game_Message.
  184. // * 'Emoji-Dialogue' : Special system made for work's exclusively with
  185. // * this system.
  186. // * 'YourOwnSystem' : can be rename it's your own message system.
  187. // * Please notice when you use your own personnal message system it's have
  188. // * to use either .add or you have to build your own method call.
  189. //
  190. Game_AI.prototype.checkMessageType = function() {
  191.     switch($emoji.messageType){
  192.     // if no case are meet throw a error.
  193.         default :
  194.         throw new Error("Out of range error : Undefined messageType");
  195.         break;
  196.     // Use MV default Message System.
  197.         case 'MV-default' :
  198.         this.messageSystem = $gameMessage;
  199.         break;
  200.     // Use EEM::EmojiDialogue.
  201.         case 'Emoji-Dialogue' :
  202.         this.messageSystem = $gameDialogue;
  203.         break;
  204.     // Use User system.
  205.         case 'YouOwnSystem' :
  206.         this.messageSystem = undefined;
  207.         break;
  208.     }
  209. };
  210.  
  211. //----------------------------------------------------------------------------
  212. // ○ new function: update
  213. //----------------------------------------------------------------------------
  214. Game_AI.prototype.update = function() {
  215.     this.update_sprite();
  216.     if(this.update_flag){
  217.         update_effect();
  218.     }
  219. };
  220.  
  221. //===============================================================================
  222. // => END : Game_AI {Core}
  223. //===============================================================================
  224.  
  225. //==============================================================================
  226. // ■ Game_AI {Core::interactions}
  227. //------------------------------------------------------------------------------
  228.  // Cette section sert pour la configuration qui dicte comment votre IA reagit
  229.  // a vos actions. Il est generalement dicter par
  230.  // $game_personalities[ai_id].interaction_type = :key
  231.  // et activer par
  232.  // $game_personalities[ai_id].interaction
  233. //==============================================================================
  234.  
  235. //----------------------------------------------------------------------------
  236. // ○ new function: interaction
  237. //----------------------------------------------------------------------------
  238. // * this method is the core of everything's it's where all action are made.
  239. // * in the Game_AI. Let's say it's like the "brain" of your AI. It's
  240. // * check wich reaction to do depending of the call you do.
  241. // * can be call exterior : /varname/.interaction(interactionType);
  242. //
  243. Game_AI.prototype.interaction = function(interactionType) {
  244.     switch (interactionType) {
  245.         default :
  246.          throw new Error("Out of Range Error: undefined interactionType");
  247.          break;
  248.          case 'buy' :
  249.          this.buy();
  250.          break;
  251.     }
  252. };
  253.  
  254. //----------------------------------------------------------------------------
  255. // ○ new function: buy {sample function}
  256. //----------------------------------------------------------------------------
  257. // * Sample method for show how you guys can use this system. It's a messy
  258. // * method but it's permit to take in consideration a all the instance of
  259. // * message system.
  260. // *
  261. Game_AI.prototype.buy = function() {
  262.   var n = this._id.toString();
  263. // if voice are enabledc call the SE.
  264.   if ($emoji.enableVoice){
  265.     this.callVoice("Buy_" + n,100,100,0);
  266.   }
  267.    this.changeExpression(1);
  268. // if using the default message system.
  269.   if (this.messageSystem instanceof Game_Message){
  270.     this.callDialogue(this.Buy);
  271. // if using EEMV::Dialogue
  272.   } else if (this.messageSystem instanceof Game_Dialogue){
  273.     this.callDialogueEX(this.Buy,0,null,null);
  274. // if using custom (can be change if using other method)
  275.   } else {
  276.     this.callDialogue(this.Buy);
  277.   }
  278.  
  279. };
  280.  
  281. //----------------------------------------------------------------------------
  282. // ○ new function: curtain_interactions
  283. //----------------------------------------------------------------------------
  284. // * It's the Entering reaction of the game it's can be call when you start
  285. // * Your Scene.
  286. Game_AI.prototype.curtain_interactions = function(curtainType) {
  287.     switch(curtainType){
  288.         default :
  289.          throw new Error("Out of Range Error: Undefined curtainType");
  290.          break;
  291.         case "entering" :
  292.          this.entering_interaction();
  293.          break;
  294.         case "quitting" :
  295.          this.quitting_interaction();
  296.          break;
  297.     }
  298. };
  299.  
  300. //----------------------------------------------------------------------------
  301. // ○ new function: entering_interaction
  302. //----------------------------------------------------------------------------
  303. Game_AI.prototype.entering_interaction = function() {
  304. //  this.call_effect("inhori_slide",2,100);
  305. //  this.change_expression(1);
  306.     this.call_dialogue(this.greeting);
  307. };
  308.  
  309. //----------------------------------------------------------------------------
  310. // ○ new function: quitting_interaction
  311. //----------------------------------------------------------------------------
  312. Game_AI.prototype.quitting_interaction = function() {
  313.     this.change_expression(2);
  314.     this.dialogue_system.add(this.byebye);
  315.     this.call_effect("outhori_slie",2,100);
  316. };
  317. //===============================================================================
  318. // => END : Game_AI {Core::Interactions}
  319. //===============================================================================
  320.  
  321. //==============================================================================
  322. // ■ Game_AI {Sprite}
  323. //------------------------------------------------------------------------------
  324. // This section serve for Sprite initialization and configuration purpose
  325. //==============================================================================
  326.  
  327. //----------------------------------------------------------------------------
  328. // ○ new function: createContents
  329. //----------------------------------------------------------------------------
  330. // * Main function for create the Sprite Content. No need to touch this.
  331. //
  332. Game_AI.prototype.createContents = function() {
  333.   // if picture is not ready the system is loading them.
  334.     while(ImageManager.isReady() != true){
  335.         this.loadAI();
  336.     }
  337.     this.aiGraphics = null;
  338.     this.createSprite();
  339. };
  340.  
  341. //----------------------------------------------------------------------------
  342. // ○ new function: loadAI
  343. //----------------------------------------------------------------------------
  344. Game_AI.prototype.loadAI = function() {
  345.     this.aiGraphics = ImageManager.loadAI(this.spriteName() + "_" + this.spriteIndex());
  346. };
  347.  
  348. //----------------------------------------------------------------------------
  349. // ○ new function: create_sprite
  350. //----------------------------------------------------------------------------
  351. Game_AI.prototype.createSprite = function() {
  352.     this.aiSprite = new Sprite();
  353.     this.aiSprite.x = this._personality.xOffset;
  354.     this.aiSprite.y = this._personality.yOffset;
  355.     this.aiSprite.opacity = 0;
  356.     this.aiSprite.setOrigin(0.5,1);
  357.     this.aiSprite.visible = false;
  358.     SceneManager._scene.addChild(this.aiSprite);
  359. };
  360.  
  361. //----------------------------------------------------------------------------
  362. // ○ new function: change_expression
  363. //----------------------------------------------------------------------------
  364. // * Change the expression of the AI. It's autorefresh the expression after
  365. // * the message is cleared. For this reason you may input this call before
  366. // * the message or this will not update properly. Use the call internally.
  367. // * this.changeExpression(value);
  368. //
  369. Game_AI.prototype.changeExpression = function(expression) {
  370.     this._index = expression;
  371. };
  372.  
  373. //----------------------------------------------------------------------------
  374. // ○ new function: terminate_sprite {obsolete Method}
  375. //----------------------------------------------------------------------------
  376. Game_AI.prototype.terminateSprite = function() {};
  377.  
  378. //----------------------------------------------------------------------------
  379. // ○ new function: update
  380. //----------------------------------------------------------------------------
  381. Game_AI.prototype.update_sprite = function() {
  382.     this.updateSpriteBitmap();
  383.     this.refreshExpression();
  384.     if(this.isActive()) {this.updateSpriteEffect();}
  385. };
  386.  
  387. //----------------------------------------------------------------------------
  388. // ○ new function: update_sprite_location
  389. //----------------------------------------------------------------------------
  390. Game_AI.prototype.updateSpriteBitmap = function() {
  391.     var n = this._index.toString();
  392.  this.sprite.bitmap = ImageManager.ai_bust(this.ai_sprite + n);
  393. };
  394.  
  395. //----------------------------------------------------------------------------
  396. // ○ new function: refreshExpression
  397. //----------------------------------------------------------------------------
  398. Game_AI.prototype.refreshExpression = function() {
  399.     if($game_message.isbusy != true) {
  400.         this.change_expression(0);
  401.     }
  402. };
  403. //===============================================================================
  404. // => END : Game_AI {Sprite}
  405. //===============================================================================
  406.  
  407. //==============================================================================
  408. // ■ Game_AI {Sprite::Effects}
  409. //------------------------------------------------------------------------------
  410. // This section serve for handles sprites effects
  411. //==============================================================================
  412.  
  413. //----------------------------------------------------------------------------
  414. // ○ new function: callEffect
  415. //----------------------------------------------------------------------------
  416. // * Internal function to the Game_AI  who permit to do effects to the sprite.
  417. // * Nothing stop you from creating new but here the default one.
  418. // * "horizontal" : slide the sprite to the horizontal.
  419. // * "vertical" : slide the sprite to the vertical.
  420. // * "fadein" : fadein the sprite.
  421. // * "fadeout" : fadeout the sprite.
  422. //
  423. Game_AI.prototype.callEffect = function(effectType,speed,time) {
  424.     switch(effectType.toLowerCase()){
  425.     // else if code are not defined throw a error,
  426.         default:
  427.         throw new Error("Out of range error: undefined effectType.");
  428.         break;
  429.     // do a horizontal slide.
  430.         case "horizontal":
  431.         this.setEffectFlag(true);
  432.         this.setupEffect(effectType,speed,time);
  433.         break;
  434.     // do a vertical slide.
  435.         case "vertical":
  436.         this.setEffectFlag(true);
  437.         this.setupEffect(effectType,speed,time);
  438.         break;
  439.     // do a fadein.
  440.         case "fadein":
  441.         this.setEffectFlag(true);
  442.         this.setupEffect(effectType,speed,time);
  443.         break;
  444.     // do a fadeout.
  445.         case "fadeout":
  446.         this.setEffectFlag(true);
  447.         this.setupEffect(effectType,speed,time);
  448.         break;
  449.     }
  450. };
  451.  
  452. //----------------------------------------------------------------------------
  453. // ○ new function: setEffectFlag
  454. //----------------------------------------------------------------------------
  455. Game_AI.prototype.setEffectFlag = function(booleans) {
  456.     this.effectFlag = booleans;
  457. };
  458.  
  459. //----------------------------------------------------------------------------
  460. // ○ new function: setupEffect
  461. //----------------------------------------------------------------------------
  462. Game_AI.prototype.setupEffect = function(effectType,speed,time) {
  463.     this._effect = effectType;
  464.     this._speed  = speed;
  465.     this._time   = time;
  466. };
  467.  
  468. //----------------------------------------------------------------------------
  469. // ○ new function: effects
  470. //----------------------------------------------------------------------------
  471. Game_AI.prototype.effects = function() {
  472.     return this._effect;
  473. };
  474.  
  475. //----------------------------------------------------------------------------
  476. // ○ new function: speedValue
  477. //----------------------------------------------------------------------------
  478. Game_AI.prototype.speedValue = function() {
  479.     return this._speed;
  480. };
  481.  
  482. //----------------------------------------------------------------------------
  483. // ○ new function: timeValue
  484. //----------------------------------------------------------------------------
  485. Game_AI.prototype.timeValue = function() {
  486.     return this._time;
  487. };
  488.  
  489. //----------------------------------------------------------------------------
  490. // ○ new function: updateSpriteEffect
  491. //----------------------------------------------------------------------------
  492. Game_AI.prototype.updateSpriteEffect = function() {
  493.     switch(this.effects()){
  494.         case 'horizontal' :
  495.         this.executeSlideHorizontaly(this.speedValue(),this.timeValue());
  496.         break;
  497.         case 'vertical' :
  498.         this.executeSlideVerticaly(this.speedValue(),this.timeValue());
  499.         break;
  500.         case 'fadein' :
  501.         this.executeFadeIn(this.speedValue(),this.timeValue());
  502.         break;
  503.         case 'fadeout' :
  504.         this.executeFadeOut(this.speedValue(),this.timeValue());
  505.         break;
  506.     }
  507. };
  508.  
  509. //----------------------------------------------------------------------------
  510. // ○ new function: executeSlideHorizontaly
  511. //----------------------------------------------------------------------------
  512. Game_AI.prototype.executeSlideHorizontaly = function(a,b) {};
  513. //----------------------------------------------------------------------------
  514. // ○ new function: executeSlideVertical
  515. //----------------------------------------------------------------------------
  516. Game_AI.prototype.executeSlideVertical = function(a,b) {};
  517. //----------------------------------------------------------------------------
  518. // ○ new function: executeFadeIn
  519. //----------------------------------------------------------------------------
  520. Game_AI.prototype.executeFadeIn = function(a,b) {};
  521. //----------------------------------------------------------------------------
  522. // ○ new function: executeFadeOut
  523. //----------------------------------------------------------------------------
  524. Game_AI.prototype.executeFadeOut = function(a,b) {};
  525.  
  526.  
  527. //===============================================================================
  528. // => END : Game_AI {Sprite::Effects}
  529. //===============================================================================
  530.  
  531. //==============================================================================
  532. // ■ Game_AI {dialogue}
  533. //------------------------------------------------------------------------------
  534. // This section serve for AI Voice SE purpose
  535. // use call_voice("filename",volume,pitch)this.call_dialogue("text");
  536. //==============================================================================
  537.  
  538. //----------------------------------------------------------------------------
  539. // ○ new function: call_dialogue
  540. //----------------------------------------------------------------------------
  541. // * Default Method who permit to add text to the system. Work's with the
  542. // * default message system or any message system who use "add" for their
  543. // * text. use this.callDialogue(text); for add text.
  544. //
  545. Game_AI.prototype.callDialogue = function(text) {
  546.     this.messageSystem.add(text);
  547. };
  548. //----------------------------------------------------------------------------
  549. // ○ new function: callDialogueEX
  550. //----------------------------------------------------------------------------
  551. // * Unique Message call it's only work's with EMMV::Dialogue plugin.
  552. // * it's permit to call text, a background and set the positiono of the
  553. // * message. It's not work with Yanfly message system and I don't intend
  554. // * to make it compatible.
  555. //  
  556. Game_AI.prototype.callDialogueEx = function(text,backgroundType,x,y) {
  557.   switch (backgroundType){
  558.     default :
  559.     throw new Error("Out of range error : undefined backgroundType.");
  560.     break;
  561.     case 'normal' :
  562.     $gameDialogue.backType = 0;
  563.     break;
  564.     case 'surprise' :
  565.     $gameDialogue.backType = 1;
  566.     break;
  567.     case 'none' :
  568.     $gameDialogue.backType = 4;
  569.     break;
  570.   }
  571.   $gameDialogue.setOffSet(x,y);
  572.   $gameDialogue.add(text);
  573. };
  574. //===============================================================================
  575. // => END : Game_AI {dialogue}
  576. //===============================================================================
  577.  
  578. //==============================================================================
  579. // ■ Game_AI {Voice}
  580. //------------------------------------------------------------------------------
  581. // This section serve for AI Text dialogue purpose.
  582. // Use the call this.call_voice("filename",volume,pitch);
  583. //==============================================================================
  584.  
  585. //----------------------------------------------------------------------------
  586. // ○ new function: callVoice
  587. //----------------------------------------------------------------------------
  588. Game_AI.prototype.callVoice = function(voiceIndex,volume,pitch,pan) {
  589.     var pathoFile = $emoji.voiceFolder + "/";
  590.     AudioManager.playSe(pathoFile + voiceIndex,volume,pitch,pan);
  591. };
  592.  
  593. //===============================================================================
  594. // => END : Game_AI {Voice}
  595. //===============================================================================
  596.  
  597.  
  598. //===============================================================================
  599. // => END : Game_AI
  600. //===============================================================================
  601.  
  602. //==============================================================================
  603. // ■ Game_Personalities
  604. //------------------------------------------------------------------------------
  605. //  This class handles Personality_id. It's a wrapper for the built-in class
  606. //  "Array." The instance of this class is referenced by $game_Personalities.
  607. //==============================================================================
  608.  
  609. function Game_Personalities() { this.initialize.apply(this,arguments);}
  610.  
  611. //----------------------------------------------------------------------------
  612. // ○ new function: initialize
  613. //----------------------------------------------------------------------------
  614. Game_Personalities.prototype.initialize = function() {
  615.     this._personality = this._personality || [];
  616. };
  617.  
  618. //----------------------------------------------------------------------------
  619. // ○ new function: get_personality
  620. //----------------------------------------------------------------------------
  621. Game_Personalities.prototype.get_personality = function(ai_id) {
  622.     this._personality[ai_id] = this._personality[ai_id] || new Game_AI(ai_id);
  623.     return this._personality[ai_id]
  624. };
  625. //===============================================================================
  626. // => END : Game_Personalities
  627. //===============================================================================
  628.  
  629. //==============================================================================
  630. // ■ Game_Interpreter
  631. //------------------------------------------------------------------------------
  632. //  An interpreter for executing event commands. This class is used within the
  633. // Game_Map, Game_Troop, and Game_Event classes. This snipset add executing
  634. // for Game_Personalities and Game_AI classes event processing.
  635. //==============================================================================
  636.  
  637. //----------------------------------------------------------------------------
  638. // ● alias function: clear
  639. //----------------------------------------------------------------------------
  640. var emoji_clear = Game_Interpreter.prototype.clear;
  641. Game_Interpreter.prototype.clear = function() {
  642.     emoji_clear.call(this);
  643.     this._shop_ai_id = 0;
  644.     this._enable_haggle = false;
  645. };
  646.  
  647.  
  648. //----------------------------------------------------------------------------
  649. // ○ new function: setup_shop_ai
  650. //----------------------------------------------------------------------------
  651. Game_Interpreter.prototype.setup_shop_ai = function(a,b){
  652.     this._shop_ai_id = a;
  653.     this._enable_haggle = b;
  654. };
  655.  
  656. //----------------------------------------------------------------------------
  657. // ○ new function: scene_ai
  658. //----------------------------------------------------------------------------
  659. Game_Interpreter.prototype.scene_ai = function(scene_s,ai_type) {
  660.      SceneManager.push(scene_s);
  661.      SceneManager.prepareNextScene(ai_type);
  662. };
  663.  
  664. //----------------------------------------------------------------------------
  665. // ● overwrite / alias function: command_302
  666. //----------------------------------------------------------------------------
  667. var emoji_command302 = Game_Interpreter.prototype.command302;
  668. Game_Interpreter.prototype.command302 = function() {
  669.     if(!$emoji.enable_aishop) {
  670.         emoji_command302.call(this);
  671.     }
  672.     else{
  673.   if (!$gameParty.inBattle()) {
  674.     var goods = [this._params];
  675.     while (this.nextEventCode() === 605) {
  676.       this._index++;
  677.       goods.push(this.currentCommand().parameters)
  678.     }
  679.     SceneManager.push(Scene_Shop);
  680.     SceneManager.prepareNextScene(goods, this._params[4], this._shop_ai_id,this._enable_haggle)
  681.   }
  682.   return true
  683. }
  684. };
  685. //===============================================================================
  686. // => END : Game_interpreter
  687. //===============================================================================
  688.  
  689. //==============================================================================
  690. // ■ DataManager
  691. //------------------------------------------------------------------------------
  692.  
  693. //==============================================================================
  694.  
  695. //----------------------------------------------------------------------------
  696. // ★ new global variables : $dataAI, $game_personalities
  697. //----------------------------------------------------------------------------
  698.  var $dataAI = null;
  699.  var $gamePersonalities = null;
  700.  
  701. //----------------------------------------------------------------------------
  702. // ◇ Push new data : _databaseFile[array]
  703. //----------------------------------------------------------------------------
  704.  DataManager._databaseFiles.push({name: '$dataAI',src: 'AI.json'});
  705.  
  706. //----------------------------------------------------------------------------
  707. // ● alias function: createGameObjects
  708. //----------------------------------------------------------------------------
  709. var emoji_personalities = DataManager.createGameObjects;
  710. DataManager.createGameObjects = function() {
  711.     emoji_personalities.call(this);
  712.     $gamePersonalities          = new Game_Personalities();
  713. };
  714.  
  715. //===============================================================================
  716. // => END : DataManager
  717. //===============================================================================
  718.  
  719. //==============================================================================
  720. // ■ ImageManager
  721. //------------------------------------------------------------------------------
  722.  
  723. //==============================================================================
  724.  
  725. //----------------------------------------------------------------------------
  726. // ○ new function: loadAI
  727. //----------------------------------------------------------------------------
  728. ImageManager.loadAI = function(filename) {
  729.     var folder_path = $emoji.ai_folder
  730.     return this.loadBitmap('img/' + folder_path, filename, 0, true);
  731. };
  732. //===============================================================================
  733. // => END : ImageManager
  734. //===============================================================================
  735.  
  736. // TEMPORARY
  737. function Game_Dialogue() {this.initialize.apply(this,arguments);}
  738.   Game_Dialogue.prototype.constructor = Game_Dialogue;
  739.  
  740.   Game_Dialogue.prototype.initialize = function() {
  741.     this.clear();
  742.   };
  743.  
  744.   Game_Dialogue.prototype.clear = function() {
  745.     this._texts    = [];     // text in array's (rows).
  746.     this._choices   = [];  // choice in array's.
  747.     this._backName = "";
  748.     this._choiceBackName = "";
  749.     this._backType = 0;
  750.     this._choiceBackType = 0;
  751.     this._backOffsetX = 0;
  752.     this._backOffsetY = 0;
  753.     this._choiceBackOffSetX = 0;
  754.     this._choiceBackOffSetY = 0;
  755.   };
  756.  
  757.   Game_Dialogue.prototype.choice = function() {
  758.     return this._choices;
  759.   };
  760.  
  761.   Game_Dialogue.prototype.backName = function() {
  762.     return this._backName
  763.   };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement