Open ShoukangHong opened 2 years ago
This is difficult, but ... Without this part, enemies behind walls that are out of range will be mistaken for being within range. However, I think that the judgment of whether or not there is a target within the range should be drastically corrected. Specifically, I think this way. At the beginning of the battle scene, both user and target have a range list of the skills they use and check if the opponent is within range.
For now, I think this function can be replaced by this. Unlike the range list which only stores 'red' tiles, the range table stores all the tiles that are in attack range. Enemy units will be able to cast skills to their friends with this setup.
Game_BattlerBase.prototype.isTargetInRange = function(item) {
var target = $gameTemp.targetEvent();
return $gameTemp.RangeTable(target.posX(), target.posY())[0] >= 0;
};
You remind me that when the target tries to counter-attack, they will also call the canUse() function... which makes the matter worse. For example, the user's skill can go through the wall but the target cannot... Making range tables for both the user and the target is the right solution, but yes it's difficult.
Yes, that's a good point. Therefore, instead of using the existing range table and range list, I created a new range list for the battle scene and introduced a mechanism to judge can Use based on it. The srpgRangeControl created by Dr.Q calculates the range without using the range table (common function) (a great technique). Therefore, it is now possible to create a new independent range list for each unit.
That's great. I think it's also worth the time to compile all the range checks in one function and call that function in canUse(). The current canUse() function is too complex. Some of the battle state checks can also be simplified as ['invoke_action', 'auto_actor_action','enemy_action', 'battle_window'].contains($gameSystem.isSubBattlePhase())
interesting! I haven't studied java script properly, and I'm making it by imitating the RPG maker plugin, so that kind of content is very educational. I will improve it!
I quote the code here:
range list contains a list of tiles that are in attack range but not in move range. Therefore, this function will disable skills for friends (tile with a friend is moveable, therefore such tile will in many cases appear in movelist, not range list.) Please use the range table to do the check. Actually, I don't think this function is necessary as I have never seen the canuse() function fail in 1.32Q(I may be wrong).