[Battle Scripting] Down To Last Pokemon Battle Message

Discussion in 'Server and Client Scripting' started by Nightfall Alicorn, Nov 13, 2013.

  1. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    This is a battle script to automatically send a message to your opponent when you are down to your last Pokemon. Just like the Gym Leaders in the games for example.

    You need to have the Script Window plug-in installed before you can use this.
    Code (text):
    1.  
    2. ({
    3. onTierNotification: function(){
    4.     /* SET VARIABLE */
    5.     vPokeNum = 6;
    6.     vBotSymbol = "~ ";
    7.     },
    8.    
    9. onKo: function(spot){
    10.     /* DOWN TO LAST POKEMON MESSAGE */
    11.     if (spot==battle.me){
    12.         vPokeNum--;
    13.         if (vPokeNum==1){
    14.             battle.battleMessage(battle.id, vBotSymbol + "MESSAGE HERE.");
    15.             }
    16.         }
    17.     }
    18. })
    19.  
    Script made, with the help of SongSing's example scripts (Pre-Battle Message) and coyotte508's battle script tutorial (Battle scripting (next update)).
     
    Last edited: Dec 24, 2013
  2. SongSing

    SongSing KILLL

    Joined:
    Jan 2, 2013
    Messages:
    641
    Likes Received:
    191
    PO Trainer Name:
    SongSing
    Hey, glad someone actually looks at those. Nice work! :)
     
  3. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    Thanks. :)

    Even though I had plenty of experience with JavaScript, I actually had quite a difficult time trying to understand the battle script's syntax. But your examples really helped a lot. Hopefully, this will help a lot of players get into battle scripting and understanding how it works better. ^_^
     
  4. Scatterbrain

    Scatterbrain You only live once*

    Joined:
    Jul 5, 2012
    Messages:
    865
    Likes Received:
    4
    Installed the script, works perfect, just has an unwanted ~ preceding the message.

    Is there any way I can do this for 5 Pokemon, 4 Pokemon, etc.? And if using a super effective attack, not very effective attack, OHKOing, and if it does a certain amount of damage?
     
  5. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    I mentioned in the instructions about ~ before the message. Just remove the contents of "~ " but leaving the quotes so they look like this "". This way it won't display ~ before the message. It should look like this now:
    Code (text):
    1.  
    2. vBotSymbol = "";
    3.  
    For having different number of Pokemon left messages. Just add another one of these lines, but change the ==1 part to the number of Pokémon remaining you want it to display for. And of course, giving it another message.
    Code (text):
    1.  
    2.         if (vPokeNum==1){
    3.             battle.battleMessage(battle.id, vBotSymbol + "MESSAGE HERE.");
    4.             }
    5.  
    Here's a completed one:
    Code (text):
    1.  
    2. ({
    3.  onTierNotification: function(){
    4.      /* SET VARIABLE */
    5.      vPokeNum = 6;
    6.      vBotSymbol = "";
    7.      },
    8.    
    9.  onKo: function(spot){
    10.      if (spot==battle.me){
    11.          vPokeNum--;
    12.  
    13.           // 5 POKEMON REMAINING MESSAGE
    14.          if (vPokeNum==5){
    15.              battle.battleMessage(battle.id, vBotSymbol + "MESSAGE HERE 5.");
    16.              }
    17.  
    18.           // 4 POKEMON REMAINING MESSAGE
    19.          if (vPokeNum==4){
    20.              battle.battleMessage(battle.id, vBotSymbol + "MESSAGE HERE 4.");
    21.              }
    22.  
    23.          // 3 POKEMON REMAINING MESSAGE
    24.          if (vPokeNum==3){
    25.              battle.battleMessage(battle.id, vBotSymbol + "MESSAGE HERE 3.");
    26.              }
    27.  
    28.          // 2 POKEMON REMAINING MESSAGE
    29.           if (vPokeNum==2){
    30.              battle.battleMessage(battle.id, vBotSymbol + "MESSAGE HERE 2.");
    31.              }
    32.  
    33.          // LAST POKEMON REMAINING MESSAGE
    34.          if (vPokeNum==1){
    35.              battle.battleMessage(battle.id, vBotSymbol + "MESSAGE HERE LAST.");
    36.              }
    37.  
    38.          }
    39.      },
    40.  })
    41.  
    If you don't want one of them to display. Just delete one of them. I spaced them out so you don't delete anything by accident.

    I'm afraid I don't how to detect "Super Effective", "Not Very Effective", "1 Hit KO" or "Damage Conditions" yet. I tried "Damage Condition" once before but was unsuccessful.

    Hope this helps. :)
     
    Last edited: Dec 8, 2013
  6. Scatterbrain

    Scatterbrain You only live once*

    Joined:
    Jul 5, 2012
    Messages:
    865
    Likes Received:
    4
    thanks :)