Help on Variable-Based Attack Command

Trasdill

Grumpy Knight
Member
Joined
Mar 29, 2016
Messages
10
Reaction score
1
First Language
English
Primarily Uses
RMMV
Hi All,

I'm trying to get the Attack Skill for my actors to be based on a variable - in other terms, rather than having a single set "Attack" skill, the "Attack" command actually triggers whichever Skill ID is returned by a designated variable.

(Note: this assumes actors can and have learned any skill ID that would be returned by the variable and are able to cast it at the time - I have events to check for that already in place)

I've tried using Bobstah's Battle Command Customisation to create an eval-based skill command. Doesn't work - the command doesn't eve shown.

I've tried doing a "bait-and-switch" by setting the attack skill to have no effect then using Yanfly's Action Sequences to forceAction() the desired skill in <setup action> - doesn't work at all. Using queueForceAction() works once then bugs out the battle scene.

I tried using HIME's Actor Battle Commands and Use Skill plugins, but either I'm doing something wrong or the notetags don't seem to work with evals...

Frankly, I'm stumped. Anybody tried this before or have any idea how to achieve it?
 

SmashArtist

Lazy Artist
Veteran
Joined
May 31, 2016
Messages
892
Reaction score
1,651
First Language
English
Primarily Uses
RMMV
I achieved something similar to this in one of my projects. Basically when a certain skill was used I'd call a common event.


First I'd set the usual skill, but have it give no damage. Then I'd make it's variation skills based on the numbers I want the variable to land on.

In the event I would then set a variable to a random number, then lots of if statements followed by the action to go with the number choosen : Force Action , ActorName , Attack# , Last Target.

So basically, make lots of skills that do what damage you want based on the variable. May be a bit unpractical, but it works. :)
 

Trasdill

Grumpy Knight
Member
Joined
Mar 29, 2016
Messages
10
Reaction score
1
First Language
English
Primarily Uses
RMMV
Thanks! I'm gonna try this as soon as I have time today. If it's worked on your game, hopefully it'll work on mine :D

A bit dreading this, to be fair... my game will have up to 144 different skills (24 per actor for 6 actors, assuming I don't burn out and do some duplication), and in my gameplay design, almost all of them are meant to have free scope (can target one or all of allies or enemies - so by your method I'd have to make 4 versions of each skill to account for all of the possible scopes). So many if statements... so many skills... yeeeeeeeeeeeeeesh!!! :o

Ideally if I can accomplish this by scripting the if statements instead of using the default Conditional Branch command, that might make things a lot simpler. That said, I never seemed to get the $gameParty.members()[x].forceAction(skill, target) call to work properly in a common event. It would either:
  • Play the animation but do no damage (then bug out the battle :distrust:)
  • Loop the basic attack skill (then bug out the battle >:()
  • Not register at all (then go for a few rounds... and bug out the battle D:<)

Is there something I'm missing with how this call is set up??
 

Astfgl66

Veteran
Veteran
Joined
Jan 5, 2016
Messages
722
Reaction score
578
First Language
French
Primarily Uses
Use yanfly's weapon unleash plugin and the <Custom Replace Attack></Custom Replace Attack> tag.
Something like:
Code:
<Custom Replace Attack>
id = $gameVariables.value(yourVariableId)
</Custom Replace Attack>
Should work but I haven't tested it.
 

Trasdill

Grumpy Knight
Member
Joined
Mar 29, 2016
Messages
10
Reaction score
1
First Language
English
Primarily Uses
RMMV
Hey Astfgl66. Thanks for the tip! I've just tried it, aaaaaaaand... it kinda works but it doesn't. :dizzy:

I works in the sense that it does replace the attack by the skill listed in my variable. The only problem is, it doesn't update the attack skill during the Input phase - in other terms, when an actor turn starts, it's attack skill is set to whatever the chosen variable was at the time, and that won't change until the next turn... which is kindof a problem, because the input phase is precisely when I want the skill to be changed.

I have found simple a solution for now, however. I've went and changed Line 2829 under Game_BattlerBase.prototype.attackSkillId() in rpg_objects.js to return $gameVariables.value(*my var id*). To ensure enemies don't start randomly casting the skills my actors just did, I just set their base attack to be it's own separate skill.

Works like a charm (and I probably should've thought about it earlier :headshake:). I know it's not perfect, as ideally we shouldn't be editing the core scripts, but it suits my purpose well for now without doing crazy conditional branches. I *AM* keeping SmashArt's method in mind for my battle item system, though, as it could very well come in handy for that.

Thanks again for both your inputs, as they were still very helpful (and on a side note, Astfgl66, that short Mouse Coordinates script you came up with makes 80% of my project possible, alors pour ca je te remercie profondement :cutesmile:).
 

Astfgl66

Veteran
Veteran
Joined
Jan 5, 2016
Messages
722
Reaction score
578
First Language
French
Primarily Uses
Well if it does the job you should keep it.
Just don't change the core script but make it its own plugin.
Alias the method put it in an anonymous self invocating function and you're done.
Don't modify core scripts directly your changes will be overwritten each time those files update.

Code:
(function(){
var myNewAlias = Game_BattlerBase.prototype.attackSkillId
Game_BattlerBase.prototype.attackSkillId = function() {
    if (this.isActor()) { //if actor return a variable
        return $gameVariables.value(youVariableId)
    } else { //if enemy return default
        myNewAlias.call(this)
    }
}
})()
Paste this in a .js file, name it whatever and add it in your game through the plugin manager.

This is working and I added the check for actor or enemy for you.
You'll have to solve the display problem by yourself however, because it won't update the action selection window for you so if you also want to change what the displayed name is, you'll have to do a bit more scripting. You should find what's needed in window actor command probably.

And thank you.

Edit: and if you really think about doing what the other poster said don't do it via conditional branches.
It's both complicated and error prone.
Just do it directly via script call using action sequences.

Code for the dummy action
Code:
<setup action>
Eval: $gameVariables.setValue(1,user) //store the user in a game variable
Eval: $gameVariables.setValue(2,target) //store the target in a game variable
call common event yourEventID
break action
</setup action>
It's been a while since I've used action sequences so this is pseudo code, but it should get the point across.

Common event:
Code:
//set the skill id here
var yourSkillId = 1;
//force the action with the appropriate subject and target using the stored info
$gameVariables.value(1).forceAction(yourSkillId, $gameTroop.members().indexOf($gameVariables.value(2)))
BattleManager.forceAction($gameVariables.value(1))
There, four lines of code and you're set.

It's even possible to do this inside a single action sequence if you want, without needing a common event, but I'll let you figure that out. :D

If you want the easy solution look at this thread.
I've walked someone else through this once.
 
Last edited:

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,847
Messages
1,016,968
Members
137,561
Latest member
JaCrispy85
Top