Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

How to call skill common events before skills are used?

Hello again. I'm trying to make my battle system to where skill common events get called before the skill gets used (i.e before the skill animation and effects are shown). I'm trying to do this for two reasons: 1 so that battlers can "say" something cool before they use a skill (for example when "Fire" is being casted, I want the casting actor/enemy battler to say "Burn in hell!" And then cast the spell). And 2 so that "Weapon" Skills will play the caster's weapon attack animation instead of the skill's user animation, because each weapon has its own unique attack animation showing the weapon being swung. I've got this working perfectly for actors only, but I can't figure out how to get it to work for enemies... It's so strange, I can't make any sense of this at all.

So this is how I'm trying to change it to where the skill's common event gets called first:

#Play user Animations
@common_event_id = $data_skills[@active_battler.current_action.skill_id].common_event_id
if @animation1 > 0
@active_battler.animation_id = @animation1
@wait_count = get_wait_guess_for_animation(@animation1)
end

The common event should play before the enemy's skill animation but for some reason it only calls it "after" the animation, and "after" the effects of the skill and damage pop. And if I put in something that gives an error, the error does happen before the skill gets used like it's supposed to. I'm pretty sure this is the right place because when I remove the "@active_battler.animation_id = @animation1", the user animation doesn't play at all like I'd expect.

All night I've tried placing the "@common_event_id = $data_skills[@active_battler.current_action.skill_id].common_event_id" in hundreds of different places through out the script, and everytime it works (i.e. not get an error and actually call the event), it will only call it "after" the skill's animation and effect is shown, never before. I don't know how this is even possible when it says call it before the animation, especially since this worked just fine for actors. It seems actors and enemy skills get processed differently, I guess because of the AI. Please, if anyone can help me do this... or write me a small script that will make sure skill's common events always get called "before" the skill's animation and effects are shown, I'd greatly appreciate it... It still baffles me why, no matter where I put the @common_event_id = line, it never calls it before the skill gets used, only after... I really hope someone can help me make sense of this.
 
In Scene_Battle 4

the frame update goes like this

Step 3: User Animation (casting, sword swing, whatever)
Step 4: Attack Animation (explosion, slash, ect)
Step 5: Display Damage
Step 6: Clear Forced Battler; Common Event, if valid, refresh.

You can cut & paste the Common Event part from Step 6 and put in with step3; it'll process simultaneously with the User Animation.
Or you can paste in Step 2, under make_skill_action_result; it'll run with the Skill Name over head but before the user Ani.
(Interestingly, you can't change the text box position in battle, Only Show/hide the windowskin. )
christ_zps0sfljklo.png



Another possible problem, I'm guessing, is that you're making changes to the script and running test battle without saving. I made that mistake a hundred times.
 
A quirk of the battle system.
With this, if it's a killing blow the battle will end after the common event plays, before the attack and damage happens.
So, that's a problem.

Edit: After the common event, it'll judge that the battle is over.
Need a condition to ignore this judgement during that step. But I'm not sure what the best way to do this is.
It's part of the common event update process.
So it needs a flag distinguish it as part of a skill, and not part of a battle event that should stop the battle when the event is done. Who knows, maybe you do want a common event to stop before the animation and damage happens.
 
Thanks coyotecraft for the reply, I am saving it before I test it, and thanks for reminding me. I'm using Gubid's Tactics Battle System, it replaces the battle steps/phases with its own listed here in its Battle_Scene script:

if !$game_troop.interpreter.running? and !@message_window.visible or @common_event_q.size > 0
case @tbs_phase
###ACTOR PHASES###
when 0
tbs_phase_0 #Select actor for action.
when 1
tbs_phase_1 #Select action/move
when 2
tbs_phase_2 #Use item
when 3
tbs_phase_3 #Use skill
when 4
tbs_phase_4 #Attack
when 5
tbs_phase_5 #Move
when 6
tbs_phase_6 #Choose wait direction
###ENEMY PHASE###
when 7
tbs_phase_7 #Update AI
###RESULT PHASE###
when 8
tbs_phase_8
when 9 #Action Phase, carries out attack/skill/item on targets
tbs_phase_9
end
end
end

Currently, I have it to where the common event gets called in tbs_phase_3, and I have put it before the code for the animation shows like in my first post, and while this works perfectly for actors, it doesn't call the event at all when an enemy uses the same skill, so for enemies it must be using a different part of the script when an enemy uses a skill. That's what it appears to be according to the phase list in the script shown above. Enemy phases appear to be prioritized after actor scripts. So, I tried placing @common_event_id = $data_skills[@active_battler.current_action.skill_id].common_event_id in tbs_phase_9 first, as shown in my first post, before the the code which plays the user animation, and the common event does get called when an enemy uses the skill, but only after the entire skill is used, not before. So I tried placing the call common event script line in phase 8, and even in phase 7, which handles the enemy's AI, but it still only calls the common event after the skill gets used, never before. I've even tried placing it before the make_skill_result code gets called, and it still only shows the common event after the skill gets used. And again, this is working perfectly for actors, but not enemies, which makes it more mind boggling to me.

I don't understand how that's even possible, the script says call the common event before the skill animations get played, and if the line of code I placed there returns an error, the error pops up before the skill gets used like it's supposed to. I understand that the common event will get called as the user animation gets played, that's ok I can settle with that, but I want it to get called before the animation plays so it can turn on a switch saying its a weapon skill, so it will play the enemy's attack animation instead of the skill user animation, while also saying something cool as they cast the skill.

Maybe I'm reading the script wrong, I know very little about Ruby, can't make sense of a lot of ruby stuff, though I do know other code languages pretty well like C++, and in the past few weeks I've learned quite a few things about Ruby too as I've made several fully functioning states for this battle system such as Zombie, Reflect, Damage Split, Double Blow, ect. I've even fixed a few things that were causing crashes. But according to my knowledge of how scripts work, this shouldn't be possible, it should play the common event before the skill effects are shown, especially when I place it in tbs_phase_7 as the AI selects a skill to use. But it will only call the common event after the entire skill gets used. I hope that makes sense, hopefully I've given the right info so someone can help me get this to work, or at least help me understand why it will only call the common event after the skill shows its effect for enemy's, and not before.
 
Maybe you're just setting the @common_event_id variable earlier in the script, but not actually calling the method that runs it?
Although it's weird that it works for actors and not enemies. But it's not unusual to see battle scripts that have separate methods for Actors and Enemies.
 
Yes that's it! It was only telling it which common event to call later and not actually calling it. I had to use "$game_temp.common_event_id =" instead of "@common_event_id =" ! It's working for enemies too now. Thank you so much Coyotecraft!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top