Hello,
I've been trying to write a passive skills script, and pretty much everything works, except one thing.
I want to have an option so whenever a certain skill is learned, the player gets his gold gain when he wins a battle multiplied by something.
I think i've come up with a solution, although i'm not sure it will work.
Here is the script i've written:
My "solution" gives an error.
I thought that i could use the attr_accessor :goldt in Game_Actor and then use this in Scene_Battle:
Then further down at line 184, i tried this:
But this gave me this error:
But then i tried another thing and i used attr_accessor :goldt in the Game_Battler instead, and changed:
to:
And that works without giving me an error!
But i really can't figure out why it gives me an error when it's Game_Actor..
My intentions where that it would multiply the gold gain with the number that is in the skills "ATTRIBUTES".
So does anyone know why it gives me an error when i change it to "$whatever = Game_Actor.new"?
And if you know from just looking at the script that it won't work, could you please tell me, and maybe give me some directions on how to make it work?
Any help is appreciated^_^
Over and out - Gando
I've been trying to write a passive skills script, and pretty much everything works, except one thing.
I want to have an option so whenever a certain skill is learned, the player gets his gold gain when he wins a battle multiplied by something.
I think i've come up with a solution, although i'm not sure it will work.
Here is the script i've written:
Code:
#==============================================================================
# ** Passive_Skills
#----------------------------------------------------------------------------------------------------
#
#
#
#
#
#
#
#==============================================================================
PASSIVE_SKILLS = [1, 2, 3]
#skill_id => [max_hp, max_sp, str, dex, agi, int, atk, pdef, mdef, gold_multiplier]
ATTRIBUTES =
{
1 => [999, 999, 999, 999, 999, 999, 999, 999, 999, 2] ,
2 => [0, 100, 0, 0, 0, 0, 0, 0, 0, 1] ,
3 => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
}
class Game_Actor < Game_Battler
attr_accessor :goldt
alias passive_skill_learn learn_skill
alias passive_skill_forget forget_skill
#--------------------------------------------------------------------------
# * Get Actor ID
#--------------------------------------------------------------------------
def learn_skill(skill_id)
passive_skill_learn(skill_id)
if PASSIVE_SKILLS.include?(skill_id)
@maxhp_plus += ATTRIBUTES[skill_id][0]
@maxsp_plus += ATTRIBUTES[skill_id][1]
@str_plus += ATTRIBUTES[skill_id][2]
@dex_plus += ATTRIBUTES[skill_id][3]
@agi_plus += ATTRIBUTES[skill_id][4]
@int_plus += ATTRIBUTES[skill_id][5]
@atk_plus += ATTRIBUTES[skill_id][6]
@pdef_plus += ATTRIBUTES[skill_id][7]
@mdef_plus += ATTRIBUTES[skill_id][8]
@goldt += ATTRIBUTES[skill_id][9]
end
end
def forget_skill(skill_id)
passive_skill_forget(skill_id)
if PASSIVE_SKILLS.include?(skill_id)
@maxhp_plus -= ATTRIBUTES[skill_id][0]
@maxsp_plus -= ATTRIBUTES[skill_id][1]
@str_plus -= ATTRIBUTES[skill_id][2]
@dex_plus -= ATTRIBUTES[skill_id][3]
@agi_plus -= ATTRIBUTES[skill_id][4]
@int_plus -= ATTRIBUTES[skill_id][5]
@atk_plus -= ATTRIBUTES[skill_id][6]
@pdef_plus -= ATTRIBUTES[skill_id][7]
@mdef_plus -= ATTRIBUTES[skill_id][8]
@goldt -= ATTRIBUTES[skill_id][9]
end
end
end
class Game_Battler
attr_accessor :goldt
alias parameter_init initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@atk_plus = 0
@pdef_plus = 0
@mdef_plus = 0
@goldt = 0
parameter_init
end
#--------------------------------------------------------------------------
# * Get Attack
#--------------------------------------------------------------------------
def atk
n = [[base_atk + @atk_plus, 1].max, 999].min
for state in states do n *= state.atk_rate / 100.0 end
n = [[Integer(n), 1].max, 999].min
return n
end
#--------------------------------------------------------------------------
# * Get Defense
#--------------------------------------------------------------------------
def pdef
n = [[base_pdef + @pdef_plus, 1].max, 999].min
for i in @states
n *= $data_states[i].pdef_rate / 100.0
end
return Integer(n)
end
#--------------------------------------------------------------------------
# * Get Defense
#--------------------------------------------------------------------------
def mdef
n = [[base_mdef + @mdef_plus, 1].max, 999].min
for i in @states
n *= $data_states[i].mdef_rate / 100.0
end
return Integer(n)
end
#--------------------------------------------------------------------------
# * Set Attack
# new_atk : new attack
#--------------------------------------------------------------------------
def atk=(new_atk)
@atk_plus += new_atk - self.atk
@atk_plus = [[@atk_plus, -999].max, 999].min
end
#--------------------------------------------------------------------------
# * Set Defense
# new_def : new defense
#--------------------------------------------------------------------------
def pdef=(new_pdef)
@pdef_plus += new_pdef - self.pdef
@pdef_plus = [[@pdef_plus, -999].max, 999].min
end
#--------------------------------------------------------------------------
# * Set Defense
# new_def : new defense
#--------------------------------------------------------------------------
def mdef=(new_mdef)
@mdef_plus += new_mdef - self.mdef
@mdef_plus = [[@mdef_plus, -999].max, 999].min
end
end
class Scene_Battle
#--------------------------------------------------------------------------
# * Start After Battle Phase
#--------------------------------------------------------------------------
def start_phase5
$whatever = Game_Actor.new
# Shift to phase 5
@phase = 5
# Play battle end ME
$game_system.me_play($game_system.battle_end_me)
# Return to BGM before battle started
$game_system.bgm_play($game_temp.map_bgm)
# Initialize EXP, amount of gold, and treasure
exp = 0
gold = 0
treasures = []
# Loop
for enemy in $game_troop.enemies
# If enemy is not hidden
unless enemy.hidden
# Add EXP and amount of gold obtained
exp += enemy.exp
gold += enemy.gold
# Determine if treasure appears
if rand(100) < enemy.treasure_prob
if enemy.item_id > 0
treasures.push($data_items[enemy.item_id])
end
if enemy.weapon_id > 0
treasures.push($data_weapons[enemy.weapon_id])
end
if enemy.armor_id > 0
treasures.push($data_armors[enemy.armor_id])
end
end
end
end
# Treasure is limited to a maximum of 6 items
treasures = treasures[0..5]
# Obtaining EXP
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if actor.cant_get_exp? == false
last_level = actor.level
actor.exp += exp
if actor.level > last_level
@status_window.level_up(i)
end
end
end
gold *= $whatever.goldt
# Obtaining gold
$game_party.gain_gold(gold)
# Obtaining treasure
for item in treasures
case item
when RPG::Item
$game_party.gain_item(item.id, 1)
when RPG::Weapon
$game_party.gain_weapon(item.id, 1)
when RPG::Armor
$game_party.gain_armor(item.id, 1)
end
end
# Make battle result window
@result_window = Window_BattleResult.new(exp, gold, treasures)
# Set wait count
@phase5_wait_count = 100
end
end
My "solution" gives an error.
I thought that i could use the attr_accessor :goldt in Game_Actor and then use this in Scene_Battle:
Code:
$whatever = Game_Actor.new
Then further down at line 184, i tried this:
Code:
gold *= $whatever.goldt
But this gave me this error:
Code:
Script 'Passive_Skills' line 139: ArgumentError occured.
wrong number of arguments(0 for 1)
But then i tried another thing and i used attr_accessor :goldt in the Game_Battler instead, and changed:
Code:
$whatever = Game_Actor.new
to:
Code:
$whatever = Game_Battler.new
And that works without giving me an error!
But i really can't figure out why it gives me an error when it's Game_Actor..
My intentions where that it would multiply the gold gain with the number that is in the skills "ATTRIBUTES".
So does anyone know why it gives me an error when i change it to "$whatever = Game_Actor.new"?
And if you know from just looking at the script that it won't work, could you please tell me, and maybe give me some directions on how to make it work?
Any help is appreciated^_^
Over and out - Gando