Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> 


———
Before you ask! Read! ;)

You must have 30+ Posts to create a topic here!

Thanks for reading!
———

 
Reply to this topicStart new topic
> Damaging Tiles and Prevention Spell
RedMoney
post Dec 5 2011, 11:11 PM
Post #1


Level 1
Group Icon

Group: Member
Posts: 7
Type: Writer
RM Skill: Beginner




So, I have been searching everywhere with no luck to find a poison marsh type script. What I want is a script that deals damage to all the characters in the party when they step on a specific tile. I also want to be able to easily edit the script to make stronger and weaker tiles (poison marsh, electric floor, lava, etc...).

I tried to make a script like this

if tile_id = 195
for actor in members @hp - 1
end

Which caused the game to crash.

Also, I want to be able to make a spell that prevents the tiles from causing damage.

My thoughts right now - I think that if the tile causes a state that deals slip damage and that state ends after one step, it will be easy to make a spell tat stops that state from being entered.

Thank you in advance for anyone who is willing to help.

This post has been edited by RedMoney: Dec 5 2011, 11:11 PM
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Dec 6 2011, 12:11 AM
Post #2


Level 50
Group Icon

Group: +Gold Member
Posts: 1,523
Type: Scripter
RM Skill: Undisclosed




I think that this should work, but I'm not sure how tile id's work in VX.

CODE
#==============================================================================
# ** VX: Night_Runner's Poisoned Tiles Script.
#------------------------------------------------------------------------------
# History:
#  Date Created: 6/Dec/2011
#  Created for: RedMonkey
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=54253
#
# Description:
#  This script deals damage to players when they step on a poisoned tile.
#  If an actor has a state active that counters the poison though they will
#  not be damaged.
#
# How to Install:
#  Copy this entire script. In your game's editor, select Tools >>
#  Script Editor. Along the left hand side scroll all the way to the
#  bottom, right click on the square after ( Insert here ), and select
#  "Insert". Paste the code on the right.
#  
#==============================================================================



#==============================================================================
# ** Customisation
#==============================================================================

module NR_PoisonedTiles
  Tile_ID = 195
  Damage_On_Poison = 1
  Counter_State_ID = 1
  Remove_State_After_Use = true
  Flash_Screen = true
end



#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  Edited to deal damage on poisoned tiles
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias nr_poisonedTiles_on_player_walk  on_player_walk  unless $@
  #--------------------------------------------------------------------------
  # * Processing Performed When Player Takes 1 Step
  #--------------------------------------------------------------------------
  def on_player_walk(*args)
    # Run the original on_player_walk
    nr_poisonedTiles_on_player_walk(*args)
    # If the player is stepping on tile 195
    if $game_player.tile_id == NR_PoisonedTiles::Tile_ID
      # Loop through each player
      for actor in members
        # If the actor does not have the skill to repel the poison
        if not actor.state?(NR_PoisonedTiles::Counter_Spell_ID)
          # Poison the player
          damage = NR_PoisonedTiles::Damage_On_Poison
          actor.hp -= damage if actor.hp > damage
          # Flash the screen if appropriate
          if NR_Poisoned_Tiles::Flash_Screen
            $game_map.screen.start_flash(Color.new(255,0,0,64), 4)
          end
          # Remove the state if appropriate
          if NR_PoisonedTiles::Remove_State_After_Stepping
            actor.remove_state(Counter_State_ID)
          end
        end
      end
    end
  end
end



#==============================================================================
# ** End of Script.
#==============================================================================


If it doesn't work, let me know, and I'll try and learn how the ID's work happy.gif


__________________________
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.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
RedMoney
post Dec 6 2011, 04:21 AM
Post #3


Level 1
Group Icon

Group: Member
Posts: 7
Type: Writer
RM Skill: Beginner




The following error happened :

uninitialized constant NR_PoisonTiles::Counter_Spell_ID

note, I got the tile ID number wrong so I changed it to 0, then changed the tile in the game accordingly.

This post has been edited by RedMoney: Dec 6 2011, 04:22 AM
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Dec 6 2011, 03:07 PM
Post #4


Level 50
Group Icon

Group: +Gold Member
Posts: 1,523
Type: Scripter
RM Skill: Undisclosed




Oops, I forgot to change the spell to skill.

CODE
#==============================================================================
# ** VX: Night_Runner's Poisoned Tiles Script.
#------------------------------------------------------------------------------
# History:
#  Date Created: 6/Dec/2011
#  Created for: RedMonkey
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=54253
#
# Description:
#  This script deals damage to players when they step on a poisoned tile.
#  If an actor has a state active that counters the poison though they will
#  not be damaged.
#
# How to Install:
#  Copy this entire script. In your game's editor, select Tools >>
#  Script Editor. Along the left hand side scroll all the way to the
#  bottom, right click on the square after ( Insert here ), and select
#  "Insert". Paste the code on the right.
#  
#==============================================================================



#==============================================================================
# ** Customisation
#==============================================================================

module NR_PoisonedTiles
  Tile_ID = 0
  Damage_On_Poison = 1
  Counter_State_ID = 1
  Remove_State_After_Use = true
  Remove_State_After_Stepping = false
  Flash_Screen = true
end



#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  Edited to deal damage on poisoned tiles
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias nr_poisonedTiles_on_player_walk  on_player_walk  unless $@
  #--------------------------------------------------------------------------
  # * Processing Performed When Player Takes 1 Step
  #--------------------------------------------------------------------------
  def on_player_walk(*args)
    # Run the original on_player_walk
    nr_poisonedTiles_on_player_walk(*args)
    # If the player is stepping on tile 195
    if $game_player.tile_id == NR_PoisonedTiles::Tile_ID
      # Loop through each player
      for actor in members
        # If the actor does not have the skill to repel the poison
        if not actor.state?(NR_PoisonedTiles::Counter_State_ID)
          # Poison the player
          damage = NR_PoisonedTiles::Damage_On_Poison
          actor.hp -= damage if actor.hp > damage
          # Flash the screen if appropriate
          if NR_PoisonedTiles::Flash_Screen
            $game_map.screen.start_flash(Color.new(255,0,0,64), 4)
          end
          # Remove the state if appropriate
          if NR_PoisonedTiles::Remove_State_After_Use
            actor.remove_state(NR_PoisonedTiles::Counter_State_ID)
          end
        end
      end
    end
    # If we remove the state
    if NR_PoisonedTiles::Remove_State_After_Stepping
      actor.remove_state(NR_PoisonedTiles::Counter_State_ID)
    end
  end
end



#==============================================================================
# ** End of Script.
#==============================================================================


__________________________
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.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
RedMoney
post Dec 6 2011, 03:14 PM
Post #5


Level 1
Group Icon

Group: Member
Posts: 7
Type: Writer
RM Skill: Beginner




still same error. Also, it broke the game, I can now walk through any tile. I removed the script and the bug still did not go away.

should be noted, I can only pass through floor tiles, not Tile B types.
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Dec 6 2011, 03:36 PM
Post #6


Level 50
Group Icon

Group: +Gold Member
Posts: 1,523
Type: Scripter
RM Skill: Undisclosed




Oops, I forgot to change the spell to skill.

CODE
#==============================================================================
# ** VX: Night_Runner's Poisoned Tiles Script.
#------------------------------------------------------------------------------
# History:
#  Date Created: 6/Dec/2011
#  Created for: RedMonkey
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=54253
#
# Description:
#  This script deals damage to players when they step on a poisoned tile.
#  If an actor has a state active that counters the poison though they will
#  not be damaged.
#
# How to Install:
#  Copy this entire script. In your game's editor, select Tools >>
#  Script Editor. Along the left hand side scroll all the way to the
#  bottom, right click on the square after ( Insert here ), and select
#  "Insert". Paste the code on the right.
#  
#==============================================================================



#==============================================================================
# ** Customisation
#==============================================================================

module NR_PoisonedTiles
  Tile_ID = 0
  Damage_On_Poison = 1
  Counter_State_ID = 1
  Remove_State_After_Use = true
  Flash_Screen = true
end



#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  Edited to deal damage on poisoned tiles
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias nr_poisonedTiles_on_player_walk  on_player_walk  unless $@
  #--------------------------------------------------------------------------
  # * Processing Performed When Player Takes 1 Step
  #--------------------------------------------------------------------------
  def on_player_walk(*args)
    # Run the original on_player_walk
    nr_poisonedTiles_on_player_walk(*args)
    # If the player is stepping on tile 195
    if $game_player.tile_id == NR_PoisonedTiles::Tile_ID
      # Loop through each player
      for actor in members
        # If the actor does not have the skill to repel the poison
        if not actor.state?(NR_PoisonedTiles::Counter_State_ID)
          # Poison the player
          damage = NR_PoisonedTiles::Damage_On_Poison
          actor.hp -= damage if actor.hp > damage
          # Flash the screen if appropriate
          if NR_Poisoned_Tiles::Flash_Screen
            $game_map.screen.start_flash(Color.new(255,0,0,64), 4)
          end
          # Remove the state if appropriate
          if NR_PoisonedTiles::Remove_State_After_Stepping
            actor.remove_state(Counter_State_ID)
          end
        end
      end
    end
  end
end



#==============================================================================
# ** End of Script.
#==============================================================================




*Edit*
I don't think that the tile_id's work in the same way you think it does. I've been looking through the code, and only the events tile_id will ever get set to a non-zero value, and that's based off the character graphic you give them.
I've redone the script, it has two parts now, this first script is supposed to be removed when you're finished setting up, and it simply shows a window that displays the tile ID's that the player is standing on
CODE
#==============================================================================
# ** Window_TileID
#------------------------------------------------------------------------------
#  This window displays tile ID underneath the player
#==============================================================================

