The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: blueXx on December 08, 2005, 11:42:19 AM

Title: i am too young to die, and so are you- deathless script!!
Post by: blueXx on December 08, 2005, 11:42:19 AM
this script was made by me blablabla, credits to me and such.
for as far as i tested it , it works perfectly, if it doesn't for you, please let me know.

what does the script do:
the script will cancel the effect of dying after a normal battle however it will still allow death from the "gameover" line
it will also drain exp and gold from the heroes upon losing judging by the amount of gold the enemy should drop and by the exp the heroes got atm.
after that it will send you to a map of your choice and a spot of your choice in it (set it in the script, i wrote inside it in green where to change what)
from there it's up to you to send the hero elsewhere.
in the demo i made i sent the hero to a map called "angel of death" he removed the death status (don't forget to do it ) and reducded the sp to 0 and then sent you to the inn you "saved" in (you can check out the saving in the demo by opening it in editing mode)

ok now for the script:
replace the script "Scene_Battle 1" with this one:
#==============================================================================
# ? Scene_Battle (???? 1)
#------------------------------------------------------------------------------
# edited by bluexx , when you die in a normal battle you will now lose exp and gold
# and you will be sent to a map of your choice (such as the angel of death, and from there to an inn)
#==============================================================================

class Scene_Battle
 #--------------------------------------------------------------------------
 # ? ?????
 #--------------------------------------------------------------------------
 def main
   # ???????????????
   $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
   # ??????????????????
   $game_system.battle_interpreter.setup(nil, 0)
   # ???????
   @troop_id = $game_temp.battle_troop_id
   $game_troop.setup(@troop_id)
   # ????????????????
   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
   # ????????????
   @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
   @message_window = Window_Message.new
   # ???????????
   @spriteset = Spriteset_Battle.new
   # ????????????
   @wait_count = 0
   # ?????????
   if $data_system.battle_transition == ""
     Graphics.transition(20)
   else
     Graphics.transition(40, "Graphics/Transitions/" +
       $data_system.battle_transition)
   end
   # ???????????
   start_phase1
   # ??????
   loop do
     # ????????
     Graphics.update
     # ???????
     Input.update
     # ??????
     update
     # ????????????????
     if $scene != self
       break
     end
   end
   # ??????????
   $game_map.refresh
   # ?????????
   Graphics.freeze
   # ????????
   @actor_command_window.dispose
   @party_command_window.dispose
   @help_window.dispose
   @status_window.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
   # ???????????
   @spriteset.dispose
   # ???????????????
   if $scene.is_a?(Scene_Title)
     # ??????????
     Graphics.transition
     Graphics.freeze
   end
   # ???????????????????????????
   if $BTEST and not $scene.is_a?(Scene_Gameover)
     $scene = nil
   end
 end
 #--------------------------------------------------------------------------
 # ? ????
 #--------------------------------------------------------------------------
 def judge
  if $game_party.all_dead? or $game_party.actors.size == 0
        if $game_temp.battle_can_lose
       # ??????? BGM ???
       $game_system.bgm_play($game_temp.map_bgm)
       # ?????
       battle_end(2)
       # true ???
       return true
     end
   @phase = 6
  $game_system.me_play($data_system.gameover_me)
   $game_system.bgm_play($game_temp.map_bgm)
   exp = 0
   gold = 0
   treasures = []
   for i in 0...$game_party.actors.size
     actor = $game_party.actors[i]
       last_level = actor.level
#set the amount of exp you want the hero to lose here:
       actor.exp -= actor.exp/30
       if actor.level > last_level
         @status_window.level_up(i)
       end
     end
   for enemy in $game_troop.enemies
     unless enemy.hidden
#set the amount of gold you want the hero to lose here: (amount per enemy)
      gold -= enemy.gold*3
     end
   end
   $game_party.gain_gold(gold)
   @result_window = Window_BattleLose.new
   @phase6_wait_count = 40
 end
   def update_phase6
   if @phase6_wait_count > 0
     @phase6_wait_count -= 1
     if @phase6_wait_count == 0
       @result_window.visible = true
       $game_temp.battle_main_phase = false
       @status_window.refresh
     end
     return
   end
#set the map id of "the angel of death" here:
   $game_map.setup(2)
#set the postion (x,y) in that map here:
   $game_player.moveto(10, 10)
   $game_player.straighten
   $game_map.update
   if Input.trigger?(Input::C)
     battle_end(0)
   end
 return true
end
   for enemy in $game_troop.enemies
     if enemy.exist?
       return false
     end
   end
   # ????????????? (??)
   start_phase5
   # true ???
   return true
 end
 #--------------------------------------------------------------------------
 # ? ?????
 #     result : ?? (0:?? 1:?? 2:??)
 #--------------------------------------------------------------------------
 def battle_end(result)
   # ??????????
   $game_temp.in_battle = false
   # ????????????????
   $game_party.clear_actions
   # ???????????
   for actor in $game_party.actors
     actor.remove_states_battle
   end
   # ????????
   $game_troop.enemies.clear
   # ??? ?????????
   if $game_temp.battle_proc != nil
     $game_temp.battle_proc.call(result)
     $game_temp.battle_proc = nil
   end
   # ??????????
   $scene = Scene_Map.new
 end
 #--------------------------------------------------------------------------
 # ? ??????????????
 #--------------------------------------------------------------------------
 def setup_battle_event
   # ?????????????
   if $game_system.battle_interpreter.running?
     return
   end
   # ???????????????
   for index in 0...$data_troops[@troop_id].pages.size
     # ??????????
     page = $data_troops[@troop_id].pages[index]
     # ??????? c ??????
     c = page.condition
     # ??????????????????????
     unless c.turn_valid or c.enemy_valid or
            c.actor_valid or c.switch_valid
       next
     end
     # ??????????????
     if $game_temp.battle_event_flags[index]
       next
     end
     # ??? ????
     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
     # ???? ????
     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
     # ???? ????
     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
     # ???? ????
     if c.switch_valid
       if $game_switches[c.switch_id] == false
         next
       end
     end
     # ???????????
     $game_system.battle_interpreter.setup(page.list, 0)
     # ?????????? [???] ? [???] ???
     if page.span <= 1
       # ???????????
       $game_temp.battle_event_flags[index] = true
     end
     return
   end
 end
 #--------------------------------------------------------------------------
 # ? ??????
 #--------------------------------------------------------------------------
 def update
   # ?????????????
   if $game_system.battle_interpreter.running?
     # ?????????
     $game_system.battle_interpreter.update
     # ?????????????????????????
     if $game_temp.forcing_battler == nil
       # ?????????????????
       unless $game_system.battle_interpreter.running?
         # ??????????????????????????
         unless judge
           setup_battle_event
         end
       end
       # ????????????????
       if @phase != 5
         # ?????????????????
         @status_window.refresh
       end
     end
   end
   # ???? (????)??????
   $game_system.update
   $game_screen.update
   # ????? 0 ??????
   if $game_system.timer_working and $game_system.timer == 0
     # ?????
     $game_temp.battle_abort = true
   end
   # ????????
   @help_window.update
   @party_command_window.update
   @actor_command_window.update
   @status_window.update
   @message_window.update
   # ???????????
   @spriteset.update
   # ?????????????
   if $game_temp.transition_processing
     # ?????????????????
     $game_temp.transition_processing = false
     # ?????????
     if $game_temp.transition_name == ""
       Graphics.transition(20)
     else
       Graphics.transition(40, "Graphics/Transitions/" +
         $game_temp.transition_name)
     end
   end
   # ????????????????
   if $game_temp.message_window_showing
     return
   end
   # ???????????
   if @spriteset.effect?
     return
   end
   # ??????????
   if $game_temp.gameover
     # ??????????????
     $scene = Scene_Gameover.new
     return
   end
   # ???????????
   if $game_temp.to_title
     # ???????????
     $scene = Scene_Title.new
     return
   end
   # ????????
   if $game_temp.battle_abort
     # ??????? BGM ???
     $game_system.bgm_play($game_temp.map_bgm)
     # ?????
     battle_end(1)
     return
   end
   # ????????
   if @wait_count > 0
     # ????????????
     @wait_count -= 1
     return
   end
   # ???????????????????????
   # ????????????????
   if $game_temp.forcing_battler == nil and
      $game_system.battle_interpreter.running?
     return
   end
   # ??????????
   case @phase
   when 1  # ?????????
     update_phase1
   when 2  # ????????????
     update_phase2
   when 3  # ????????????
     update_phase3
   when 4  # ???????
     update_phase4
   when 5  # ???????????
     update_phase5
   when 6
     update_phase6
   end
 end
end



after that, under the script "Window_BattleResult" it's important you'll put it right there and not just above main
(actually you can put it anywhere for as long as it's above the other scene_battle1 script, but you get the point, i hope)

make a new script and call it "WindowBattleLose"
and put this in it:
#==============================================================================
# ? Window_BattleResult
#------------------------------------------------------------------------------
# made by bluexx
#==============================================================================

class Window_BattleLose < Window_Base
 #--------------------------------------------------------------------------
 # this is a part of the "losing exp + gold upon losing a battle" script
 #    
 #    made by bluexx
 #    
 #--------------------------------------------------------------------------
 def initialize
   super(80, 304, 480, 160)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.contents.font.name = $defaultfonttype  # "Battle Result" window font
   self.contents.font.size = $defaultfontsize
   self.y = 160 - height / 2
   self.back_opacity = 160
   self.visible = false
   refresh
 end
 #--------------------------------------------------------------------------
 # ? ??????
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   self.contents.font.color = system_color
   cx = contents.text_size("You lost the fight").width
   self.contents.draw_text(x, 0, 130, 70, "You lost the fight")
   self.contents.font.color = system_color
   cx = contents.text_size("now you shall meet the angel of death").width
   self.contents.draw_text(x, 20, 250, 70, "now you shall meet the angel of death")
   cx = contents.text_size("your heroes lost some exp and gold").width
   self.contents.draw_text(x, 40, 250, 70, "your heroes lost some exp and gold")
   end
 end


feel free to change what the window says, it won't do any damage.

i hope you understood, if not i made a demo that shows what i did and how it works:
-dead link-

if you wanna use it please leave the lines "made/edited by bluexx" inside the script, thank you.

p.s the cow sprite was made by me using charas and then edited in paint :P

(oh and dwarra i expect to see you bow ;) -edit: he did ;))

still edit:
file reuploaded. demo can be found at:
http://www.megaupload.com/?d=KP6W9HKY
Title: i am too young to die, and so are you- deathless script!!
Post by: graywolf on December 08, 2005, 01:09:02 PM
thaTS SO COOL GOOD JOB BLUEXX 10/10
Title: i am too young to die, and so are you- deathless script!!
Post by: Sasame Kiryu on December 08, 2005, 05:33:48 PM
VERY nice script. I've been looking for something like this! Thanks!!

Mad credit to BlueXx!!!!!!
Title: i am too young to die, and so are you- deathless script!!
Post by: VampireHSS on February 05, 2006, 03:01:18 PM
I got teleported to the top of a building :S when testing the script? (I use post. knights)
Title: i am too young to die, and so are you- deathless script!!
Post by: Zeriab on February 05, 2006, 03:22:49 PM
Change the destination in the script. It's in the Scene_Battle a little over the middle.
Title: i am too young to die, and so are you- deathless script!!
Post by: blueXx on February 05, 2006, 03:39:36 PM
Quote#set the map id of "the angel of death" here:
   $game_map.setup(2)
#set the postion (x,y) in that map here:
   $game_player.moveto(10, 10)

look for those lines...
i thought it's quite clear what they do and how to edit them..
Title: i am too young to die, and so are you- deathless script!!
Post by: Zeriab on February 05, 2006, 04:04:56 PM
I guess you could edit those lines from
Quote#set the map id of "the angel of death" here:
$game_map.setup(2)
#set the postion (x,y) in that map here:
$game_player.moveto(10, 10)
to something like this:
Quote#set the map id of "the angel of death" here:
$game_map.setup($game_variables[1])
#set the postion (x,y) in that map here:
$game_player.moveto($game_variables[2], $game_variables[3])
Then you could change the destination ingame with variables, where:
Variable 1 = map id
Variable 2 = x-coordinate
Variable 3 = y-coordinate

You could of course change the variables used by change then cursive numbers.

There's also the possibility of using global values to determine the destination.
Title: i am too young to die, and so are you- deathless script!!
Post by: Jakexxx on February 05, 2006, 04:56:33 PM
wee im using this
Title: i am too young to die, and so are you- deathless script!!
Post by: blueXx on February 05, 2006, 05:05:11 PM
one problem with it zeriab is that by the time person X find it and want to add it he realize "crap i wasted variable 1 2 and 3!"
then he gotta change them, so he walks to the script to change the variable numbers but wait just a sec i am already here and i can change it on my own!

and as for changing the location of respawning upon death, i did it in my demo, simply make a dark map , say a word or 2 or just shut up, and use auto start to teleport the player to the inn they saved in

but zeriab's edit will save the dark map, so use it if you don't have anything to say in the dark map

jake- have fun :P
(oh wow someone is actually using that .. been so many months since i posted this script :O.. almost 2 -.-)
Title: i am too young to die, and so are you- deathless script!!
Post by: Zeriab on February 05, 2006, 05:51:57 PM
You are right about the variables. There quite high changes for discovering it too late. You could also use an array:
Quote#set the map id of "the angel of death" here:
$game_map.setup($deathless[0])
#set the postion (x,y) in that map here:
$game_player.moveto($deathless[1], $deathless[2])
It might also be an idea to add an "if $deathless != nil" case around the block like this:
if $deathless != nil
 #set the map id of "the angel of death" here:
 $game_map.setup($deathless[0])
 #set the postion (x,y) in that map here:
 $game_player.moveto($deathless[1], $deathless[2])
end

Edit I forgot the ending bracket on line 5
----------

Now to change the position from an event one must call a script. This can be found under Event Commands on page 3. (Lower-Right).
In this enter: $deathless = [map id, x-coordinate, y-coordinate]

Let's have an example:
We want to be teleported back to the Inn.
This Inn is located on map 005. (You can see it on the status bar. It's right before the map name.
We want to land next to that strange old hooded man.
We want to land exactly at the (17, 21)-tile. (Status-bar)

Now before the hero are unleased into battle you should use the call script with this in it: "$deathless = [5, 17, 21]"


Just use whatever way you feel most comfortable with.
Title: i am too young to die, and so are you- deathless script!!
Post by: frabbage on February 11, 2006, 01:12:12 PM
i have a problem; say i am level 6 or whatever, if i fight and lose, i return back to level 1 etc... anyway to fix this?
Title: i am too young to die, and so are you- deathless script!!
Post by: blueXx on February 11, 2006, 02:25:48 PM
weird it was always sort of working normally for me Oo

find
#set the amount of exp you want the hero to lose here:
       actor.exp -= actor.exp/30


and set a lower amount (actor.exp/a bigger number)
Title: i am too young to die, and so are you- deathless script!!
Post by: LinkaN on February 11, 2006, 06:11:15 PM
I think i will use this to! :D
I discovered this script recently and it fit perfect to my game :)
Title: i am too young to die, and so are you- deathless script!!
Post by: A really NoOby Guy on February 26, 2006, 10:33:30 PM
8)  BlueXx saves the day again... erm.... the game!!!
Title: i am too young to die, and so are you- deathless script!!
Post by: Nightwolf on February 27, 2006, 05:05:08 AM
The demo expired.
BUT THE SCRIPTS COOL!
Good job, Blue.
Title: i am too young to die, and so are you- deathless script!!
Post by: blueXx on February 27, 2006, 10:42:58 AM
woah demo expired...

QuotePosted: Thu Dec 08, 2005 11:42 am

that may just be the reason

i'll try finding the demo and reuploading it asap
Title: i am too young to die, and so are you- deathless script!!
Post by: Neko on February 28, 2006, 05:14:35 AM
Is there a way to set the Location to send you to by having the hero talk to an innkeeper and have the area to be sent to set?
Title: i am too young to die, and so are you- deathless script!!
Post by: Zeriab on February 28, 2006, 06:23:11 AM
Quote from: NekoIs there a way to set the Location to send you to by having the hero talk to an innkeeper and have the area to be sent to set?
Yes.
You could have a event in the dark map sent you to different locations depending on switches or variables set by the innkeeper.

You could also implement what I've talked about in the previous map.
Then you should either change the variables you've specified or change $deathless. What you should change depends on what you choose to implement into the script.
Title: i am too young to die, and so are you- deathless script!!
Post by: blueXx on February 28, 2006, 01:09:32 PM
neko's problem is actually showen in the demo
(i just hope you can get the thing open i made it with the legal version so just about any dumb thing can happen ~_~)
(btw, first post edited, file reuploaded)
Title: i am too young to die, and so are you- deathless script!!
Post by: Neko on February 28, 2006, 08:31:52 PM
This is the only scripting Ive seen from you. its good. Huzzah for you. And thanks for the help