Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

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

outofreach.png

Demo

N/A

Script

Code:
 

#===============================================================================

# Flying Enemies

# Version 1.1

# Author game_guy

#-------------------------------------------------------------------------------

# Intro:

# 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

#

# Instructions:

# -Go to the config, set the following data there. To make a weapon hit a flying

#  enemy, you must give it the flying element you specified below. The same for

#  skills, except some skills get exceptions. Read Notes. 

#

# Notes:

# -Only weapons marked with the Flying_Element can hit a flying enemy.

# -Only skills with the flying element can hit flying enemies.

#

# 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:

# -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

#===============================================================================

 

module GG_Fly

  #---------------------------------------------

  # Weapons and skill must have this element

  # in order to attack flying enemies.

  #---------------------------------------------

  Flying_Element  = 17

  #---------------------------------------------

  # Place enemy ids in the array below to mark

  # them as flying enemies.

  #---------------------------------------------

  Flying_Enemies  = [1, 2]

  #---------------------------------------------

  # The 'miss' message displayed when an out of

  # reach attacker attempts to hit a flying

  # enemy.

  #---------------------------------------------

  Miss_Message    = "Out of reach!"

  #---------------------------------------------

  # Moves flying enemies up and down to give

  # the "floating" feeling.

  #---------------------------------------------

  Animate_Enemy   = true

end

 

class Game_Enemy

  

  def flying?

    return GG_Fly::Flying_Enemies.include?(self.id)

  end

  

end

 

class Game_Battler

  

  alias gg_fly_attack_effect_lat attack_effect

  def attack_effect(attacker)

    if self.is_a?(Game_Enemy) && attacker.is_a?(Game_Actor)

      if self.flying? && !attacker.element_set.include?(GG_Fly::Flying_Element)

        self.damage = GG_Fly::Miss_Message

        return true

      end

    end

    return gg_fly_attack_effect_lat(attacker)

  end

  

  alias gg_fly_skill_effect_lat skill_effect

  def skill_effect(user, skill)

    if self.is_a?(Game_Enemy) && user.is_a?(Game_Actor)

      if self.flying? && !skill.element_set.include?(GG_Fly::Flying_Element)

        self.damage = GG_Fly::Miss_Message

        return true

      end

    end

    return gg_fly_skill_effect_lat(user, skill)

  end

  

end

 

class Sprite_Battler < RPG::Sprite

  

  alias gg_init_flying_enemy_lat initialize

  def initialize(viewport, battler = nil)

    gg_init_flying_enemy_lat(viewport, battler)

    if battler != nil && battler.is_a?(Game_Enemy)

      @update_frame = 0

      @speed = 2

      @new_y = battler.screen_y

    end

  end

  

  alias gg_animate_flying_enemy_lat update

  def update

    gg_animate_flying_enemy_lat

    if GG_Fly::Animate_Enemy && @battler.is_a?(Game_Enemy) && @battler.flying?

      @update_frame += 1

      if @update_frame == 2

        @update_frame = 0

        @new_y += @speed

        if @new_y == @battler.screen_y

          @speed = 1

        elsif @new_y == @battler.screen_y + 16

          @speed = -1

        end

      end

      self.y = @new_y

    end

  end

  

end

 

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.
 

Atoa

Member

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.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top