Jump to content

Patch for Double Battle "Revive" Bug (Update 6/14/19)


Recommended Posts

Explanation in picture: https://imgur.com/a/quS8e0k

Basically, if you use any revive item on the 1st or 2nd party slot in Double Battle, your pokemon will encounter this bug:

-If you revive the first battler (left) or second battler (right), it will lose its sprite and HP bar while also taking damage the same turn you used revive.

 

This bug occurs in almost every fan game that uses Essentials, including Reborn.

Luckily, with the help from @groniack, we have a patch to fixing this problem.

 

Fix Explanation

This patch will make revive work as intended even when all party members have been fainted.

It will also bring the player back to the party screen to send out a revived Pokémon.

If no Pokemon are in the field and a revive is used, it will automatically be sent out.

When revived, abilities such as Intimidate will activate upon entering the battle.

This patch is compatible with any version of Essentials, such as v15, v16 and 17.2.

 

Script Editor Fix

Step 1:

Open the Script Editor.

Find the script section Pokebattle_Battle. In there, use Ctrl+F and search for "# Initialize battle".

Spoiler

#==================
# Initialize battle
#==================

 

Place this one line of code directly under that.

Spoiler

    $revived=0

 

Step 2:

In the same script section of Pokebattle_Battle, use Ctrl+F and search for "def pbRecallAndReplace(index,newpoke,batonpass=false)". ***

Spoiler

def pbRecallAndReplace(index,newpoke,batonpass=false)
    @battlers[index].pbResetForm
    if !@battlers[index].isFainted?
      @scene.pbRecall(index)
    end
    pbMessagesOnReplace(index,newpoke)
    pbReplace(index,newpoke,batonpass)
    return pbOnActiveOne(@battlers[index])
end

 

 

Place this script directly under that. ***

Spoiler

def pbJustReplace(index,newpoke,batonpass=false)
    @battlers[index].pbResetForm
    pbMessagesOnReplace(index,newpoke)
    pbReplace(index,newpoke,batonpass)
    return pbOnActiveOne(@battlers[index])
end

 

 

Step 3:

Continuing from Pokebattle_Battle, use Ctrl+F and search for "# Lucky Chant".

Spoiler

# Lucky Chant
for i in 0...2
  if sides[i].effects[PBEffects::LuckyChant]>0
    sides[i].effects[PBEffects::LuckyChant]-=1
    if sides[i].effects[PBEffects::LuckyChant]==0
      pbDisplay(_INTL("Your team's Lucky Chant faded!")) if i==0
      pbDisplay(_INTL("The opposing team's Lucky Chant faded!")) if i==1
      PBDebug.log("[End of effect] Lucky Chant ended on the player's side") if i==0
      PBDebug.log("[End of effect] Lucky Chant ended on the opponent's side") if i==1
    end
  end
end

 

 

Place this script directly under that. ***

Spoiler

#Double Battle Fix
if @doublebattle
  if $revived!=0 && !@player.is_a?(Array)
    if @battlers[0].isFainted?
      sendout1=pbFindNextUnfainted(@party1,0)
      if $revived!=@party1[sendout1]
        sendout1=pbFindNextUnfainted(@party1,sendout1+1)
      end
      pbJustReplace(0,sendout1)
      pbOnActiveOne(@battlers[0])
      @battlers[0].pbAbilitiesOnSwitchIn(true)
      $revived=0
    else
      sendout1=pbFindNextUnfainted(@party1,0)  
      if $revived!=@party1[sendout1]
        sendout1=pbFindNextUnfainted(@party1,sendout1+1)
      end
      pbJustReplace(2,sendout1)
      pbOnActiveOne(@battlers[2])
      @battlers[2].pbAbilitiesOnSwitchIn(true)
      $revived=0
    end
  end
end
$revived=0

 

 

Step 4:

Find the script section PItem_ItemEffects. Ctrl+F and search for the revive item that you want to change (Ex. REVIVE, MAXREVIVE and REVIVALHERB).

Take note: Check that item code is attached to "BattleUseOnPokemon.add", not just UseOnPokemon.add.

Example for Revival Herb:

Spoiler

fHWrWOl.png

 

Change the script. If it is not a Revival Herb, delete happiness line of code. You may have to copy and paste the 1/2 HP code for regular Revive.

Example:

Spoiler

ItemHandlers::BattleUseOnPokemon.add(:REVIVALHERB,proc{|item,pokemon,battler,scene|
   if pokemon.hp>0
     scene.pbDisplay(_INTL("It won't have any effect."))
     next false
   else
   if battler
     $revived=pokemon
     $revivedBattler=battler
   end
     pokemon.healStatus
     pokemon.hp=pokemon.totalhp
     pokemon.changeHappiness("Revival Herb")
     scene.pbRefresh
     scene.pbDisplay(_INTL("{1}'s HP was restored.",pokemon.name))
     next true
  end
})

 

 

*** = indicates new/updated script. Ignore if you're patching for the first time.

And there you have it. A patch where a revive works as intended.

No more invisible pokemon. No more invisible HP bars. No more enemies targeting revived pokemon in same turn.

Enjoy!

  • Like 1
Link to comment
Share on other sites

alright so I'm pretty tired and aren't too familiar with ruby but I'll give a shot as to something that might be going on (always good to practice debugging lol)

 

so from what I can tell, the battler's just not being refreshed properly through pbRefresh

Quote

def pbRefresh
    for i in 0...4
      if @sprites["battlebox#{i}"]
        @sprites["battlebox#{i}"].refresh
      end
    end
  end

so in that definition, the code checks to see if there's a sprite so that it doesn't get a null error, but when a Pokemon's fainted its sprite doesn't exist in the battle so the refresh isn't reached, meaning the HP bar or anything is never drawn for it

 

if this is the case (because like I said I'm not too familiar with this so I could be wrong) then it'll probably be an easy fix to add a line into the revive items' functions before pbRefresh to add the sprite back to the @sprites array using pbAddSprite so that it gets properly refreshed

 

regardless, I think your solution's probably fine as long as the player doesn't lose if their last pokemon is knocked out the turn the revive is used, since they'd technically have 0 pokemon before the end of the turn even though another is on its way, but that'd really be the only concern. It also doesn't let players revive a "sacrafice" mon in case they want the opponent to not target their last one, but that part's probably less of an issue.

 

Hope y'all can figure something out soon

 

Link to comment
Share on other sites

26 minutes ago, Endstrom said:

so from what I can tell, the battler's just not being refreshed properly through pbRefresh

so in that definition, the code checks to see if there's a sprite so that it doesn't get a null error, but when a Pokemon's fainted its sprite doesn't exist in the battle so the refresh isn't reached, meaning the HP bar or anything is never drawn for it

 

if this is the case (because like I said I'm not too familiar with this so I could be wrong) then it'll probably be an easy fix to add a line into the revive items' functions before pbRefresh to add the sprite back to the @sprites array using pbAddSprite so that it gets properly refreshed

Ah yes, my friend and I did something similar to fix it by adding "reveal" before pbRefresh.

 

Spoiler

Under def pbFainted(pkmn)

QKa6lko.png

Where reveal is placed

apCbHP0.png

It was buggy for me at my end but the big issue is that the enemy can still damage or even KO revived pokemon in the same turn revive is used.

So we thought of a way on how the enemy can't do damage and that's where we decided to make a script where revive would work at the end of the turn.

Link to comment
Share on other sites

3 hours ago, Endstrom said:

alright so I'm pretty tired and aren't too familiar with ruby but I'll give a shot as to something that might be going on (always good to practice debugging lol)

 

so from what I can tell, the battler's just not being refreshed properly through pbRefresh

so in that definition, the code checks to see if there's a sprite so that it doesn't get a null error, but when a Pokemon's fainted its sprite doesn't exist in the battle so the refresh isn't reached, meaning the HP bar or anything is never drawn for it

 

if this is the case (because like I said I'm not too familiar with this so I could be wrong) then it'll probably be an easy fix to add a line into the revive items' functions before pbRefresh to add the sprite back to the @sprites array using pbAddSprite so that it gets properly refreshed

 

regardless, I think your solution's probably fine as long as the player doesn't lose if their last pokemon is knocked out the turn the revive is used, since they'd technically have 0 pokemon before the end of the turn even though another is on its way, but that'd really be the only concern. It also doesn't let players revive a "sacrafice" mon in case they want the opponent to not target their last one, but that part's probably less of an issue.

 

Hope y'all can figure something out soon

 

 

We wanted to avoid having the battler automatically being in battle after it was revived because it would be a target instantly without being able to use a move at that time. Also, if your other battler faints when you use revive, you won't lose the battle. The health of your pokemon is restored in your party which is what the scripts check to determine the outcome of the battle.

On another note, this script is meant only for the player to use. It doesn't work for your opponents since in the majority of the games out there, the opponents don't use revive. If anyone is interested in changing this so as to be used by the opponents as well, go ahead 🙂

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

I have updated the Original Post. A new Step 2 has been added. There were some bugs that needed to be fixed from last time.

Changes include being able to go to the Party Screen and having abilities work after a revived pokemon is sent out. Enjoy!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...