- Joined
- Aug 28, 2014
- Messages
- 2
- Reaction score
- 0
- Primarily Uses
So I'm no scripter, and even though I've tried to mess with this for an hour I'm out of ideas. Basically I'm using Fomar's AP System II script, but with a twist. I'm trying to have an NPC vendor that will sell passive skills in exchange for AP, and I have no idea how to reference the amount of AP each individual character has. The closest I've gotten is $game_actors[x].ap, which doesn't throw any errors but doesn't give accurate amounts. Here is my method, just in case I'm going about it wrong: I'm trying to set a variable for each actor that is equal to that character's total Ap gained. (If I manage that I can come up with a way to keep track of a running total of AP available, I'm not worried about that.) But setting a variable to $game_actors[1].ap for example keeps returning 0 no matter how many battles are fought. any help would be appreciated. here is the script:
I'm also using a small snippet to make it compatible with a yanfly script, so here's that in case it's relevant:
thanks ahead of time for any help.
=begin
AP System Script II
by Fomar0153
Version 1.0
----------------------
Notes
----------------------
No requirements
Implements an ap system for you to use when creating skill
systems that utilise AP.
----------------------
Instructions
----------------------
Notetag <ap x> e.g. <ap 4> <ap 100>----------------------
Known bugs
----------------------
None
=end
module Vocab
ObtainAp = "%s AP was obtained!"
end
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● New Method gain_ap
#--------------------------------------------------------------------------
def gain_ap(ap)
# your code goes here
end
end
module BattleManager
#--------------------------------------------------------------------------
# ● Rewrote self.display_exp
#--------------------------------------------------------------------------
def self.display_exp
if $game_troop.exp_total > 0
text = sprintf(Vocab:
btainExp, $game_troop.exp_total)
$game_message.add('\.' + text)
end
if $game_troop.ap_total > 0
text = sprintf(Vocab:
btainAp, $game_troop.ap_total)
$game_message.add('\.' + text)
end
end
#--------------------------------------------------------------------------
# ● Rewrote self.gain_exp
#--------------------------------------------------------------------------
def self.gain_exp
$game_party.all_members.each do |actor|
actor.gain_exp($game_troop.exp_total)
end
wait_for_message
$game_party.all_members.each do |actor|
actor.gain_ap($game_troop.ap_total)
end
wait_for_message
end
end
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# ● New Method ap_total
#--------------------------------------------------------------------------
def ap_total
dead_members.inject(0) {|r, enemy| r += enemy.ap }
end
end
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ● New Method ap_total
#--------------------------------------------------------------------------
def ap
if enemy.note =~ //i
return $1.to_i
else
return 0
end
end
end
AP System Script II
by Fomar0153
Version 1.0
----------------------
Notes
----------------------
No requirements
Implements an ap system for you to use when creating skill
systems that utilise AP.
----------------------
Instructions
----------------------
Notetag <ap x> e.g. <ap 4> <ap 100>----------------------
Known bugs
----------------------
None
=end
module Vocab
ObtainAp = "%s AP was obtained!"
end
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● New Method gain_ap
#--------------------------------------------------------------------------
def gain_ap(ap)
# your code goes here
end
end
module BattleManager
#--------------------------------------------------------------------------
# ● Rewrote self.display_exp
#--------------------------------------------------------------------------
def self.display_exp
if $game_troop.exp_total > 0
text = sprintf(Vocab:
$game_message.add('\.' + text)
end
if $game_troop.ap_total > 0
text = sprintf(Vocab:
$game_message.add('\.' + text)
end
end
#--------------------------------------------------------------------------
# ● Rewrote self.gain_exp
#--------------------------------------------------------------------------
def self.gain_exp
$game_party.all_members.each do |actor|
actor.gain_exp($game_troop.exp_total)
end
wait_for_message
$game_party.all_members.each do |actor|
actor.gain_ap($game_troop.ap_total)
end
wait_for_message
end
end
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# ● New Method ap_total
#--------------------------------------------------------------------------
def ap_total
dead_members.inject(0) {|r, enemy| r += enemy.ap }
end
end
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ● New Method ap_total
#--------------------------------------------------------------------------
def ap
if enemy.note =~ //i
return $1.to_i
else
return 0
end
end
end
module Vocab
ObtainAp = "+%sAP"
end
module BattleManager
def self.display_exp
SceneManager.scene.show_victory_display_exp
actor = $game_party.random_target
@victory_actor = actor
set_victory_text(@victory_actor, :win)
end
def self.gain_exp
$game_party.all_members.each do |actor|
temp_actor = Marshal.load(Marshal.dump(actor))
actor.gain_exp($game_troop.exp_total)
actor.gain_ap($game_troop.ap_total)
next if actor.level == temp_actor.level
SceneManager.scene.show_victory_level_up(actor, temp_actor)
set_victory_text(actor, :level)
wait_for_message
end
end
end
class Window_VictoryEXP_Back < Window_Selectable
alias ap_draw_jp_gain draw_jp_gain
def draw_jp_gain(actor, rect)
ap_draw_jp_gain(actor, rect)
dw = rect.width - (rect.width - [rect.width, 96].min) / 2
dy = rect.y + line_height * 4 + 96
dy += line_height if $imported["YEA-JPManager"]
text = sprintf(Vocab:
btainAp, $game_troop.ap_total)
contents.font.size = YEA::VICTORY_AFTERMATH::FONTSIZE_EXP
change_color(power_up_color)
draw_text(rect.x, dy, dw, line_height, text, 2)
end
end
ObtainAp = "+%sAP"
end
module BattleManager
def self.display_exp
SceneManager.scene.show_victory_display_exp
actor = $game_party.random_target
@victory_actor = actor
set_victory_text(@victory_actor, :win)
end
def self.gain_exp
$game_party.all_members.each do |actor|
temp_actor = Marshal.load(Marshal.dump(actor))
actor.gain_exp($game_troop.exp_total)
actor.gain_ap($game_troop.ap_total)
next if actor.level == temp_actor.level
SceneManager.scene.show_victory_level_up(actor, temp_actor)
set_victory_text(actor, :level)
wait_for_message
end
end
end
class Window_VictoryEXP_Back < Window_Selectable
alias ap_draw_jp_gain draw_jp_gain
def draw_jp_gain(actor, rect)
ap_draw_jp_gain(actor, rect)
dw = rect.width - (rect.width - [rect.width, 96].min) / 2
dy = rect.y + line_height * 4 + 96
dy += line_height if $imported["YEA-JPManager"]
text = sprintf(Vocab:
contents.font.size = YEA::VICTORY_AFTERMATH::FONTSIZE_EXP
change_color(power_up_color)
draw_text(rect.x, dy, dw, line_height, text, 2)
end
end