class Window_TileID < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize(x = 0, y = 0)
    super(x, y, 160, 3 * WLH + 32)
    self.back_opacity = 200
    @counter = 0
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    data = $game_map.data
    px = $game_player.x
    py = $game_player.y
    width = self.contents.width
    for i in 0..2
      text = "Layer %d: %d" % [i, data[px, py, i]]
      self.contents.draw_text(0, i * WLH, width, WLH, text)
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    @counter += 1
    if @counter > 5
      refresh
      @counter = 0
    end
  end
end



#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  Edited to show the Window_TileID
#==============================================================================

class Scene_Map
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias nr_windowTileID_main    main    unless $@
  alias nr_windowTileID_update  update  unless $@
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main(*args)
    @id_window = Window_TileID.new
    # Run the original main
    nr_windowTileID_main(*args)
    @id_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update(*args)
    @id_window.update
    return nr_windowTileID_update(*args)
  end
end

And this second script is just like the previous poisons script, but you use the tile id shown from the previous script when you're standing on the poisoned tile, and it poisons the player when they're standing on it smile.gif
CODE
#==============================================================================
# ** VX: Night_Runner's Poisoned Tiles Script.
#------------------------------------------------------------------------------
# History:
#  Date Created: 6/Dec/2011
#  Created for: RedMonkey
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=54253
#
# Description:
#  This script deals damage to players when they step on a poisoned tile.
#  If an actor has a state active that counters the poison though they will
#  not be damaged.
#
# How to Install:
#  Copy this entire script. In your game's editor, select Tools >>
#  Script Editor. Along the left hand side scroll all the way to the
#  bottom, right click on the square after ( Insert here ), and select
#  "Insert". Paste the code on the right.
#  
#==============================================================================



#==============================================================================
# ** Customisation
#==============================================================================

module NR_PoisonedTiles
  Tilemap_ID = 1600
  Damage_On_Poison = 1
  Counter_State_ID = 1
  Remove_State_After_Use = true
  Remove_State_After_Stepping = false
  Flash_Screen = true
end



#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  Edited to deal damage on poisoned tiles
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias nr_poisonedTiles_on_player_walk  on_player_walk  unless $@
  #--------------------------------------------------------------------------
  # * Processing Performed When Player Takes 1 Step
  #--------------------------------------------------------------------------
  def on_player_walk(*args)
    # Run the original on_player_walk
    nr_poisonedTiles_on_player_walk(*args)
    # If the player is stepping on tile 195
    if get_maptiles.include? NR_PoisonedTiles::Tilemap_ID
      # Loop through each player
      for actor in members
        # If the actor does not have the skill to repel the poison
        if not actor.state?(NR_PoisonedTiles::Counter_State_ID)
          # Poison the player
          damage = NR_PoisonedTiles::Damage_On_Poison
          actor.hp -= damage if actor.hp > damage
          # Flash the screen if appropriate
          if NR_PoisonedTiles::Flash_Screen
            $game_map.screen.start_flash(Color.new(255,0,0,64), 4)
          end
          # Remove the state if appropriate
          if NR_PoisonedTiles::Remove_State_After_Use
            actor.remove_state(NR_PoisonedTiles::Counter_State_ID)
          end
        end
      end
    end
    # If we remove the state
    if NR_PoisonedTiles::Remove_State_After_Stepping
      actor.remove_state(NR_PoisonedTiles::Counter_State_ID)
    end
  end
  #--------------------------------------------------------------------------
  # * Get the Tiles that player is standing on
  #--------------------------------------------------------------------------
  def get_maptiles
    output_data = []
    map_data = $game_map.data
    px = $game_player.x
    py = $game_player.y
    for i in 0..2
      output_data << map_data[px, py, i]
    end
    return output_data
  end
end



#==============================================================================
# ** End of Script.
#==============================================================================


__________________________
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.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
RedMoney
post Dec 6 2011, 04:03 PM
Post #7


Level 1
Group Icon

Group: Member
Posts: 7
Type: Writer
RM Skill: Beginner




Nice, check out the big brain on night runner! It works properly, i set it to tile id 1591 and the purple floor dealt the damage.

Thank you very much for the script.

This post has been edited by RedMoney: Dec 6 2011, 06:13 PM
Go to the top of the page
 
+Quote Post
   
The Buffoon Plat...
post Dec 6 2011, 04:18 PM
Post #8


Level 1
Group Icon

Group: Member
Posts: 5
Type: Artist
RM Skill: Advanced




You can definitely do this with events; I did it in XP a while back. I just can't remember how exactly it was done.
Go to the top of the page
 
+Quote Post
   
Cleril
post Dec 7 2011, 03:13 PM
Post #9


Level 16
Group Icon

Group: Revolutionary
Posts: 303
Type: Writer
RM Skill: Skilled
Rev Points: 25




QUOTE (The Buffoon Platoon @ Dec 6 2011, 07:18 PM) *
You can definitely do this with events; I did it in XP a while back. I just can't remember how exactly it was done.


Make the event below characters as priority.

Set it to damage the player (change HP), have it flash/tint the screen if you want the player to be aware of the damage (put a sound effect too if you want to tell them through sound what's going on).

Tada, pretty simple stuff!


__________________________
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 23rd May 2013 - 04:31 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker