I dunno if this is the appropriate place to ask about this, but I was trying to modify the DispHPonMap plugin to display MP bars instead of HP. I figured it would be as simple as replacing all mentions of .hp and .mhp with .mp and .mmp.
That turned out to not be the case. When I run a test battle, I get TypeError: Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': The provided double value is non-finite.
I'm not really a coder, but I almost know why this is happening. The line of code that actually draws the bar is:
this.drawGauge(x, y, width, rate, color1, color2);
The problem appears to occur because 'rate' isn't being defined properly. I can set it to some arbitrary test number and the plugin won't cause an error. The value for rate is defined with:
var rate = this._displayedValue / actor.mmp;
Actor.mmp here used to be actor.mhp. I think the problem is that it's returning some kind of null value and this._displayedValue gets divided by 0. I'm just not sure why that line would return a null value.
I also attached the modified plugin, if anyone wants to take a look.
You just need to avoid having zero as the denominator. Replace all
actor.mmp with
Math.max(1, actor.mmp)
Can someone enlighten me? How it be possible to do something like this with the SRPG engine?
MV - Are there any TBS plugins that allow this kind of battle system?
You can still enjoy regular RPG battles with SRPG plugins. Therefore, a simple thought is to turn SRPG mode off in the battle scene and turn SRPG mode on after battle. Some fix on determining battle members is also needed. But so far I'm not planning to do this.
hey again! so I've come back because of another problem, I had been having issues with optimization because of the tiles that the plugin needs to draw, so because my light archers shoot in 9 tiles it takes 1.5 seconds to load, which is a bit annoying but not too bad, but the samurai archers which have a range of 12 tiles take a whopping 6 seconds to load, 6! and that can be a bit painful if my players are using him, so I am hoping to find an answer or an update to solve the performance of the tiles drawn.
Wow, I'm so glad you point this out. I thought the time complexity of the make range table function is O(n^2), quadratic growth(n refers to skill range). However, after looking into the function again, it turned out that the complexity is O(2^n), horrible exponential growth...
In your case, 12^2 =144, 2^12 =4096... That's a huge difference.
I updated the
SRPG_ShowAoERange.js to fix this issue, now it's O(n^2) complexity, you won't feel the freezing. If you don't need the entire plugin, you can simply replace the
Game_CharacterBase.prototype.makeRangeTable function in SRPG_RangeControl with the one in SRPG_ShowAoERange.