- 2
- Posts
- 4
- Years
- Buenos Aires, Argentina
- Seen Sep 17, 2023
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:
in Battler_Statuses:
The status effects at the end of a turn.
in Battle_Phase_EndOfRound:
The status graphics.
in PokeBattle_SceneElements:
![[PokeCommunity.com] Making a Hunger System by Script. [PokeCommunity.com] Making a Hunger System by Script.](https://data.pokecommunity.com/attachments/15/15731-6658abd0105ceae0d06b86946e8e97f9.jpg)
![[PokeCommunity.com] Making a Hunger System by Script. [PokeCommunity.com] Making a Hunger System by Script.](https://data.pokecommunity.com/attachments/15/15732-4d426131cf93a1e23a57ae2d662b04a8.jpg)
Now for making the step counter, this part is large stay ready.
Now for charge and discharge a pokemon in the pokemon storage.
in UI_PokemonStorage:
Now to set the food.
in Item_Utilities:
in Item_Effects:
in Item_BattleEffects:
in BattleHandlers at the bottom:
in BattleHandlers_Items:
To charge a wild pokemon.
in PokeBattle_BattleCommon:
To charge a pokemon given by commands.
in Utilities_Pokemon:
In def pbGenerateEgg(pkmn, text = "")
# Add egg to party
$Trainer.party[$Trainer.party.length] = pkmn
if $game_switches[59]==true
pbHungerGiveStore(pkmn)
end
[/CODE]
To charge a pokemon by daycare.
in Overworld_DayCare:
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:
For the $flags.
in Battle_StartAndEnd:
In def pbEndOfBattle
$f1=0
$f2=0
$f3=0
$f4=0
$f5=0
$f6=0
oldDecision = @decision
@decision = 4 if @decision==1 && wildBattle? && @caughtPokemon.length>0
case oldDecision[/CODE]
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.
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]
![[PokeCommunity.com] Making a Hunger System by Script. [PokeCommunity.com] Making a Hunger System by Script.](https://data.pokecommunity.com/attachments/15/15731-6658abd0105ceae0d06b86946e8e97f9.jpg)
![[PokeCommunity.com] Making a Hunger System by Script. [PokeCommunity.com] Making a Hunger System by Script.](https://data.pokecommunity.com/attachments/15/15732-4d426131cf93a1e23a57ae2d662b04a8.jpg)
Now for making the step counter, this part is large stay ready.
Spoiler:
in Overworld:
Code:
def pbCheckAllFainted
if $Trainer.able_pokemon_count == 0
pbMessage(_INTL("You have no more Pokémon that can fight!\1"))
pbMessage(_INTL("You blacked out!"))
pbBGMFade(1.0)
pbBGSFade(1.0)
pbFadeOutIn { pbStartOver }
end
end
[COLOR="Red"]# Checks per step hunger increase
def pbHunger(i,idp)
if $pkmid1==idp && $f !=1 [COLOR="Green"]# If the id1==first pokemon in the party [/COLOR]
$f=1
if !i.egg? || !i.fainted?
$game_variables[26]+=1 [COLOR="Green"]# Add x number to counter[/COLOR]
end
$game_variables[32]=$game_variables[26]
elsif $pkmid2==idp && $f !=1
$f=1
if !i.egg? || !i.fainted?
$game_variables[27]+=1
end
$game_variables[32]=$game_variables[27]
elsif $pkmid3==idp && $f !=1
$f=1
if !i.egg? || !i.fainted?
$game_variables[28]+=1
end
$game_variables[32]=$game_variables[28]
elsif $pkmid4==idp && $f !=1
$f=1
if !i.egg? || !i.fainted?
$game_variables[29]+=1
end
$game_variables[32]=$game_variables[29]
elsif $pkmid5==idp && $f !=1
$f=1
if !i.egg? || !i.fainted?
$game_variables[30]+=1
end
$game_variables[32]=$game_variables[30]
elsif $pkmid6==idp && $f !=1
$f=1
if !i.egg? || !i.fainted?
$game_variables[31]+=1
end
$game_variables[32]=$game_variables[31]
end
end
u=0
idp=0
ide=0
$pkmid1=0
$pkmid2=0
$pkmid3=0
$pkmid4=0
$pkmid5=0
$pkmid6=0
Events.onStepTakenTransferPossible += proc { |_sender,e|
if $game_switches[59]==true [COLOR="Green"]# The activation switch[/COLOR]
handled = e[0]
next if handled[0]
next if $Trainer.able_pokemon_count==0
next if $game_temp.in_menu== true
if u!=1 # frist pokemon charge
firstPkmn= $Trainer.first_party
next if firstPkmn.egg? || firstPkmn.fainted?
idp=firstPkmn.personalID
r=0
i=0
$f=0
for i in $Trainer.party[0..5] [COLOR="Green"]# The six pokemon in party [/COLOR]
r +=1
case r
when 1
[COLOR="Yellow"]if $pkmid1==0 [COLOR="Green"]# This part is to charge a pokemon by the debug option [/COLOR]
$pkmid1=i.personalID
if $pkmid1==$pkmid2 || $pkmid1==$pkmid3 || $pkmid1==$pkmid4 || $pkmid1==$pkmid5 || $pkmid1==$pkmid6
$pkmid1=0
end
end[/COLOR]
pbHunger(i,idp)
when 2
if $pkmid2==0
$pkmid2=i.personalID
if $pkmid2==$pkmid1 || $pkmid2==$pkmid3 || $pkmid2==$pkmid4 || $pkmid2==$pkmid5 || $pkmid2==$pkmid6
$pkmid2=0
end
end
pbHunger(i,idp)
when 3
if $pkmid3==0
$pkmid3=i.personalID
if $pkmid3==$pkmid1 || $pkmid3==$pkmid2 || $pkmid3==$pkmid4 || $pkmid3==$pkmid5 || $pkmid3==$pkmid6
$pkmid3=0
end
end
pbHunger(i,idp)
when 4
if $pkmid4==0
$pkmid4=i.personalID
if $pkmid4==$pkmid1 || $pkmid4==$pkmid2 || $pkmid4==$pkmid3 || $pkmid4==$pkmid5 || $pkmid4==$pkmid6
$pkmid4=0
end
end
pbHunger(i,idp)
when 5
if $pkmid5==0
$pkmid5=i.personalID
if $pkmid5==$pkmid1 || $pkmid5==$pkmid2 || $pkmid5==$pkmid3 || $pkmid5==$pkmid4 || $pkmid5==$pkmid6
$pkmid5=0
end
end
pbHunger(i,idp)
when 6
if $pkmid6==0
$pkmid6=i.personalID
if $pkmid6==$pkmid2 || $pkmid6==$pkmid3 || $pkmid6==$pkmid4 || $pkmid6==$pkmid5 || $pkmid6==$pkmid1
$pkmid6=0
end
end
pbHunger(i,idp)
end
end
flashed = false
if $game_variables[32]>=20 [COLOR="Green"]# Check the hunger counter to give hunger to the first pokemon in the party [/COLOR]
firstPkmn.status = :HUNGER
elsif firstPkmn.status == :HUNGER
firstPkmn.status = :NONE
end
if firstPkmn.status == :HUNGER [COLOR="Green"]#If first pokemon has hunger lower hp by step[/COLOR]
firstPkmn.hp -= 1 if firstPkmn.hp>0
if !flashed
$game_screen.start_flash(Color.new(98,255,0,128), 4)
flashed = true
end
end
if firstPkmn.hp==0
firstPkmn.changeHappiness("faint")
firstPkmn.status = :NONE
pbMessage(_INTL("{1} fainted...",firstPkmn.name))
end
if $Trainer.able_pokemon_count == 0
handled[0] = true
pbCheckAllFainted
end
u += 1
elsif u==1 # while pokemon still same
firstPkmn= $Trainer.first_party
next if firstPkmn.egg? || firstPkmn.fainted?
ide=firstPkmn.personalID
if ide==idp
r=0
i=0
$f=0
for i in $Trainer.party[0..5]
r +=1
case r
when 1
pbHunger(i,idp)
when 2
pbHunger(i,idp)
when 3
pbHunger(i,idp)
when 4
pbHunger(i,idp)
when 5
pbHunger(i,idp)
when 6
pbHunger(i,idp)
end
end
flashed = false
if $game_variables[32]>=20
firstPkmn.status = :HUNGER
elsif firstPkmn.status == :HUNGER
firstPkmn.status = :NONE
end
if firstPkmn.status == :HUNGER
firstPkmn.hp -= 1 if firstPkmn.hp>0
if !flashed
$game_screen.start_flash(Color.new(98,255,0,128), 4)
flashed = true
end
end
if firstPkmn.hp==0
firstPkmn.changeHappiness("faint")
firstPkmn.status = :NONE
pbMessage(_INTL("{1} fainted...",firstPkmn.name))
end
if $Trainer.able_pokemon_count == 0
handled[0] = true
pbCheckAllFainted
end
elsif ide != idp #if pokemon is NOT the frist pokemon charged
r=0
i=0
$f=0
for i in $Trainer.party[0..5]
r +=1
case r
when 1
pbHunger(i,ide)
when 2
pbHunger(i,ide)
when 3
pbHunger(i,ide)
when 4
pbHunger(i,ide)
when 5
pbHunger(i,ide)
when 6
pbHunger(i,ide)
end
end
flashed = false
if $game_variables[32]>=20
firstPkmn.status = :HUNGER
elsif firstPkmn.status == :HUNGER
firstPkmn.status = :NONE
end
if firstPkmn.status == :HUNGER
firstPkmn.hp -= 1 if firstPkmn.hp>0
if !flashed
$game_screen.start_flash(Color.new(98,255,0,128), 4)
flashed = true
end
end
if firstPkmn.hp==0
firstPkmn.changeHappiness("faint")
firstPkmn.status = :NONE
pbMessage(_INTL("{1} fainted...",firstPkmn.name))
end
if $Trainer.able_pokemon_count == 0
handled[0] = true
pbCheckAllFainted
end
u=0
end
end
end
}[/COLOR]
Now for charge and discharge a pokemon in the pokemon storage.
in UI_PokemonStorage:
Spoiler:
Code:
[U]Add This[/U]
[COLOR="Red"]def pbHungerChargeDischarge(pkmidp,pkmidp1,pkmidp2,pkmidp3,pkmidp4,pkmidp5,pkmidp6)
if pkmidp!=$pkmid1 && pkmidp!=$pkmid2 && pkmidp!=$pkmid3 && pkmidp!=$pkmid4 && pkmidp!=$pkmid5 && pkmidp!=$pkmid6
if $pkmid1!=pkmidp1 && $pkmid1!=pkmidp2 && $pkmid1!=pkmidp3 && $pkmid1!=pkmidp4 && $pkmid1!=pkmidp5 && $pkmid1!=pkmidp6
if $pkmid1==0
$game_variables[26]=0
$pkmid1=pkmidp
end
elsif $pkmid2!=pkmidp1 && $pkmid2!=pkmidp2 && $pkmid2!=pkmidp3 && $pkmid2!=pkmidp4 && $pkmid2!=pkmidp5 && $pkmid2!=pkmidp6
if $pkmid2==0
$game_variables[27]=0
$pkmid2=pkmidp
end
elsif $pkmid3!=pkmidp1 && $pkmid3!=pkmidp2 && $pkmid3!=pkmidp3 && $pkmid3!=pkmidp4 && $pkmid3!=pkmidp5 && $pkmid3!=pkmidp6
if $pkmid3==0
$game_variables[28]=0
$pkmid3=pkmidp
end
elsif $pkmid4!=pkmidp1 && $pkmid4!=pkmidp2 && $pkmid4!=pkmidp3 && $pkmid4!=pkmidp4 && $pkmid4!=pkmidp5 && $pkmid4!=pkmidp6
if $pkmid4==0
$game_variables[29]=0
$pkmid4=pkmidp
end
elsif $pkmid5!=pkmidp1 && $pkmid5!=pkmidp2 && $pkmid5!=pkmidp3 && $pkmid5!=pkmidp4 && $pkmid5!=pkmidp5 && $pkmid5!=pkmidp6
if $pkmid5==0
$game_variables[30]=0
$pkmid5=pkmidp
end
elsif $pkmid6!=pkmidp1 && $pkmid6!=pkmidp2 && $pkmid6!=pkmidp3 && $pkmid6!=pkmidp4 && $pkmid6!=pkmidp5 && $pkmid6!=pkmidp6
if $pkmid6==0
$game_variables[31]=0
$pkmid6=pkmidp
end
end
end
end[/COLOR]
[U]Up This[/U]
def pbStartScreen(command)
@heldpkmn = nil
if command==0 # Organise
@scene.pbStartBox(self,command)
[U]Add This[/U]
[COLOR="Red"]if $game_switches[59]==true
pkmidp1=1
pkmidp2=1
pkmidp3=1
pkmidp4=1
pkmidp5=1
pkmidp6=1
rx=0
g=0
for g in $Trainer.party[0..5]
rx+=1
case rx
when 1
pkmidp1=$Trainer.party[0].personalID
when 2
pkmidp2=$Trainer.party[1].personalID
when 3
pkmidp3=$Trainer.party[2].personalID
when 4
pkmidp4=$Trainer.party[3].personalID
when 5
pkmidp5=$Trainer.party[4].personalID
when 6
pkmidp6=$Trainer.party[5].personalID
end
end
rx=0
g=0
for g in $Trainer.party[0..5]
rx+=1
case rx
when 1
pbHungerChargeDischarge(pkmidp1,pkmidp1,pkmidp2,pkmidp3,pkmidp4,pkmidp5,pkmidp6)
when 2
pbHungerChargeDischarge(pkmidp2,pkmidp1,pkmidp2,pkmidp3,pkmidp4,pkmidp5,pkmidp6)
when 3
pbHungerChargeDischarge(pkmidp3,pkmidp1,pkmidp2,pkmidp3,pkmidp4,pkmidp5,pkmidp6)
when 4
pbHungerChargeDischarge(pkmidp4,pkmidp1,pkmidp2,pkmidp3,pkmidp4,pkmidp5,pkmidp6)
when 5
pbHungerChargeDischarge(pkmidp5,pkmidp1,pkmidp2,pkmidp3,pkmidp4,pkmidp5,pkmidp6)
when 6
pbHungerChargeDischarge(pkmidp6,pkmidp1,pkmidp2,pkmidp3,pkmidp4,pkmidp5,pkmidp6)
end
end
end[/COLOR]
[U]Up This[/U]
else
pbHold(selected)
end
elsif cmdSummary>=0 && command==cmdSummary # Summary
pbSummary(selected,@heldpkmn)
elsif cmdWithdraw>=0 && command==cmdWithdraw # Store/Withdraw
(selected[0]==-1) ? pbStore(selected,@heldpkmn) : pbWithdraw(selected,@heldpkmn)
[U]Below This[/U]
def pbHeldPokemon
return @heldpkmn
end
[U]Add This[/U]
[COLOR="Red"] def pbBoxHungerChargeDischarge(p)
if $pkmid1==p.personalID
pkmid1=0
$game_variables[26]=0
elsif $pkmid2==p.personalID
$pkmid2=0
$game_variables[27]=0
elsif $pkmid3==p.personalID
$pkmid3=0
$game_variables[28]=0
elsif $pkmid4==p.personalID
$pkmid4=0
$game_variables[29]=0
elsif $pkmid5==p.personalID
$pkmid5=0
$game_variables[30]=0
elsif $pkmid6==p.personalID
$pkmid6=0
$game_variables[31]=0
end
end[/COLOR]
[U]in def pbWithdraw(selected,heldpoke[/U]
if (heldpoke || selected[0]==-1) && Settings::MECHANICS_GENERATION >= 8
p = (heldpoke) ? heldpoke : @storage[-1,index]
p.time_form_set = nil
p.form = 0 if p.isSpecies?(:SHAYMIN) || p.isSpecies?(:HOOPA)
end
[COLOR="Red"]if $game_switches[59]==true
pt = (heldpoke) ? heldpoke : @storage[-1,index]
if $pkmid1==0
$pkmid1=pt.personalID
$game_variables[26]=0
elsif $pkmid2==0
$pkmid2=pt.personalID
$game_variables[27]=0
elsif $pkmid3==0
$pkmid3=pt.personalID
$game_variables[28]=0
elsif $pkmid4==0
$pkmid4=pt.personalID
$game_variables[29]=0
elsif $pkmid5==0
$pkmid5=pt.personalID
$game_variables[30]=0
elsif $pkmid6==0
$pkmid6=pt.personalID
$game_variables[31]=0
end
end[/COLOR]
[U]in def pbStore(selected,heldpoke)[/U]
pbDisplay(_INTL("The Box is full."))
next
end
if heldpoke || selected[0]==-1
p = (heldpoke) ? heldpoke : @storage[-1,index]
p.time_form_set = nil
p.form = 0 if p.isSpecies?(:SHAYMIN)
p.heal
[COLOR="Red"] if $game_switches[59]==true
pbBoxHungerChargeDischarge(p)
end[/COLOR]
[U]in def pbPlace(selected)[/U]
if box!=-1 && @heldpkmn.mail
pbDisplay("Please remove the mail.")
return
end
if box>=0
@heldpkmn.time_form_set = nil
@heldpkmn.form = 0 if @heldpkmn.isSpecies?(:SHAYMIN)
@heldpkmn.heal
[COLOR="Red"]if $game_switches[59]==true
pbBoxHungerChargeDischarge(@heldpkmn)
end[/COLOR]
[U]in def pbSwap(selected)[/U]
if box!=-1 && @heldpkmn.mail
pbDisplay("Please remove the mail.")
return false
end
if box>=0
[COLOR="Red"]if $game_switches[59]==true
pbBoxHungerChargeDischarge(@heldpkmn)
end[/COLOR]
[U]in def pbRelease(selected,heldpoke)[/U])
@scene.pbRelease(selected,heldpoke)
if heldpoke
@heldpkmn = nil
else
@storage.pbDelete(box,index)
end
[COLOR="Red"]if $game_switches[59]==true
pbBoxHungerChargeDischarge(pokemon)
end[/COLOR]
Now to set the food.
in Item_Utilities:
Spoiler:
Code:
[U]in the bottom add this[/U]
[COLOR="Red"]def pbEatOutBattle(pkmn,numer,scene)
if pkmn.personalID==$pkmid1
$game_variables[26]-=numer
$game_variables[32]=$game_variables[26]
if $game_variables[26]<20 && pkmn.status == :HUNGER
pkmn.heal_status
scene.pbRefresh
scene.pbDisplay(_INTL("{1} is not hungry anymore.",pkmn.name))
end
elsif pkmn.personalID==$pkmid2
$game_variables[27]-=numer
$game_variables[32]=$game_variables[27]
if $game_variables[27]<20 && pkmn.status == :HUNGER
pkmn.heal_status
scene.pbRefresh
scene.pbDisplay(_INTL("{1} is not hungry anymore.",pkmn.name))
end
elsif pkmn.personalID==$pkmid3
$game_variables[28]-=numer
$game_variables[32]=$game_variables[28]
if $game_variables[28]<20 && pkmn.status == :HUNGER
pkmn.heal_status
scene.pbRefresh
scene.pbDisplay(_INTL("{1} is not hungry anymore.",pkmn.name))
end
elsif pkmn.personalID==$pkmid4
$game_variables[29]-=numer
$game_variables[32]=$game_variables[29]
if $game_variables[29]<20 && pkmn.status == :HUNGER
pkmn.heal_status
scene.pbRefresh
scene.pbDisplay(_INTL("{1} is not hungry anymore.",pkmn.name))
end
elsif pkmn.personalID==$pkmid5
$game_variables[30]-=numer
$game_variables[32]=$game_variables[30]
if $game_variables[30]<20 && pkmn.status == :HUNGER
pkmn.heal_status
scene.pbRefresh
scene.pbDisplay(_INTL("{1} is not hungry anymore.",pkmn.name))
end
elsif pkmn.personalID==$pkmid6
$game_variables[31]-=numer
$game_variables[32]=$game_variables[31]
if $game_variables[31]<20 && pkmn.status == :HUNGER
pkmn.heal_status
scene.pbRefresh
scene.pbDisplay(_INTL("{1} is not hungry anymore.",pkmn.name))
end
end
end
def pbEatInBattle(pokemon,battler,nume,scene)
if pokemon.personalID==$pkmid1
$game_variables[26]-=nume
if $game_variables[26]<20 && pokemon.status == :HUNGER
pokemon.heal_status
battler.pbCureStatus(false) if battler
name = (battler) ? battler.pbThis : pokemon.name
scene.pbRefresh
scene.pbDisplay(_INTL("{1} is not hungry anymore.",name))
end
elsif pokemon.personalID==$pkmid2
$game_variables[27]-=nume
if $game_variables[27]<20 && pokemon.status == :HUNGER
pokemon.heal_status
battler.pbCureStatus(false) if battler
name = (battler) ? battler.pbThis : pokemon.name
scene.pbRefresh
scene.pbDisplay(_INTL("{1} is not hungry anymore.",name))
end
elsif pokemon.personalID==$pkmid3
$game_variables[28]-=nume
if $game_variables[28]<20 && pokemon.status == :HUNGER
pokemon.heal_status
battler.pbCureStatus(false) if battler
name = (battler) ? battler.pbThis : pokemon.name
scene.pbRefresh
scene.pbDisplay(_INTL("{1} is not hungry anymore.",name))
end
elsif pokemon.personalID==$pkmid4
$game_variables[29]-=nume
if $game_variables[29]<20 && pokemon.status == :HUNGER
pokemon.heal_status
battler.pbCureStatus(false) if battler
name = (battler) ? battler.pbThis : pokemon.name
scene.pbRefresh
scene.pbDisplay(_INTL("{1} is not hungry anymore.",name))
end
elsif pokemon.personalID==$pkmid5
$game_variables[30]-=nume
if $game_variables[30]<20 && pokemon.status == :HUNGER
pokemon.heal_status
battler.pbCureStatus(false) if battler
name = (battler) ? battler.pbThis : pokemon.name
scene.pbRefresh
scene.pbDisplay(_INTL("{1} is not hungry anymore.",name))
end
elsif pokemon.personalID==$pkmid6
$game_variables[31]-=nume
if $game_variables[31]<20 && pokemon.status == :HUNGER
pokemon.heal_status
battler.pbCureStatus(false) if battler
name = (battler) ? battler.pbThis : pokemon.name
scene.pbRefresh
scene.pbDisplay(_INTL("{1} is not hungry anymore.",name))
end
end
end[/COLOR]
in Item_Effects:
Code:
ItemHandlers::UseOnPokemon.add(:SITRUSBERRY,proc { |item,pkmn,scene|
[COLOR="Red"] pbEatOutBattle(pkmn,10,scene)[/COLOR]
next pbHPItem(pkmn,pkmn.totalhp/4,scene)
})
in Item_BattleEffects:
Code:
ItemHandlers::BattleUseOnPokemon.add(:SITRUSBERRY,proc { |item,pokemon,battler,choices,scene|
[COLOR="Red"]pbEatInBattle(pokemon,battler,10,scene)[/COLOR]
pbBattleHPItem(pokemon,battler,pokemon.totalhp/4,scene)
})
in BattleHandlers at the bottom:
Spoiler:
Code:
[COLOR="Red"]def pbHungerEatBattle(numi,itemName,battler,battle,forced)
if $Trainer.able_party[numi].personalID==$pkmid1
$game_variables[26]-=25
$game_variables[32]=$game_variables[26]
if $game_variables[32]<20 && battler.status == :HUNGER
battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbCureStatus(forced)
battle.pbDisplay(_INTL("{1}'s has eaten an {2} is not hungry anymore.",battler.pbThis,itemName)) if !forced
end
elsif $Trainer.able_party[numi].personalID==$pkmid2
$game_variables[27]-=25
$game_variables[32]=$game_variables[27]
if $game_variables[32]<20 && battler.status == :HUNGER
battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbCureStatus(forced)
battle.pbDisplay(_INTL("{1}'s has eaten an {2} is not hungry anymore.",battler.pbThis,itemName)) if !forced
end
elsif $Trainer.able_party[numi].personalID==$pkmid3
$game_variables[28]-=25
$game_variables[32]=$game_variables[28]
if $game_variables[32]<20 && battler.status == :HUNGER
battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbCureStatus(forced)
battle.pbDisplay(_INTL("{1}'s has eaten an {2} is not hungry anymore.",battler.pbThis,itemName)) if !forced
end
elsif $Trainer.able_party[numi].personalID==$pkmid4
$game_variables[29]-=25
$game_variables[32]=$game_variables[29]
if $game_variables[32]<20 && battler.status == :HUNGER
battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbCureStatus(forced)
battle.pbDisplay(_INTL("{1}'s has eaten an {2} is not hungry anymore.",battler.pbThis,itemName)) if !forced
end
elsif $Trainer.able_party[numi].personalID==$pkmid5
$game_variables[30]-=25
$game_variables[32]=$game_variables[30]
if $game_variables[32]<20 && battler.status == :HUNGER
battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbCureStatus(forced)
battle.pbDisplay(_INTL("{1}'s has eaten an {2} is not hungry anymore.",battler.pbThis,itemName)) if !forced
end
elsif $Trainer.able_party[numi].personalID==$pkmid6
$game_variables[31]-=25
$game_variables[32]=$game_variables[31]
if $game_variables[32]<20 && battler.status == :HUNGER
battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbCureStatus(forced)
battle.pbDisplay(_INTL("{1}'s has eaten an {2} is not hungry anymore.",battler.pbThis,itemName)) if !forced
end
end
end[/COLOR]
in BattleHandlers_Items:
Spoiler:
Code:
BattleHandlers::HPHealItem.add(:SITRUSBERRY,
proc { |item,battler,battle,forced|
next false if !battler.canHeal?
next false if !forced && !battler.canConsumePinchBerry?(false)
battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbRecoverHP(battler.totalhp/4)
itemName = GameData::Item.get(item).name
[COLOR="Red"] pbHungerEatBattle(0,itemName,battler,battle,forced)
if $Trainer.able_pokemon_count>1
pbHungerEatBattle(1,itemName,battler,battle,forced)
end
if $Trainer.able_pokemon_count>2
pbHungerEatBattle(2,itemName,battler,battle,forced)
end[/COLOR]
To charge a wild pokemon.
in PokeBattle_BattleCommon:
Code:
[U]in def pbStorePokemon(pkmn)[/U]
if storedBox<0
pbDisplayPaused(_INTL("{1} has been added to your party.",pkmn.name))
[COLOR="Red"]if $game_switches[59]==true # Charge wild Pokémon
if $pkmid1==0
$pkmid1=pkmn.personalID
$game_variables[26]=0
elsif $pkmid2==0
$pkmid2=pkmn.personalID
$game_variables[27]=0
elsif $pkmid3==0
$pkmid3=pkmn.personalID
$game_variables[28]=0
elsif $pkmid4==0
$pkmid4=pkmn.personalID
$game_variables[29]=0
elsif $pkmid5==0
$pkmid5=pkmn.personalID
$game_variables[30]=0
elsif $pkmid6==0
$pkmid6=pkmn.personalID
$game_variables[31]=0
end
end[/COLOR]
To charge a pokemon given by commands.
in Utilities_Pokemon:
Spoiler:
Code:
[COLOR="Red"]def pbHungerGiveStore(pkmn)
if $pkmid1==0
$pkmid1=pkmn.personalID
$game_variables[26]=0
elsif $pkmid2==0
$pkmid2=pkmn.personalID
$game_variables[27]=0
elsif $pkmid3==0
$pkmid3=pkmn.personalID
$game_variables[28]=0
elsif $pkmid4==0
$pkmid4=pkmn.personalID
$game_variables[29]=0
elsif $pkmid5==0
$pkmid5=pkmn.personalID
$game_variables[30]=0
elsif $pkmid6==0
$pkmid6=pkmn.personalID
$game_variables[31]=0
end
end[/COLOR]
[U]Up this[/U])
def pbNicknameAndStore(pkmn)
[U]Inside this[/U])
pbNickname(pkmn)
pbStorePokemon(pkmn)
[COLOR="Red"] if $game_switches[59]==true
pbHungerGiveStore(pkmn)
end[/COLOR]
[U]In def pbAddPokemonSilent(pkmn, level = 1, see_form = true)[/U]
if $Trainer.party_full?
$PokemonStorage.pbStoreCaught(pkmn)
else
$Trainer.party[$Trainer.party.length] = pkmn
[COLOR="Red"] if $game_switches[59]==true
pbHungerGiveStore(pkmn)
end[/COLOR]
[U]In def pbAddToPartySilent(pkmn, level = nil, see_form = true)[/U])
$Trainer.pokedex.set_owned(pkmn.species)
pkmn.record_first_moves
$Trainer.party[$Trainer.party.length] = pkmn
[COLOR="Red"] if $game_switches[59]==true
pbHungerGiveStore(pkmn)
end[/COLOR]
In def pbGenerateEgg(pkmn, text = "")
# Add egg to party
$Trainer.party[$Trainer.party.length] = pkmn
if $game_switches[59]==true
pbHungerGiveStore(pkmn)
end
[/CODE]
To charge a pokemon by daycare.
in Overworld_DayCare:
Spoiler:
Code:
[U]In def pbDayCareDeposit(index)[/U]
$PokemonGlobal.daycareEgg = 0
$PokemonGlobal.daycareEggSteps = 0
[COLOR="Red"] pkmi1=$PokemonGlobal.daycare[0][0]
pkmi2=$PokemonGlobal.daycare[1][0]
if $game_switches[59]==true
if i==0
if $pkmid1==pkmi1.personalID # Hunger discharge in the Day Care.
$pkmid1=0
$pkmmi1=pkmi1.personalID
$game_variables[26]=0
elsif $pkmid2==pkmi1.personalID
$pkmid2=0
$pkmmi1=pkmi1.personalID
$game_variables[27]=0
elsif $pkmid3==pkmi1.personalID
$pkmid3=0
$pkmmi1=pkmi1.personalID
$game_variables[28]=0
elsif $pkmid4==pkmi1.personalID
$pkmid4=0
$pkmmi1=pkmi1.personalID
$game_variables[29]=0
elsif $pkmid5==pkmi1.personalID
$pkmid5=0
$pkmmi1=pkmi1.personalID
$game_variables[30]=0
elsif $pkmid6==pkmi1.personalID
$pkmid6=0
$pkmmi1=pkmi1.personalID
$game_variables[31]=0
end
end
if i==1
if $pkmid1==pkmi2.personalID
$pkmid1=0
$pkmmi2=pkmi2.personalID
$game_variables[26]=0
elsif $pkmid2==pkmi2.personalID
$pkmid2=0
$pkmmi2=pkmi2.personalID
$game_variables[27]=0
elsif $pkmid3==pkmi2.personalID
$pkmid3=0
$pkmmi2=pkmi2.personalID
$game_variables[28]=0
elsif $pkmid4==pkmi2.personalID
$pkmid4=0
$pkmmi2=pkmi2.personalID
$game_variables[29]=0
elsif $pkmid5==pkmi2.personalID
$pkmid5=0
$pkmmi2=pkmi2.personalID
$game_variables[30]=0
elsif $pkmid6==pkmi2.personalID
$pkmid6=0
$pkmmi2=pkmi2.personalID
$game_variables[31]=0
end
end
end[/COLOR]
[U]In def pbDayCareWithdraw(index)[/U]
$PokemonGlobal.daycare[index][1] = 0
$PokemonGlobal.daycareEgg = 0
[COLOR="Red"]if $game_switches[59]==true # Hunger Charge Withdraw in the Day Care.
if $pkmid1==0
$pkmid1=$pkmmi1
elsif $pkmid2==0
$pkmid2=$pkmmi1
elsif $pkmid3==0
$pkmid3=$pkmmi1
elsif $pkmid4==0
$pkmid4=$pkmmi1
elsif $pkmid5==0
$pkmid5=$pkmmi1
elsif $pkmid6==0
$pkmid6=$pkmmi1
end
if $pkmid1==0
$pkmid1=$pkmmi2
elsif $pkmid2==0
$pkmid2=$pkmmi2
elsif $pkmid3==0
$pkmid3=$pkmmi2
elsif $pkmid4==0
$pkmid4=$pkmmi2
elsif $pkmid5==0
$pkmid5=$pkmmi2
elsif $pkmid6==0
$pkmid6=$pkmmi2
end
end
end[/COLOR]
[U]In def pbDayCareGenerateEgg[/U]
# Add egg to party
$Trainer.party[$Trainer.party.length] = egg
[COLOR="Red"]if $game_switches[59]==true
if $pkmid1==0
$pkmid1=egg.personalID
$game_variables[26]=0
elsif $pkmid2==0
$pkmid2=egg.personalID
$game_variables[27]=0
elsif $pkmid3==0
$pkmid3=egg.personalID
$game_variables[28]=0
elsif $pkmid4==0
$pkmid4=egg.personalID
$game_variables[29]=0
elsif $pkmid5==0
$pkmid5=egg.personalID
$game_variables[30]=0
elsif $pkmid6==0
$pkmid6=egg.personalID
$game_variables[31]=0
end
end[/COLOR]
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:
Code:
[U]Add this[/U]
[COLOR="Red"]def pbInCombatHungerEffects(badgeLevel)
if @pokemon.status!= :HUNGER && $game_variables[32]>19 && @status != :SLEEP
@pokemon.status = :HUNGER
pbHungry(_INTL("{1} is hungry!",pbThis))
a = ((@level+badgeLevel)*@battle.pbRandom(256)/256).floor
disobedient |= (a>=badgeLevel)
self.stages[:ATTACK] = -1.9 #heavy debuff
self.stages[:SPECIAL_ATTACK] = -1.9
elsif @pokemon.status== :HUNGER && $game_variables[32]>19
a = ((@level+badgeLevel)*@battle.pbRandom(256)/256).floor
disobedient |= (a>=badgeLevel)
self.stages[:ATTACK] = -1.9
self.stages[:SPECIAL_ATTACK] = -1.9
elsif $game_variables[32]<5
self.stages[:ATTACK] = 1.3 #light buff
self.stages[:SPECIAL_ATTACK] = 1.3
elsif $game_variables[32]>14
self.stages[:ATTACK] = -1.3 #light debuff
self.stages[:SPECIAL_ATTACK] = -1.3
end
end[/COLOR]
[U]Up this[/U]
#=============================================================================
# Obedience check
#=============================================================================
# Return true if Pokémon continues attacking (although it may have chosen to
# use a different move in disobedience), or false if attack stops.
[U]In def pbObedienceCheck?(choice)[/U]
if @pokemon.foreign?(@battle.pbPlayer) && @level>badgeLevel [COLOR="Red"]|| $game_variables[32]>19 && @pokemon.status== :HUNGER[/COLOR]
a = ((@level+badgeLevel)*@battle.pbRandom(256)/256).floor
disobedient |= (a>=badgeLevel)
[COLOR="Red"] if $game_switches[59]==true
if @pokemon.personalID==$pkmid1
if $f1==0 #add 1 to the first time that the pokemon is used
$game_variables[26]+=1
$f1=1
end
$game_variables[32]=$game_variables[26]
self.stages[:ATTACK] = -1.9
self.stages[:SPECIAL_ATTACK] = -1.9
elsif @pokemon.personalID==$pkmid2
if $f2==0
$game_variables[27]+=1
$f2=1
end
$game_variables[32]=$game_variables[27]
self.stages[:ATTACK] = -1.9
self.stages[:SPECIAL_ATTACK] = -1.9
elsif @pokemon.personalID==$pkmid3
if $f3==0
$game_variables[28]+=1
$f3=1
end
$game_variables[32]=$game_variables[28]
self.stages[:ATTACK] = -1.9
self.stages[:SPECIAL_ATTACK] = -1.9
elsif @pokemon.personalID==$pkmid4
if $f4==0
$game_variables[29]+=1
$f4=1
end
$game_variables[32]=$game_variables[29]
self.stages[:ATTACK] = -1.9
self.stages[:SPECIAL_ATTACK] = -1.9
elsif @pokemon.personalID==$pkmid5
if $f5==0
$game_variables[30]+=1
$f5=1
end
$game_variables[32]=$game_variables[30]
self.stages[:ATTACK] = -1.9
self.stages[:SPECIAL_ATTACK] = -1.9
elsif @pokemon.personalID==$pkmid6
if $f6==0
$game_variables[31]+=1
$f6=1
end
$game_variables[32]=$game_variables[31]
self.stages[:ATTACK] = -1.9
self.stages[:SPECIAL_ATTACK] = -1.9
end
end[/COLOR]
[COLOR="Red"]else
if @pokemon.personalID==$pkmid1
if $f1==0
$game_variables[26]+=1
$f1=1
end
$game_variables[32]=$game_variables[26]
pbInCombatHungerEffects(badgeLevel)
elsif @pokemon.personalID==$pkmid2
if $f2==0
$game_variables[27]+=1
$f2=1
end
$game_variables[32]=$game_variables[27]
pbInCombatHungerEffects(badgeLevel)
elsif @pokemon.personalID==$pkmid3
if $f3==0
$game_variables[28]+=1
$f3=1
end
$game_variables[32]=$game_variables[28]
pbInCombatHungerEffects(badgeLevel)
elsif @pokemon.personalID==$pkmid4
if $f4==0
$game_variables[29]+=1
$f4=1
end
$game_variables[32]=$game_variables[29]
pbInCombatHungerEffects(badgeLevel)
elsif @pokemon.personalID==$pkmid5
if $f5==0
$game_variables[30]+=1
$f5=1
end
$game_variables[32]=$game_variables[30]
pbInCombatHungerEffects(badgeLevel)
elsif @pokemon.personalID==$pkmid6
if $f6==0
$game_variables[31]+=1
$f6=1
end
$game_variables[32]=$game_variables[31]
pbInCombatHungerEffects(badgeLevel)
end
end[/COLOR]
For the $flags.
in Battle_StartAndEnd:
Spoiler:
Code:
[U]In def pbStartBattle[/U]
[COLOR="Red"]$f1=0
$f2=0
$f3=0
$f4=0
$f5=0
$f6=0[/COLOR]
PBDebug.log("")
PBDebug.log("******************************************")
In def pbEndOfBattle
$f1=0
$f2=0
$f3=0
$f4=0
$f5=0
$f6=0
oldDecision = @decision
@decision = 4 if @decision==1 && wildBattle? && @caughtPokemon.length>0
case oldDecision[/CODE]
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: