Flying Enemies

Flying Enemies
Authors: game_guy
Version: 1.1
Type: Adds Realism
Key Term: Battle Add-on



Introduction

Script was created completely from inspiration.

Flying Enemies adds some realism to your game. It basically gives the appearance and feel that enemies are floating off the ground. Only weapons with the "flying" element can attack enemies that aren't on the ground. e.g. a gun or a bow. A guy with a sword couldn't very well jump 20 feet and kill something could they? (maybe, it is just a game)


Features

  • Flying Enemies
  • Specific Spells and Weapons can hurt
  • Floating animation for enemies


Screenshots

Content Hidden Spoiler
Image



Demo

N/A


Script

Content Hidden Spoiler
  1.  
  2. #===============================================================================
  3. # Flying Enemies
  4. # Version 1.1
  5. # Author game_guy
  6. #-------------------------------------------------------------------------------
  7. # Intro:
  8. # Flying Enemies adds some realism to your game. It basically gives the
  9. # appearance and feel that enemies are floating off the ground. Only weapons
  10. # with the "flying" element can attack enemies that aren't on the ground. e.g.
  11. # a gun or a bow. A guy with a sword couldn't very well jump 20 feet and kill
  12. # something could they? (maybe, it is just a game)
  13. #
  14. # Features:
  15. # -Flying Enemies
  16. # -Specific Spells and Weapons can hurt
  17. # -Floating animation for enemies
  18. #
  19. # Instructions:
  20. # -Go to the config, set the following data there. To make a weapon hit a flying
  21. #  enemy, you must give it the flying element you specified below. The same for
  22. #  skills, except some skills get exceptions. Read Notes.
  23. #
  24. # Notes:
  25. # -Only weapons marked with the Flying_Element can hit a flying enemy.
  26. # -Only skills with the flying element can hit flying enemies.
  27. #
  28. # Compatibility:
  29. # -Not tested with SDK.
  30. # -Not tested with any custom battle systems.
  31. # -Attacking flying enemies (and missing) will most likely work throughout all
  32. #  custom battle systems.
  33. # -Animating enemy up and down may or may not work in any custom battle system.
  34. #
  35. # Credits:
  36. # -game_guy ~ For creating it.
  37. # -Final Fantasy X ~ Started playing this game again and Tidus was unable to
  38. #  hit any flying enemies. ;_; Hence inspiration. :3
  39. #===============================================================================
  40.  
  41. module GG_Fly
  42.   #---------------------------------------------
  43.   # Weapons and skill must have this element
  44.   # in order to attack flying enemies.
  45.   #---------------------------------------------
  46.   Flying_Element  = 17
  47.   #---------------------------------------------
  48.   # Place enemy ids in the array below to mark
  49.   # them as flying enemies.
  50.   #---------------------------------------------
  51.   Flying_Enemies  = [1, 2]
  52.   #---------------------------------------------
  53.   # The 'miss' message displayed when an out of
  54.   # reach attacker attempts to hit a flying
  55.   # enemy.
  56.   #---------------------------------------------
  57.   Miss_Message    = "Out of reach!"
  58.   #---------------------------------------------
  59.   # Moves flying enemies up and down to give
  60.   # the "floating" feeling.
  61.   #---------------------------------------------
  62.   Animate_Enemy   = true
  63. end
  64.  
  65. class Game_Enemy
  66.   
  67.   def flying?
  68.     return GG_Fly::Flying_Enemies.include?(self.id)
  69.   end
  70.   
  71. end
  72.  
  73. class Game_Battler
  74.   
  75.   alias gg_fly_attack_effect_lat attack_effect
  76.   def attack_effect(attacker)
  77.     if self.is_a?(Game_Enemy) && attacker.is_a?(Game_Actor)
  78.       if self.flying? && !attacker.element_set.include?(GG_Fly::Flying_Element)
  79.         self.damage = GG_Fly::Miss_Message
  80.         return true
  81.       end
  82.     end
  83.     return gg_fly_attack_effect_lat(attacker)
  84.   end
  85.   
  86.   alias gg_fly_skill_effect_lat skill_effect
  87.   def skill_effect(user, skill)
  88.     if self.is_a?(Game_Enemy) && user.is_a?(Game_Actor)
  89.       if self.flying? && !skill.element_set.include?(GG_Fly::Flying_Element)
  90.         self.damage = GG_Fly::Miss_Message
  91.         return true
  92.       end
  93.     end
  94.     return gg_fly_skill_effect_lat(user, skill)
  95.   end
  96.   
  97. end
  98.  
  99. class Sprite_Battler < RPG::Sprite
  100.   
  101.   alias gg_init_flying_enemy_lat initialize
  102.   def initialize(viewport, battler = nil)
  103.     gg_init_flying_enemy_lat(viewport, battler)
  104.     if battler != nil && battler.is_a?(Game_Enemy)
  105.       @update_frame = 0
  106.       @speed = 2
  107.       @new_y = battler.screen_y
  108.     end
  109.   end
  110.   
  111.   alias gg_animate_flying_enemy_lat update
  112.   def update
  113.     gg_animate_flying_enemy_lat
  114.     if GG_Fly::Animate_Enemy && @battler.is_a?(Game_Enemy) && @battler.flying?
  115.       @update_frame += 1
  116.       if @update_frame == 2
  117.         @update_frame = 0
  118.         @new_y += @speed
  119.         if @new_y == @battler.screen_y
  120.           @speed = 1
  121.         elsif @new_y == @battler.screen_y + 16
  122.           @speed = -1
  123.         end
  124.       end
  125.       self.y = @new_y
  126.     end
  127.   end
  128.   
  129. end
  130.  
Expand to see the code.



Instructions

In the script. In fact there is even a small notes section you should read.

Any weapon you want to hit flying enemies with must have the Flying element. Same thing for skills.


Compatibility

  • Not tested with SDK.
  • Not tested with any custom battle systems.
  • Attacking flying enemies (and missing) will most likely work throughout all custom battle systems.
  • Animating enemy up and down may or may not work in any custom battle system.


Credits and Thanks

  • game_guy ~ For creating it.
  • Final Fantasy X ~ Started playing this game again and Tidus was unable to hit any flying enemies. ;_; Hence inspiration. :3


Author's Notes

Enjoy!
Hi:-)

I like the idea that you have, but I have one suggestion: get rid of the int_f > atk_f allows you to hit flying and just use the flying element. Since you can't know who will be using this script, you can't predict how exactly they'll be using those stats; or if they'll even be using them as stats and not some other type of indicator. Hence, the int_f > atk_f introduces needless side effects to watch out for.

At any rate, sorry I went on and on about such a small thing, but something to think about:-) Thank you for sharing:-) Have an awesome day :-)
I thought about it and true. The sole purpose of setting it up that way was to try and reduce work from the game creators so they wouldn't have to go through every skill and mark the flying element. But its not too much extra work. Script is updated, thanks for the feedback, its much appreciated. :3
Pretty slim and straightforward script... and a cool feature besides, reminds me a lot of MTG: Duels of the Planeswalkers' card effects. I'd probably rename the state to 'Reach', though, as 'Flying' doesn'T really make too much sense there, plus might confuse 87% of the PKMN game makers.
I liked the way you made it, although it can be done via elemental damage setting, it would just make the weapon deal 0 damage, instead of showing a message. Although i really don't like element taging. Since it can mess sometimes with elemental resistance.
I would prefer an array with weapons and skills. But it's just my opinion.
@BlueScope: I think Flying suits it pretty well. I might change the name to try and clarify the point of it more.
@Atoa: You have some valid points. I was thinking the same thing with the elemental resistance as I started to code it but even so You can't have the custom message. I'll most likely change it to an array when I'm not feeling lazy. :P

Thanks for the feedback guys.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=75104