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.

Enhanced Battle Cursors v2.2b

Enhanced Battle Cursors
Version: 2.2b

Introduction

This script packages some nifty cursor movements and effects and the ability to use animations over the cursors.

Features

  • Animations are used for the cursor, which means the scope for variety is now virtually unlimited
  • Can use two different animations for the actors and enemies

Screenshots

A moving cursor is only good when seen in motion ;)

Demo

Rather pointless, as this is a fairly simple plug-and-play script.

Script


Code:
 

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

# Enhanced Battle Cursors v2.2 beta

# by Fantasist

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

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

# - code reviewed, optimized, freed from potential bugs and beta tested by Blizzard

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

# Note: DO NOT USE THIS if you're using Tons of Addons!

#          This is already integrated there and will cause problems.

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

# * Config (these can't be changed in-game)

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

# Position

#       Set the position of the cursor

#

# 1) MONSTER_OFFSET: The height of the cursor from the monster graphic's base.

# 2) ACTOR_OFFSET: The height of the cursor from the actor graphic's base.

# 3) TOP: Whether the cursor is on the top of the monster or at the bottom.

MONSTER_OFFSET = 0

ACTOR_OFFSET = 0

TOP = true

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

# Movement Type Config

#       Configuration for the movement types used

#

# 1) Phase_Range: The distance the cursor moves away from the height while

#    phasing.

# 2) Zoom_Factor: The amount the cursor zooms in and out. Recommended range is

#    from 0 to 1, refrain from using more than 2 digits after decimal.

# 3) EBC_Type: This is the configuration of animation types

#        [Anim or not(true/false), movement type, transition type]

#      available movement types   -> phase, zoom, spin, spin2

#      available transition types -> trans, default

#    If you are using animations (first parameter is true) then use numbers

#    instead of movement and transition types to determine the animation IDs

#    of the animations used. The first is the actor, the second is the enemy

#    animation ID.

PHASE_RANGE = 16

ZOOM_FACTOR = 0.2

EBC_TYPE = [false, 'phase', 'trans']

# EBC_type can be changed ingame, refer to $game_system.battle_cursor and

# set the new values. This change is being saved with the save file.

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

 

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

# ** Game Battler

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

 

class Game_Battler

  

  def height

    RPG::Cache.battler(@battler_name, 0).height

  end

  

  def width

    RPG::Cache.battler(@battler_name, 0).width

  end

  

end

 

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

# ** Game System

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

 

class Game_System

  

  attr_accessor :battle_cursor

  

  alias init_battle_cursor initialize

  def initialize

    init_battle_cursor

    @battle_cursor = EBC_TYPE

  end  

  

end

 

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

# ** Arrow_Base

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

 

class Arrow_Base < RPG::Sprite

 

  attr_reader   :index

  attr_reader   :help_window

    

  def initialize(viewport)

    super

    if $game_system.battle_cursor[0]

      tmp, @battler = $game_system.battle_cursor, nil

      @actor_cursor = (tmp[1].is_a?(Numeric) ? tmp[1] : 98)

      @enemy_cursor = (tmp[2].is_a?(Numeric) ? tmp[2] : 99)

    else

      # Main Sprite initialization

      self.bitmap = RPG::Cache.windowskin($game_system.windowskin_name)

      self.src_rect.set(128, 96, 32, 32)

      self.ox, self.oy, self.z = 16, 64, 2501

      # Sub-sprite initialization

      if animtype('trans')

        @sp2 = Sprite.new(viewport)

        @sp2.bitmap = self.bitmap

        @sp2.src_rect.set(160, 96, 32, 32)

        @sp2.ox, @sp2.oy, @sp2.z = self.ox, self.oy, self.z-1

      end

      # Variable initialization

      @rad = 0 if animtype('trans') || ['phase', 'zoom', 'spin2'].any? {|i| movetype(i)}

      @deg = 0 if movetype('spin')

      @battler = nil

      @blink_count = 0 if animtype('default')

    end

    @y, @index, @help_window = 0, 0, nil

    update

  end

  

  def movetype(type)

    return ($game_system.battle_cursor[1] == type)

  end

  

  def animtype(type)

    return ($game_system.battle_cursor[2] == type)

  end

  

  def index=(index)

    @index = index

    update

  end

 

  def help_window=(help_window)

    @help_window = help_window

    # Update help text (update_help is defined by the subclasses)

    update_help if @help_window != nil

  end

 

  def update

    super

      if $game_system.battle_cursor[0]

        # Update animation

        id = self.is_a?(Arrow_Actor) ? @actor_cursor : @enemy_cursor

        loop_animation($data_animations[id])

      else

      if @rad

        # Cycle @rad from 0 to 2 Pi

        if @rad < 2 * Math::PI

          @rad += Math::PI/(movetype('spin2') ? 30 : 10)

        else

          @rad = 0

        end

      end

      # Animations

      trans if animtype('trans')

      default if animtype('default')

      # Movement Types

      phase if movetype('phase')

      spin if movetype('spin')

      spin2 if movetype('spin2')

      zoom if movetype('zoom')

    end

    # Update Help Window

    update_help if @help_window != nil

  end

 

  def dispose

    @sp2.dispose unless @sp2 == nil || @sp2.disposed?

    super

  end

 

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

  # * Cursor Animations

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

  def trans

    self.opacity = (Math.sin(@rad)*255).round

  end

  

  def default

    @blink_count = (@blink_count + 1) % 8

    self.src_rect.set((@blink_count < 4 ? 128 : 160), 96, 32, 32)

  end

 

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

  # * Cursor Movements

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

  def phase

    @y = ((Math.sin(@rad))*PHASE_RANGE).round

  end

 

  def spin

    # Cycle @deg from 0 to 360

    self.angle = @deg = (@deg + 18) % 360

    @sp2.angle = @deg if @sp2

  end

 

  def spin2

    self.angle = (Math.sin(@rad)*360).round

    @sp2.angle = self.angle if @sp2

  end

  

  def zoom

    self.zoom_x = self.zoom_y = 1 + Math.sin(@rad)*ZOOM_FACTOR

    @sp2.zoom_x = self.zoom_x if @sp2

  end

 

