Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

I think i need a script :)

Kyubi

Member

ok...i want to create Good/Evil System like in FABLE THE LOST CHAPTERS...and i think it can be done with events only...but i need a script...to see how much Good/Evil i have...here is what i did...this is for boss...im just testin it on blob..

http://i140.photobucket.com/albums/r7/G ... led-22.jpg[/img]

this is when hp is 90% or below...in troops....well...later i would have to ...when Good/Evil is -50% i look evil (change battler and sprite) and when its 50% i look like good guy :D

but i really cant do anything...with this...if i cant see how much i have...so pls write me a script for this...like...when i press esc i can see it like money...or in corner while im playing...i didnt found this system anywhere on forum...so i wanted to make one for me....i tried with events but i need scripting also..and i dont know that...
 
I think you can do this with a common event. Just make a conditional branch:
If Good/Evil is greater than or equal to 50, change actor graphic to whatever and if it is below 50 change actor graphic to an evil one.
 

Kyubi

Member

i know that :)) i need when ppl play game...that they can see how much Evil/Good they have ... if -Number ...then they are evil...if 0 then they are not evil or good..they are normal...and when its number+ ther are good...but i need ppl to see it how much they have that...you know...create new box where it says...how much u have...like money :D
 

OS

Sponsor

This isn't exactly what you want, I don't think, but it will show you your Good/Evil (called Align). If your Align is below 0, you are evil, if your align is above 0, you are good.
Code:
class Game_Align
  ALIGN = 1 #Variable ID of the Alignment
  def initialize
    @align = $game_variables[ALIGN]
  end
  
  def align?
    @align = $game_variables[ALIGN]
    return @align
  end
  
  def print_align
    @align = $game_variables[ALIGN]
    if @align > 0
      align_string = "Good"
    elsif @align < 0
      align_string = "Evil"
    elsif @align == 0
      align_string = "Neutral"
    end
    print "Alignment: " + @align.to_s + ". You are " + align_string + "."
  end
end

class Scene_Map
  def update
    # Loop
    loop do
      # Update map, interpreter, and player order
      # (this update order is important for when conditions are fulfilled 
      # to run any event, and the player isn't provided the opportunity to
      # move in an instant)
      $game_map.update
      $game_system.map_interpreter.update
      $game_player.update
      # Update system (timer), screen
      $game_system.update
      $game_screen.update
      # Abort loop if player isn't place moving
      unless $game_temp.player_transferring
        break
      end
      # Run place move
      transfer_player
      # Abort loop if transition processing
      if $game_temp.transition_processing
        break
      end
    end
    # Update sprite set
    @spriteset.update
    # Update message window
    @message_window.update
    # If game over
    if $game_temp.gameover
      # Switch to game over screen
      $scene = Scene_Gameover.new
      return
    end
    # If returning to title screen
    if $game_temp.to_title
      # Change to title screen
      $scene = Scene_Title.new
      return
    end
    # If transition processing
    if $game_temp.transition_processing
      # Clear transition processing flag
      $game_temp.transition_processing = false
      # Execute transition
      if $game_temp.transition_name == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
          $game_temp.transition_name)
      end
    end
    # If showing message window
    if $game_temp.message_window_showing
      return
    end
    # If encounter list isn't empty, and encounter count is 0
    if $game_player.encounter_count == 0 and $game_map.encounter_list != []
      # If event is running or encounter is not forbidden
      unless $game_system.map_interpreter.running? or
             $game_system.encounter_disabled
        # Confirm troop
        n = rand($game_map.encounter_list.size)
        troop_id = $game_map.encounter_list[n]
        # If troop is valid
        if $data_troops[troop_id] != nil
          # Set battle calling flag
          $game_temp.battle_calling = true
          $game_temp.battle_troop_id = troop_id
          $game_temp.battle_can_escape = true
          $game_temp.battle_can_lose = false
          $game_temp.battle_proc = nil
        end
      end
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # If event is running, or menu is not forbidden
      unless $game_system.map_interpreter.running? or
             $game_system.menu_disabled
        # Set menu calling flag or beep flag
        $game_temp.menu_calling = true
        $game_temp.menu_beep = true
      end
    end
    # See Align+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    if Input.trigger?(Input::A)
      $game_align.print_align
    end
    # If debug mode is ON and F9 key was pressed
    if $DEBUG and Input.press?(Input::F9)
      # Set debug calling flag
      $game_temp.debug_calling = true
    end
    # If player is not moving
    unless $game_player.moving?
      # Run calling of each screen
      if $game_temp.battle_calling
        call_battle
      elsif $game_temp.shop_calling
        call_shop
      elsif $game_temp.name_calling
        call_name
      elsif $game_temp.menu_calling
        call_menu
      elsif $game_temp.save_calling
        call_save
      elsif $game_temp.debug_calling
        call_debug
      end
    end
  end
end

class Scene_Title
  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
    $game_align         = Game_Align.new #Added=================================
    # 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
end
To use it:

Change ALIGN to the Variable ID you want to use. Then name that variable Align or Good/Evil, whatever. When you want to be good, add to the variable, and when you want to be evil, subtract from the variable.

You must press Shift to see your current Alignment. It also tells you if you are good or evil.

Peace!

EDIT:
You can display the value in a message box by putting \v[ID] in the Messege window.
Just make a common event that makes a window pop up when the player press SHIFT or something. The window would pretty much say the same thing my script does. So it would need some conditional branches. Hope this helps!

Peace^2!
 

Kyubi

Member

umm...i tried this now...but it looks ugly...u now...its like error lol...i need to be ...al the time ... when i play game to be in croner little box...where it says Good/Evil and unde that number from -100 to 100 ... (at start 0 ofcourse...) and when i do thing (that i set up) like kill someone in town i get -Number (evil) and if i save someone ...or spare enemy....i get +Number (good)

EDIT:and box to be like my windowskin
 

OS

Sponsor

Alright! I've done it. You will now see a window in the top left corner that says Align: and the alignment.

Place both scripts above Main, and below everything else.
Code:
class Window_Align < Window_Base
  ALIGN = 1
  def initialize
    super(0, 0, 32*3, 32*2)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  def refresh
    self.contents.clear
    reset_variables
    return if $game_align.align? == nil
    self.contents.draw_text(0, 0, 32*2, 32, "Align: " + @align.to_s + ".")
  end
  def reset_variables
    @align = $game_variables[ALIGN]
  end
  def update
    super
    refresh if @align != $game_variables[ALIGN]
  end
end

class Scene_Map
  alias brkn_main main
  alias brkn_update_hud update
  def main
    @window_align = Window_Align.new
    brkn_main
    @window_align.dispose
  end
  def update
    @window_align.update
    brkn_update_hud
  end
end

Replace the first script I posted with the one below:
Code:
class Game_Align
  ALIGN = 1 #Variable ID of the Alignment
  def initialize
    @align = $game_variables[ALIGN]
    @show = true
  end
  
  def align?
    @align = $game_variables[ALIGN]
    return @align
  end
  
  def show?
    return @show
  end
  
  def show=(bool)
    @show = bool
  end
  
  def print_align
    @align = $game_variables[ALIGN]
    if @align > 0
      align_string = "Good"
    elsif @align < 0
      align_string = "Evil"
    elsif @align == 0
      align_string = "Neutral"
    end
    print "Alignment: " + @align.to_s + ". You are " + align_string + "."
  end
end

class Scene_Map
  def update
    # Loop
    loop do
      # Update map, interpreter, and player order
      # (this update order is important for when conditions are fulfilled 
      # to run any event, and the player isn't provided the opportunity to
      # move in an instant)
      $game_map.update
      $game_system.map_interpreter.update
      $game_player.update
      # Update system (timer), screen
      $game_system.update
      $game_screen.update
      # Abort loop if player isn't place moving
      unless $game_temp.player_transferring
        break
      end
      # Run place move
      transfer_player
      # Abort loop if transition processing
      if $game_temp.transition_processing
        break
      end
    end
    # Update sprite set
    @spriteset.update
    # Update message window
    @message_window.update
    # If game over
    if $game_temp.gameover
      # Switch to game over screen
      $scene = Scene_Gameover.new
      return
    end
    # If returning to title screen
    if $game_temp.to_title
      # Change to title screen
      $scene = Scene_Title.new
      return
    end
    # If transition processing
    if $game_temp.transition_processing
      # Clear transition processing flag
      $game_temp.transition_processing = false
      # Execute transition
      if $game_temp.transition_name == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
          $game_temp.transition_name)
      end
    end
    # If showing message window
    if $game_temp.message_window_showing
      return
    end
    # If encounter list isn't empty, and encounter count is 0
    if $game_player.encounter_count == 0 and $game_map.encounter_list != []
      # If event is running or encounter is not forbidden
      unless $game_system.map_interpreter.running? or
             $game_system.encounter_disabled
        # Confirm troop
        n = rand($game_map.encounter_list.size)
        troop_id = $game_map.encounter_list[n]
        # If troop is valid
        if $data_troops[troop_id] != nil
          # Set battle calling flag
          $game_temp.battle_calling = true
          $game_temp.battle_troop_id = troop_id
          $game_temp.battle_can_escape = true
          $game_temp.battle_can_lose = false
          $game_temp.battle_proc = nil
        end
      end
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # If event is running, or menu is not forbidden
      unless $game_system.map_interpreter.running? or
             $game_system.menu_disabled
        # Set menu calling flag or beep flag
        $game_temp.menu_calling = true
        $game_temp.menu_beep = true
      end
    end
    # See Align+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    if Input.trigger?(Input::A)
      $game_align.print_align
    end
    # If debug mode is ON and F9 key was pressed
    if $DEBUG and Input.press?(Input::F9)
      # Set debug calling flag
      $game_temp.debug_calling = true
    end
    # If player is not moving
    unless $game_player.moving?
      # Run calling of each screen
      if $game_temp.battle_calling
        call_battle
      elsif $game_temp.shop_calling
        call_shop
      elsif $game_temp.name_calling
        call_name
      elsif $game_temp.menu_calling
        call_menu
      elsif $game_temp.save_calling
        call_save
      elsif $game_temp.debug_calling
        call_debug
      end
    end
  end
end

class Scene_Title
  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
    $game_align         = Game_Align.new #Added=================================
    # 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
end

Both scripts have an ALIGN constant. Theymust both be the same if you want the script to work right.

Peace!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top