Author Topic: [XP] Action Recharge Times (for BABS)  (Read 30743 times)

Offline winkio

  • Epiq
  • Administrator
  • Guardian of Chaos
  • *****
  • Posts: 4506
  • LV: 199
  • Gender: Male
  • I am lying.
    • View Profile
[XP] Action Recharge Times (for BABS)
« on: December 12, 2008, 02:25:43 AM »
Action Recharge Times
Authors: winkio
Version: 1.11
Type: Misc. Add-on
Key Term: Blizz-ABS Plugin

Introduction

This script adds the function of recharge times for weapons, items, skills, and enemy attacks to Blizz-ABS.

Features

  • Recharge times for weapons, items, skills, and enemy attacks
  • Works with custom HUDs
  • Recharge bar and number counter

Screenshots
Note: this screenshot also features my custom HUD, but this script works without it.
(click to show/hide)

Script

(click to show/hide)


Instructions
PUT BELOW BLIZZ-ABS
Configure the recharge times like they are in Blizz-ABS.  What that means in for each skill/item/weapo/enemy, under the appropriate area, put in
Code: [Select]
when (ID OF SKILL/ITEM/WEAPON/ENEMY) then return (RECHARGE TIME)The recharge time is in frames.  40 frames is about 1 second.

Compatibility

Made for Blizz-ABS 2.82 and above.

Credits and Thanks

  • Blizzard for setting down some main code
  • Aqua for testing it and telling me all my stupid mistakes
  • winkio

Author's Notes

Just a note: it seems to lag very slightly if a lot of stuff is recharging at once, like 5 or more things.

If you have any ideas for other ways to show something recharging that you want implemented, let me know.  I originally had a spiral recharge thing like most MMOs do (WoW and Guild Wars, for example), but it lagged too much.  I will look into ways to reduce that lag, but it may not be possible.
« Last Edit: August 16, 2013, 04:31:41 AM by KK20 »

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19906
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Recharge times for Blizz-ABS
« Reply #1 on: December 12, 2008, 12:23:55 PM »
I actually made a plugin for that. I just can't remember for whom it was. >.< I think it was NAMKCOR. Anyway, I promised not to release it. ._. You should ask him if it's ok with him. Or wait until I implement it into Blizz-ABS. >.<
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline winkio

  • Epiq
  • Administrator
  • Guardian of Chaos
  • *****
  • Posts: 4506
  • LV: 199
  • Gender: Male
  • I am lying.
    • View Profile