end

 

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

# ** Arrow_Enemy

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

 

class Arrow_Enemy < Arrow_Base

    

  def enemy

    return $game_troop.enemies[@index]

  end

 

  def update

    super

    # Skip if indicating a nonexistant enemy

    $game_troop.enemies.size.times do

      break if self.enemy.exist?

      @index = (@index + 1) % $game_troop.enemies.size

    end

    # Cursor right

    if Input.repeat?(Input::RIGHT)

      $game_system.se_play($data_system.cursor_se)

      $game_troop.enemies.size.times do

        @index = (@index + 1) % $game_troop.enemies.size

        break if self.enemy.exist?

      end

    # Cursor left

    elsif Input.repeat?(Input::LEFT)

      $game_system.se_play($data_system.cursor_se)

      $game_troop.enemies.size.times do

        @index = (@index + $game_troop.enemies.size - 1) % $game_troop.enemies.size

        break if self.enemy.exist?

      end

    end

    # Set sprite coordinates

    if self.enemy != nil

      self.x = self.enemy.screen_x

      if TOP

        if self.enemy.screen_y - self.enemy.height - PHASE_RANGE < 6

          self.y = self.enemy.screen_y - self.enemy.height / 2

        else

          self.y = self.enemy.screen_y - self.enemy.height

        end

      end

      self.y += -@y - MONSTER_OFFSET

      @sp2.x, @sp2.y = self.x, self.y if @sp2

    end

  end

 

  def update_help

    # Display enemy name and state in the help window

    @help_window.set_enemy(self.enemy)

  end

  

end

 

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

# ** Arrow_Actor

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

 

class Arrow_Actor < Arrow_Base

  

  def actor

    return $game_party.actors[@index]

  end

  

  def update

    super

    # Cursor right

    if Input.repeat?(Input::RIGHT)

      $game_system.se_play($data_system.cursor_se)

      @index = (@index + 1) % $game_party.actors.size

    # Cursor left

    elsif Input.repeat?(Input::LEFT)

      $game_system.se_play($data_system.cursor_se)

      @index = (@index + $game_party.actors.size - 1) % $game_party.actors.size

    end

    # Set sprite coordinates

    if self.actor != nil

      self.x = self.actor.screen_x

      self.y = self.actor.screen_y - 160

      self.y += -@y - ACTOR_OFFSET

      @sp2.x, @sp2.y = self.x, self.y if @sp2

    end

  end

  

  def update_help

    # Display actor status in help window

    @help_window.set_actor(self.actor)

  end

  

end

 

Instructions

Make a new page in the script editor just below Arrow_Actor and paste this script into it. DON'T USE THIS if you're using Tons of Addons by Blizzard. This is already integrated and will cause problems. Other instructions in script header.

FAQ

