• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Making a Hunger System by Script.

  • 2
    Posts
    3
    Years
    Hello this is my frist post and my first script and i'm very new in programing, also i'm not a native english speaker, so take that in consideration.

    This script is for pokemon essentials 19.1

    So what this script do? Makes a new status condition called "hunger" actived by a switch and controlled by a counter, one counter by pokemon in trainer party, this counter adds a x number per step and by the first time your pokemon attack in a battle if the pokemon is not fainted or is an egg, when the counter reach an x condition can give buff / debuff, disobey or do damage to the hp of a pokemon by step / turn depending on the x condition. The only way to lower a counter is eating berrys (but you can add more thing if you want).

    i will update this script with error corrections and optimizations, stay alert.

    Creating a new status.
    in Status:
    Code:
    GameData::Status.register({
      :id        => :FROZEN,
      :id_number => 5,
      :name      => _INTL("Frozen"),
      :animation => "Frozen"
    })
    
    [COLOR="Red"]GameData::Status.register({
      :id        => :HUNGER,
      :id_number => 6,
      :name      => _INTL("Hunger"),
      :animation => "Hunger"
    })[/COLOR]

    in Battler_Statuses:
    Code:
    when :FROZEN
            @battle.pbDisplay(_INTL("{1} was frozen solid!", pbThis))
         [COLOR="Red"] when :HUNGER
            @battle.pbDisplay(_INTL("{1} is hungry!", pbThis))
          end
        end[/COLOR]
    
      def pbFreeze(msg = nil)
        pbInflictStatus(:FROZEN, 0, msg)
      end
      
    [COLOR="Red"]  #=============================================================================
      # Hunger
      #=============================================================================
      def hunger?
        return pbHasStatus?(:HUNGER)
      end
    
      def pbHungry(msg = nil)
        pbInflictStatus(:HUNGER, 0, msg)
      end[/COLOR]
    
        when :FROZEN
          @battle.pbDisplay(_INTL("{1} is frozen solid!", pbThis))
        [COLOR="Red"]when :HUNGER
          @battle.pbDisplay(_INTL("{1} has hunger!", pbThis))
        end[/COLOR]
        PBDebug.log("[Status continues] #{pbThis}'s sleep count is #{@statusCount}") if self.status == :SLEEP
      end

    The status effects at the end of a turn.
    in Battle_Phase_EndOfRound:
    Code:
    # Damage from burn
        priority.each do |b|
          next if b.status != :BURN || !b.takesIndirectDamage?
          oldHP = b.hp
          dmg = (Settings::MECHANICS_GENERATION >= 7) ? b.totalhp/16 : b.totalhp/8
          dmg = (dmg/2.0).round if b.hasActiveAbility?(:HEATPROOF)
          b.pbContinueStatus { b.pbReduceHP(dmg,false) }
          b.pbItemHPHealCheck
          b.pbAbilitiesOnDamageTaken(oldHP)
          b.pbFaint if b.fainted?
        end
       [COLOR="Red"] # Damage from hunger
        priority.each do |b|
          next if b.fainted?
          next if b.status!= :HUNGER
          oldHP = b.hp
          dmg = b.totalhp/12
          b.pbContinueStatus { b.pbReduceHP(dmg,false) }
          b.pbItemHPHealCheck
          b.pbAbilitiesOnDamageTaken(oldHP)
          b.pbFaint if b.fainted?
        end[/COLOR]

    The status graphics.
    in PokeBattle_SceneElements:
    Code:
     # Draw status icon
        if @battler.status != :NONE
          [COLOR="Red"]if @battler.status == :HUNGER
            s = GameData::Status.get(@battler.status).id_number+1
          elsif @battler.status != :HUNGER
            s = GameData::Status.get(@battler.status).id_number
          end[/COLOR]
    Making a Hunger System by Script.Making a Hunger System by Script.

    Now for making the step counter, this part is large stay ready.
    Spoiler:

    Now for charge and discharge a pokemon in the pokemon storage.
    in UI_PokemonStorage:
    Spoiler:

    Now to set the food.
    in Item_Utilities:
    Spoiler:

    in BattleHandlers at the bottom:
    Spoiler:

    in BattleHandlers_Items:
    Spoiler:

    To charge a pokemon given by commands.
    in Utilities_Pokemon:
    Spoiler:


    To charge a pokemon by daycare.
    in Overworld_DayCare:
    Spoiler:

    For the hunger effects in battle, disobey/buff/debuff and add 1 to the first time that a pokemon is used in combat.
    in Battler_UseMove_SuccessChecks:
    Spoiler:

    For the $flags.
    in Battle_StartAndEnd:
    Spoiler:


    That is all, in the future maybe i will try integrate this with the Following Pokemon EX/Elite Battle: DX script for now it's just a prototype that i've tested and works for me but please remember i'm very new in this so can be error or things that i forgot to add, so if you want optimize this script or add more things, do it you are doing me a great favor.
    ONE MORE THING: there's a bug in the Events.onStepTakenTransferPossible were if you are walking and press esc at the same time sometimes the StepTaken will loop in the esc menu until you press esc again. This is a bug of pokemon essentials 19.1 not of my script, i partially fix it.
     
    Last edited:

    Cpt.Lavendar

    Aliases: Cap, Lav, Bleeps
  • 3
    Posts
    2
    Years
    • Seen Nov 13, 2023
    I'm trying really hard to implement this into Pokemon Essentials v21 but I am not a programmer and I just can't seem to get it to work. Have you built off this since posting? I'd love to use this mechanic.
     
    Back
    Top