Log in

View Full Version : I actually need help, again.


Goodlookinguy
2007-08-22, 05:45 PM
I need a little help with the RGSS scripting. I am trying to make another selection that will start out the game diffently (see below). Can you see what I'm doing wrong?
#================================================= =============================
# ** Scene_Title
#------------------------------------------------------------------------------
# This class performs title screen processing.
#================================================= =============================
class Scene_Title
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# If battle test
if $BTEST
battle_test
return
end
# Load database
$data_actors = load_data("Data/Actors.rxdata")
$data_classes = load_data("Data/Classes.rxdata")
$data_skills = load_data("Data/Skills.rxdata")
$data_items = load_data("Data/Items.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
$data_armors = load_data("Data/Armors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
$data_troops = load_data("Data/Troops.rxdata")
$data_states = load_data("Data/States.rxdata")
$data_animations = load_data("Data/Animations.rxdata")
$data_tilesets = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system = load_data("Data/System.rxdata")
# Make system object
$game_system = Game_System.new
# Make title graphic
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
# Make command window
s1 = "New Game"
s2 = "Continue"
s3 = "End Game"
s4 = "New Game [Special]"
@command_window = Window_Command.new(192, [s1, s2, s3, s4])
@command_window.back_opacity = 80
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 288
# Continue enabled determinant
# Check if at least one save file exists
# If enabled, make @continue_enabled true; if disabled, make it false
@continue_enabled = false
for i in 0..3
if FileTest.exist?("Save#{i+1}.rxdata")
@continue_enabled = true
end
end
# If continue is enabled, move cursor to "Continue"
# If disabled, display "Continue" text in gray
if @continue_enabled
@command_window.index = 1
else
@command_window.disable_item(1)
end
# Play title BGM
$game_system.bgm_play($data_system.title_bgm)
# Stop playing ME and BGS
Audio.me_stop
Audio.bgs_stop
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of command window
@command_window.dispose
# Dispose of title graphic
@sprite.bitmap.dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update command window
@command_window.update
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # New game
command_new_game
when 1 # Continue
command_continue
when 2 # Shutdown
command_shutdown
when 4 # New Game [Special]
command_new_game_special
end
end
end
#--------------------------------------------------------------------------
# * Command: New Game
#--------------------------------------------------------------------------
def command_new_game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Stop BGM
Audio.bgm_stop
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each type of game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up initial party
$game_party.setup_starting_members
# Set up initial map position
$game_map.setup($data_system.start_map_id)
# Move player to initial position
$game_player.moveto($data_system.start_x, $data_system.start_y)
# Refresh player
$game_player.refresh
# Run automatic change for BGM and BGS set with map
$game_map.autoplay
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * Command: Continue
#--------------------------------------------------------------------------
def command_continue
# If continue is disabled
unless @continue_enabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to load screen
$scene = Scene_Load.new
end
#--------------------------------------------------------------------------
# * Command: End Game
#--------------------------------------------------------------------------
def command_shutdown
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Fade out BGM, BGS, and ME
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# Shutdown Gameplay
$scene = nil
end
#--------------------------------------------------------------------------
# * Command: New Game [Special]
#--------------------------------------------------------------------------
def command_new_game_special
command_new_game
$game_party.setup_starting_members_sp
end
#--------------------------------------------------------------------------
# * Battle Test
#--------------------------------------------------------------------------
def battle_test
# Load database (for battle test)
$data_actors = load_data("Data/BT_Actors.rxdata")
$data_classes = load_data("Data/BT_Classes.rxdata")
$data_skills = load_data("Data/BT_Skills.rxdata")
$data_items = load_data("Data/BT_Items.rxdata")
$data_weapons = load_data("Data/BT_Weapons.rxdata")
$data_armors = load_data("Data/BT_Armors.rxdata")
$data_enemies = load_data("Data/BT_Enemies.rxdata")
$data_troops = load_data("Data/BT_Troops.rxdata")
$data_states = load_data("Data/BT_States.rxdata")
$data_animations = load_data("Data/BT_Animations.rxdata")
$data_tilesets = load_data("Data/BT_Tilesets.rxdata")
$data_common_events = load_data("Data/BT_CommonEvents.rxdata")
$data_system = load_data("Data/BT_System.rxdata")
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up party for battle test
$game_party.setup_battle_test_members
# Set troop ID, can escape flag, and battleback
$game_temp.battle_troop_id = $data_system.test_troop_id
$game_temp.battle_can_escape = true
$game_map.battleback_name = $data_system.battleback_name
# Play battle start SE
$game_system.se_play($data_system.battle_start_se)
# Play battle BGM
$game_system.bgm_play($game_system.battle_bgm)
# Switch to battle screen
$scene = Scene_Battle.new
end
end

Lenny
2007-08-23, 06:32 AM
Haven't the faintest idea about scripting, so an answer will have to wait until a scripter pops online.

But I will ask, "What is it you want to do, exactly?".

gamescripter
2007-08-24, 02:09 AM
How is New Game[Special] being created after you complete it or before and does it have a variable not being shown

gamescripter
2007-08-24, 02:13 AM
Whne its creating the "New Game" Special it isnt creating any map location, etc.. (look at new game) and what would you like this specail to be a new game + or just a harder version as either way you need to set the variables Game_Party etc to values if you want it to create a new game with specail conditions by modifying values such as:

$Game_Party = Game_Party_Special.New with "Game_Party_Special" being another class.

Hope that makes sense

Willkillforfood
2007-08-24, 09:41 AM
If you're in a more immediate need of an answer you can always try contacting WetWired and Mjordan2nd

!King_Amazon!
2007-08-24, 12:12 PM
I'm pretty sure this is some RPGmaker scripting or what have you, and I'm pretty sure neither Mjordan or WW know anything about it. Bluecube would be a better bet.

Lenny
2007-08-24, 02:17 PM
To be honest, I'm not sure about that. BlueCube is an absolute genius with everything RPGMakery... but not the scripting. At least, last time he posted about it he said he didn't know.

Atnas is a good bet for scripting.

BlueCube
2007-08-27, 04:55 AM
To be honest, I'm not sure about that. BlueCube is an absolute genius with everything RPGMakery... but not the scripting. At least, last time he posted about it he said he didn't know.

Atnas is a good bet for scripting.

Yeah, Ruby just has odd quirks that completely baffle me at this point - maybe one day it'll click. (For now, I'll stick with Perl, it's the language of the moment for me)

Goodlookinguy
2007-08-28, 09:17 AM
Before I had posted the other day I had done this gamescripter, and it didn't work. All I was doing was copying the exact data from a normal start, I am just trying to get it to work then I will apply things afterword.
#================================================= =============================
# ** Game_Party
#------------------------------------------------------------------------------
# This class handles the party. It includes information on amount of gold
# and items. Refer to "$game_party" for the instance of this class.
#================================================= =============================
class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :actors # actors
attr_reader :gold # amount of gold
attr_reader :steps # number of steps
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Create actor array
@actors = []
# Initialize amount of gold and steps
@gold = 0
@steps = 0
# Create amount in possession hash for items, weapons, and armor
@items = {}
@weapons = {}
@armors = {}
end
#--------------------------------------------------------------------------
# * Initial Party Setup
#--------------------------------------------------------------------------
def setup_starting_members
@actors = []
for i in $data_system.party_members
@actors.push($game_actors[i])
end
end
#--------------------------------------------------------------------------
# * Initial Party Setup Special
#--------------------------------------------------------------------------
def setup_starting_members_sp
@actors = []
for i in $data_system.party_members
@actors.push($game_actors[i])
end
end
#--------------------------------------------------------------------------
# * Battle Test Party Setup
#--------------------------------------------------------------------------
def setup_battle_test_members
@actors = []
for battler in $data_system.test_battlers
actor = $game_actors[battler.actor_id]
actor.level = battler.level
gain_weapon(battler.weapon_id, 1)
gain_armor(battler.armor1_id, 1)
gain_armor(battler.armor2_id, 1)
gain_armor(battler.armor3_id, 1)
gain_armor(battler.armor4_id, 1)
actor.equip(0, battler.weapon_id)
actor.equip(1, battler.armor1_id)
actor.equip(2, battler.armor2_id)
actor.equip(3, battler.armor3_id)
actor.equip(4, battler.armor4_id)
actor.recover_all
@actors.push(actor)
end
@items = {}
for i in 1...$data_items.size
if $data_items[i].name != ""
occasion = $data_items[i].occasion
if occasion == 0 or occasion == 1
@items[i] = 99
end
end
end
end
#--------------------------------------------------------------------------
# * Refresh Party Members
#--------------------------------------------------------------------------
def refresh
# Actor objects split from $game_actors right after loading game data
# Avoid this problem by resetting the actors each time data is loaded.
new_actors = []
for i in [email protected]
if $data_actors[@actors[i].id] != nil
new_actors.push($game_actors[@actors[i].id])
end
end
@actors = new_actors
end
#--------------------------------------------------------------------------
# * Getting Maximum Level
#--------------------------------------------------------------------------
def max_level
# If 0 members are in the party
if @actors.size == 0
return 0
end
# Initialize local variable: level
level = 0
# Get maximum level of party members
for actor in @actors
if level < actor.level
level = actor.level
end
end
return level
end
#--------------------------------------------------------------------------
# * Add an Actor
# actor_id : actor ID
#--------------------------------------------------------------------------
def add_actor(actor_id)
# Get actor
actor = $game_actors[actor_id]
# If the party has less than 4 members and this actor is not in the party
if @actors.size < 4 and not @actors.include?(actor)
# Add actor
@actors.push(actor)
# Refresh player
$game_player.refresh
end
end
#--------------------------------------------------------------------------
# * Remove Actor
# actor_id : actor ID
#--------------------------------------------------------------------------
def remove_actor(actor_id)
# Delete actor
@actors.delete($game_actors[actor_id])
# Refresh player
$game_player.refresh
end
#--------------------------------------------------------------------------
# * Gain Gold (or lose)
# n : amount of gold
#--------------------------------------------------------------------------
def gain_gold(n)
@gold = [[@gold + n, 0].max, 9999999].min
end
#--------------------------------------------------------------------------
# * Lose Gold
# n : amount of gold
#--------------------------------------------------------------------------
def lose_gold(n)
# Reverse the numerical value and call it gain_gold
gain_gold(-n)
end
#--------------------------------------------------------------------------
# * Increase Steps
#--------------------------------------------------------------------------
def increase_steps
@steps = [@steps + 1, 9999999].min
end
#--------------------------------------------------------------------------
# * Get Number of Items Possessed
# item_id : item ID
#--------------------------------------------------------------------------
def item_number(item_id)
# If quantity data is in the hash, use it. If not, return 0
return @items.include?(item_id) ? @items[item_id] : 0
end
#--------------------------------------------------------------------------
# * Get Number of Weapons Possessed
# weapon_id : weapon ID
#--------------------------------------------------------------------------
def weapon_number(weapon_id)
# If quantity data is in the hash, use it. If not, return 0
return @weapons.include?(weapon_id) ? @weapons[weapon_id] : 0
end
#--------------------------------------------------------------------------
# * Get Amount of Armor Possessed
# armor_id : armor ID
#--------------------------------------------------------------------------
def armor_number(armor_id)
# If quantity data is in the hash, use it. If not, return 0
return @armors.include?(armor_id) ? @armors[armor_id] : 0
end
#--------------------------------------------------------------------------
# * Gain Items (or lose)
# item_id : item ID
# n : quantity
#--------------------------------------------------------------------------
def gain_item(item_id, n)
# Update quantity data in the hash.
if item_id > 0
@items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
end
end
#--------------------------------------------------------------------------
# * Gain Weapons (or lose)
# weapon_id : weapon ID
# n : quantity
#--------------------------------------------------------------------------
def gain_weapon(weapon_id, n)
# Update quantity data in the hash.
if weapon_id > 0
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
end
end
#--------------------------------------------------------------------------
# * Gain Armor (or lose)
# armor_id : armor ID
# n : quantity
#--------------------------------------------------------------------------
def gain_armor(armor_id, n)
# Update quantity data in the hash.
if armor_id > 0
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
end
end
#--------------------------------------------------------------------------
# * Lose Items
# item_id : item ID
# n : quantity
#--------------------------------------------------------------------------
def lose_item(item_id, n)
# Reverse the numerical value and call it gain_item
gain_item(item_id, -n)
end
#--------------------------------------------------------------------------
# * Lose Weapons
# weapon_id : weapon ID
# n : quantity
#--------------------------------------------------------------------------
def lose_weapon(weapon_id, n)
# Reverse the numerical value and call it gain_weapon
gain_weapon(weapon_id, -n)
end
#--------------------------------------------------------------------------
# * Lose Armor
# armor_id : armor ID
# n : quantity
#--------------------------------------------------------------------------
def lose_armor(armor_id, n)
# Reverse the numerical value and call it gain_armor
gain_armor(armor_id, -n)
end
#--------------------------------------------------------------------------
# * Determine if Item is Usable
# item_id : item ID
#--------------------------------------------------------------------------
def item_can_use?(item_id)
# If item quantity is 0
if item_number(item_id) == 0
# Unusable
return false
end
# Get usable time
occasion = $data_items[item_id].occasion
# If in battle
if $game_temp.in_battle
# If useable time is 0 (normal) or 1 (only battle) it's usable
return (occasion == 0 or occasion == 1)
end
# If useable time is 0 (normal) or 2 (only menu) it's usable
return (occasion == 0 or occasion == 2)
end
#--------------------------------------------------------------------------
# * Clear All Member Actions
#--------------------------------------------------------------------------
def clear_actions
# Clear All Member Actions
for actor in @actors
actor.current_action.clear
end
end
#--------------------------------------------------------------------------
# * Determine if Command is Inputable
#--------------------------------------------------------------------------
def inputable?
# Return true if input is possible for one person as well
for actor in @actors
if actor.inputable?
return true
end
end
return false
end
#--------------------------------------------------------------------------
# * Determine Everyone is Dead
#--------------------------------------------------------------------------
def all_dead?
# If number of party members is 0
if $game_party.actors.size == 0
return false
end
# If an actor is in the party with 0 or more HP
for actor in @actors
if actor.hp > 0
return false
end
end
# All members dead
return true
end
#--------------------------------------------------------------------------
# * Slip Damage Check (for map)
#--------------------------------------------------------------------------
def check_map_slip_damage
for actor in @actors
if actor.hp > 0 and actor.slip_damage?
actor.hp -= [actor.maxhp / 100, 1].max
if actor.hp == 0
$game_system.se_play($data_system.actor_collapse_s e)
end
$game_screen.start_flash(Color.new(255,0,0,128), 4)
$game_temp.gameover = $game_party.all_dead?
end
end
end
#--------------------------------------------------------------------------
# * Random Selection of Target Actor
# hp0 : limited to actors with 0 HP
#--------------------------------------------------------------------------
def random_target_actor(hp0 = false)
# Initialize roulette
roulette = []
# Loop
for actor in @actors
# If it fits the conditions
if (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
# Get actor class [position]
position = $data_classes[actor.class_id].position
# Front guard: n = 4; Mid guard: n = 3; Rear guard: n = 2
n = 4 - position
# Add actor to roulette n times
n.times do
roulette.push(actor)
end
end
end
# If roulette size is 0
if roulette.size == 0
return nil
end
# Spin the roulette, choose an actor
return roulette[rand(roulette.size)]
end
#--------------------------------------------------------------------------
# * Random Selection of Target Actor (HP 0)
#--------------------------------------------------------------------------
def random_target_actor_hp0
return random_target_actor(true)
end
#--------------------------------------------------------------------------
# * Smooth Selection of Target Actor
# actor_index : actor index
#--------------------------------------------------------------------------
def smooth_target_actor(actor_index)
# Get an actor
actor = @actors[actor_index]
# If an actor exists
if actor != nil and actor.exist?
return actor
end
# Loop
for actor in @actors
# If an actor exists
if actor.exist?
return actor
end
end
end
end