The PokéCommunity Forums Fan Games Game Development Pokémon Essentials
Scripting Question Adding to Pokemon Essentials from another Toolkit?

Pokémon Essentials All questions and discussion about Pokémon Essentials, the Pokémon game kit for RPG Maker XP, go in here. Also contains links to the latest downloads and the Essentials Wiki.

Reply
 
Thread Tools
  #1    
Old September 26th, 2018 (1:06 AM). Edited September 26th, 2018 by SpartaLazor.
CallMeClueless CallMeClueless is offline
     
    Join Date: Sep 2018
    Posts: 8
    Sorry if this is a silly question, I'm still really new to all this and don't really understand the language ruby yet, so I was wondering if it's possible to implement features from another toolkit into Pokemon Essentials?

    I want to add a relationship system from a Harvest Moon Toolkit I found, but just straight up copying it only returns an error when I try to use it in game. I'd ask the creator of the toolkit if this is possible, but from what I can tell they're not around anymore. If anyone could help me I'd be very grateful!

    This is the code from the HM Toolkit I want to use, this first one is under Object Classes above Main:

    Code:
    class Villager
      
      attr_reader   :id
      attr_reader   :name
      attr_reader   :affection
      attr_reader   :age
      attr_accessor :talk_count
      
      def initialize(id)
        @id=id
        @name=Villagers::Names[0][id][0]
        @affection=0
        @age=0#temporary
        @talk_count=0
        @first_encounter=true
        @engaged=false
        @married=false
        @item_given=false
      end
      
      def interact
        begin
          affection_level=get_affection_level
          
          if !$game_player.held_item || Kernel.is_tool?($game_player.held_item)
            #if meeting the villager for the first time
            if @first_encounter
              message=Villagers::Messages[0][@id][0].clone
            else
              #clone target text so nothing mistakenly happens to it
              message=Villagers::Messages[0][@id][affection_level][$world.season][@talk_count].clone
            end
            
            [email protected]
            
            #only displays a heart when speaking to an eligible bachelor/bachelorette
            if $game_player.is_male?
              if Villagers::Bachelorettes.include?(id)
                $game_temp.message_heart=affection_level
              end
            else
              if Villagers::Bachelors.include?(id)
                $game_temp.message_heart=affection_level
              end
            end
            
            Kernel.show_text(message)
              
            #if player just met this NPC, set first encounter flag to false
            if @first_encounter
              @first_encounter=false
              @affection+=Villagers::Affection_Rates[0][@id]
            #count up # of times player talked to this NPC
            else
              #only gain affection from talking once
              if @talk_count < 1
                #if current affection is less than maximum affection for this villager
                if @affection < Villagers::Affection_Levels[0][@id].last.last
                  @affection += Villagers::Affection_Rates[0][@id]
                end
              end
    
              if @talk_count < Villagers::Messages[0][@id][affection_level][$world.season].length - 1
                @talk_count+=1
              end
            end
          else
            give($game_player.held_item.id)
          end
        rescue
          Kernel.show_text("Message data missing.\nAdd some to Villagers::Messages.")
        end
      end
      
      def get_affection_level
        Villagers::Affection_Levels[0][@id].each do |level|
          if @affection.between?(level.first, level.last)
            return Villagers::Affection_Levels[0][@id].index(level) + 1
          end
        end
      end
      
      def give(item_id)
        preference=-1
        for i in 0...Villagers::Preferences[0][@id].length
          for k in 0...Villagers::Preferences[0][@id][i].length
            if Villagers::Preferences[0][@id][i][k]==item_id
              preference=i
              break
            end
          end
        end
        
        if [email protected]_given
          case preference
          when 0
            @affection-=5
          when 1
            @affection-=2
          when 2
            @affection+=2
          when 3
            @affection+=5
          end
          @item_given=true
        end
        
        #enforce value range of affection (prevents text bug)
        if @affection<0
          @affection=0
        elsif @affection > Villagers::Affection_Levels[0][@id].last.last
          @affection=Villagers::Affection_Levels[0][@id].last.last
        end
        
        $game_player.held_item=nil
        [email protected]#change this based on reaction
        Kernel.show_text(Villagers::Reactions[0][@id][preference+1].clone)
        $game_player.restore_graphic
        $game_player.update_held_item
      end
    
      def propose
        
      end
      
      def reset
        @talk_count=0
        @item_given=false
      end
      
      #note: might make villager age
      #def mature
      #     #might use this to simulate aging of the villagers as time goes by.
      #end
    end
    And this next one is in Data Modules above Main:

    Code:
    module Villagers
      
      Names=
      [
        0 => ["Ann"],
        1 => ["Ellen"],
        2 => ["Eve"],
        3 => ["Maria"],
        4 => ["Nina"],
        5 => ["Mayor"]
      ]
      
      #Ids of female marriage candidates (must match up with Names array above)
      Bachelorettes=[0, 1, 2, 3, 4]
      
      #Ids of male marriage candidates
      Bachelors=[]
      
      #specifies the affection points for each affection level per villager
      #for bachelors/bachelorettes, this corresponds to hearts.
      Affection_Levels=
      [
        0 => [0..51, 52..103, 104..155, 156..207, 208..255],
        1 => [0..51, 52..103, 104..155, 156..207, 208..255],
        2 => [0..51, 52..103, 104..155, 156..207, 208..255],
        3 => [0..51, 52..103, 104..155, 156..207, 208..255],
        4 => [0..51, 52..103, 104..155, 156..207, 208..255],
        5 => [0..51, 52..103, 104..155, 156..207, 208..255]
      ]
      
      #specifies how much affection a villager gains when you interact with them.
      #bachelors/bachelorettes are typically slower to gain affection. This provides
      #enough flexibility to give any and every villager a different rate if desired.
      #This can make some bachelors/bachelorettes "easier" or "harder."
      Affection_Rates=
      [
        0 => 1,
        1 => 1,
        2 => 1,
        3 => 1,
        4 => 1,
        5 => 3
      ]
      
      #messages should be cycled through until the last one is reached. when
        #reached, display the corresponding ending only
        
      Messages=
      [
        #villager 0
        0 => [
                "First acquaintance message",
                [
                  [
                    "lvl 1 affection message spring",
                    "lvl 1 affection message 2 spring",
                    "lvl 1 affection ending spring"
                  ],
              
                  [
                    "lvl 1 affection message summer",
                    "lvl 1 affection message 2 summer",
                    "lvl 1 affection ending summer"
                  ],
               
                  [
                    "lvl 1 affection message fall",
                    "lvl 1 affection message 2 fall",
                    "lvl 1 affection ending fall"
                  ],
               
                  [
                    "lvl 1 affection message winter",
                    "lvl 1 affection message 2 winter",
                    "lvl 1 affection ending winter"
                  ]
                ],
              
                [
                  [
                    "lvl 2 affection message spring",
                    "lvl 2 affection message 2 spring",
                    "lvl 2 affection ending spring"
                  ],
                  
                  [
                    "lvl 2 affection message summer",
                    "lvl 2 affection message 2 summer",
                    "lvl 2 affection ending summer"
                  ]
                ]
    
             ],
        #villager 1
        1 => [
                "First acquaintance message",
                [
                  [
                    "lvl 1 affection message spring",
                    "lvl 1 affection message 2 spring",
                    "lvl 1 affection ending spring"
                  ],
              
                  [
                    "lvl 1 affection message summer",
                    "lvl 1 affection message 2 summer",
                    "lvl 1 affection ending summer"
                  ],
               
                  [
                    "lvl 1 affection message fall",
                    "lvl 1 affection message 2 fall",
                    "lvl 1 affection ending fall"
                  ],
               
                  [
                    "lvl 1 affection message winter",
                    "lvl 1 affection message 2 winter",
                    "lvl 1 affection ending winter"
                  ]
                ],
              
                [
                  [
                    "lvl 2 affection message spring",
                    "lvl 2 affection message 2 spring",
                    "lvl 2 affection ending spring"
                  ],
                  
                  [
                    "lvl 2 affection message summer",
                    "lvl 2 affection message 2 summer",
                    "lvl 2 affection ending summer"
                  ]
                ]
    
             ],
      ]
        
      Reactions=
      [
        0 => [
        
               "neutral",
               "hates item",
               "dislikes item",
               "likes item",
               "loves item"
                         
             ],
      
        1 => [
        
               "neutral",
               "hates item",
               "dislikes item",
               "likes item",
               "loves item"
              
             ]
      ]
      
      Preferences=
      [
        #entries match the entres in Reactions. stores arrays of item ids in this
        #order: hated items, disliked items, liked items, loved items
        0 => [
               [1],
               [],
               [0],
               []
             
             ],
        
        1 => [
        
               [],
               [0],
               [],
               [1]
               
             ]
      ]
      
    end
    Reply With Quote
      #2    
    Old September 26th, 2018 (7:08 PM).
    SpartaLazor's Avatar
    SpartaLazor SpartaLazor is offline
    A238
       
      Join Date: Sep 2015
      Gender: Male
      Posts: 182
      Well, it's not completely impossible to add these scripts in. The main issue is that Essentials has a ton of its own code in there, and code designed for something else can't just be dropped in there and expected to work perfectly.

      You would probably need to do a ton of work on the script to get it working, but honestly it might just be easier to make it or something similar from the ground up at this point.
      __________________
      "The past can hold us back and yet still drive us forward."
      Reply With Quote
        #3    
      Old September 26th, 2018 (7:24 PM).
      CallMeClueless CallMeClueless is offline
         
        Join Date: Sep 2018
        Posts: 8
        I thought that might be the case, oh well, back to the drawing board. Thank you for taking the time to answer my question!
        Reply With Quote
        Reply

        Quick Reply

        Join the conversation!

        Create an account to post a reply in this thread, participate in other discussions, and more!

        Create a PokéCommunity Account
        Thread Tools

        Posting Rules
        You may not post new threads
        You may not post replies
        You may not post attachments
        You may not edit your posts

        BB code is On
        Smilies are On
        [IMG] code is On
        HTML code is Off

        Forum Jump


        All times are GMT -8. The time now is 10:10 AM.