- 119
- Posts
- 11
- Years
- Seen Sep 1, 2023
This scripts adds the functionality of an asynchronous co-op system similar to that in the "tales of" games. This means that player 2 can control the partner trainer during combat. The basics are controls for two players, player 2 controlling the partner trainer who can attack, switch Pokémon, and use items from player 1's bag. How to implement this is explained below. Besides that there will be some add-ons added in the future (i.e. no auto healing after battle, instead at a PokéCenter; player 2 also gaining experience and leveling). When used credits would be appreciated.
Controls:
Turning on the co-op controls moves player 1's controls to the right side of the keyboard and sets player 2's controls at the left side. Note that while co-op is disabled the player can still use the controls at the right side of the keyboard (the same as when co-op is enabled). The controls are:
The Basics
Make the following changes to the PokemonControls script:
Make the following changes to the PokemonOptions script:
Make the following changes to the PokeBattle_Battle script:
Make the following changes to the PokeBattle_ActualScene script:
Add-ons
Will add the following in the future;
- No healing after battle, instead the partner's Pokémon are also healed at a Pokémon Center.
- The partner's Pokémon gaining xp.
Controls:
Turning on the co-op controls moves player 1's controls to the right side of the keyboard and sets player 2's controls at the left side. Note that while co-op is disabled the player can still use the controls at the right side of the keyboard (the same as when co-op is enabled). The controls are:
Spoiler:
Player 1:
- Arrow keys = move
- numpad 1 = Accept
- numpad 2 = Cancel/Menu
- Numpad 3 = run
- Numpad 4/5/6 = Z/Y/X (rmxp input)
- Numpad 0 and Period = L and R
Player 2:
- WASD = move
- F = Accept
- G = Cancel/Menu
- H = run
- R/T/Y = Z/Y/X (rmxp input)
- Q/E = L and R
Note: If you'd like to change the controls you'll have to change the script in PokemonControls. For the key codes I recommend looking in FLs "set the input" script.
- Arrow keys = move
- numpad 1 = Accept
- numpad 2 = Cancel/Menu
- Numpad 3 = run
- Numpad 4/5/6 = Z/Y/X (rmxp input)
- Numpad 0 and Period = L and R
Player 2:
- WASD = move
- F = Accept
- G = Cancel/Menu
- H = run
- R/T/Y = Z/Y/X (rmxp input)
- Q/E = L and R
Note: If you'd like to change the controls you'll have to change the script in PokemonControls. For the key codes I recommend looking in FLs "set the input" script.
The Basics
Make the following changes to the PokemonControls script:
Spoiler:
Search for the following section;
And replace it by the code below;
Code:
case button
when Input::DOWN
return [0x28] # Down
when Input::LEFT
return [0x25] # Left
when Input::RIGHT
return [0x27] # Right
when Input::UP
return [0x26] # Up
when Input::A
return [0x5A,0x10] # Z, Shift
when Input::B
return [0x58,0x1B] # X, ESC
when Input::C
return [0x43,0x0d,0x20] # C, ENTER, Space
when Input::X
return [0x41] # A
when Input::Y
return [0x53] # S
when Input::Z
return [0x44] # D
when Input::L
return [0x51,0x21] # Q, Page Up
when Input::R
return [0x57,0x22] # W, Page Down
Code:
$PokemonSystem.multiplayer = 0 if $PokemonSystem.multiplayer == nil
$PokemonSystem.cur_player = 0 if $PokemonSystem.cur_player == nil
case button
when Input::DOWN # DOWN
if $PokemonSystem.multiplayer == 1 && $PokemonSystem.cur_player == 1
return [0x53] # S (Only for player 2 when co-op)
else # Player 1, or solo
return [0x28] # Down
end
when Input::LEFT # LEFT
if $PokemonSystem.multiplayer == 1 && $PokemonSystem.cur_player == 1
return [0x41] # A
else
return [0x25] # Left
end
when Input::RIGHT # RIGHT
if $PokemonSystem.multiplayer == 1 && $PokemonSystem.cur_player == 1
return [0x44] # D
else
return [0x27] # Right
end
when Input::UP # UP
if $PokemonSystem.multiplayer == 1 && $PokemonSystem.cur_player == 1
return [0x57] # W
else
return [0x26] # Up
end
when Input::A # MENU / Start
if $PokemonSystem.multiplayer == 0 # Solo
return [0x5A,0x10,0x63] # Z, Shift, Num 3
else
if $PokemonSystem.cur_player == 0 # Player 1
return [0x63] # Num 3
else # Player 2
return [0x48] # H
end
end
when Input::B # B / Cancel
if $PokemonSystem.multiplayer == 0
return [0x58,0x1B,0x62] # X, ESC , Num 2
else
if $PokemonSystem.cur_player == 0
return [0x62] # Num 2
else
return [0x47] # G
end
end
when Input::C # A / Accept
if $PokemonSystem.multiplayer == 0
return [0x43,0x0d,0x20,0x61] # C, ENTER, Space, Num 1
else
if $PokemonSystem.cur_player == 0
return [0x61,0x0d] # Num 1 (,Enter)
else
return [0x46] # F
end
end
when Input::X
if $PokemonSystem.multiplayer == 0
return [0x41,0x66] # A, Num 6
else
if $PokemonSystem.cur_player == 0
return [0x66] # Num 6
else
return [0x59] # Y
end
end
when Input::Y
if $PokemonSystem.multiplayer == 0
return [0x53,0x65] # S, Num 5
else
if $PokemonSystem.cur_player == 0
return [0x65] # Num 5
else
return [0x54] # T
end
end
when Input::Z
if $PokemonSystem.multiplayer == 0
return [0x44,0x64] # D, Num 4
else
if $PokemonSystem.cur_player == 0
return [0x64] # Num 4
else
return [0x52] # R
end
end
when Input::L # L
if $PokemonSystem.multiplayer == 0
return [0x51,0x21,0x60] # Q, Page Up, Num 0
else
if $PokemonSystem.cur_player == 0
return [0x60] # Num 0
else
return [0x51] # Q
end
end
when Input::R # R
if $PokemonSystem.multiplayer == 0
return [0x57,0x22,0x6E] # W, Page Down, Decimal
else
if $PokemonSystem.cur_player == 0
return [0x6E] # Num Decimal
else
return [0x45] # E
end
end
Make the following changes to the PokemonOptions script:
Spoiler:
- Search for "attr_accessor :language" and add "attr_accessor :multiplayer" on the line below, and "attr_accessor :cur_player" on the line below that.
- Then find "@language = 0 # Language (see also LANGUAGES in script PokemonSystem)" and add "@multiplayer = 0 # if 0 = solo controls, 1 = co-op controls" on the line below, and "@cur_player = 0 # Player which can currently give input" on the line below that.
- Finally find "NumberOption.new(_INTL("Speech Frame"),_INTL("Type %d"),1,$SpeechFrames.length," and add the following code above that line;
- Then find "@language = 0 # Language (see also LANGUAGES in script PokemonSystem)" and add "@multiplayer = 0 # if 0 = solo controls, 1 = co-op controls" on the line below, and "@cur_player = 0 # Player which can currently give input" on the line below that.
- Finally find "NumberOption.new(_INTL("Speech Frame"),_INTL("Type %d"),1,$SpeechFrames.length," and add the following code above that line;
Code:
EnumOption.new(_INTL("Players"),[_INTL("Solo"),_INTL("Co-op")],
proc { $PokemonSystem.multiplayer },
proc {|value| $PokemonSystem.multiplayer=value
}
),
Make the following changes to the PokeBattle_Battle script:
Spoiler:
- Find "return false if @player.is_a?(Array) && index==2" and replace it by the following code:
- Search for "def pbSecondPartyBegin(battlerIndex)" and add the following code on the empty line above it:
- Find "return pbSwitchPlayer(index,lax,cancancel)" and add "SetInputPlayer(index)" above that line, then add "SetInputPlayer(0)" below that line.
- Search for "if !pbOwnedByPlayer?(i) || @controlPlayer" and add "SetInputPlayer(i)" above that line.
- Finally search for "break if commandDone" then add "SetInputPlayer(0)" before the last 'end' below that line.
Code:
if @player.is_a?(Array) #If has partner trainer, yet no curtrainer id
return false if index==2 && $PokemonSystem.multiplayer == 0
end
Code:
def pbPartyExact(index)
return party1 if index==0
return party1 if index==2 && [email protected]_a?(Array)
return party2 if index==1
return party2 if index==3 && [email protected]_a?(Array)
if index==2 && @player.is_a?(Array)
party = []
for i in 0...6; party.push(party1[6+i]); end
elsif index==3 && @opponent.is_a?(Array)
party = []
for i in 0...6; party.push(party2[6+i]); end
end
return party
end
def pbController(index) #returns 0 if player 1, 1 if partner, etc.
ret = 0
if @player.is_a?(Array) && index==2 && $PokemonSystem.multiplayer == 1
ret = 1 #if partner trainer and co-op is turned on
end
return ret
end
def SetInputPlayer(index)
# Single player is always P1
if $PokemonSystem.multiplayer == 0
$PokemonSystem.cur_player = 0
else # Co-op controls are enabled
# Player 1:
if @player.is_a?(Array) && index==0
$PokemonSystem.cur_player = 0
# Player 2:
elsif @player.is_a?(Array) && index==2
$PokemonSystem.cur_player = 1
end
end
return
end
- Search for "if !pbOwnedByPlayer?(i) || @controlPlayer" and add "SetInputPlayer(i)" above that line.
- Finally search for "break if commandDone" then add "SetInputPlayer(0)" before the last 'end' below that line.
Make the following changes to the PokeBattle_ActualScene script:
Spoiler:
- Search for "itemscene.pbStartScene($PokemonBag)" and add "[email protected](index)" below that, followed by "offset = 6 * @battle.pbController(index)" below that.
- Find "modparty.push(@battle.party1[@battle.partyorder])" and replace it by "modparty.push(party)".
- Search for "[email protected][activecmd]" and replace it by "[email protected][activecmd]+offset".
- Find "[email protected](index)" and "[email protected]". Then remove these lines and replace with the following code:
- Replace "modparty.push(party[partypos])" by "modparty.push(party)".
- Replace "pkmnindex=partypos[activecmd]" by "pkmnindex=activecmd".
- Replace "canswitch=lax ? @battle.pbCanSwitchLax?(index,pkmnindex,true) :" by "canswitch=lax ? @battle.pbCanSwitchLax?(index,pkmnindex+whichpart,true) :".
- Replace "@battle.pbCanSwitch?(index,pkmnindex,true)" by "@battle.pbCanSwitch?(index,pkmnindex+whichpart,true)".
- Finally Replace "ret=pkmnindex" by "ret=pkmnindex+whichpart".
- Find "modparty.push(@battle.party1[@battle.partyorder])" and replace it by "modparty.push(party)".
- Search for "[email protected][activecmd]" and replace it by "[email protected][activecmd]+offset".
- Find "[email protected](index)" and "[email protected]". Then remove these lines and replace with the following code:
Code:
[email protected](index)
whichpart= 6 * @battle.pbController(index)
- Replace "pkmnindex=partypos[activecmd]" by "pkmnindex=activecmd".
- Replace "canswitch=lax ? @battle.pbCanSwitchLax?(index,pkmnindex,true) :" by "canswitch=lax ? @battle.pbCanSwitchLax?(index,pkmnindex+whichpart,true) :".
- Replace "@battle.pbCanSwitch?(index,pkmnindex,true)" by "@battle.pbCanSwitch?(index,pkmnindex+whichpart,true)".
- Finally Replace "ret=pkmnindex" by "ret=pkmnindex+whichpart".
Add-ons
Will add the following in the future;
- No healing after battle, instead the partner's Pokémon are also healed at a Pokémon Center.
- The partner's Pokémon gaining xp.