Save-Point

Full Version: Save-Point
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Board Message
Sorry, you do not have permission to access this resource.
Save-Point - Skill Reuse Delay

Save-Point

Full Version: Skill Reuse Delay
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello people.

I have been searching for this XP script the last few days. I'm sure I've seen it in the past, but can't find it now.

For those unfamiliar with the "skill reuse delay" term;
When a skill is used it becomes temporarily unavailable for the next X turns.
This is a popular way to prevent the player from using powerful skills repeatedly.

So, I'm looking for a script that adds this option to the DBS of RPG Maker Xp, and an SDK compatible one, if possible.

Thank you in advance for your time.
Which System/Engine is this supposed to be for?
Excuse my horrible initial post, I didn't realise I actually posted this. Confused

I rewrote it and I hope it's ok now...
*bump*
Well, bump.

I might as well ask someone with scripting knowledge to help me with this. I have thought about it a bit and I came up with some simple algorhithms. My rgss skill is pretty much zero though, so I'll need help.

================================================================================
Code:
1st Part
We'll need an integer table that specifies the reuse delay for each skill in terms of turns. That's pretty simple, I think.
(If there is no reason to use tables or see any mistakes or anything, correct me. I'd like to learn.)

2nd part
We'll need another integer table, this time a AxB one, where A is the characters ans B is the skills.
Initially all integers are set to 0.
These integers represent the number of turns each character has to wait before using a skill.

3rd part
We'll need to disallow characters to use skills if the integer above is not zero.

4th part
Whenever character A uses skill B, the (A,B) integer on the second table becomes equal with the (B) integer of the first table (the specified delay of that skill).

5th part
At the beginning of each turn, all positive, non-zero integers on the second table are reduced by 1.
[/code]
============================================================================

I believe this would be a script many people would enjoy, so I think it would really be cool if someone with some rgss skill decided to give it a shot. As I see it, it shouldn't be too difficult. It would be a great learning experience for me, too.

Thank you for your time.
1st part: a hash, imho, is the solution that best fits the requirement. It's like an array, but it lets you define only the values you're interested into.

Code:
SKILL_REUSE_DELAY={
57 => 2,
58 => 3
} # {skill_id => delay}

2nd part: a table could work, but it would force you to know how many actors you have and change the code accordingly anytime you modify it. Usually, an additional attribute to the Game_Actor class is used.

Code:
class Game_Actor
  attr_accessor :skill_reuse_delays
  
  alias srd_setup setup
  def setup(actor_id)
    srd_setup(actor_id)
    @skill_reuse_delays={}
  end
  
  # To be called at the beginning of a battle
  def reset_delays
    @skill_reuse_delays={}
  end

  def delay?(skill_id)
    if @skill_reuse_delays[skill_id]!=nil
      return @skill_reuse_delays[skill_id]
    end
    return 0
  end
  
  alias srd_skill_can_use? skill_can_use?
  def skill_can_use?(skill_id)
    if delay?(skill_id) > 0
      return false
    end
    return srd_skill_can_use?(skill_id)
  end
  
  def decrease_delays
    for k in @skill_reuse_delays.keys
      @skill_reuse_delays[k]=[@skill_reuse_delays[k]-1,0].max
    end
  end
  
  def skill_used(skill_id)
    return if SKILL_REUSE_DELAY[skill_id]==nil
    @skill_reuse_delays[skill_id]=SKILL_REUSE_DELAY[skill_id]
  end
end

class Scene_Battle
  alias srd_start_phase1 start_phase1
  def start_phase1
    srd_start_phase1
    for actor in $game_party.actors
      actor.reset_delays
    end
  end
  
  alias srd_start_phase4 start_phase4
  def start_phase4
    srd_start_phase4
    for actor in $game_party.actors
      actor.decrease_delays
    end
  end
  
  alias srd_make_skill_action_result make_skill_action_result
  def make_skill_action_result
    # Memorize current SP
    active_battler_sp = @active_battler.sp unless @active_battler.is_a?(Game_Enemy)
    srd_make_skill_action_result
    return if @active_battler.is_a?(Game_Enemy)
    if active_battler_sp != @active_battler.sp
      @active_battler.skill_used(@active_battler.current_action.skill_id)
    end
  end
end

3rd part: the skill_can_use? method does that.
4th part: the skill_used method does that.
5th part: I did it in the start_phase4 method as other methods are executed more than once per turn.
Thank you very much, you've been most helpful!
Thank you for your tips too!

EDIT: As expected, it works lika a charm.
*BUMP*

I hope I'm not going too far with requesting support...

...but is there a way to make this compatible with the "Sideview Battle System Tankentai XP" script? (not for atoa's ctb or atb, just the dbs edit)

Thanks in advance...