Re: Recharge times for Blizz-ABS
« Reply #2 on: December 13, 2008, 12:45:04 AM »
I think it's all right.  I don't want to get you in trouble (although I don't know why the person would think that recharge times are so original) but I figured it out from the AI triggers :P
(don't know why I didn't look there earlier)

So... once I end up getting this to work, will it be allowed for me to post it up?  Because this is kind of independent...

And if I do end up posting this up, will you just put yours up too thereby nullifying mine?  In which case, it wouldn't even be worth it to develop it on my own...

I'll pm Namkcor and see what he thinks as well.

Offline tSwitch

  • The Haunting
  • Chaos User
  • ******
  • Posts: 1448
  • LV: 1046
  • Gender: Female
  • formerly NAMKCOR
    • View Profile
Re: Recharge times for Blizz-ABS
« Reply #3 on: December 15, 2008, 06:12:41 PM »
I actually made a plugin for that. I just can't remember for whom it was. >.< I think it was NAMKCOR. Anyway, I promised not to release it. ._. You should ask him if it's ok with him. Or wait until I implement it into Blizz-ABS. >.<

Blizz, go ahead and release it

FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: tSwitch.us | Twitter | Tumblr

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19906
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Recharge times for Blizz-ABS
« Reply #4 on: December 15, 2008, 09:50:20 PM »
Alright, here you go:

Code: [Select]
class BlizzABS::Cache
 
  alias init_recharger_later initialize
  def initialize
    init_recharger_later
    @data['empty_hud_yellow_bar'] = @data['empty_hud_green_bar'].clone
    @data['empty_hud_yellow_bar'].hue_change(-60)
    @data['hud_yellow_bar'] = @data['hud_green_bar'].clone
    @data['hud_yellow_bar'].hue_change(-60)
    #p 1
    #p self.image('hud_yellow_bar')
  end
   
end
 
$BlizzABS = BlizzABS::Processor.new

class Recharger < Sprite
  def initialize
    super
    self.bitmap = Bitmap.new(156, 14)
    color = case BlizzABS::Config::HUD_TYPE
    when 0 then Color.new(255, 255, 255, 192)
    when 1 then Color.new(0, 0, 0, 0)
    end
    self.bitmap.fill_rect(0, 0, 156, 14, color) if color.is_a?(Color)
    self.x = 4
    update
  end
  def update
    super
    now, full = $game_player.recharge
    self.bitmap.gradient_bar_hud(0, 0, 154, now.to_f/full, 'hud_yellow_bar')
    self.dispose if !$game_player.recharging?
  end
end

class Scene_Map
  alias main_recharger_later main
  def main
    @recharge_bar = Recharger.new if $game_player.recharging?
    main_recharger_later
    @recharge_bar.dispose if @recharge_bar != nil
  end
  alias upd_recharger_later update
  def update
    if $game_player.recharging? && @recharge_bar == nil
      @recharge_bar = Recharger.new
    end
    upd_recharger_later
    if @recharge_bar != nil
      if @hud != nil
        @recharge_bar.y = @hud.y + @hud.bitmap.height + 4
      else
        @recharge_bar.y = 4
      end
      @recharge_bar.update
      @recharge_bar = nil if @recharge_bar.disposed?
    end
  end
end

class Map_Battler
  attr_reader :recharge
  alias upd_recharger_later update
  def update
    @recharge[0] -= 1 if recharging?
    upd_recharger_later
  end
  alias freeze_action_recharger_later freeze_action
  def freeze_action
    return (freeze_action_recharger_later || recharging?)
  end
  alias skill_penalty_recharger_later skill_penalty
  def skill_penalty(id)
    re = BlizzABS::Skills.recharge(id)
    @recharge = [re, re]
    return skill_penalty_recharger_later(id)
  end
  alias item_penalty_recharger_later item_penalty
  def item_penalty(id)
    re = BlizzABS::Skills.recharge(id)
    @recharge = [re, re]
    return item_penalty_recharger_later(id)
  end
  def recharging?
    return (@recharge != nil && @recharge[0] > 0)
  end
end

class Map_Actor
  alias attack_penalty_recharger_later attack_penalty
  def attack_penalty
    re = BlizzABS::Weapons.recharge(@battler.weapon_id)
    @recharge = [re, re]
    return attack_penalty_recharger_later
  end
end

class Map_Enemy
  alias attack_penalty_recharger_later attack_penalty
  def attack_penalty
    re = BlizzABS::Enemies.recharge(@battler.weapon_id)
    @recharge = [re, re]
    return attack_penalty_recharger_later
  end
end

module BlizzABS
  module Weapons
    def self.recharge(id)
      case id
      when 1 then return 40
      end
      return 40
    end
  end
  module Skills
    def self.recharge(id)
      case id
      when 1 then return 40
      end
      return 40
    end
  end
  module Items
    def self.recharge(id)
      case id
      when 1 then return 40
      end
      return 40
    end
  end
  module Enemies
    def self.recharge(id)
      case id
      when 1 then return 40
      end
      return 40
    end
  end
end

I'll put it up later as plugin.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline Aqua

  • Lexima Warrior
  • *******
  • Posts: 2554
  • LV: 118
  • Gender: Female
  • Quack!
    • View Profile
Re: Recharge times for Blizz-ABS
« Reply #5 on: December 15, 2008, 11:36:20 PM »
Eep!  This is not what I wanted...

Lol winkio was actually making this system because I requested it.

I wanted that each skill have its OWN counter to prevent itself from being used spammily instead of just one that prevents the character from doing anything else.
*cough* like in MMOs *cough*

I'm pretty sure winkio knows what I'm talking about.

Offline winkio

  • Epiq
  • Administrator
  • Guardian of Chaos
  • *****
  • Posts: 4506
  • LV: 199
  • Gender: Male
  • I am lying.
    • View Profile
Re: Recharge times for Blizz-ABS
« Reply #6 on: December 16, 2008, 01:05:10 AM »
Yeah sorry Aqua for not doing this over the weekend.  I underestimated the amount of studying I needed (and still need) to do for finals, which I have through friday this week.  I should have it done by Christmas, as long as my family doesn't have too much planned...

Blizz's system is pretty much how I am doing mine, except of course the array of recharge counters that I have, and the update is on the hotkey bar, not the hud.

Another thing that you might be able to help me with blizz is if there is any method to fill a polygon.  I'm sure there is, I just can't seem to find it.

And yes, Aqua requested this, but I had this idea for a while on my back burner, along with most of my other stuff.  So it's for me too.  (And other people may want this as well)

Offline Aqua

  • Lexima Warrior
  • *******
  • Posts: 2554
  • LV: 118
  • Gender: Female
  • Quack!
    • View Profile
Re: Recharge times for Blizz-ABS
« Reply #7 on: December 16, 2008, 01:11:20 AM »
winkio, take your time with this; I'm in no rush.
Eductation is always important!

Offline Diokatsu

  • Wind God
  • Lexima Warrior
  • *******
  • Posts: 2805
  • LV: 52
  • Gender: Male
  • Fuck yes.
    • View Profile
Re: Recharge times for Blizz-ABS
« Reply #8 on: December 16, 2008, 01:13:31 AM »
"Eductation"...Irony! XD

I'm actually look to use this :X This is quite neat and really simplifies my project that I'm working on.

Offline winkio

  • Epiq
  • Administrator
  • Guardian of Chaos
  • *****
  • Posts: 4506
  • LV: 199
  • Gender: Male
  • I am lying.
    • View Profile
Re: Recharge times for Blizz-ABS
« Reply #9 on: December 16, 2008, 03:38:56 AM »
I'm working on it a bit tonight because it kind-of counts as studying for my low-level computer science class. ;)

EDIT:  Ok, finished the system, only through borrowing a small part of Blizz's code.  Now to add the visual indicators on the hotkey bar.

@anyone who knows: how do I fill a polygon?
« Last Edit: December 16, 2008, 04:33:35 AM by winkio »

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19906
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Recharge times for Blizz-ABS
« Reply #10 on: December 16, 2008, 01:18:42 PM »
LMAO! I made that for NAMK almost a year ago. xD Feel free to take the entire code and make a new version featuring individual recharges without the bar. Just be sure to add the appropriate stuff like Blizz-ABS-is-there check, etc. Best you integrate the check for usage in Map_Battler#skill_can_use? instead of direct implementation in the deriving classes like I did.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline winkio

  • Epiq
  • Administrator
  • Guardian of Chaos
  • *****
  • Posts: 4506
  • LV: 199
  • Gender: Male
  • I am lying.
    • View Profile
Re: Recharge times for Blizz-ABS
« Reply #11 on: December 16, 2008, 04:06:50 PM »
Yes, I modified skill_can_use, attack_can_use, and item_can use, and I'm using two paralell arrays: one for max recharge times, and one for the counters.  And there is no lag:)

The only thing left is some way to show it's charging.  If there is a way to fill a polygon or triangle, I can use that, otherwise, I'll make a little bar for each thing on the hotkeys

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19906
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Recharge times for Blizz-ABS
« Reply #12 on: December 16, 2008, 05:33:34 PM »
You have to code the filling of polygons or triangles yourself by using pixel and rectangle filling. In other words: no.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline winkio

  • Epiq
  • Administrator
  • Guardian of Chaos
  • *****
  • Posts: 4506
  • LV: 199
  • Gender: Male
  • I am lying.
    • View Profile
Re: Recharge times for Blizz-ABS
« Reply #13 on: December 16, 2008, 06:49:05 PM »
darn, thought so.  Well, as might as well just code the whole drawing of the sector at once.

EDIT:  Sweet, I finished it, using a 3-part piecewise function.  The only problem is that it seems to go one pixel over each edge of the icon.  Any ideas why?

Also, it won't fill the rectangle the opacity of the color I give it.  Why?

Final question: It seems that the hotkey bar only updates upon activation/deactivation for me.  Why?
« Last Edit: December 17, 2008, 11:21:56 PM by winkio »

Offline Aqua

  • Lexima Warrior
  • *******
  • Posts: 2554
  • LV: 118
  • Gender: Female
  • Quack!
    • View Profile
Re: Recharge times for Blizz-ABS
« Reply #14 on: December 18, 2008, 12:06:49 AM »
Woah that lagged a lot :O
And I'm not sure about this, but the rectangles over the icons might not be disposed when the time is over.

Other than that, good job :)

Offline winkio

  • Epiq
  • Administrator
  • Guardian of Chaos
  • *****
  • Posts: 4506
  • LV: 199
  • Gender: Male
  • I am lying.
    • View Profile
Re: Recharge times for Blizz-ABS
« Reply #15 on: December 18, 2008, 12:20:55 AM »
MAJOR EDIT: All the old testing code is gone, because the script is finished!!!
« Last Edit: December 19, 2008, 07:13:07 PM by winkio »

Offline winkio

  • Epiq
  • Administrator
  • Guardian of Chaos
  • *****
  • Posts: 4506
  • LV: 199
  • Gender: Male
  • I am lying.
    • View Profile
Re: [XP] Action Recharge Times (for BABS)
« Reply #16 on: December 19, 2008, 11:54:17 PM »
bump bump bump bump BUMP BUMP BUMP BUMP BUMP BUUMMMMMMMMMMMMP

Ah, that felt good. :^_^':

Yep, this thing is done, so look at it!

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19906
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP] Action Recharge Times (for BABS)
« Reply #17 on: December 20, 2008, 01:37:13 PM »
The recharge time is in frames.  40 frames is about 1 second.

Lol, 40 frames is exactly one second.
That reminds me of that episode of Big Bang Theory where those two guys have to push a closet up the stairs and the angle is 30°. One of them is like "That should decrease the power needed by around half." and the other is like "... by EXACTLY half."
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline Kagutsuchi

  • Ethereal Devastator
  • ****
  • Posts: 468
  • LV: 2
  • Gender: Male
  • The God of .. eating souls?
    • View Profile
    • University Hosted Web Page - In Norwegian
Re: [XP] Action Recharge Times (for BABS)
« Reply #18 on: December 22, 2008, 12:14:13 AM »
Very nice ^^ a long awaited script =D

Offline Makasu

  • Transcended Spirit
  • ***
  • Posts: 194
  • LV: 0
  • Gender: Male
  • Kermit wants to sex you up. Yes he does. ;]
    • View Profile
    • Scribbles-n-bits.com
Re: [XP] Action Recharge Times (for BABS)
« Reply #19 on: December 22, 2008, 02:01:16 AM »
Does it matter where this script is posted? IE above BABS or below it? Just curious is all. G'job as well. :3
Dead on Arrival is the name of my project. Topic thread coming sooner or later.

Me on deviantart.com
(click to show/hide)