Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: G_G on July 18, 2011, 10:09:44 am

Title: [XP] Flying Enemies
Post by: G_G on July 18, 2011, 10:09:44 am
Flying Battlers
Authors: game_guy
Version: 1.11
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




Screenshots

Spoiler: ShowHide
(http://decisive-media.net/gameguy/outofreach.png)



Demo

N/A


Script

Spoiler: ShowHide

#===============================================================================
# Flying Battlers
# Version 1.11
# Author game_guy
# Edit KK20
#-------------------------------------------------------------------------------
# Intro:
# Flying battlers adds a tad bit of realism to the game.
#
# Features:
# -Flying Enemies
# -Flying Actors for like a "Float" effect
# -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.
# -Skills with a higher INT F then ATK F will hit a flying enemy since these
#  skills are considered "Magic". (Think Fire over Double Slash or something)
# -Skills with a higher ATK F will need to be marked with the Flying Element in
#  order to hit a flying enemy.
#
# 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
  #---------------------------------------------
  # States that give enemies or actors the
  # "flying" effect.
  #---------------------------------------------
  Flying_States   = [17, 18]
  #---------------------------------------------
  # 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_Battler
 
  def flying?
    return ((self.is_a?(Game_Enemy) && GG_Fly::Flying_Enemies.include?(self.id)) || @states.any? {|id| GG_Fly::Flying_States.include?(id)})
  end
 
  alias gg_fly_attack_effect_lat attack_effect
  def attack_effect(attacker)
    if self.flying? && !attacker.element_set.include?(GG_Fly::Flying_Element)
      self.damage = GG_Fly::Miss_Message
      return true
    end
    return gg_fly_attack_effect_lat(attacker)
  end
 
  alias gg_fly_skill_effect_lat skill_effect
  def skill_effect(user, skill)
    if self.flying? && !skill.element_set.include?(GG_Fly::Flying_Element)
      if skill.atk_f >= skill.int_f
        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
      @update_frame = 0
      @speed = 2
      @new_y = battler.screen_y
    end
  end
 
  def battler=(bat)
    @battler = bat
    return if bat == nil
    @update_frame = 0
    @speed = 2
    @new_y = @battler.screen_y
  end
 
  alias gg_animate_flying_enemy_lat update
  def update
    gg_animate_flying_enemy_lat
    return if @battler.nil?
    if GG_Fly::Animate_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. In fact, here are the notes visually explained.

Skills with a higher INT F then ATK F are considered "Magic" skills. So therefore skills like these will hit flying enemies regardless if they have the Flying element or not. Any skill that does not meet this condition must have the Flying element in order to attack Flying enemies. However, all weapons

Note how fire does not have the flying element, it can still hit flying enemies since in a sense its magic and you don't need to be next to the enemy
Spoiler: ShowHide
(http://decisive-media.net/gameguy/flying.png)

This is a skill used by a hunter with his bow. In a sense it should be able to hit flying enemies, but since its not "magic" it needs to have the flying element.
Spoiler: ShowHide
(http://decisive-media.net/gameguy/flying2.png)


Any weapon you want to hit flying enemies with must have the Flying element.


Compatibility




Credits and Thanks




Author's Notes

Enjoy!
Title: Re: [XP] Flying Enemies
Post by: Magus on August 09, 2011, 01:13:32 pm
Interesting. I think I'm going to remake Flame of Life Season 2 and add this in here.
Title: Re: [XP] Flying Enemies
Post by: InfinateX on August 20, 2011, 02:52:23 am
I really like XP better then VX. Here's another reason :(
Title: Re: [XP] Flying Enemies
Post by: Vexus on February 28, 2012, 04:22:41 pm
Sorry for the necropost but would it be hard to edit this script so that the "fly" effect could be given by a status effect too?

I got a cbs which has the sort of floating feature by adding a flying status effect and I would like it to be optional as I have some monsters that stay on the ground but got a skill fly that adds the status effect.

Thanks.
Title: Re: [XP] Flying Enemies
Post by: G_G on February 28, 2012, 06:20:12 pm
Honestly, I don't know why I didn't do that in the first place. Took two minutes to edit it in, actors and enemies can now "fly" or "float". To make an actor float, all they need to do is have a "Flying" state. Same goes for enemies. They can be flying by default or they can be inflicted with a flying state. Note I didn't test this so there might be an error but I'm pretty sure its right.
Title: Re: [XP] Flying Enemies
Post by: Vexus on February 29, 2012, 11:04:49 am
Thanks that was fast :)

It seems to work.

Thanks again.
Title: Re: [XP] Flying Enemies
Post by: Spoofus on May 05, 2012, 01:33:33 am
i keep getting this error:

line 113:NoMethodError
indefined method '+' for nil:NilClass

dunno what is causing it,I have not touched anything in the script.
Title: Re: [XP] Flying Enemies
Post by: KK20 on May 05, 2012, 02:35:20 am
Couple of things I noticed:
1. The array that is suppose to configure which enemies are flying also applied to actors (fixed it)
2. When updating the battle sprites, sometimes @battler was nil. This was most likely caused by parties not of size 4. Class Spriteset_Battle, for some stupid reason, likes to think there are 4 actor sprites to update (fixed it)
Editted: ShowHide
#===============================================================================
# Flying Battlers
# Version 1.11
# Author game_guy
# Edit KK20
#-------------------------------------------------------------------------------
# Intro:
# Flying battlers adds a tad bit of realism to the game.
#
# Features:
# -Flying Enemies
# -Flying Actors for like a "Float" effect
# -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.
# -Skills with a higher INT F then ATK F will hit a flying enemy since these
#  skills are considered "Magic". (Think Fire over Double Slash or something)
# -Skills with a higher ATK F will need to be marked with the Flying Element in
#  order to hit a flying enemy.
#
# 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
  #---------------------------------------------
  # States that give enemies or actors the
  # "flying" effect.
  #---------------------------------------------
  Flying_States   = [17, 18]
  #---------------------------------------------
  # 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_Battler
 
  def flying?
    return ((self.is_a?(Game_Enemy) && GG_Fly::Flying_Enemies.include?(self.id)) || @states.any? {|id| GG_Fly::Flying_States.include?(id)})
  end
 
  alias gg_fly_attack_effect_lat attack_effect
  def attack_effect(attacker)
    if self.flying? && !attacker.element_set.include?(GG_Fly::Flying_Element)
      self.damage = GG_Fly::Miss_Message
      return true
    end
    return gg_fly_attack_effect_lat(attacker)
  end
 
  alias gg_fly_skill_effect_lat skill_effect
  def skill_effect(user, skill)
    if self.flying? && !skill.element_set.include?(GG_Fly::Flying_Element)
      if skill.atk_f >= skill.int_f
        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
      @update_frame = 0
      @speed = 2
      @new_y = battler.screen_y
    end
  end
 
  def battler=(bat)
    @battler = bat
    return if bat == nil
    @update_frame = 0
    @speed = 2
    @new_y = @battler.screen_y
  end
 
  alias gg_animate_flying_enemy_lat update
  def update
    gg_animate_flying_enemy_lat
    return if @battler.nil?
    if GG_Fly::Animate_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
Title: Re: [XP] Flying Enemies
Post by: Spoofus on May 05, 2012, 04:18:44 am
awesome,it works now.

thanks for the quick response KK now my flying enemies look the way they should.
Title: Re: [XP] Flying Enemies
Post by: G_G on May 06, 2012, 09:28:56 pm
Updated first post with KK20's fix. Sorry for my absence and thank you for fixing it. :3