RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
State affects item/skill usage

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 71
RMRK Junior
I need a script made that allows the creation of states that allow/disallow the use of items and abilities through tags.

For example: you use a revive item on someone, want them to be unable to be revived again for 10 turns.
You use an ability, let's say it's a powerful buff, and you don't want the character to be able to use it again for a while, etc.

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Woah, good idea. I'm on it. Shouldn't take long.
it's like a metaphor or something i don't know

***
Rep:
Level 71
RMRK Junior
Thanks a lot man, I can't speak on behalf of anyone else, but I try to make my games relatively challenging. I'm also always seeking new ways to spice up boss encounters as well. For example, in my new game, one of the early bosses uses a 'Flame Shield' spell that negates ALL damage, and the only way to break it is to find an item that teaches a special skill that removes flame shields. It not only removes it, but also inflicts tremendous damage, which is useful because every turn the shield remains active, the boss regenerates like 8% health. and each time the shield goes up, she strikes you with a tremendously powerful attack.

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Code: [Select]
#===============================================================================
#
# Pacman's State Skills and Items
# 4/10/2011
# Request by zerothedarklord
#
#===============================================================================
#
# To require a state for a skill or item to be used, use the tag
# <allow state: ID> where ID is the id of the state in the database.
# To require a state to not be present for a skill or item to be used, use the
# tag <disallow state: ID> as above.
# The skill function works for both enemies and actors, but the items function
# can only be used for actors because enemies can't use items.
# The way the items function works is by checking all of the actors' states and
# comparing them to the item's allow and disallow cache. Because of this, if
# one actor has the required state or disallowing state, any actor can or cannot
# use the item.
# The skills function works differently, because skills are handled per actor,
# not for the entire party.
#
#===============================================================================

#==============================================================================
# ** RPG::UsableItem
#------------------------------------------------------------------------------
#  Superclass of Skill and Item.
#==============================================================================

class RPG::UsableItem < RPG::BaseItem
  #--------------------------------------------------------------------------
  # * Get array of 'allow states'
  #--------------------------------------------------------------------------
  def allow_states_cache
    return @allow_states_cache unless @allow_states_cache.nil?
    @allow_states_cache = []
    self.note.split(/[\r\n]+/).each { |line|
      case line
      when /<(?:ALLOW STATE|allow_state):[ ](\d+(?:\s*,\s*\d+)*)>/i
        $1.scan(/\d+/).each { |num|
          @allow_states_cache.push($data_states[num.to_i]) if num.to_i > 0
        }
      end
    }
    return @allow_states_cache
  end
  #--------------------------------------------------------------------------
  # * Get array of 'disallow states'
  #--------------------------------------------------------------------------
  def disallow_states_cache
    return @disallow_states_cache unless @disallow_states_cache.nil?
    @disallow_states_cache = []
    self.note.split(/[\r\n]+/).each { |line|
      case line
      when /<(?:DISALLOW STATE|disallow_state):[ ](\d+(?:\s*,\s*\d+)*)>/i
        $1.scan(/\d+/).each { |num|
          @disallow_states_cache.push($data_states[num.to_i]) if num.to_i > 0
        }
      end
    }
    return @disallow_states_cache
  end
end

#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass of the Game_Actor
# and Game_Enemy classes.
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # Alias listing
  #--------------------------------------------------------------------------
  alias pacman_item_state_skcnus? skill_can_use?
  #--------------------------------------------------------------------------
  # * Determine Usable Skills
  #     skill : skill
  #--------------------------------------------------------------------------
  def skill_can_use?(skill, *args)
    return false unless skill.is_a?(RPG::Skill)
    if skill.disallow_states_cache.size > 0         # Find disallow states
      for state in states
        return false if skill.disallow_states_cache.include?(state)
      end
    end
    if skill.allow_states_cache.size > 0            # Find allow states
      for state in skill.allow_states_cache
        return false unless states.include?(state)
      end
    end
    return pacman_item_state_skcnus?(skill, *args)  # Run usual method
  end
end

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold
# and items. The instance of this class is referenced by $game_party.
#==============================================================================

class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # Alias listing
  #--------------------------------------------------------------------------
  alias pacman_item_state_itcnus? item_can_use?
  #--------------------------------------------------------------------------
  # * Determine if Item is Usable
  #     item : item
  #--------------------------------------------------------------------------
  def item_can_use?(item, *args)
    return false unless item.is_a?(RPG::Item)
    states = []
    for actor in members
      for state in actor.states
        states.push(state)  # Get full array of states
      end
    end
    if item.disallow_states_cache.size > 0
      for state in states
        return false if item.disallow_states_cache.include?(state)  # Disallow
      end
    end
    if item.allow_states_cache.size > 0
      for state in item.allow_states_cache
        return false unless states.include?(state)                  # Allow
      end
    end
    return pacman_item_state_itcnus?(item, *args)                   # Usual
  end
end

#===============================================================================
#
# END OF SCRIPT
#
#===============================================================================
Like this?
it's like a metaphor or something i don't know

***
Rep:
Level 71
RMRK Junior
that ought to work, but it isn't. I tested it. but according to your little notes at the top, that is what I wanted, yeah. you also didn't mention where to put the note tags though.

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Umm... yeah it is. I thought anyone would figure out that you put the tags in the notebox of the item or skill. l'll show you an example.

You use an ability, let's say it's a powerful buff, and you don't want the character to be able to use it again for a while, etc.
In the notebox of the ability that gives you the buff, you put <disallow state: ID> where ID is the id of the state the buff gives you. Then you won't be able to use it until it wears off.
You could also make a dummy state that stays there only to keep the skill from working.
it's like a metaphor or something i don't know

***
Rep:
Level 71
RMRK Junior
yeah, I did that. I put <disallow state: ID> in both the state and in the ability, then temporarily removed the ability-in-question's cooldown so I could test it and it still functioned as normal every time I used it, and the debuff the ability caused was never applied (I gave it a visible icon and it didn't ever appear).

***
Rep:
Level 71
RMRK Junior
nvm man, I got it. the ability I was using triggered a common event, and the effects of the ability went through that. as soon as I changed it to not use a common event, it worked perfectly.

For clarity: I was retarded, lmfao. my ability instant heals the user to 100%, and I did it through a common event that used the "full recovery" function. I'm a fucking idiot and failed to remember that the "full recovery" command not only heals, but removes state changes, obviously making it not work. LMFAO