# NPC Battles (NPC vs. NPC) 1.01

Pokémon Essentials Version
NPC BATTLE SCRIPT

This script allows you to let two NPCs battle each other in an actual battle enviroment, so that the player can watch it. The outcome can not be modified.

Features:
- let any two NPCs battle that are defined in the trainer pbs
- allows double battles
- player can control the NPCs action if wanted
- doesn't level NPCs Pokemon
- doesn't effect players money
- by default each battle can be lost, so the player won't black out
- the party that is defined in trainers pbs can be substituted
- battle outcome can be stored in a variable

How to set up:
1) Copy the code from the txt file into a new script section or place it before def pbTrainerBattle
2) Set NPCSWITCH and NPCBATTLE to a free switch that you have not used yet anywhere in the project
3) find if !pbOwnedByPlayer?(i) || @controlPlayer and add the following before that line: @controlPlayer=true if $game_switches[NPCSWITCH] 4) find if !pbOwnedByPlayer?(index) and add the following right behind it: && !$game_switches[NPCBATTLE] #NPC Battle
5) find def pbGainEXP and right under that add the following: return if $game_switches[NPCBATTLE] NPC Battle  6) find def pbObedienceCheck?(choice) and add the following right under it: return true if$game_switches[NPCBATTLE] #NPC Battle
7) find # Calculate money gained for winning
and after if @internalbattle add  && !$game_switches[NPCBATTLE] do the same after PBDebug.log("***Player drew with opponent***") if @decision==5 8) find  def pbSwitchInBetween(index,lax,cancancel) and after if !pbOwnedByPlayer?(index) add ||$game_switches[NPCBATTLE]
How to use:
See attachted screenshot

Format of the array contents
Ruby:
trainers=[trainer1("opponent"),trainer2("player"),trainer3("opponent"),trainer4("player")]
trainer1=[trainerid,trainername,endspeech,trainerversion,party] same for trainer3
trainer2=[trainerid,trainername,trainerversion,party] same for trainer4

Explanation of each argument:

trainer1/trainer2/trainer3/trainer4 are each an array in the above mentioned format

trainerid: the type of trainer (e.g. :FISHERMAN)

trainername: the name of the trainer that is defined in the trainers pbs

endspeech: what the trainer will say after losing: Only for trainers on opposing side

trainerversion: the version of the trainer if there are multiple (like for rivals); this argument is optional

party: the party that the trainer should use instead of the defined one

Explanation of arguments in pbNPCBattle

trainers: the array of trainers as shown above

doublebattle: wether this should be a double battle or not; if there are two trainers on the opposing side it will always be a double battle; if double battle is false and 4 trainers are defined only one trainer will be on the players side (e.g. 1v2)

controlled: wether the AI should controll the NPC or the player should

canlose: wether you black out when the trainer on your side is losing or not

variable: if given stores the outcome of the battle in the variable

For questions and bug reports visit our Discord channel https://discord.gg/7msDPaN or post them here.

Notes:

1) The trainers that will be on the player side are the 2nd and 4th trainer in the trainers array

2) The trainers on the player side must not have an endspeech

3) trainerversion and party are optional

4) you can force a double with the override (if you want a 1v1 double

5) the battles by default can always be losed, otherwise it could disrupt the story

6) you can store the outcome in a variable, just like in regular battles

7) if you don't have a backsprite for a trainer type then it won't show anything upon entering the battle
Credits
Credit if used:
hollow_ego
• Example simple 1v1.png
29.2 KB · Views: 578
Author
Hollow_Ego
362
Views
362
First release
Last update
Rating
0 ratings