I'm awaiting questions...

Compatibility

  • This script REWRITES the Arrow_Base, Arrow_Enemy and Arrow_Actor classes, I haven't aliased anything.
  • With SDK: I haven't tested it out as I'm not an SDK user. Feel free to make it, though ^_^
  • Compatible with Blizzard's 'Tons of Add-ons v4.98(or more)'.

Credits and Thanks

Thanks: Blizzard, for helping me
Credits: Fantasist, for making

Author's Notes

If you have any questions, suggestions or problems, you can find me at:

- http://www.chaos-project.com
- http://www.quantumcore.forumotion.com

Enjoy ^_^

Terms and Conditions

You can use this as long as you give me proper credit.
 
Nice script! I like it! Cool for a first script, but my game is commercial, can I please use it if I give you 100% credit, (And Blizzard gets 100% already for SR Battle System)

I'll even cut you a deal, You allow me to keep the script, and I'll give you a free copy of the game, Exile. People say it's worth ?15/?20 when it's done and has a "5-Star Story"...

PLEASE?

Amos36

P.S- If you don't then I'll take you to the high court and charge you for being "Hairist" towards gingers..>"

P.P.S- I like P.S's :D
 
Mention in the credits that it's free and you can use it. You shouldn't be charging for the EBC, but you can charge all you want for your game ;) *goes and edits the Terms and Conditions*
And yeah, I'd appreciate a free copy. Can you point me to the thread of your game if any? I'd like to have a look. You say it's commercial, you say it has a good story, and finally, it uses the SR system. I'm really curious.

P.S - I'm glad you like the script ^_^
 
I haven't got a thread yet but I'll be sure to make one when it's nearing it's completion, as well as forums and a proper site. (Maybe)

I'm gonna upload it very soon, (Demo) so hang on tight. The story doesn't really come through until Chapter 2 in the demo, Chapter 1 is just basically the basics of battlesystem and stuffs and a bit of story and characters thrown in... But in chapter 2 it gets intresting...

I'll PM you when it's uploaded, I'm just checking through for minor errors now!

Amos36

P.S- How should I mention that this script is free? I don't wanna write it in the credits cos' I really am going for an ultimately professional look as much as possible...
 
Animated Battlers which I'm still maintaining has targetting cursor control now... but NOTHING like this!

I pasted this below AnimBat and had a good time. I had to adjust the target cursor's height (viewport thing going on), but other than that... I liked it.

Planning on an X-Coordinate adjustment too?
 
@Amos36: Hm, just add a 'freeware' tag somewhere if you can. Or, if you're going to link to the topic, nothing is necessary. I assume you'll also be distributing a txt file with detailed credits and stuff. If so, just mention it there. You don't need to do anything in the game.
@DerVVulfman: Wow, haha, you replied, yay! I'm glad you like it. I searched many forums for something like this and when I didn't coma across any, I made one myself.
Planning on an X-Coordinate adjustment too?
I don't see the point as the ox of the battler graphic is it's center(at least, I'm assuming so). But I think it works differently in your scripts. It's really easy to do. Just declare another constant and add it to "self.x = self.enemy.screen_x" and "@sp2.x = self.enemy.screen_x". I originally intended to get the battler graphic's height and width, and center the cursor. I think Dargor did that here. You can do something like that, it goes well for the DBS. But anyway, I'm working on a new idea for the cursor. If all goes well, it will be the PERFECT battle cursor and the scope for variety is... unlimited(not joking).
 
'Course I responded. :) Again... It works just fine.

Only reason I mentioned the X-Position is that Final Fantasy-type games have a tendency to have their arrows pointing to the left or right of the battlers rather than over or under them.

Nah... doesn't work differently in my system (save for the viewport... big whoop ;) ). Other than the cheapo x/y positioning system (wow... two lines of code) that your system can overwrite, the cursor positioning I have is absolutely nothing special. Yours if far better in features and customization.

Waiting to see what you're adding. :please:
 
Waiting to see what you're adding.
Sorry, I'm on other projects for the time being. It'll be long before I come up with an update.

To everyone: If you know how to add other effects, feel free to customize the script. Do whatever you want with it.
 
:bump:
Major update on its way, and it's an integrated version of v1.4 and v2.

@Amos36: Sorry man, seems like you left this because of the credit thing. If you have a credit scene, just mention the script and my name, no need of mentioning that it's free, okay? Good luck with your game.

[EDIT]
v2.2b is up, and changed Terms of Conditions.
[/edit]
 

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