Posts: 29
Threads: 4
Joined: Dec 2019
Hello,
After balancing the stats and working out the skills and talents for my rmxp game during the past couple of days, I am running into a bump.
For many of the skills my actors use, I want to have a cooldown function. Meaning they cannot use specific skills for X number of turns (I use the default battle system).
Example:
Skill 1 has no cooldown
Skill 2 has a cooldown of 3 turns
Skill 3 has a cooldown of 10 turns
Ideally these skills will be greyed-out when on cooldown.
I suppose this can be done with eventing, but I think it would be far more efficient with a script.
When I looked for one, I could not find anything for rmxp.
I am hoping someone can refer me to a working script or help me tweaking one to make it work in the way I'm looking for.
As mentioned, I do not use a custom battle system, but I do use some scripts that influence battle/skills which I'll post just in case:
Threat system by Fantasist, reflection by Blizzard, hots dots by Shdwlink1993.
Posts: 449
Threads: 18
Joined: Sep 2015
12-06-2019, 06:07 PM
(This post was last modified: 12-06-2019, 06:09 PM by Mel.)
You could try this script.
Sadly I don't know who made this anymore
Code: #==============================================================================
#
#------------------------------------------------------------------------------
#
#==============================================================================
module Config
Cooldown = {} # Do not touch
Cooldown[1] = 10 # Skill with ID 1 has a cooldown of 10 turns.
end
#==============================================================================
#
#------------------------------------------------------------------------------
#
#==============================================================================
class RPG::Skill
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
def cooldown
return (Config::Cooldown[@id] != nil ? Config::Cooldown[@id] : 0)
end
end
#==============================================================================
#
#------------------------------------------------------------------------------
#
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
attr_accessor :cooldown
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
alias cooldown_initialize initialize
def initialize
cooldown_initialize
@cooldown = {}
end
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
alias cooldown_skill_can_use skill_can_use?
def skill_can_use?(skill_id)
return false if @cooldown[skill_id] != nil and @cooldown[skill_id] > 0
return cooldown_skill_can_use(skill_id)
end
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
def update_cooldowns
@cooldown.keys.each {|id|
@cooldown[id] = [@cooldown[id] - 1, 0].max if @cooldown[id] != nil
}
end
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
def cooldown_clear
@cooldown.keys.each {|id| @cooldown[id] = 0}
end
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
alias cooldown_skill_effect skill_effect
def skill_effect(user, skill)
effective = cooldown_skill_effect(user, skill)
user.cooldown[skill.id] = skill.cooldown if effective
return effective
end
end
#==============================================================================
#
#------------------------------------------------------------------------------
#
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
alias cooldown_update_phase4_step2 update_phase4_step2
def update_phase4_step2
@active_battler.update_cooldowns
cooldown_update_phase4_step2
end
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
alias cooldown_battle_end battle_end
def battle_end(result)
for actor in $game_party.actors
actor.cooldown_clear
end
cooldown_battle_end(result)
end
end
Posts: 29
Threads: 4
Joined: Dec 2019
12-06-2019, 06:30 PM
(This post was last modified: 12-06-2019, 06:39 PM by Fenriswolf.)
(12-06-2019, 06:07 PM)Melana Wrote: You could try this script.
Sadly I don't know who made this anymore
Thanks for the script!
But, when I tested, the skill was still available after the first turn.
When I used it again in turn 2, it became grey in turn 3 though.
Any idea why?
EDIT: it doesn't seem to be working at all now. I'm using a fresh project without scripts to test.
Posts: 449
Threads: 18
Joined: Sep 2015
Hmm it works for me.
If I start a fresh project and give Aluxes' Cross Cut Skill a cooldown of 3 turns, it greys out once he uses the skill.
Posts: 29
Threads: 4
Joined: Dec 2019
(12-07-2019, 12:40 AM)Melana Wrote: Hmm it works for me.
If I start a fresh project and give Aluxes' Cross Cut Skill a cooldown of 3 turns, it greys out once he uses the skill.
It might have been because I used a healing skill, I will try again tomorrow morning.
Posts: 11,230
Threads: 649
Joined: May 2009
Hey, guys. That script is by Victor Sant. He wrote that back in 2011 when he was still known as Atoa.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Above are clickable links
Posts: 29
Threads: 4
Joined: Dec 2019
(12-07-2019, 04:53 AM)DerVVulfman Wrote: Hey, guys. That script is by Victor Sant. He wrote that back in 2011 when he was still known as Atoa.
Alright, I'll put his name in the script so I won't forget to credit him if I ever share it.
Also, it seems to be pretty glitchy with healing spells (I need to use a spell twice in a row to trigger the cooldown and it will be one turn less than supposed to).
Could it be that the script will have trouble with such skills because of their scope or occasion?
Posts: 29
Threads: 4
Joined: Dec 2019
(12-07-2019, 12:24 PM)Fenriswolf Wrote: (12-07-2019, 04:53 AM)DerVVulfman Wrote: Hey, guys. That script is by Victor Sant. He wrote that back in 2011 when he was still known as Atoa.
Alright, I'll put his name in the script so I won't forget to credit him if I ever share it.
Also, it seems to be pretty glitchy with healing spells (I need to use a spell twice in a row to trigger the cooldown and it will be one turn less than supposed to).
Could it be that the script will have trouble with such skills because of their scope or occasion?
I figured out what the problem is.
Whenever a skill has a negative number or 0 as power value, the script won't work as intended.
Problem is, I mostly want to use cooldowns for utility skills (buffs, disabling abilities, etc.).
Meaning I can not use the script this way.
Anybody willing to help me fix this?
Posts: 4,606
Threads: 543
Joined: Dec 2009
There's a part of the script that says "if effective"... Why don't you comment it out? That means placing a # pound symbol right in front of it... Check out if it now works as expected.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Posts: 29
Threads: 4
Joined: Dec 2019
(12-09-2019, 12:28 AM)kyonides Wrote: There's a part of the script that says "if effective"... Why don't you comment it out? That means placing a # pound symbol right in front of it... Check out if it now works as expected.
Thanks, that did the trick!
It works now, so long as a skill doesn't have scope "none", which is fine.
This should make the combat much more interesting, by having to use rotations and timing your "once in a battle" skills.
|