Save-Point

Full Version: Save-Point
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Board Message
Sorry, you do not have permission to access this resource.
Save-Point - have the player respawn at a set location after death in random battle

Save-Point

Full Version: have the player respawn at a set location after death in random battle
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
hello everyone what I would like for my game is to have a machine which re-spawns the player if he dies in certain rooms and I would like to have it switch activated. so if someone could write a script which says if the player dies in room A and switch 1 is on he will be teleported to room B with 1 health.
also if you could write a second version which also changes character aswell I would be super grateful thanks in advance everyone
This can be done with scripts and conditional modifiers... if we're not dealing with reandom troops...

If dealing with actual events that create battle Processing, simply click the box of Continue if Lost, and then call the common event that corresponds to the switch involved.
Switch 1, call common Event for Switch 1, change HP to 1% or 1, and spawn player in Map X with X and Y coordinates.
Switch 2, Call common event for switch 2, change HP to 1% or 1, and spawn player in Map Z with X and Y coordinates,
etcetera...

If you are dealing with random troops, the troop itself has conditional modifiers that can act in battle span during the entire battle, in case of player death or KNOCKOUT state, and that can activate certains wtichs which can activate certain common events.

But with that said, if you still want a long script, someone may have your answer here.
I didn't know you could activate switches in random battles using the troops tab in database anyway that still did not work I tried setting the trigger as the player having 0% or less health and if the player died it still went to game over so instead i tried to create a parallel common event and that did not work if the player dies it always goes to gameover. and I am afraid it has to be random battles the FPLE engine I use crashes if the player touches other moving events in fps mode
[Image: 9ebc60da70cfba466bc535706e717bf3.png]
This didn't work?
nope I hate to ask a stupid question but if it is activated by the actors health being 0% or lower why do you need the switch is the switch activated by a common event? something like this
[Image: help_common.png]
well, here's the kicker on that... usually the common events only work for me from Scene_Map. You want something that takes charge during scene_battle (from random troops) right? The switch would be activated form a common event that changes switches PER map, as you had requested...

If player map ID is yadayada, then the switch 14 on and all the rest off...
That way, depending on the troop, you can place conditionals for each switch, so that...

If ghost kills player on Map 3, Player instead gets respawned on map 5...
If ghost kills player on Map 2, Player instead gets reppawned on map 3

If clown killed player on Map 2, Player spawns at Map 5


If emeny battle processing was form map then of course, you can use this, but it appeared you were wanting this from the scene_battle



EDIT: I'll work on an event system tonight, to see how that works out...
Thanks I appreciate any help you can give.
alternatively, to ensure that you don't go to Scene-End you can also just remove the Scene=Scene_end portion of your Scene Battle, so that it's FORCED to register that actor hitpoints had reached 0.
You can try this :

First, find script scene_battle 1, then find line def judge, right below it, delele
Code:
if $game_temp.battle_can_lose
, and then go below it, delete 1 line
Code:
end
.
Then, still in script scene_battle 1, scroll down, find line
Code:
def battle_end(result)
, in this def, find line
Code:
$scene = Scene_Map.new
, and right below it, paste this code:
Code:
if $game_party.all_dead?
   for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      actor.hp = actor.maxhp
   end
   value = $game_party.gold
   $game_party.gain_gold(-value/2)
   $game_map.setup($game_variables[1])
   $game_player.moveto($game_variables[2], $game_variables[3])
end

From now on, when you come to a town/city, let's active an event, in this event we'll use control variables commands, and create 3 variables like this:
variable id 1 = id of the map of this town/city (or INN in this town/city)
variable id 2 = X of that map
variable id 3 = Y of that map

Done, when you die in a random battle, you will be revived in the last town/city you already traveled, recover 100% HP and lose 50% gold.

PS: not work for event "battle progressing" command, if use that event, you should use option "continue even if lose" and use teleport command by yourself.
I'm sorry I may of done it wrong but i still seem to be getting the game over screen.
Code:
#==============================================================================
# ** Scene_Battle (part 1)
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Initialize each kind of temporary battle data
    $game_temp.in_battle = true
    $game_temp.battle_turn = 0
    $game_temp.battle_event_flags.clear
    $game_temp.battle_abort = false
    $game_temp.battle_main_phase = false
    $game_temp.battleback_name = $game_map.battleback_name
    $game_temp.forcing_battler = nil
    # Initialize battle event interpreter
    $game_system.battle_interpreter.setup(nil, 0)
    # Prepare troop
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)
    # Make actor command window
    s1 = $data_system.words.attack
    s2 = $data_system.words.skill
    s3 = $data_system.words.guard
    s4 = $data_system.words.item
    @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
    @actor_command_window.y = 160
    @actor_command_window.back_opacity = 160
    @actor_command_window.active = false
    @actor_command_window.visible = false
    # Make other windows
    @party_command_window = Window_PartyCommand.new
    @help_window = Window_Help.new
    @help_window.back_opacity = 160
    @help_window.visible = false
    @status_window = Window_BattleStatus.new
    @yourhud = Window_YourHUD.new
    @message_window = Window_Message.new
    # Make sprite set
    @spriteset = Spriteset_Battle.new
    # Initialize wait count
    @wait_count = 0
    # Execute transition
    if $data_system.battle_transition == ""
      Graphics.transition(20)
    else
      Graphics.transition(40, "Graphics/Transitions/" +
        $data_system.battle_transition)
    end
    # Start pre-battle phase
    start_phase1
    # 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
    # Refresh map
    $game_map.refresh
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @actor_command_window.dispose
    @party_command_window.dispose
    @help_window.dispose
    @status_window.dispose
    @yourhud.dispose
    @message_window.dispose
    if @skill_window != nil
      @skill_window.dispose
    end
    if @item_window != nil
      @item_window.dispose
    end
    if @result_window != nil
      @result_window.dispose
    end
    # Dispose of sprite set
    @spriteset.dispose
    # If switching to title screen
    if $scene.is_a?(Scene_Title)
      # Fade out screen
      Graphics.transition
      Graphics.freeze
    end
    # If switching from battle test to any screen other than game over screen
    if $BTEST and not $scene.is_a?(Scene_Gameover)
      $scene = nil
    end
  end
  #--------------------------------------------------------------------------
  # * Determine Battle Win/Loss Results
  #--------------------------------------------------------------------------
  def judge
    # If all dead determinant is true, or number of members in party is 0
    if $game_party.all_dead? or $game_party.actors.size == 0
      # If possible to lose
        # Return to BGM before battle starts
        $game_system.bgm_play($game_temp.map_bgm)
        # Battle ends
        battle_end(2)
        # Return true
        return true
      # Set game over flag
      $game_temp.gameover = true
      # Return true
      return true
    end
    # Return false if even 1 enemy exists
    for enemy in $game_troop.enemies
      if enemy.exist?
        return false
      end
    end
    # Start after battle phase (win)
    start_phase5
    # Return true
    return true
  end
  #--------------------------------------------------------------------------
  # * Battle Ends
  #     result : results (0:win 1:lose 2:escape)
  #--------------------------------------------------------------------------
  def battle_end(result)
    # Clear in battle flag
    $game_temp.in_battle = false
    # Clear entire party actions flag
    $game_party.clear_actions
    # Remove battle states
    for actor in $game_party.actors
      actor.remove_states_battle
    end
    # Clear enemies
    $game_troop.enemies.clear
    # my picture erase edit
    for i in 1..100
    $game_screen.pictures[i].erase
    end
    # Call battle callback
    if $game_temp.battle_proc != nil
      $game_temp.battle_proc.call(result)
      $game_temp.battle_proc = nil
    end
    # Switch to map screen
    $scene = Scene_Map.new
    if $game_party.all_dead?
   for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      actor.hp = actor.maxhp
   end
   value = $game_party.gold
   $game_party.gain_gold(-value/2)
   if $game_map.map_id != $game_temp.player_new_map_id
      $game_map.setup($game_variables[29])
   end
   $game_player.moveto($game_variables[30], $game_variables[31])
end
  end
  #--------------------------------------------------------------------------
  # * Battle Event Setup
  #--------------------------------------------------------------------------
  def setup_battle_event
    # If battle event is running
    if $game_system.battle_interpreter.running?
      return
    end
    # Search for all battle event pages
    for index in 0...$data_troops[@troop_id].pages.size
      # Get event pages
      page = $data_troops[@troop_id].pages[index]
      # Make event conditions possible for reference with c
      c = page.condition
      # Go to next page if no conditions are appointed
      unless c.turn_valid or c.enemy_valid or
             c.actor_valid or c.switch_valid
        next
      end
      # Go to next page if action has been completed
      if $game_temp.battle_event_flags[index]
        next
      end
      # Confirm turn conditions
      if c.turn_valid
        n = $game_temp.battle_turn
        a = c.turn_a
        b = c.turn_b
        if (b == 0 and n != a) or
           (b > 0 and (n < 1 or n < a or n % b != a % b))
          next
        end
      end
      # Confirm enemy conditions
      if c.enemy_valid
        enemy = $game_troop.enemies[c.enemy_index]
        if enemy == nil or enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp
          next
        end
      end
      # Confirm actor conditions
      if c.actor_valid
        actor = $game_actors[c.actor_id]
        if actor == nil or actor.hp * 100.0 / actor.maxhp > c.actor_hp
          next
        end
      end
      # Confirm switch conditions
      if c.switch_valid
        if $game_switches[c.switch_id] == false
          next
        end
      end
      # Set up event
      $game_system.battle_interpreter.setup(page.list, 0)
      # If this page span is [battle] or [turn]
      if page.span <= 1
        # Set action completed flag
        $game_temp.battle_event_flags[index] = true
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # If battle event is running
    if $game_system.battle_interpreter.running?
      # Update interpreter
      $game_system.battle_interpreter.update
      # If a battler which is forcing actions doesn't exist
      if $game_temp.forcing_battler == nil
        # If battle event has finished running
        unless $game_system.battle_interpreter.running?
          # Rerun battle event set up if battle continues
          unless judge
            setup_battle_event
          end
        end
        # If not after battle phase
        if @phase != 5
          # Refresh status window
          @status_window.refresh
          @yourhud.refresh
        end
      end
    end
    # Update system (timer) and screen
    $game_system.update
    $game_screen.update
    # If timer has reached 0
    if $game_system.timer_working and $game_system.timer == 0
      # Abort battle
      $game_temp.battle_abort = true
    end
    # Update windows
    @help_window.update
    @party_command_window.update
    @actor_command_window.update
    @status_window.update
    @yourhud.update
    @message_window.update
    # Update sprite set
    @spriteset.update
    # If transition is 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 message window is showing
    if $game_temp.message_window_showing
      return
    end
    # If effect is showing
    if @spriteset.effect?
      return
    end
    # 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
      # Switch to title screen
      $scene = Scene_Title.new
      return
    end
    # If battle is aborted
    if $game_temp.battle_abort
      # Return to BGM used before battle started
      $game_system.bgm_play($game_temp.map_bgm)
      # Battle ends
      battle_end(1)
      return
    end
    # If waiting
    if @wait_count > 0
      # Decrease wait count
      @wait_count -= 1
      return
    end
    # If battler forcing an action doesn't exist,
    # and battle event is running
    if $game_temp.forcing_battler == nil and
       $game_system.battle_interpreter.running?
      return
    end
    # Branch according to phase
    case @phase
    when 1  # pre-battle phase
      update_phase1
    when 2  # party command phase
      update_phase2
    when 3  # actor command phase
      update_phase3
    when 4  # main phase
      update_phase4
    when 5  # after battle phase
      update_phase5
    end
  end
end

Also would it be possible to make it so you only re-spawn if a switch is on? I want it to be In my game that there are re-spawn bays if you turn it on you reappear there but if you die without turning the machine on then you just go to the game over screen.
Pages: 1 2