Advertisement
nio_kasgami

beta

Oct 9th, 2015
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //==============================================================================
  2. // ■ Emoji Engine MV - Origin "AI Core"
  3. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  4. // Dev Script who permit to have interactive basic AI for your scene.
  5. // Created by Nio Kasgami.
  6. // Data : 2015/10/05
  7. // Version : 1.0.0
  8. // Require : NA
  9. //==============================================================================
  10.  
  11. //==============================================================================
  12. // History
  13. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. // 2015/10/05 - Begin of the conversion Ruby -> JS {Beta}.
  15. //==============================================================================
  16.  
  17. //==============================================================================
  18. // Introduction
  19. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  20. //
  21. //==============================================================================
  22.  
  23. //==============================================================================
  24. // ◎ Global_Variable : Version
  25. //------------------------------------------------------------------------------
  26. // Cette variable sert tout bonnement pour pouvoir ajouter des mise a jours
  27. // supplementaire a mon scripts sans forcer les gens a recopier mon script
  28. // constament effaçant ainsi leurs propre modifications au script.
  29. // si vous voulez ajoutez une "patch" supplementaire changer le numeros de la
  30. // version.
  31. //(le script original sera toujours mit a jours dans le lien principal)
  32.    var $version = 1.00;
  33. //=============================================================================
  34.  
  35. //==============================================================================
  36. // ■ Game_AI
  37. //------------------------------------------------------------------------------
  38. // This class handles ai actions. It used within the Game_Personalities class
  39. // ($game_personalities).
  40. //==============================================================================
  41.  
  42. function Game_AI() { this.initialize.apply(this,arguments); }
  43. Game_AI.prototype.constructor = Game_AI;
  44.  
  45. //==============================================================================
  46. // ■ Game_AI {Core}
  47. //------------------------------------------------------------------------------
  48.  // This section is the place where I initialize everything's and permit to
  49.  // retrieve the whole AI_Personality[id] informations. It's also inits the
  50.  // firts actions made by the system.
  51.  // {exclude sprite configurations}
  52. //==============================================================================
  53.  
  54. //----------------------------------------------------------------------------
  55. // ○ new function: initialize
  56. //----------------------------------------------------------------------------
  57. Game_AI.prototype.initialize = function(ai_id) {
  58.     this._id = ai_id;
  59.     this._personality = AI_Personality[this._id];
  60.  
  61.     this.check_message_type();
  62.     this.retrieve_dialogue_and_voices();
  63.     this.create_sprite();
  64.     this.curtain_interactions("entering");
  65. };
  66.  
  67. Game_AI.prototype.check_message_type = function() {
  68. /*  switch (PARAM_ME) {
  69.         case 'default' :
  70.         this.dialogue_system = $game_message;
  71.         break;
  72.         case 'custom'
  73.         this.dialogue_system = PARAM_MNAME;
  74.         break;
  75.     } */
  76. };
  77.  
  78. Game_AI.prototype.retrieve_dialogue_and_voices = function() {
  79.     this.greeting = "";
  80. };
  81.  
  82.  
  83. //===============================================================================
  84. // => END : Game_AI {Core}
  85. //===============================================================================
  86.  
  87. //==============================================================================
  88. // ■ Game_AI {Core::interactions}
  89. //------------------------------------------------------------------------------
  90.  // Cette section sert pour la configuration qui dicte comment votre IA reagit
  91.  // a vos actions. Il est generalement dicter par
  92.  // $game_personalities[ai_id].interaction_type = :key
  93.  // et activer par
  94.  // $game_personalities[ai_id].interaction
  95. //==============================================================================
  96.  
  97. //----------------------------------------------------------------------------
  98. // ○ new function: interaction
  99. //----------------------------------------------------------------------------
  100. Game_AI.prototype.interaction = function(interaction_type) {
  101.     switch (interaction_type) {
  102.         case 'normal' :
  103.         this.dialogue_system.add("text");
  104.         this.change_expression(1);
  105.         break;
  106.     }
  107. };
  108.  
  109. Game_AI.prototype.curtain_interactions = function(curtain_type) {
  110.     switch(curtain_type){
  111.         case "entering" :
  112.          this.entering_interaction();
  113.          break;
  114.         case "quitting" :
  115.         this.quitting_interaction();
  116.     }
  117. };
  118.  
  119. Game_AI.prototype.entering_interaction = function() {
  120.     this.call_effect("inhori_slide",2,100);
  121.     this.change_expression(1);
  122.     this.dialogue_system.add(this.greeting);
  123. };
  124.  
  125. Game_AI.prototype.quitting_interaction = function() {
  126.     this.change_expression(2);
  127.     this.dialogue_system.add(this.byebye);
  128.     this.call_effect("outhori_slie",2,100);
  129. };
  130.  
  131. //===============================================================================
  132. // => END : Game_AI {Core::Interactions}
  133. //===============================================================================
  134.  
  135. //==============================================================================
  136. // ■ Game_AI {Sprite}
  137. //------------------------------------------------------------------------------
  138. // This section serve for Sprite initialization and configuration purpose
  139. //==============================================================================
  140.  
  141. //----------------------------------------------------------------------------
  142. // ○ new function: create_sprite
  143. //----------------------------------------------------------------------------
  144. Game_AI.prototype.create_sprite = function() {
  145.     this.ai_sprite = AI_Personality[bitmap];
  146.     this._index = 0;
  147.     this.sprite = new Sprite();
  148.     addchild(sprite);
  149. };
  150.  
  151. //----------------------------------------------------------------------------
  152. // ○ new function: change_expression
  153. //----------------------------------------------------------------------------
  154. Game_AI.prototype.change_expression = function(expres) {
  155.     this._index = expres;
  156. };
  157.  
  158. //----------------------------------------------------------------------------
  159. // ○ new function: terminate_sprite
  160. //----------------------------------------------------------------------------
  161. Game_AI.prototype.terminate_sprite = function() {
  162.  
  163. };
  164. //----------------------------------------------------------------------------
  165. // ○ new function: update
  166. //----------------------------------------------------------------------------
  167. Game_AI.prototype.update_sprite = function() {
  168.     this.update_sprite_location();
  169.     this.refresh_expression();
  170. };
  171.  
  172. //----------------------------------------------------------------------------
  173. // ○ new function: update_sprite_location
  174. //----------------------------------------------------------------------------
  175. Game_AI.prototype.update_sprite_location = function() {
  176.     var n = this._index.toString();
  177.  this.sprite.bitmap = ImageManager.ai_bust(this.ai_sprite + n);
  178. };
  179.  
  180. //----------------------------------------------------------------------------
  181. // ○ new function: refresh_expression
  182. //----------------------------------------------------------------------------
  183. Game_AI.prototype.refresh_expression = function() {
  184.     if($game_message.isbusy) {
  185.         this.change_expression(0);
  186.     }
  187. };
  188.  
  189.  
  190.  
  191. //===============================================================================
  192. // => END : Game_AI {Sprite}
  193. //===============================================================================
  194.  
  195. //==============================================================================
  196. // ■ Game_AI {Sprite::Effects}
  197. //------------------------------------------------------------------------------
  198. // This section serve for handles sprites effects
  199. //==============================================================================
  200.  
  201. //----------------------------------------------------------------------------
  202. // ○ new function: call_effect
  203. //----------------------------------------------------------------------------
  204. Game_AI.prototype.call_effect = function(effect_type,speed,time) {
  205.     switch (effect_type) {
  206.         case  "inhori_slide" :
  207.          this.execute_inhori_slide(speed,time);
  208.          break;
  209.         case "inverti_slide" :
  210.          this.execute_inverti_slide(speed,time);
  211.          break;
  212.         case "fadein" :
  213.          this.execute_fadein(speed,time;
  214.          break;
  215.     }
  216. };
  217.  
  218. //===============================================================================
  219. // => END : Game_AI {Sprite::Effects}
  220. //===============================================================================
  221.  
  222.  
  223. //==============================================================================
  224. // ■ Game_AI {Voice}
  225. //------------------------------------------------------------------------------
  226. // This section serve for AI Voice SE purpose
  227. // use call_voice("filename",volume,pitch)
  228. //==============================================================================
  229.  
  230. //----------------------------------------------------------------------------
  231. // ○ new function: call_voice
  232. //----------------------------------------------------------------------------
  233. Game_AI.prototype.call_voice = function(voice_index,volume,pitch) {
  234.     var voice_folder = PARAMSYSTEM;
  235.     var pathofile = voice_folder + "/";
  236.     AudioManager.playSe(pathofile + voice_index, volume,pitch);
  237. };
  238. //===============================================================================
  239. // => END : Game_AI {Voice}
  240. //===============================================================================
  241.  
  242. //==============================================================================
  243. // ■ Game_Personalities
  244. //------------------------------------------------------------------------------
  245. //  This class handles Personality_id. It's a wrapper for the built-in class
  246. //  "Array." The instance of this class is referenced by $game_Personalities.
  247. //==============================================================================
  248.  
  249. function Game_Personalities() { this.initialize.apply(this,arguments);}
  250. Game_Personalities.prototype.constructor = Game_Personalities;
  251.  
  252. //----------------------------------------------------------------------------
  253. // ○ new function: initialize
  254. //----------------------------------------------------------------------------
  255. Game_Personalities.prototype.initialize = function() {
  256.  
  257. };
  258.  
  259.  
  260. //===============================================================================
  261. // => END : Game_Personalities
  262. //===============================================================================
  263.  
  264. //==============================================================================
  265. // ■ Game_Interpreter
  266. //------------------------------------------------------------------------------
  267. //  An interpreter for executing event commands. This class is used within the
  268. // Game_Map, Game_Troop, and Game_Event classes. This snipset add executing
  269. // for Game_Personalities and Game_AI classes event processing.
  270. //==============================================================================
  271.  
  272. //----------------------------------------------------------------------------
  273. // ● alias function: clear
  274. //----------------------------------------------------------------------------
  275. var emoji_clear = Game_Interpreter.prototype.clear;
  276. Game_Interpreter.prototype.clear = function() {
  277.     emoji_clear.call(this);
  278.     this._shop_ai_id = 0;
  279.     this._enable_haggle = false;
  280. };
  281.  
  282.  
  283. //----------------------------------------------------------------------------
  284. // ○ new function: setup_shop_ai
  285. //----------------------------------------------------------------------------
  286. Game_Interpreter.prototype.setup_shop_ai = function(a,b){
  287.     this._shop_ai_id = a;
  288.     this._enable_haggle = b;
  289. };
  290.  
  291. //----------------------------------------------------------------------------
  292. // ○ new function: scene_ai
  293. //----------------------------------------------------------------------------
  294. Game_Interpreter.prototype.scene_ai = function(scene_s,ai_type) {
  295.      SceneManager.push(scene_s);
  296.      SceneManager.prepareNextScene(ai_type);
  297. };
  298.  
  299. //----------------------------------------------------------------------------
  300. // ● overwrite function: command_302 { desactivate }
  301. //----------------------------------------------------------------------------  
  302. Game_Interpreter.prototype.command302 = function() {
  303.   if (!$gameParty.inBattle()) {
  304.     var goods = [this._params];
  305.     while (this.nextEventCode() === 605) {
  306.       this._index++;
  307.       goods.push(this.currentCommand().parameters)
  308.     }
  309.     SceneManager.push(Scene_Shop);
  310.     SceneManager.prepareNextScene(goods, this._params[4], this._shop_ai_id,this._enable_haggle)
  311.   }
  312.   return true
  313. };
  314. //===============================================================================
  315. // => END : Game_interpreter
  316. //===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement