Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ■ Nio Kasgami Engine Ace "Basic AI Module"
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Dev Script who permit to have interactive basic AI for your scene.
- # Created by Nio Kasgami.
- # Data : 2015/05/31
- # Version : 1.0.0
- #
- #==============================================================================
- #==============================================================================
- # Introduction
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Ce script est un outil de develloppeur pour permettre le develloppement de IA
- # pour les scenes. Cependant, il ne s'agit pas pour les system de combats,
- # mais plutot pour l'aspect interaction du jeux. B.A.M a pour but de simuler
- # une interaction dynamique dans les scene ou le dialogue est de mise. Pour
- # faire plus simple, il permet d'implementer des émotions ainsi que des
- # personalitées a vos vendeur, forgerons, gérant de mission, ect...
- # Les possibilitées sont illimitées et vont selon votre imagination.
- # Cela require quelque petite connaissance en rgss3, mais le module est conçu
- # pour vous permetre de batir vos IA avec des personalitée diversifier sans
- # trop de difficulté.
- # Ce script est fait pour vous simplifier la vie!
- #==============================================================================
- #==============================================================================
- # How to use
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # TO NORMAL USER :
- # "Veuillez prendre note si vous n'avez pas mes add-ons commme
- # NKEA-"Dynamic ShopKeeper" ce script ne vous sert strictement a rien sauf si
- # vous avez intentions d'utiliser le module pour batir votre IA."
- #------------------------------------------------------------------------------
- #------------------------------------------------------------------------------
- # TO SCRIPTER USER:
- # "Merci d'avoir décidé d'utiliser Basic AI Module ou B.A.M pour l'implementer
- # dans votre script!
- #
- # Les première chose qu'il faut s'avoir est que le script ne fonctionnera pas
- # tant que vous ne aurez pas implementer certaine methode dans votre propre
- # script.
- # La methode primordial a implementer au commencement est:
- # -> AI_Base.pre_check_setup
- # Apres avoir implementer cette methode le personnage apparaitra comme il se
- # doit et fera la premiere reaction qui est le "greeting". Cependant, l'IA
- # ne reagira pas tant que vous ne lui aurez pas dicter ou programmer ses actions
- # ne vous inquietez pas il déja la plupart des code implementer pour les
- # reactions il ne vous reste qu'a les activer en appellant cette method
- # -> AI_Base.interaction
- # Cependant, il faut avant tout avant d'executer de la commande de s'assurer
- # que cette commande soit integrer :
- # -> AI_Base.interaction_type = :key
- # Sinon le personnage ne reagira pas
- # Et voici quelque example de ":key" déja conçu dans le systeme:
- # -> AI_Base.interaction_type = :buying_good
- # -> AI_Base.interaction_type = :goodbye
- # B.A.M est conçut pour faire une mise a jour tout de suite apres que vous
- # avez appuyer sur la touche "Entrer" ou attendue 10 frames pour revenir a
- # l'expression "neutral" SAUF! si vous avez l'ad-ons NKEA-"Mood AI" dans votre
- # éditeur de script.
- #------------------------------------------------------------------------------
- # Les "key" que vous voyez ne sont la que pour reference n'hésitez pas a
- # les modifier, les retirer ou en ajouter des supplementaires!Tout le script
- # est structurer pour vous aider a bien modifier le script pour vos besoins!
- #==============================================================================
- #==============================================================================
- #
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- #
- module Nio
- module IA_Setup
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # SYSTEM
- # -----------------------------------------------------------------------------
- # This section serve for configure the basic option of the script
- #==============================================================================
- SYSTEM ={
- :ia_enable => true
- }
- AIV_Default ={
- :vendor_graphics => "",
- :greeting => "",
- :good_bye => "",
- :buy_goods_dialogues => "what you want to buy?",
- :sell_goods_dialogues => "",
- :not_buying_dialogues => "",
- :not_selling_dialogues => "",
- #not yet
- :haggle_goods_dialogues => "",
- :suceed_haggles_dialogues => "",
- :fail_haggles_dialogues => "",
- #not yet implemented
- :good_reputation_greeting => "",
- :bad_reputation_greeting => "",
- :kick_out_shop_dialogues => "",
- :patience => 100
- }
- AI_Personality ||= { } # do not touch!
- AI_Personality[1] ={
- :buy_goods_dialogues => "text"
- }
- NIV ={
- :enter_shop_dialogues => "",
- :buy_goods_dialogues => "",
- :sell_goods_dialogues => "",
- :quit_shops_dialogues => ""
- }
- end
- end
- module AI_Base
- include Nio::IA_Setup
- #==============================================================================
- # ■ AI_Base {Public Instance Variables}
- #------------------------------------------------------------------------------
- # this the section where I handdle all the variables who can be change in games
- # or in script in simple this permit to handle variable who change a lots
- #==============================================================================
- class << self
- #----------------------------------------------------------------------------
- # ♦ Public Instance Variables {System}
- #----------------------------------------------------------------------------
- attr_accessor :AI_enable # AI Activation flag
- #----------------------------------------------------------------------------
- # ♦ Public Instance Variables {Interactive AI::Dialogues}
- #----------------------------------------------------------------------------
- attr_accessor :dialogues # Get text (in row)
- attr_accessor :greeting # Greeting dialogues
- attr_accessor :goodbye # Good bye dialogues
- attr_accessor :buy_goods_dialogues # Buying dialogues
- attr_accessor :sell_goods_dialogues # Selling dialogues
- attr_accessor :not_buying_dialogues # not buying dialogues
- attr_accessor :not_selling_dialogues # not selling dialogues
- #----------------------------------------------------------------------------
- # ♦ Public Instance Variables {Interactive AI::Interaction}
- #----------------------------------------------------------------------------
- attr_accessor :interaction_type # define the type of interaction
- attr_accessor :interaction_emotion_type # define the type of emotion
- #----------------------------------------------------------------------------
- # ♦ Public Instance Variables {Interactive AI::Graphics}
- #----------------------------------------------------------------------------
- attr_accessor :vendor_graphics # For the shopkeeper bust graphics
- attr_accessor :index # for define the file index
- attr_accessor :ai_id
- end
- #===============================================================================
- # => END : AI_Base {Public Instance Variables}
- #===============================================================================
- #==============================================================================
- # ■ AI_Base {Interactive AI::Dialogues}
- #------------------------------------------------------------------------------
- # This Section handle all the Dialogues of the scripts I building them into
- # method for permit to be easily change in game when you not use AI_Personality
- # how to change in game via script call
- # Vendor_IA.method_name = "string"
- #===============================================================================
- # def self.ai_id
- #return @ai_id
- #end
- def self.as_personality?
- ai_id > 0 #and ai_id <= @ai_personality.size
- end
- #----------------------------------------------------------------------------
- # ○ new method: default_AI
- #----------------------------------------------------------------------------
- def self.default_AI
- return AIV_Default
- end
- #----------------------------------------------------------------------------
- # ○ new method: vendor_graphics
- #----------------------------------------------------------------------------
- def self.vendor_graphics
- @vendor_graphics = default_AI[:vendor_graphics]
- end
- #----------------------------------------------------------------------------
- # ○ new method: greeting
- #----------------------------------------------------------------------------
- def self.greeting
- @greeting = default_AI[:greeting_dialogues]
- end
- #----------------------------------------------------------------------------
- # ○ new method: goodbye
- #----------------------------------------------------------------------------
- def self.goodbye
- @goodbye = default_AI[:goodbye_dialogues]
- end
- #----------------------------------------------------------------------------
- # ○ new method: buy_goods_dialogues
- #----------------------------------------------------------------------------
- def self.buy_goods_dialogues
- # if !as_personality?
- # @buy_goods_dialogues = default_AI[:buy_goods_dialogues]
- # else
- @buy_goods_dialogues = AI_Personality[:buy_goods_dialogues]
- # end
- end
- #----------------------------------------------------------------------------
- # ○ new method: sell_goods_dialogues
- #----------------------------------------------------------------------------
- def self.sell_goods_dialogues
- @sell_goods_dialogues = default_AI[:sell_goods_dialogues]
- end
- #----------------------------------------------------------------------------
- # ○ new method: not_buying_dialogues
- #----------------------------------------------------------------------------
- def self.not_buying_dialogues
- @not_buying_dialogues = default_AI[:not_buying_dialogues]
- end
- #----------------------------------------------------------------------------
- # ○ new method: not_selling_dialogues
- #----------------------------------------------------------------------------
- def self.not_selling_dialogues
- @not_selling_dialogues = default_AI[:not_selling_dialogues]
- end
- #===============================================================================
- # => END : AI_Base {Interactive AI::Dialogues}
- #===============================================================================
- #==============================================================================
- # ■ AI_Base {AI::Initialization}
- #------------------------------------------------------------------------------
- # This section handle the initialization, the update and the dispose of the
- # script. it's mostly the important method you call in your own script for make
- # them enable in your system.
- #===============================================================================
- def self.pre_check_setup
- setup
- # ia_active
- update_AI until scene_changing?
- terminate_AI
- end
- def self.scene_changing?
- SceneManager.scene != self
- end
- def self.setup
- @ai_id = ai_id
- @ai_personality = AI_Personality[@ai_id]
- end
- def self.update_AI
- interaction
- interaction_emotion
- refresh_dialogues
- refresh_interaction
- end
- def self.terminate_AI
- end
- def self.ia_is_active?
- SYSTEM[:ia_enable] == true
- end
- #===============================================================================
- # => END : AI_Base {AI::Initialization}
- #===============================================================================
- #==============================================================================
- # ■ AI_Base {Interactive AI::Graphics}
- #------------------------------------------------------------------------------
- def self.create_vendor
- @vendor = Sprite.new
- @vendor.bitmap = Cache.system(@vendor_graphics + @index.to_s)
- end
- def self.initialize_non_interactive_vendor
- @text = []
- @vendor_graphics = ""
- @index = 0
- end
- def self.initialize_non_interactive_vendor
- end
- ###############################################################################
- #temporary header
- ###############################################################################
- #==============================================================================
- # ■ AI_Base {Interactive AI::Interaction}
- #------------------------------------------------------------------------------
- #==============================================================================
- #----------------------------------------------------------------------------
- # ○ new method: interaction_type
- #----------------------------------------------------------------------------
- def self.interaction_type
- return @interaction_type
- end
- #----------------------------------------------------------------------------
- # ○ new method: interaction_emotion_type
- #----------------------------------------------------------------------------
- def self.interaction_emotion_type
- return @interaction_emotion_type
- end
- ###############################################################################
- # EDITABLE_SECTION
- #-----------------------------------------------------------------------------
- def self.interaction
- case interaction_type
- when :buying_shop
- call_buying_reaction
- end
- end
- def self.interaction_emotion
- case interaction_emotion_type
- when :neutral
- @index = 0
- when :irritated
- @index = 1
- when :happy
- @index = 2
- end
- end
- def self.call_buying_reaction
- interaction_emotion_type = :happy
- # call_dialogues(buy_goods_dialogues)
- msgbox_p(buy_goods_dialogues)
- # refresh if Input.trigger?(:C)
- end
- ################################################################################
- #===============================================================================
- # => END : AI_Base {AI::Interaction}
- #===============================================================================
- #==============================================================================
- # ■ AI_Base {Interactive AI::AI_Personality}
- #------------------------------------------------------------------------------
- #===============================================================================
- # => END : AI_Base {Interactive AI::AI_Personality}
- #===============================================================================
- end
- #===============================================================================
- # => END : AI_Base {Interactive AI::Haggle}
- #===============================================================================
- #==============================================================================
- # => END: Module Vendor_AI
- #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement