Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
#============================================================================== # □ CTB(2013/03/08) #------------------------------------------------------------------------------ # CTB introduction #============================================================================== module R2_CTB_SETTINGS #============================================================================== # ☆ Customization here. #============================================================================== # Set the AP required to act. CC_CTB_AP_ACTION_LIMIT = 100 # Select whether to set AP to 0 after action. # Specify true to set to 0, false otherwise. CC_CTB_AP_RESET = true # Set combat speed. Smaller is faster. # Set a value greater than 0. CC_CTB_BATTLE_SPEED = 20.0 # Adjust or set combat speed to be constant regardless of agility. # When true, make battle speed constant. CC_CTB_BATTLE_SPEED_ADJUST = true # Sets the battle speed when CC_CTB_BATTLE_SPEED_ADJUST is true. # Higher values are faster. CC_CTB_ADJUSTED_SPEED = 20.0 # Set the timing of automatic recovery. # At the end of action = 0, at the time of TP natural increase = 1 CC_CTB_REGENERATE_TIMING = 1 # Adjust the auto-recovery speed. Smaller is faster. # Set a value greater than 0. CC_CTB_REGENERATE_SPEED = 20.0 # Set the AP consumed when using the item. CC_CTB_ITEM_AP_COST = CC_CTB_AP_ACTION_LIMIT #============================================================================== # ☆ Customization here. #============================================================================== end #============================================================================== # □ BattleManager #------------------------------------------------------------------------------ # A module that manages the progress of battles. #============================================================================== module BattleManager class << self #-------------------------------------------------------------------------- # ○ Combat start #-------------------------------------------------------------------------- alias cc_ctb_battle_start battle_start def battle_start cc_ctb_battle_start if @preemptive $game_party.members.each {|member| member.ap += R2_CTB_SETTINGS::CC_CTB_AP_ACTION_LIMIT / 2 } elsif @surprise $game_troop.members.each {|member| member.ap += R2_CTB_SETTINGS::CC_CTB_AP_ACTION_LIMIT / 2 } end speed_adjust_set if R2_CTB_SETTINGS::CC_CTB_BATTLE_SPEED_ADJUST end #-------------------------------------------------------------------------- # ○ Creating action sequences #-------------------------------------------------------------------------- def make_action_orders @action_battlers = [next_action_battler] @action_battlers[0].increase_turn if @action_battlers[0].is_a?(Game_Enemy) end #-------------------------------------------------------------------------- # ○ Acquiring the next battler to act #-------------------------------------------------------------------------- def next_action_battler battlers = [] battlers += $game_party.alive_members unless @surprise battlers += $game_troop.alive_members unless @preemptive battlers.sort! {|a,b| b.agi - a.agi } battlers.min_by {|battler| (R2_CTB_SETTINGS::CC_CTB_AP_ACTION_LIMIT - battler.ap) / battler.agi } end #-------------------------------------------------------------------------- # ○ Get Combat Speed Modifier #-------------------------------------------------------------------------- def speed_adjust_set battlers = $game_party.members + $game_troop.members $cc_ctb_speed_adjust = battlers.max_by {|battler| battler.agi }.agi / R2_CTB_SETTINGS::CC_CTB_ADJUSTED_SPEED end end end #============================================================================== # □ Game_BattlerBase #------------------------------------------------------------------------------ # This is the basic class that handles battlers. # Mainly contains methods for ability score calculation. child # class is used as the superclass of the Game_Battler class. #============================================================================== class Game_BattlerBase alias cc_ctb_hrg hrg alias cc_ctb_mrg mrg alias cc_ctb_trg trg def hrg; cc_ctb_hrg / (R2_CTB_SETTINGS::CC_CTB_REGENERATE_TIMING == 1 ? R2_CTB_SETTINGS::CC_CTB_REGENERATE_SPEED : 1); end # HP再生率 Hp ReGeneration rate def mrg; cc_ctb_mrg / (R2_CTB_SETTINGS::CC_CTB_REGENERATE_TIMING == 1 ? R2_CTB_SETTINGS::CC_CTB_REGENERATE_SPEED : 1); end # MP再生率 Mp ReGeneration rate def trg; cc_ctb_trg / (R2_CTB_SETTINGS::CC_CTB_REGENERATE_TIMING == 1 ? R2_CTB_SETTINGS::CC_CTB_REGENERATE_SPEED : 1); end # TP再生率 Tp ReGeneration rate #-------------------------------------------------------------------------- # ○ public instance variables #-------------------------------------------------------------------------- attr_reader :ap # AP #-------------------------------------------------------------------------- # ○ object initialization #-------------------------------------------------------------------------- alias cc_atb_initialize initialize def initialize @ap = 0 cc_atb_initialize end #-------------------------------------------------------------------------- # ○ AP change of #-------------------------------------------------------------------------- def ap=(ap) @ap = [[ap, max_ap].min, 0].max end #-------------------------------------------------------------------------- # ○ AP get the percentage of #-------------------------------------------------------------------------- def ap_rate @ap.to_f / max_ap end #-------------------------------------------------------------------------- # ○ AP get the maximum value of #-------------------------------------------------------------------------- def max_ap return R2_CTB_SETTINGS::CC_CTB_AP_ACTION_LIMIT end #-------------------------------------------------------------------------- # ○ Skill AP consumption calculation #-------------------------------------------------------------------------- def skill_ap_cost(skill) skill.speed end #-------------------------------------------------------------------------- # ○ Ability to pay for skill use cost #-------------------------------------------------------------------------- alias cc_ctb_skill_cost_payable? skill_cost_payable? def skill_cost_payable?(skill) (!$game_party.in_battle || ap >= skill_ap_cost(skill)) && cc_ctb_skill_cost_payable?(skill) end #-------------------------------------------------------------------------- # ○ Pay skill use cost #-------------------------------------------------------------------------- alias cc_ctb_pay_skill_cost pay_skill_cost def pay_skill_cost(skill) cc_ctb_pay_skill_cost(skill) self.ap -= skill_ap_cost(skill) if $game_party.in_battle end #-------------------------------------------------------------------------- # ○ action judgment #-------------------------------------------------------------------------- def action? ap >= R2_CTB_SETTINGS::CC_CTB_AP_ACTION_LIMIT && self == BattleManager.next_action_battler end end #============================================================================== # □ Game_Battler #------------------------------------------------------------------------------ # A Butler class with sprite and action related methods added. this class # is used as the superclass for the Game_Actor and Game_Enemy classes. #============================================================================== class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # ○ AP initialization of #-------------------------------------------------------------------------- def init_ap self.ap = rand * 25 end #-------------------------------------------------------------------------- # ○ Battle start process #-------------------------------------------------------------------------- alias cc_ctb_on_battle_start on_battle_start def on_battle_start cc_ctb_on_battle_start init_ap end #-------------------------------------------------------------------------- # ○ Combat action creation #-------------------------------------------------------------------------- alias cc_ctb_make_actions make_actions def make_actions cc_ctb_make_actions @actions = [] if self != BattleManager.next_action_battler end #-------------------------------------------------------------------------- # ○ Judgment that command input is possible #-------------------------------------------------------------------------- alias cc_ctb_inputable? inputable? def inputable? cc_ctb_inputable? && action? end #-------------------------------------------------------------------------- # ○ HP the playback of #-------------------------------------------------------------------------- def regenerate_hp damage = -(mhp * hrg / (R2_CTB_SETTINGS::CC_CTB_REGENERATE_TIMING == 1 && R2_CTB_SETTINGS::CC_CTB_BATTLE_SPEED_ADJUST ? $cc_ctb_speed_adjust : 1)).to_i perform_map_damage_effect if $game_party.in_battle && damage > 0 @result.hp_damage = [damage, max_slip_damage].min self.hp -= @result.hp_damage end #-------------------------------------------------------------------------- # ○ MP the playback of #-------------------------------------------------------------------------- def regenerate_mp @result.mp_damage = -(mmp * mrg / (R2_CTB_SETTINGS::CC_CTB_REGENERATE_TIMING == 1 && R2_CTB_SETTINGS::CC_CTB_BATTLE_SPEED_ADJUST ? $cc_ctb_speed_adjust : 1)) self.mp -= @result.mp_damage end #-------------------------------------------------------------------------- # ○ TP the playback of #-------------------------------------------------------------------------- def regenerate_tp self.tp += R2_CTB_SETTINGS::CC_CTB_AP_ACTION_LIMIT * trg / (R2_CTB_SETTINGS::CC_CTB_REGENERATE_TIMING == 1 && R2_CTB_SETTINGS::CC_CTB_BATTLE_SPEED_ADJUST ? $cc_ctb_speed_adjust : 1) end #-------------------------------------------------------------------------- # ○ Processing at the end of combat action #-------------------------------------------------------------------------- alias cc_ctb_on_action_end on_action_end def on_action_end cc_ctb_on_action_end regenerate_all if R2_CTB_SETTINGS::CC_CTB_REGENERATE_TIMING == 0 end #-------------------------------------------------------------------------- # ○ TP consumption when acting #-------------------------------------------------------------------------- def cc_ctb_ap_action_cost if (R2_CTB_SETTINGS::CC_CTB_AP_RESET || !current_action) && action? self.ap -= R2_CTB_SETTINGS::CC_CTB_AP_ACTION_LIMIT elsif current_action && current_action.item.is_a?(RPG::Item) self.ap -= R2_CTB_SETTINGS::CC_CTB_ITEM_AP_COST end end #-------------------------------------------------------------------------- # ○ End of turn process #-------------------------------------------------------------------------- def on_turn_end @result.clear remove_states_auto(2) end end #============================================================================== # □ Game_Enemy #------------------------------------------------------------------------------ # A class that handles enemy characters. This class is the Game_Troop class # ($game_troop) Used internally. #============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ○ public instance variables #-------------------------------------------------------------------------- attr_reader :turn_count # Enemy group index #-------------------------------------------------------------------------- # ○ object initialization #-------------------------------------------------------------------------- alias cc_ctb_initialize initialize def initialize(index, enemy_id) cc_ctb_initialize(index, enemy_id) @turn_count = 1 end #-------------------------------------------------------------------------- # ○ Action condition match judgment [number of turns] #-------------------------------------------------------------------------- def conditions_met_turns?(param1, param2) n = @turn_count if param2 == 0 n == param1 else n > 0 && n >= param1 && n % param2 == param1 % param2 end end #-------------------------------------------------------------------------- # ○ increase in turns #-------------------------------------------------------------------------- def increase_turn @turn_count += 1 end end #============================================================================== # □ Window_Base #------------------------------------------------------------------------------ # The superclass of all windows in the game. #============================================================================== class Window_Base < Window #-------------------------------------------------------------------------- # ○ Acquisition of various character colors #-------------------------------------------------------------------------- def ap_gauge_color1; text_color(30); end; # AP gauge 1 def ap_gauge_color2; text_color(31); end; # AP gauge 2 #-------------------------------------------------------------------------- # ○ AP get the text color of #-------------------------------------------------------------------------- def ap_color(actor) return normal_color end #-------------------------------------------------------------------------- # ○ AP Drawing of #-------------------------------------------------------------------------- def draw_actor_ap(actor, x, y, width = 124) draw_gauge(x, y, width, actor.ap_rate, ap_gauge_color1, ap_gauge_color2) #change_color(system_color) #draw_text(x, y, 30, line_height, Vocab::ap_a) #change_color(ap_color(actor)) #draw_text(x + width - 42, y, 42, line_height, actor.ap.to_i, 2) end #-------------------------------------------------------------------------- # ○ HP Drawing of #-------------------------------------------------------------------------- def draw_actor_hp(actor, x, y, width = 124) draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2) change_color(system_color) draw_text(x, y, 30, line_height, Vocab::hp_a) draw_current_and_max_values(x, y, width, actor.hp.to_i, actor.mhp, hp_color(actor), normal_color) end #-------------------------------------------------------------------------- # ○ MP Drawing of #-------------------------------------------------------------------------- def draw_actor_mp(actor, x, y, width = 124) draw_gauge(x, y, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2) change_color(system_color) draw_text(x, y, 30, line_height, Vocab::mp_a) draw_current_and_max_values(x, y, width, actor.mp.to_i, actor.mmp, mp_color(actor), normal_color) end end #============================================================================== # □ Window_BattleStatus #------------------------------------------------------------------------------ # A window that displays the status of party members on the battle screen. #============================================================================== class Window_BattleStatus < Window_Selectable #-------------------------------------------------------------------------- # ○ Draw a basic area #-------------------------------------------------------------------------- alias cc_atb_draw_basic_area draw_basic_area def draw_basic_area(rect, actor) draw_actor_ap(actor, rect.x + 0, rect.y, 100) cc_atb_draw_basic_area(rect, actor) end end #============================================================================== # □ Window_Selectable #------------------------------------------------------------------------------ # Window class with cursor movement and scrolling functions. #============================================================================== class Window_Selectable < Window_Base #-------------------------------------------------------------------------- # ○ Redraw all items #-------------------------------------------------------------------------- def redraw_all_items item_max.times {|i| clear_item(i) } item_max.times {|i| draw_item(i) } end end #============================================================================== # □ Scene_Battle #------------------------------------------------------------------------------ # A class that processes the battle screen. #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ○ Redraw the information in the status window #-------------------------------------------------------------------------- def redraw_status @status_window.redraw_all_items @enemy_window.redraw_all_items end #-------------------------------------------------------------------------- # ○ Update information in status window #-------------------------------------------------------------------------- def refresh_status @status_window.refresh @enemy_window.refresh end #-------------------------------------------------------------------------- # ○ Frame update (AP increase) #-------------------------------------------------------------------------- def update_ap all_alive_members.each do |member| member.ap += member.agi / R2_CTB_SETTINGS::CC_CTB_BATTLE_SPEED / (R2_CTB_SETTINGS::CC_CTB_BATTLE_SPEED_ADJUST ? $cc_ctb_speed_adjust : 1) member.regenerate_all if R2_CTB_SETTINGS::CC_CTB_REGENERATE_TIMING == 1 end redraw_status update_basic end #-------------------------------------------------------------------------- # ○ Start party command selection #-------------------------------------------------------------------------- def start_party_command_selection unless scene_changing? refresh_status @status_window.unselect @status_window.open while BattleManager.next_action_battler.ap < R2_CTB_SETTINGS::CC_CTB_AP_ACTION_LIMIT update_ap end if BattleManager.input_start @actor_command_window.close @party_command_window.setup else @party_command_window.deactivate turn_start end end end #-------------------------------------------------------------------------- # ○ Acquisition of all battle members including enemies and allies #-------------------------------------------------------------------------- def all_movable_members $game_party.movable_members + $game_troop.movable_members end #-------------------------------------------------------------------------- # ○ Acquisition of all surviving members including enemies and allies #-------------------------------------------------------------------------- def all_alive_members $game_party.alive_members + $game_troop.alive_members end #-------------------------------------------------------------------------- # ○ Command [Escape] #-------------------------------------------------------------------------- alias cc_ctb_command_escape command_escape def command_escape cc_ctb_command_escape $game_party.movable_members.each do |member| member.ap = 0 end end #-------------------------------------------------------------------------- # ○ start of turn #-------------------------------------------------------------------------- def turn_start @party_command_window.close @actor_command_window.close @status_window.unselect @subject = nil BattleManager.turn_start @log_window.clear end #-------------------------------------------------------------------------- # ○ Handling Combat Actions #-------------------------------------------------------------------------- def process_action return if scene_changing? if !@subject || !@subject.current_action @subject = BattleManager.next_subject end return turn_end unless @subject if @subject.action? @subject.update_state_turns @subject.update_buff_turns end if @subject.current_action @subject.current_action.prepare if @subject.current_action.valid? @status_window.open execute_action end end if @subject.action? @subject.cc_ctb_ap_action_cost end if @subject.current_action @subject.remove_current_action end process_action_end unless @subject.current_action end end
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Untitled
1 hour ago | 12.49 KB
Untitled
3 hours ago | 12.40 KB
programacion_algoritmos_flashcards.tsv
5 hours ago | 2.67 KB
Untitled
5 hours ago | 17.13 KB
Untitled
7 hours ago | 18.40 KB
Untitled
9 hours ago | 17.70 KB
Untitled
11 hours ago | 16.97 KB
Untitled
13 hours ago | 21.75 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!