Advertisement
Vlue

Enhanced Encounter Conditions

Sep 15th, 2013
1,242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.69 KB | None | 0 0
  1. #Enhanced Encounter Conditions
  2. #----------#
  3. #Features: Grant's you complete control over how your encounters get encountered!
  4. #
  5. #Usage:  Set up your conditions below, then use the note tags in map properties
  6. #
  7. #        Several examples are below, the format runs like...
  8. #           id => "script",
  9. #          can use variable(id) for variables and switch(id) for switches
  10. #           and if the script call returns true, then that encounter can be
  11. #           encountered!
  12. #
  13. #        Example:
  14. #          1 => "variable(1) > 50",
  15. #         And any encounter with that condition will only occur if variable 1
  16. #          is greater than 50! Oooh, ahhh.
  17. #
  18. #        Note tags:
  19. #         This is how you define which encounters get which condition
  20. #         (Only one condition per encounter, the first will be used)
  21. #         <TROOP id# condition#>
  22. #          Where id is the number it is on the encounter list and condition
  23. #           is the number of the condition to use
  24. #
  25. #        Example:
  26. #         <TROOP 1 1>
  27. #         Which would give the first encounter in the list condition 1.
  28. #
  29. #----------#
  30. #-- Script by: V.M of D.T
  31. #
  32. #- Questions or comments can be:
  33. #    given by email: sumptuaryspade@live.ca
  34. #    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  35. #   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
  36. #
  37. #--- Free to use in any project, commercial or non-commercial, with credit given
  38. # - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
  39.  
  40.  
  41. class Troop_Encounters
  42.  
  43.   #########
  44.   #Set up you Conditions here! Here! Here!!
  45.   #########
  46.  
  47.   CONDITIONS = { 1 => "variable(1) > 50",
  48.                  2 => "switch(5)",
  49.                  3 => "$game_party.highest_level > 25",}
  50.  
  51.   ##### Not here
  52.   def self.condition(id)
  53.     return "false" if CONDITIONS[id].nil?
  54.     return CONDITIONS[id]
  55.   end
  56. end
  57.  
  58. class Game_Player
  59.   alias enc_cond_mati make_encounter_troop_id
  60.   def make_encounter_troop_id
  61.     @id = 0
  62.     enc_cond_mati
  63.   end
  64.   def encounter_ok?(encounter)
  65.     @id += 1
  66.     return false unless encounter.region_set.include?(region_id) || encounter.region_set.empty?
  67.     return false unless special_encounter_condition(encounter,id)
  68.     return true
  69.   end
  70.   def special_encounter_condition(encounter,id)
  71.     return true if $game_map.map_note.empty?
  72.     return true unless /<TROOP #{id} (?<cond>\d{1,3})>/ =~ $game_map.map_note
  73.     return eval(Troop_Encounters.condition($1.to_i))
  74.   end
  75.   def switch(id)
  76.     $game_switches[id]
  77.   end
  78.   def variable(id)
  79.     $game_variables[id]
  80.   end
  81. end
  82.  
  83. class Game_Map
  84.   def map_note
  85.     return @map.note unless @map.nil?
  86.   end
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement