Advertisement
roninator2

Damage for more types of Floors v1.1b

Nov 21st, 2024
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.02 KB | None | 0 0
  1. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. #Damage for more types of Floors Script v 1.1b
  3. #Author = Kio Kurashi
  4. #Credit = Kio Kurashi
  5. #Modded by Roninator2
  6. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. #Notes:
  8. #  Currently this script only works for three types of Floor damage. It doesn't
  9. #  nessesarily need to be Poison, Lava, and Shock, however. If more than the
  10. #  provided number of Floors are needed I can add more.
  11. #  Options added to allow inflicting states when damaged
  12. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  13. #Instructions:
  14. #  The editable section is directly bellow. For each you will have a Terrain tag,
  15. #  and a Damage ammount. The Terrain tag will be a number between 0 and 7.
  16. #  as the number on the tiles. Damage will be the Base damage that is
  17. #  applied for each number.
  18. #Important:
  19. #  The map tileset must be properly configured.
  20. #  The tile that will be a damage tile must be marked as a damage tile. go figure
  21. #  The tile must also have the terrain tag matching the settings below.
  22. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23. #Update:
  24. #  The script will now apply a damage effect at the specified interval
  25. #  60 = 1 second
  26. #  Also available is a switch to block state infliction.
  27. #  Turn switch off to stop state infliction.
  28. #~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  29. #~     BEGINING OF EDITABLE SECTION
  30. #~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  31.  
  32. module R2_Floor_Damage
  33.  
  34. NORMAL_TERRAIN_REGION = 0
  35. NORMAL_TERRAIN_DAMAGE = 0
  36.  
  37. POISON_TERRAIN_REGION = 1   # Poison terrain tag
  38. POISON_TERRAIN_DAMAGE = 10  # Poison damage
  39. CHANCE_POISON = 15          # Chance to inflict poison
  40. POISON_STATE = 2            # Poison state
  41.  
  42. LAVA_TERRAIN_REGION = 2     # Burn terrain tag
  43. LAVA_TERRAIN_DAMAGE = 40    # Burn damage
  44. CHANGE_BURN = 25            # Chance to inflict burn
  45. BURN_STATE = 25             # Burn state
  46.  
  47. SHOCK_TERRAIN_REGION = 3    # Shock terrain tag
  48. SHOCK_TERRAIN_DAMAGE = 20   # Shock damage
  49. CHANGE_SHOCK = 50           # Chance to inflict shock
  50. SHOCK_STATE = 35            # Shock state
  51.  
  52. FDR_DAMAGE_INT = 60         # interval at which the damage effect will apply again.
  53. FDR_DAMAGE_SWITCH = 151     # Turn switch on to turn off interval damage
  54.  
  55. BLOCK_STATES = [160, 190]   # States that will block damage
  56. INFLICT_STATE = 191         # Switch used to inflict states
  57.  
  58. end
  59. #~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  60. #~     END OF EDITABLE SECTION
  61. #~       Editing beyond this point without prior knowledge is dangerous!!
  62. #~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  63.  
  64. class Game_Actor
  65.   def basic_floor_damage
  66.     case $game_map.terrain_tag($game_player.x, $game_player.y)
  67.     when R2_Floor_Damage::NORMAL_TERRAIN_REGION
  68.       return R2_Floor_Damage::NORMAL_TERRAIN_DAMAGE
  69.     when R2_Floor_Damage::POISON_TERRAIN_REGION
  70.       return R2_Floor_Damage::POISON_TERRAIN_DAMAGE
  71.     when R2_Floor_Damage::LAVA_TERRAIN_REGION
  72.       return R2_Floor_Damage::LAVA_TERRAIN_DAMAGE
  73.     when R2_Floor_Damage::SHOCK_TERRAIN_REGION
  74.       return R2_Floor_Damage::SHOCK_TERRAIN_DAMAGE
  75.     when nil
  76.       return 10
  77.     end
  78.   end
  79. end
  80.  
  81. class Game_Player < Game_Character
  82.   alias r2_fdr_initialize initialize
  83.   def initialize
  84.     @standingtime = 0
  85.     r2_fdr_initialize
  86.   end
  87.   alias r2_input_move_fdr move_by_input
  88.   def move_by_input
  89.     @standingtime = 0 if $game_player.moving?
  90.     r2_input_move_fdr
  91.   end
  92.   alias r2_fdr_update_nonmoving update_nonmoving
  93.   def update_nonmoving(last_moving)
  94.     if !$game_switches[R2_Floor_Damage::FDR_DAMAGE_SWITCH]
  95.       @standingtime += 1 if !$game_map.interpreter.running?
  96.       actor.check_floor_effect if @standingtime > R2_Floor_Damage::FDR_DAMAGE_INT
  97.       @standingtime = 0 if @standingtime > R2_Floor_Damage::FDR_DAMAGE_INT
  98.     end
  99.     r2_fdr_update_nonmoving(last_moving)
  100.   end
  101. end
  102.  
  103. class Game_Actor < Game_Battler
  104.   alias r2_state_block_floor_damage execute_floor_damage
  105.   def execute_floor_damage
  106.     state_ids = self.states.collect {|obj| obj.id }
  107.     return if state_ids.include?(R2_Floor_Damage::BLOCK_STATES)
  108.     r2_state_block_floor_damage
  109.     case $game_map.terrain_tag($game_player.x, $game_player.y)
  110.     when R2_Floor_Damage::POISON_TERRAIN_REGION
  111.       chance = R2_Floor_Damage::CHANCE_POISON
  112.       state = R2_Floor_Damage::POISON_STATE
  113.     when R2_Floor_Damage::LAVA_TERRAIN_REGION
  114.       chance = R2_Floor_Damage::CHANCE_BURN
  115.       state = R2_Floor_Damage::BURN_STATE
  116.     when R2_Floor_Damage::SHOCK_TERRAIN_REGION
  117.       chance = R2_Floor_Damage::CHANCE_SHOCK
  118.       state = R2_Floor_Damage::SHOCK_STATE
  119.     else
  120.       return
  121.     end
  122.     return if $game_switches[R2_Floor_Damage::INFLICT_STATE] == false
  123.     roll = rand(100).to_i
  124.     if roll <= chance
  125.       act = $game_actors[@actor_id]
  126.       act.add_state(state)
  127.     end
  128.   end
  129. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement