Quicktime Event during battle

Cobblestone

Warper
Member
Joined
Feb 11, 2018
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMVXA
Hello there,
So basically I'm new to ruby (and RPGMVXA) and tried to get some Quicktime Events during battle going but still have some issues on typing a script.
So what I'm trying to write is:
A new event is created and called whenever the actor himself or an enemy does an attack or skill but it only happens with a 27% probability. Depending on whoever called the event there are two cases:
- Case 1: The actor. If the actor calls the Quicktime Event, the player has two seconds time to press a random button which will be shown on the screen. If he fails nothing will happen; if he succeeds the damage on the chosen skill will be doubled.
-Case 2: The enemy. If the enemy calls the Quicktime Event, the player has two seconds time to press a random button which will be shown on the screen. If he fails the attack/skill will normally been executed and if he succeeds the damage will be negated.

So far, this is the code I have but it probably has lots of mistakes and I still have some questions ons my Mind.

Code:
class QuicktimeEvent < Game_Battler;
 
  #Could start at BattleManager StartTurn or Game_Battler
 
 
  #Initialize
  def initialize;
    @@SaveLetter = 0;
    translate();
    run();
  end;
 
 
  #Decision if Enemy: calls Game_BattlerBase
  def run();
    if(super.actor? == true); 
      event1();
    else if(super.enemy? == true); 
      event2();
    else;
      nil;
    end;
  end;
 
  #Returns if the QuicktimeEvent (with a chance of 27% will be called)
 def percent();
   x = Random.new(101);
   if (x >= 27);
     return 1;
   else;
     return 0;
   end;
 end;


#Event1 (when run() returns an actor)
 def event1();
    if(percent() == 1);
      #show picturen(missing)
    t1 = Time.getlocal + "00:00:02";
    if(t1 <= Time.getlocal && Input.press?(:@@SaveLetter) == true);
      super.make_damage_value = super.make_damage_value*2;
    end;
     #remove picture (missing)
   end;   
 end;


 #Event2 (when run() returns an enemy)
 def event2();
if(percent() == 1);
   #Show picture (missing)
    t2 = Time.getlocal + "00:00:02";
    if(t2 <= Time.getlocal && Input.press?(:@@SaveLetter) == true);
      super.make_damage_value = 0;
    end;
     #remove picture (missing)
    end;
   end;

  #Returns a random Letter (a-z)
 def translate();
   x = Random.new(27)
  case(x != 27);
   when x == 1;
     @@SaveLetter = A;
   when x == 2;
     @@SaveLetter = B;
   when x == 3;
     @@SaveLetter = C;
    when x == 4;
     @@SaveLetter = D;
   when x == 5;
     @@SaveLetter = E;
   when x == 6;
     @@SaveLetter = F;
   when x == 7;
     @@SaveLetter = G;
   when x == 8;
     @@SaveLetter = H;
   when x == 9;
     @@SaveLetter = I;
   when x == 10;
     @@SaveLetter = J;
   when x == 11;
     @@SaveLetter = K;
   when x == 12;
     @@SaveLetter = L;
   when x == 13;
     @@SaveLetter = M;
   when x == 14;
     @@SaveLetter = N;
   when x == 15;
     @@SaveLetter = O;
   when x == 16;
     @@SaveLetter = P;
   when x == 17;
     @@SaveLetter = Q;
   when x == 18;
     @@SaveLetter = R;
   when x == 19;
     @@SaveLetter = S;
   when x == 20;
     @@SaveLetter = T;
   when x == 21;
     @@SaveLetter = U;
   when x == 22;
     @@SaveLetter = V;
   when x == 23;
     @@SaveLetter = W;
   when x == 24;
     @@SaveLetter = X;
   when x == 25;
     @@SaveLetter = Y;
   when x == 26;
     @@SaveLetter = Z;
   else;
     nil;
   end;
 end;
   
