Need Help with Script Call

bcapek

Warper
Member
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:

=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::obtainExp, $game_troop.exp_total)
$game_message.add('\.' + text)
end
if $game_troop.ap_total > 0
text = sprintf(Vocab::obtainAp, $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
I'm also using a small snippet to make it compatible with a yanfly script, so here's that in case it's relevant:

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::obtainAp, $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
thanks ahead of time for any help.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
569
Reaction score
153
First Language
Serbian
Primarily Uses
N/A
Did you populate your gain_ap method?

And did you insert the "your code goes here"?

Because you would need to insert something like this :

class Game_Actor < Game_Battler attr_accessor :ap def gain_ap(ap) (@ap ||= 0) += ap endend in the new script slot below both of the above.Note that the code above will crash if actor's AP is 0
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,990
Members
137,562
Latest member
tamedeathman
Top