subengari

Villager
Member
Joined
Dec 12, 2020
Messages
11
Reaction score
2
First Language
king's english
Primarily Uses
RMMV
Could somebody please explain Game_Action to me?

As in, what would a script that pits one battler against another look like?

I am trying to code a rather rudimentary ABS and I am at the point where my projectile successfully makes its way from one source ($gamePlayer) to its target ("Enemy" Event)...

Currently, the "Enemy" Event is assigned HP from a corresponding $dataEnemies member upon its initialization on the map, a property which decreases when the event collides with projectiles and a Game_Event.prototype.gotHit() function is invoked...

Game_Event_gotHit.png

There must be a better way though- that uses Game_Action- so that the $gamePlayer's skills and equipment as well as the target Enemy Event's skills and Stats are taken into account?

Is there a kind soul out there who might be able to explain the basics of creating a new Game_Action instance to do this?

Thanks in advance!
 

Jragyn

JABS codemonkey
Veteran
Joined
Aug 14, 2012
Messages
221
Reaction score
169
First Language
English
Primarily Uses
RMMZ
Ya know, that same question and curiosity- it is one of the first questions/problems I had to solve when building JABS. As such, if you're looking to create a "crude" ABS yourself, I'd encourage taking a peek at the source code for JABS. I left a billion and one comments all throughout the code explaining what is happening, because when you're trying to understand stuff, seeing stuff that is actually working is sometimes the easiest way to lower yourself into it.

Specifically, "how would I use Game_Action to do things?" I'll write about in a bit, but you can see it's actual use here in my plugin. The link will bring you to a specific line that is the entry to a function that generates an event onto the map that will represent the visual component of your skill execution and add it to the map (what it sounds like you're trying to accomplish).

So I'd like to start this speech by saying this:
There isn't anything inherently wrong with what you're doing. It is your ABS, and if you want to write your own custom formula for handling what happens when an event hits the enemy instead of leveraging the internal mechanics of RPG Maker MZ, then you're totally welcome to! The only reason I opted to leverage as much of the built in stuff RPG Maker MZ has to offer is because the more you deviate away from the base code (like by writing your own functions and stuff for it), the less stuff is inherently compatible with your plugin (though maybe thats okay because its not gonna be for public use?).

As far as "how actually does Game_Action work?"... Well, generally, the way I see it, is that the "Game_Action" class encapsulates the execution of an action against a particular target. Typically, you'll create a "new Game_Action" and provide it the battler that is executing the action as a constructor argument (like const gameAction = new Game_Action(castersGameBattler)), set the "action", or the skill id/item id associated with the Game_Action with gameAction.setSkill(skillId);, and then "apply" the action against the target (presumably when it collides with an opposing battler) with gameAction.apply(targetGameBattler);. The act of "applying" the action against the target battler is the time of which all the stuff like formulas are calculated (from the skill in the database), additional effects (states, etc) are executed, and so on. When a game action is applied to a target battler, the battler's .result() becomes populated with a "Game_ActionResult" object, containing the (surprise!) result of the action. Inside the Game_ActionResult will be stuff like hp/mp/tp damage, states applied, etc. You could leverage that to generate popups for the player and whatnot.

Do feel free to reach out to me directly if you want, I'd be happy to talk through my learning experience with JABS and offer guidance from my learnings if you want.
 
Last edited:

subengari

Villager
Member
Joined
Dec 12, 2020
Messages
11
Reaction score
2
First Language
king's english
Primarily Uses
RMMV
@Jragyn thank you for the primer and link to your plugin code!

After reading your response and browsing your code, I ended up "extending" the Game_Action and creating my own Game_AbsAction class (with amended / added functions) to handle the on-map attacks.

I appreciate your help very much. Rock on!
 

Jragyn

JABS codemonkey
Veteran
Joined
Aug 14, 2012
Messages
221
Reaction score
169
First Language
English
Primarily Uses
RMMZ
@Jragyn thank you for the primer and link to your plugin code!

After reading your response and browsing your code, I ended up "extending" the Game_Action and creating my own Game_AbsAction class (with amended / added functions) to handle the on-map attacks.

I appreciate your help very much. Rock on!
Totally valid approach I say!
I am interested in what you've got going on, do continue posting your updates here if its not too much a hassle!
 

Latest Threads

Latest Posts

Latest Profile Posts

Ohh man, Weapon animations plugin feels so mandatory. Seeing that same image regardless of the icon of the weapon....ugh :p
Ok so......Maaaaybe I've taken a ''little'' bit of inspiration from FF9 when it comes to battle hud xD

ff9.PNG

Just maybe....
New version of my wife's art for Tundra's opening map. No new version of Katrina yet, but I think this looks awesome.1624062754755.png
Devil May Cry-Style Action Shooter in RPG Maker 2000! | RPG Maker News #75

Forum statistics

Threads
112,353
Messages
1,067,696
Members
146,002
Latest member
Raytoly
Top