end;
1.) In which Script can I call a new QTE? I thought about calling it in BattleManager or Game_Battler but I'm not quite sure yet.
2.) How can I show and erase a picture during battle? That's probably the main problem because I have absolutely no idea how to do that since Common Events can't be called during battle.... :( That's also where I'm trying to implement the "SaveLetter". The letter should also be used for the path where you can find the picture afterwards. For example if @SaveLetter == A it should show the picture wit the name "A.png".
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
'Scripts' is where completed scripts which people have written and want to share with others can be posted.

[move]Learning Ruby and RGSSx[/move]
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
First, you have really unusual ruby writing style, as we don't usually use "()" at the end of method name while it's not wrong anyway. It just kinda hard to read

Second, I dont think you really need to make an inheritance out of Game_Battler unless you know what you do. Instead, you might need to create quicktime object inside the Game_Battler, not inherited from it.

Third, you don't really need Time module, you can use frame as measure, such as 120 frames is equal as two second. Unless you're making a rhythm game.

Fourth, everything I see are wrong. Now, don't get offended yet. But, I really suggest you that before you start making on whatever script you've been dreaming of, it's better to understand how default script works first before you start making a new system. Start to learn by making changes, not start to learn by making a new system without knowing where you gonna put it. Eventually understanding why default script structured like that. Believe me, I learned a lot just by looking at how default script is being written
 

Cobblestone

Warper
Member
Joined
Feb 11, 2018
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMVXA
First, you have really unusual ruby writing style, as we don't usually use "()" at the end of method name while it's not wrong anyway. It just kinda hard to read

Second, I dont think you really need to make an inheritance out of Game_Battler unless you know what you do. Instead, you might need to create quicktime object inside the Game_Battler, not inherited from it.

Third, you don't really need Time module, you can use frame as measure, such as 120 frames is equal as two second. Unless you're making a rhythm game.

Fourth, everything I see are wrong. Now, don't get offended yet. But, I really suggest you that before you start making on whatever script you've been dreaming of, it's better to understand how default script works first before you start making a new system. Start to learn by making changes, not start to learn by making a new system without knowing where you gonna put it. Eventually understanding why default script structured like that. Believe me, I learned a lot just by looking at how default script is being written
First thanks for your response. ^^
Yeah I already knew that my writing style with all the () and ; is kind of complicated but I'm used to use Java so that's why.
To Fourth: Yeah, I already had that kind of feeling :(. Like I said I'm pretty new to RPGMaker and just read some scripts trying to find out how to do these QTEs.
 

Cobblestone

Warper
Member
Joined
Feb 11, 2018
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMVXA
Ok so I looked some things up and tried to improve my code.

Code:
class QuicktimeEvent
 
  #Initialize
  def initialize
    @SaveLetter = ""
    translate()
    $in_progress = false
  end
 
  #Returns if the QuicktimeEvent (with a chance of 27% will be called)
 def percent?()
   x = Random.rand(101)
   if (x >= 27)
     return true
   else
     return false
   end
 end
 
#Event1 (for actor)
 def event_1()
   $in_progress = true
    if percent?
       show_picture
       return 1  if check_for_input_in_time?
  end 
  $in_progress = false
 end
 
 #Event2 (for enemy)
 def event_2()
   $in_progress = true
    if percent?
       show_picture
       return 2  if check_for_input_in_time?
  end   
  $in_progress = false
  end

  #Returns a random Letter from a-z
 def translate()
   x = Random.rand(27)
   @temp = x
   @temp.to_i
  case(x != 0 || 27)
   when x == 1
     @SaveLetter = "A"
   when x == 2
     @SaveLetter = "B"
   when x == 3
     @SaveLetter = "C"
    when x == 4
     @SaveLetter = "D"
   when x == 5
     @SaveLetter = "E"
   when x == 6
     @SaveLetter = "F"
   when x == 7
     @SaveLetter = "G"
   when x == 8
     @SaveLetter = "H"
   when x == 9
     @SaveLetter = "I"
   when x == 10
     @SaveLetter = "J"
   when x == 11
     @SaveLetter = "K"
   when x == 12
     @SaveLetter = "L"
   when x == 13
     @SaveLetter = "M"
   when x == 14
     @SaveLetter = "N"
   when x == 15
     @SaveLetter = "O"
   when x == 16
     @SaveLetter = "P"
   when x == 17
     @SaveLetter = "Q"
   when x == 18
     @SaveLetter = "R"
   when x == 19
     @SaveLetter = "S"
   when x == 20
     @SaveLetter = "T"
   when x == 21
     @SaveLetter = "U"
   when x == 22
     @SaveLetter = "V"
   when x == 23
     @SaveLetter = "W"
   when x == 24
     @SaveLetter = "X"
   when x == 25
     @SaveLetter = "Y"
   when x == 26
     @SaveLetter = "Z"
   else
     translate if x == 0
   end
 end
 
 #calls Scene_Battle to update pictures
 def show_picture()
  QTENeedToWork(@SaveLetter)
 end
 
 def check_for_input_in_time?()
       if($in_progress2 == true && Input.press?(:@SaveLetter) == true)
        return true
      else
        return false
      end
  end
 
end
So whenever the method execute_damage in Game_Battler is being called, a new Quicktime Event will be initialized and the corresponding event will be triggered (works so far). Also I've put the damage calculation into the execute_damage method as well.

Now I still have problems with showing pictures......

I figured out that Scene_Battle uses Spriteset_Battle which contains a method called create_pictures.
Am I able to use that method and how (What do I have to put into this empty array? I guess Filename and an Index as well as Position, Opacity, etc.) or are there other (smarter) methods to show a picture during battle? And if I use it; how can I refer to exactly that Scene_Battle? (I dont have an object or something like that to refer to)
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
There are two approach. First approach would be use built-in show picture, by calling
Code:
$game_troop.screen.pictures[index].show(.........)
The code is located in Game_Picture, line 72. Make sure to erase the picture after you're done with it

Second approach would be make your own sprite handler. And how you handle is up to you, but you gotta know how the sprite and bitmap class works to do so. It can be located on the spriteset, or scene, or whatever. But don't put a sprite object inside the Game_Battler, it will mess up the save file.

For starter, you might want to learn what sprite can do. For easy learning, you might want a "playground"
Code:
@sprite = Sprite.new
@sprite.bitmap = Bitmap.new(32,32)
@sprite.bitmap.fill_rect(@sprite.bitmap.rect, Color.new(255,255,255))
def update_basic
  Graphics.update
  Input.update
  @sprite.update
end
This is my usual "playground" code to learn how RGSS3 built-in classes works. You can start experimenting on how flash works, how zoom works, and many things there. It may took time, so if you want a quick solution, use the first approach
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,045
Members
137,569
Latest member
Shtelsky
Top