(Chrono Engine also contains the option to use a combat system similar to the SNES game it derives its name from but for my project, I am only interested in the ABS aspect of the plug-in.)
As many of you probably know the plug-in doesn't work out of the box with RMMZ, which means it doesn't work with the RMMV project that I am working on that uses the RMMZ core files (including updated NWJS and Pixi.js)...
So, I sat down this morning to see what I could do to integrate the two. It turned out better than I anticipated, but success is many lines of code away. Still, I am presenting my findings to the hive, with hopes that minds greater than mine might be able to contribute their two centavos and set me on the right path.
Where to begin? For me, it was adding four plug-ins to my existing project:
After setting the plug-ins accordingly and configuring my tool map, I play-test the project and the following error immediately occurs:
This is understandable- Sprite_Base was removed in RMMZ, and sprites use the Sprite.prototype directly instead.
To fix it, I just move Sprite_Base down the prototype tree to where I assume it is going to be used (in Sprite_Character):
I can see that the function causing the problem also makes reference to properties that are not a part of Sprite_Character (._animationSprites) so to be safe, I also carry over any Sprite_Base properties and functions from RMMV to Sprite_Character:
For good measure, I merge the functions from MV's Sprite_Character too:
Subsequently, I also had to add two functions to Game_CharacterBase:
I also notice that MOG_ChronoEngine has Sprite_Animation functions, so I change these to Sprite_AnimationMV:
Now, that seems to do the trick- play-test runs without any errors, the character's idle pose seems to work; but hitting the "Z" (weapon attack button) does nothing!
To diagnose, I trace the path through the code of what is supposed to happen when I press the "Z" button.
It starts in Game_Player.prototype.update():
Then goes to Game_Player.prototype.updateToolCommand():
This is where MOG_ChronoEngine decides which button is being pressed. Since "Z" is for weapon attack, we move onto Game_Player.prototype.commandRasWeapon():
Then, finally to Game_Player.prototype.act() (actually Game_CharacterBase.prototype.act(), because of inheritance):
By using log.warn() at certain points, I am able to determine that the problem is on the first line of Game_Player.prototype.commandRasWeapon()- this.battler().toolWeaponID() is returning a 0 value as the actionID.
this.battler().toolWeaponID() is a function of the Game_Actor class that simply returns its ._toolWeaponActionId property:
That property's value is determined by Game_Actor.prototype.getToolActionID(), which is invoked by Game_Actor.prototype.setToolWeaponID(), which, in turn, is invoked by Game_Actor.prototype.refreshToolIds(), originating in Game_Actor.prototype.changeEquip():
The problem, though, is that this.equips()[0] in the second line of setToolWeaponID() is returning a null value for the item variable.
This is happening, even if I have a Common Event that successfully runs and is supposed to equip the Player with a weapon at startup:
Manually changing the Player's equipment using a script call doesn't seem to work either:
What does seem to work is using the following script call:
JavaScript:
$gameActors.actor(1)._equips[0]._dataClass = `weapon`;
$gameActors.actor(1)._equips[0]._itemId = 1;
$gameActors.actor(1).refreshToolIds();With that, hitting the "Z" button actually works! My $gamePlayer is swinging and can do damage to enemy events. Unfortunately, the enemy events just stand still and don't attack back... but that is a problem for another day.
I am wondering if anybody can surmise what is up weapons not being equipped automatically? Or at least give me a suggestion where to sniff around.
Merci, maraming salamat, asante sana and all that good stuff :)