Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Common Events in Combat
Dalhan
post Nov 2 2012, 12:00 AM
Post #1


Level 1
Group Icon

Group: Member
Posts: 5
Type: None
RM Skill: Undisclosed




I'm trying to rig up a common event system that checks a players class when they attack an opponent. If the player is X class, regen Z SP on normal attacks. I know common events can be fairly powerful and not being an expert scripter, I figured this would be my work around.

The Goal:

Common Event Checks for 4 classes [1, 2, 3, 4]
If class is [1, 2], regen SP on normal attack only
If class is [3, 4] Regen % of SP each turn

If there is a way to do this, can some one please direct me. Thanks in advance!
Go to the top of the page
 
+Quote Post
   
Jens of Zanicuud
post Nov 2 2012, 04:47 AM
Post #2


Dark Jentleman
Group Icon

Group: Local Mod
Posts: 904
Type: Scripter
RM Skill: Skilled
Rev Points: 120




Let's use some conditional branch smile.gif

In page 4, you have the option to insert a script, right?
First off, remember that there's some problems for the common event to understand who the last active battler was.

Then, first step:

1. Open the script editor, go to Scene_Battle 1 and add this in line 8:

CODE
attr_reader :active_battler


By calling $scene.active_battler, your game will recognize who was the last one doing the action.

So... 2nd step:

2. create the desired common event and use a conditional branch with this code:

CODE
[1,2].include?($scene.active_battler.class_id)


Just replace [1,2] with the class id you wanna check. For example [1,4].include?($scene.active_battler.class_id) will let the branch execute the command if and only if the actor who attacked has a class id equal to 1 or 4.

So, you should be able to solve your problem.
Remember you can employ Common Events only in skills.

Anyway, if I wasn't too much explanatory, just reply here (don't be afraid to ask, this isn't too easy to understand).

I hope this can help,

Jens


__________________________
"Thorns are the rose's sweetest essence..."
-Jens of Zanicuud


Games I'm working on:
>

official website: TryAdIne eFfeCt

>

Games I worked on (mainly as a scripter):
>
(Warning: it's a 3rr3's project and it's in Italian!)


Awards

Go to the top of the page
 
+Quote Post
   
Dalhan
post Nov 2 2012, 03:05 PM
Post #3


Level 1
Group Icon

Group: Member
Posts: 5
Type: None
RM Skill: Undisclosed




Thanks, this is pretty much what I wanted! But I have two more questions now :x

Firstly, you said common events can only be employed in skills. Does this mean I wont be able to have the event run when players do standard attacks? (Guard, attack, etc)

Secondly, the GUI input for increasing a players SP (The option on page 3, change SP) doesn't work with percentages. Am I able to assign a percentage to a variable and then reference that?

I get the odd feeling I'm going to end up scripting all of this >_<
Go to the top of the page
 
+Quote Post
   
Jens of Zanicuud
post Nov 3 2012, 01:56 AM
Post #4


Dark Jentleman
Group Icon

Group: Local Mod
Posts: 904
Type: Scripter
RM Skill: Skilled
Rev Points: 120




QUOTE (Dalhan @ Nov 3 2012, 12:05 AM) *
Thanks, this is pretty much what I wanted! But I have two more questions now :x

Firstly, you said common events can only be employed in skills. Does this mean I wont be able to have the event run when players do standard attacks? (Guard, attack, etc)

Secondly, the GUI input for increasing a players SP (The option on page 3, change SP) doesn't work with percentages. Am I able to assign a percentage to a variable and then reference that?

I get the odd feeling I'm going to end up scripting all of this >_<


Unfortunately... you're going to script everything if you're planning to use normal attacks.
This is because common events are only tied to skills and items.
BTW, no need to worry, it's not so much difficult to do smile.gif

Try pasting this above main smile.gif

CODE
#--------------------------------------------------------------------------
  # ** Battle Invariables
  #--------------------------------------------------------------------------
  module Battle
     SP_RECOVERY_RATE = 3.0 #percentage of SP recovered with every attack
  end
  #--------------------------------------------------------------------------
  # ** Scene_Battle
  #--------------------------------------------------------------------------
  class Scene_Battle
  #--------------------------------------------------------------------------
  # * aliases
  #--------------------------------------------------------------------------
  alias old_update_phase4_step5 update_phase4_step5
  #--------------------------------------------------------------------------
  # * update phase 4 (step 5 - id est damage display)
  #--------------------------------------------------------------------------
  def update_phase4_step5
    # call aliased method
    old_update_phase4_step5
    # show active battler "damage"
    if @active_battler.damage != nil
        @active_battler.damage_pop = true
    end
  end
  # class end
  end

  #--------------------------------------------------------------------------
  # ** Game_Battler
  #--------------------------------------------------------------------------
  class Game_Battler
  #--------------------------------------------------------------------------
  # * aliases
  #--------------------------------------------------------------------------
  alias old_attack_effect attack_effect
  #--------------------------------------------------------------------------
  # * attack_effect
  #     attacker : battler who performs the attack
  #--------------------------------------------------------------------------
  def attack_effect(attacker)
    # call aliased method
    old_attack_effect(attacker)
    # add sp recovery
    if self.damage != nil and self.damage != "Miss"
    dmg          = (Battle::SP_RECOVERY_RATE*attacker.maxsp/100).to_i
    attacker.sp     += dmg
    attacker.damage  = - dmg
    end
  end
end



Anyway, remember that you can also use variable to vary SP. To increase a character's SP by means of a variable, just do what I list below:

1. Variable[001] = Battler MAXSP
2. Variable[001] *= 3
3. Variable[001] /= 100
4. Change Battler SP (battler, Variable[001])

without using scripts smile.gif
You can also do this:

(call script)

battler = $scene.active_battler
sp_recovery = battler.maxsp * 3 / 100
battler.sp += sp_recovery

(end of the call script)

I hope this can help smile.gif
Jens


__________________________
"Thorns are the rose's sweetest essence..."
-Jens of Zanicuud


Games I'm working on:
>

official website: TryAdIne eFfeCt

>

Games I worked on (mainly as a scripter):
>
(Warning: it's a 3rr3's project and it's in Italian!)


Awards

Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 23rd May 2013 - 02:08 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker