Thread: [Essentials Script] Pokemon Birthsigns
View Single Post
  #209    
Old October 12th, 2018 (2:52 AM).
Richard PT's Avatar
Richard PT Richard PT is offline
     
    Join Date: Aug 2014
    Location: Portugal
    Gender: Male
    Nature: Calm
    Posts: 123
    Quote:
    Originally Posted by Lucidious89 View Post
    Yes, I think this helped out a lot. By using what you wrote, and looking at other examples in the script, I ended up changing the original code:
    Code:
    def initialize(species,level,player=nil,withMoves=true)
        if species.is_a?(String) || species.is_a?(Symbol)
          species = getID(PBSpecies,species)
        end
        cname = getConstantName(PBSpecies,species) rescue nil
        if !species || species<1 || species>PBSpecies.maxValue || !cname
          raise ArgumentError.new(_INTL("The species number (no. {1} of {2}) is invalid.",species,PBSpecies.maxValue))
          return nil
        end
        @species       = species
        @name          = PBSpecies.getName(@species)
        @personalID    = rand(256)
        @personalID    |= rand(256)<<8
        @personalID    |= rand(256)<<16
        @personalID    |= rand(256)<<24
        @hp            = 1
        @totalhp       = 1
        @ev            = [0,0,0,0,0,0]
        @iv            = []
        for i in 0...6
          @iv[i]       = rand(32)
        end
        @moves         = []
        @status        = 0
        @statusCount   = 0
        @item          = 0
        @mail          = nil
        @fused         = nil
        @ribbons       = []
        @ballused      = 0
        @eggsteps      = 0
        #===========================================================================
        # Newly generated Pokemon have all flags set to neutral
        #===========================================================================
        @zodiacflag    = 0
        @leafflag      = 0
        @celestial     = false
        @blessed       = false
        #===========================================================================
        if player
          @trainerID   = player.id
          @ot          = player.name
          @otgender    = player.gender
          @language    = player.language
        else
          @trainerID   = 0
          @ot          = ""
          @otgender    = 2
        end
        if $game_map
          @obtainMap   = $game_map.map_id
          @obtainText  = nil
          @obtainLevel = level
        else
          @obtainMap   = 0
          @obtainText  = nil
          @obtainLevel = level
        end
        @obtainMode    = 0   # Met
        @obtainMode    = 4 if $game_switches && $game_switches[FATEFUL_ENCOUNTER_SWITCH]
        @hatchedMap    = 0
        @timeReceived  = pbGetTimeNow.to_i
        self.level     = level
        calcStats
        @hp            = @totalhp
        dexdata = pbOpenDexData
        pbDexDataOffset(dexdata,self.fSpecies,19)
        @happiness     = dexdata.fgetb
        dexdata.close
        if withMoves
          self.resetMoves
        else
          for i in 0...4
            @moves[i] = PBMove.new(0)
          end
        end
      end


    into this updated code:
    Code:
    alias birthsign_initialize initialize  
      def initialize(*args)
        birthsign_initialize(*args)
        #===========================================================================
        # Newly generated Pokemon have all flags set to neutral
        #===========================================================================
        @zodiacflag    = 0
        @leafflag      = 0
        @celestial     = false
        @blessed       = false
        #===========================================================================
      end

    Everything seems to work as intended. I tested this out against wild Unown, and I can see the difference. Previously, the way I had the code set up before would only spawn Unown in their default "A" form. But now they properly spawn in randomized forms. Ill update my script in the link with these changes. Perhaps there are other areas of my scripts I can utilize aliasing with to condense the code a bit?
    Did you update the birthsigns with this recent change? In my pokemon essentials v17.2, i had problems with pokemon forms, i already told about that to Maruno, he said that some people had the same error after capturing a pokemon that contain forms. I used a fix from him, but pokemon like unown, don't randomize itself in battles. So, maybe, with your update, i can get the thing "fixed".
    __________________
    Reply With Quote