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.

[resolved] SetSkill(x), missing step?

Hi,

I've managed to edit the counter attack function so that it applies a different skill for a certain enemy, instead of attacking. My function looks like this:



BattleManager.invokeCounterAttack = function(subject, target) {
var action = new Game_Action(target);

if (target.enemyId() == 2)
{
action.setSkill(17);
}
else
{
action.setAttack();
};


action.apply(subject);
this._logWindow.displayCounter(target);
this._logWindow.displayActionResults(target, subject);
};




This works absolutely fine. Excecutes the skill number 17. BUT...

- Doesn't play any associated common event
- Doesn't show any animation on the player


Does anyone know what command I need to use alongside setSkill(x) to make that happen? Long shot, I know.
 
Solution
Does the normal counter attack play any animation on the player? That would indicate that there's a limitation to how the counter attack is implemented in MV.

From looking at the code, the action object is created and then discarded in the invokeCounterAttack function, which means that it's simply being used as damage calculation, rather than animation/event or whatever (notice how that action object is never sent off to anything, it's just setAttack and then apply to subject).

I'd inspect the way actions are handled, it looks like there's a startAction, updateAction, endAction thing in the BattleManager:
https://github.com/rpgtkoolmv/corescrip ... Manager.js

The counter attack is modified in the updateAction phase, I have a...
Does the normal counter attack play any animation on the player? That would indicate that there's a limitation to how the counter attack is implemented in MV.

From looking at the code, the action object is created and then discarded in the invokeCounterAttack function, which means that it's simply being used as damage calculation, rather than animation/event or whatever (notice how that action object is never sent off to anything, it's just setAttack and then apply to subject).

I'd inspect the way actions are handled, it looks like there's a startAction, updateAction, endAction thing in the BattleManager:
https://github.com/rpgtkoolmv/corescrip ... Manager.js

The counter attack is modified in the updateAction phase, I have a feeling that to change this to a skill with animations + common events, etc you'd need to first end the currentAction, then start your skill as a new action.

What I'd probably do is figure out how the Force Action event command works and hijack that:
https://github.com/rpgtkoolmv/corescrip ... r.js#L1717

Maybe you'd need something like:
battler.forceAction( skillId, targetIndex );
BattleManager.forceAction( battler );
 
Solution
Excellent thank you.

Yeah you were right, even the counter attack didn't show any animation.

Replacing setSkill(x) with this worked:


$gameTroop.members()[0].forceAction( 17, subject );
BattleManager.forceAction( target );



I had to use $gameTroop.members()[0] because target just gave me errors for some reason. Not a problem as this is only going to be used in one boss fight where there's only one enemy in the troop.
 
Strange that target gives you errors on the first line but not the second line - which does expect a battler. Could be that the BattleManager.forceAction doesn't actually do anything and you're just good with the first line. Also you're in the BattleManager so you can just use this.forceAction( target )
 
It seems to think target is null, when target has been grabbed from the function arguments. So perhaps BattleManager.forceAction will work with null as an argument.

(Target and subject are the opposite way around, by the way, because this is a counter attack, so the target is attacking the subject)
 

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