after reading ( patienly ) some RGSS tutorials, i started creating some battle result script. I have already created the basics for window structures and the scene ... Then, how can I show the scene i created after the battle? And how can i show the items obtained during battle? And lastly, how can i show the skills learned if there is any skill learned after battle. ex. Leveling up. Thank you.
def refresh_BS self.contents.clear self.contents.draw_text(0, 0, 150, 32, "Battle Info") end end
#============================================================================== # Battle Result Scene #==============================================================================
class Scene_BattleResult
def main # make window for BRWindow, Items_GoldWindow, Exp_Window and BS_Window @br_window = BRWindow.new @ig_window = Items_GoldWindow.new @exp_window = Exp_Window.new @bs_window = BS_Window.new # graphics transition Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end # prepare for transition Graphics.freeze # dispose windows @br_window.dispose @ig_window.dispose @exp_window.dispose @bs_window.dispose end
# * Define Update def update @ig_window.update @exp_window.update @bs_window.update if Input.trigger?(Input::B) or if Input.trigger?(Input::C) # Play Decision SE $game_system.se_play($data_system.decision_se) # Switch to Scene Map $scene = Scene_Map.new end end end end
This post has been edited by SleepingSirenx: Nov 4 2011, 09:59 PM
__________________________
My First Game .... Yeah .... ~♥ I'm In Need Of A Team To Help Me WIth The Development Of My Game PM Me. :) - DEMO's On Progress!
I Support This Projects!
Please Teach Me How To Script. :( I'm Learning How To Script. But Still Teach Me How To Script :) Damn THERMODYNAMICS! Makes My Head Spin!
And because you made two initialize functions the second initialize overwrites the first, so the var1 and var2 were getting lost, so just make that into 1 big initialize function and it's all good The if statement problem was you had
CODE
if @var1 and if @var2 // Do something end end
Ruby is a bit loose with it's coding formalities which is what may have caused the confusion, but you need to remember that you only need one if statement, so it becomes
CODE
if ( var1 and var2 ) // Do something end
I've done some other things as well, mostly just alias ( a better tutorial ) a few methods in Scene_Battle, so it will switch to the Scene_BattleResult when you win, and I've made a hash in $game_temp that holds the information about the experience, gold and treasures from the battle ( Oh, and made the experience, gold and treasures readable from the window that is supposed to show it )
code
CODE
#============================================================================== # * Battle Statistics Window #============================================================================== class Game_Temp
alias ssx_battleResults_initialize initialize
attr_accessor :items_gained_from_battle
def initialize @items_gained_from_battle = {} # Run the original initialize ssx_battleResults_initialize end end
#============================================================================== # * Battle Statistics Window #============================================================================== class Window_BattleResult
def refresh_BS self.contents.clear self.contents.draw_text(0, 0, 150, 32, "Battle Info") end end
#============================================================================== # Battle Result Scene #==============================================================================
class Scene_BattleResult
def main # make window for BRWindow, Items_GoldWindow, Exp_Window and BS_Window @exp = $game_temp.items_gained_from_battle[:exp] @gold = $game_temp.items_gained_from_battle[:gold] @treasures = $game_temp.items_gained_from_battle[:treasures] # Reset the items_gained_from_battle $game_temp.items_gained_from_battle = {} @br_window = BRwindow.new @ig_window = Items_Goldwindow.new(@gold, @treasures) @exp_window = Exp_window.new(@exp) @bs_window = BS_window.new # graphics transition Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end # prepare for transition Graphics.freeze # dispose windows @br_window.dispose @ig_window.dispose @exp_window.dispose @bs_window.dispose end
# * Define Update def update @ig_window.update @exp_window.update @bs_window.update if Input.trigger?(Input::B) or Input.trigger?(Input::C) # Play Decision SE $game_system.se_play($data_system.decision_se) # Switch to Scene Map $scene = Scene_Map.new end end end
#============================================================================== # Battle Scene #==============================================================================
class Scene_Battle
alias ssx_battleResult_main main alias ssx_battleResult_start_phase5 start_phase5
def main # Run the original main ssx_battleResult_main # If it is transferring to the map then redirect to the battleresults window $scene = Scene_BattleResult.new if $scene.is_a?(Scene_Map) end
def start_phase5 # Run the original start_phase5 ssx_battleResult_start_phase5 # Get the items $game_temp.items_gained_from_battle[:exp] = @result_window.exp $game_temp.items_gained_from_battle[:gold] = @result_window.gold $game_temp.items_gained_from_battle[:treasures] = @result_window.treasures # Skip the rest, go straight to the Scene_BattleResults $scene = Scene_BattleResult.new end end
__________________________
K.I.S.S. Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.
Thank you for the compliment, though I still have a long way in scripting and thank you sir for the help you made. I now understand (somehow - laughs ) how to use alias . Thank you again.
Side Note : is this code syntax enough to make skill learned through level appear?
CODE
def generate_data(initial_levels) i = 0 # Actors gain level for actor in $game_party.actors @actors_data.push (ResultActor.new(actor, initial_levels[i], [], 0)) count = 0 # Valid actor? if actor.cant_get_exp? == false difference = actor.level - @actors_initals_levels[i] # Check diff so can gain levels or exp if difference > 0
# SKILL GAIN UP. for lv in 0...difference # If it have skills learning for lea in $data_classes[actor.class_id].learnings if lea.level == @actors_initals_levels[i] + lv @actors_data.last.gained_skills.push (lea.skill_id) end end end end end i += 1 end end
__________________________
My First Game .... Yeah .... ~♥ I'm In Need Of A Team To Help Me WIth The Development Of My Game PM Me. :) - DEMO's On Progress!
I Support This Projects!
Please Teach Me How To Script. :( I'm Learning How To Script. But Still Teach Me How To Script :) Damn THERMODYNAMICS! Makes My Head Spin!
Group: +Gold Member
Posts: 1,529
Type: Scripter
RM Skill: Undisclosed
I have no way of knowing from this snippet alone. You get passed the input initial_levels, which is an array of what I'm guessing is the actors initial levels, but later you get to finding the difference and you start using @actors_initals_levels. And I am not sure what @actors_data contains.
But assuming that they all work, then yeah, it looks like it could work
__________________________
K.I.S.S. Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.