Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //==============================================================================
- // ■ Emoji Engine MV - Origin "AI Core"
- // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- // Dev Script who permit to have interactive basic AI for your scene.
- // Created by Nio Kasgami.
- // Data : 2015/10/05
- // Version : 1.0.0
- // Require : NA
- //==============================================================================
- //==============================================================================
- // History
- // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- // 2015/10/05 - Begin of the conversion Ruby -> JS {Beta}.
- //==============================================================================
- //==============================================================================
- // Introduction
- // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- //
- //==============================================================================
- //==============================================================================
- // ◎ Global_Variable : Version
- //------------------------------------------------------------------------------
- // Cette variable sert tout bonnement pour pouvoir ajouter des mise a jours
- // supplementaire a mon scripts sans forcer les gens a recopier mon script
- // constament effaçant ainsi leurs propre modifications au script.
- // si vous voulez ajoutez une "patch" supplementaire changer le numeros de la
- // version.
- //(le script original sera toujours mit a jours dans le lien principal)
- var $version = 1.00;
- //=============================================================================
- //==============================================================================
- // ■ Game_AI
- //------------------------------------------------------------------------------
- // This class handles ai actions. It used within the Game_Personalities class
- // ($game_personalities).
- //==============================================================================
- function Game_AI() { this.initialize.apply(this,arguments); }
- Game_AI.prototype.constructor = Game_AI;
- //==============================================================================
- // ■ Game_AI {Core}
- //------------------------------------------------------------------------------
- // This section is the place where I initialize everything's and permit to
- // retrieve the whole AI_Personality[id] informations. It's also inits the
- // firts actions made by the system.
- // {exclude sprite configurations}
- //==============================================================================
- //----------------------------------------------------------------------------
- // ○ new function: initialize
- //----------------------------------------------------------------------------
- Game_AI.prototype.initialize = function(ai_id) {
- this._id = ai_id;
- this._personality = AI_Personality[this._id];
- this.check_message_type();
- this.retrieve_dialogue_and_voices();
- this.create_sprite();
- this.curtain_interactions("entering");
- };
- Game_AI.prototype.check_message_type = function() {
- /* switch (PARAM_ME) {
- case 'default' :
- this.dialogue_system = $game_message;
- break;
- case 'custom'
- this.dialogue_system = PARAM_MNAME;
- break;
- } */
- };
- Game_AI.prototype.retrieve_dialogue_and_voices = function() {
- this.greeting = "";
- };
- //===============================================================================
- // => END : Game_AI {Core}
- //===============================================================================
- //==============================================================================
- // ■ Game_AI {Core::interactions}
- //------------------------------------------------------------------------------
- // Cette section sert pour la configuration qui dicte comment votre IA reagit
- // a vos actions. Il est generalement dicter par
- // $game_personalities[ai_id].interaction_type = :key
- // et activer par
- // $game_personalities[ai_id].interaction
- //==============================================================================
- //----------------------------------------------------------------------------
- // ○ new function: interaction
- //----------------------------------------------------------------------------
- Game_AI.prototype.interaction = function(interaction_type) {
- switch (interaction_type) {
- case 'normal' :
- this.dialogue_system.add("text");
- this.change_expression(1);
- break;
- }
- };
- Game_AI.prototype.curtain_interactions = function(curtain_type) {
- switch(curtain_type){
- case "entering" :
- this.entering_interaction();
- break;
- case "quitting" :
- this.quitting_interaction();
- }
- };
- Game_AI.prototype.entering_interaction = function() {
- this.call_effect("inhori_slide",2,100);
- this.change_expression(1);
- this.dialogue_system.add(this.greeting);
- };
- Game_AI.prototype.quitting_interaction = function() {
- this.change_expression(2);
- this.dialogue_system.add(this.byebye);
- this.call_effect("outhori_slie",2,100);
- };
- //===============================================================================
- // => END : Game_AI {Core::Interactions}
- //===============================================================================
- //==============================================================================
- // ■ Game_AI {Sprite}
- //------------------------------------------------------------------------------
- // This section serve for Sprite initialization and configuration purpose
- //==============================================================================
- //----------------------------------------------------------------------------
- // ○ new function: create_sprite
- //----------------------------------------------------------------------------
- Game_AI.prototype.create_sprite = function() {
- this.ai_sprite = AI_Personality[bitmap];
- this._index = 0;
- this.sprite = new Sprite();
- addchild(sprite);
- };
- //----------------------------------------------------------------------------
- // ○ new function: change_expression
- //----------------------------------------------------------------------------
- Game_AI.prototype.change_expression = function(expres) {
- this._index = expres;
- };
- //----------------------------------------------------------------------------
- // ○ new function: terminate_sprite
- //----------------------------------------------------------------------------
- Game_AI.prototype.terminate_sprite = function() {
- };
- //----------------------------------------------------------------------------
- // ○ new function: update
- //----------------------------------------------------------------------------
- Game_AI.prototype.update_sprite = function() {
- this.update_sprite_location();
- this.refresh_expression();
- };
- //----------------------------------------------------------------------------
- // ○ new function: update_sprite_location
- //----------------------------------------------------------------------------
- Game_AI.prototype.update_sprite_location = function() {
- var n = this._index.toString();
- this.sprite.bitmap = ImageManager.ai_bust(this.ai_sprite + n);
- };
- //----------------------------------------------------------------------------
- // ○ new function: refresh_expression
- //----------------------------------------------------------------------------
- Game_AI.prototype.refresh_expression = function() {
- if($game_message.isbusy) {
- this.change_expression(0);
- }
- };
- //===============================================================================
- // => END : Game_AI {Sprite}
- //===============================================================================
- //==============================================================================
- // ■ Game_AI {Sprite::Effects}
- //------------------------------------------------------------------------------
- // This section serve for handles sprites effects
- //==============================================================================
- //----------------------------------------------------------------------------
- // ○ new function: call_effect
- //----------------------------------------------------------------------------
- Game_AI.prototype.call_effect = function(effect_type,speed,time) {
- switch (effect_type) {
- case "inhori_slide" :
- this.execute_inhori_slide(speed,time);
- break;
- case "inverti_slide" :
- this.execute_inverti_slide(speed,time);
- break;
- case "fadein" :
- this.execute_fadein(speed,time;
- break;
- }
- };
- //===============================================================================
- // => END : Game_AI {Sprite::Effects}
- //===============================================================================
- //==============================================================================
- // ■ Game_AI {Voice}
- //------------------------------------------------------------------------------
- // This section serve for AI Voice SE purpose
- // use call_voice("filename",volume,pitch)
- //==============================================================================
- //----------------------------------------------------------------------------
- // ○ new function: call_voice
- //----------------------------------------------------------------------------
- Game_AI.prototype.call_voice = function(voice_index,volume,pitch) {
- var voice_folder = PARAMSYSTEM;
- var pathofile = voice_folder + "/";
- AudioManager.playSe(pathofile + voice_index, volume,pitch);
- };
- //===============================================================================
- // => END : Game_AI {Voice}
- //===============================================================================
- //==============================================================================
- // ■ Game_Personalities
- //------------------------------------------------------------------------------
- // This class handles Personality_id. It's a wrapper for the built-in class
- // "Array." The instance of this class is referenced by $game_Personalities.
- //==============================================================================
- function Game_Personalities() { this.initialize.apply(this,arguments);}
- Game_Personalities.prototype.constructor = Game_Personalities;
- //----------------------------------------------------------------------------
- // ○ new function: initialize
- //----------------------------------------------------------------------------
- Game_Personalities.prototype.initialize = function() {
- };
- //===============================================================================
- // => END : Game_Personalities
- //===============================================================================
- //==============================================================================
- // ■ Game_Interpreter
- //------------------------------------------------------------------------------
- // An interpreter for executing event commands. This class is used within the
- // Game_Map, Game_Troop, and Game_Event classes. This snipset add executing
- // for Game_Personalities and Game_AI classes event processing.
- //==============================================================================
- //----------------------------------------------------------------------------
- // ● alias function: clear
- //----------------------------------------------------------------------------
- var emoji_clear = Game_Interpreter.prototype.clear;
- Game_Interpreter.prototype.clear = function() {
- emoji_clear.call(this);
- this._shop_ai_id = 0;
- this._enable_haggle = false;
- };
- //----------------------------------------------------------------------------
- // ○ new function: setup_shop_ai
- //----------------------------------------------------------------------------
- Game_Interpreter.prototype.setup_shop_ai = function(a,b){
- this._shop_ai_id = a;
- this._enable_haggle = b;
- };
- //----------------------------------------------------------------------------
- // ○ new function: scene_ai
- //----------------------------------------------------------------------------
- Game_Interpreter.prototype.scene_ai = function(scene_s,ai_type) {
- SceneManager.push(scene_s);
- SceneManager.prepareNextScene(ai_type);
- };
- //----------------------------------------------------------------------------
- // ● overwrite function: command_302 { desactivate }
- //----------------------------------------------------------------------------
- Game_Interpreter.prototype.command302 = function() {
- if (!$gameParty.inBattle()) {
- var goods = [this._params];
- while (this.nextEventCode() === 605) {
- this._index++;
- goods.push(this.currentCommand().parameters)
- }
- SceneManager.push(Scene_Shop);
- SceneManager.prepareNextScene(goods, this._params[4], this._shop_ai_id,this._enable_haggle)
- }
- return true
- };
- //===============================================================================
- // => END : Game_interpreter
- //===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement