Using 'Instant Cast' for items, not a skill

Status
Not open for further replies.

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
In the past I have used Yanfly's Instant Cast script to enable an actor to use a skill immediately, and then have the ordinary action as well.

The comments section of the script seem to say that it is possible to do the same thing with items.  The relevant section is this:

# Item Notetags - These notetags go in the items notebox in the database.# -----------------------------------------------------------------------------# <instant># Causes the action to be an instant action. If an instant action is selected# first, then the action will be performed before the battle phase starts. If# placed behind a non-instant action, the would-be instant action will be# considered a normal action. If an enemy uses an instant action, no matter if# it was used first or after, the enemy gains an additional action.# What I would like to be able to do is to have an actor given the ability to 'instant cast' the use of any item (or maybe just a selection of items) instead of using 'instant cast' to use a skill or to attack.

However, I cannot see how to do this and restrict it to one actor.  Presumably putting <instant> in the notebox of an item makes it available for anyone to use.  I had thought of making an item which called up the ability to use an item instantly, but I can't get my head round how that might work.  Nor can I see how giving the actor a passive skill which does this might work.

Does anyone have any ideas of how to do this?  Or maybe I should be looking at a different script?

Thanks.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Not quite, as I would like everyone to be able to use healing items in the normal way, but for only one actor to be able to 'instant cast' them.  This script would mean that no one else could use the items for healing.  Also, it doesn't (I think) address the problem of how to organise Yanfly's script to use items instead of skills.

But thanks for the suggestion.
 
Last edited by a moderator:

Moogle_X

Veteran
Veteran
Joined
Apr 25, 2015
Messages
157
Reaction score
318
First Language
English
You can try use this snippet. Put this below Instant Cast script.

Change the actor id to your "instant item user" id.

class Scene_Battle < Scene_Base

  #--------------------------------------------------------------------------
  # new method: instant_action?
  #--------------------------------------------------------------------------
  def instant_action?
    return false if BattleManager.actor.nil?
    return false if BattleManager.actor.input.nil?
    action = BattleManager.actor.input.item
    if action.is_a?(RPG::Item)
      return false if BattleManager.actor.id != 1 # <= CHANGE THIS TO ACTOR ID.
    end
    return false if action.nil?
    return action.instant
  end

end
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Thank you very much, that gets me 90% of the way there - I just need one more thing.

The problem with Yanfly's script is that if the player selects an 'instant' action s/he can have as many as they like.  Instant actions only end when a non-instant action is chosen.  With a skill that is easily dealt with by having the skill perform its action and also inflict a state lasting one turn which seals that skill. I had hoped that the problem only applied to skills, but sadly it also applies to using items, and I cannot see how the inflicting state solution could be applied for this.  Can you suggest some way of restricting the use of instant item to once a turn?
 

Moogle_X

Veteran
Veteran
Joined
Apr 25, 2015
Messages
157
Reaction score
318
First Language
English
Try the new snippet. Just delete the old one. Put this below Instant Cast script.

This will limit Instant action once per turn for each actor. Don't forget to change the "instant item user" id part.

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

class Game_Actor < Game_Battler

  attr_accessor :already_instant
 
  alias moogle_setup_instant setup
  def setup(actor_id)
    moogle_setup_instant(actor_id)
    @already_instant = false
  end
 
  #--------------------------------------------------------------------------
  # * Processing at Start of Battle
  #--------------------------------------------------------------------------
  def on_battle_start
    super
    @already_instant = false
  end
 
  #--------------------------------------------------------------------------
  # * Processing at End of Battle
  #--------------------------------------------------------------------------
  def on_battle_end
    super
    @already_instant = false
  end
 
  #--------------------------------------------------------------------------
  # * Processing at End of Turn
  #--------------------------------------------------------------------------
  def on_turn_end
    super
    @already_instant = false
  end
 
end # Game_Actor

#==============================================================================
# ¡ Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base
 
  #--------------------------------------------------------------------------
  # new method: instant_action?
  #--------------------------------------------------------------------------
  def instant_action?
    return false if BattleManager.actor.nil?
    return false if BattleManager.actor.input.nil?
    action = BattleManager.actor.input.item
    if action.is_a?(RPG::Item)
      return false if BattleManager.actor.id != 2 # <= CHANGE THIS TO ACTOR ID.
    end
    return false if action.nil?
    return false if BattleManager.actor.already_instant == true
    return action.instant
  end

 
  #--------------------------------------------------------------------------
  # new method: perform_instant_action
  #--------------------------------------------------------------------------
  def perform_instant_action
    hide_instant_action_windows
    @subject = BattleManager.actor
    @subject.check_instant_action
    if @subject.current_action.valid?
      execute_action
      @subject.already_instant = true
    end
    
    process_event
    loop do
      @subject.remove_current_action
      break if $game_troop.all_dead?
      break unless @subject.current_action
      @subject.current_action.prepare
      execute_action if @subject.current_action.valid?
    end
    process_action_end
    @subject.make_actions
    @subject.restore_instant_action
    @subject = nil
    show_instant_action_windows
  end

end
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Works beautifully, does exactly what I want.

Thank you very much for this, I am most grateful.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,355
Reaction score
7,668
First Language
German
Primarily Uses
RMMV
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,986
Members
137,561
Latest member
visploo100
Top