RMMV QABS - modification of the Qabs "selecttarget" behaviour

basicleader

Veteran
Veteran
Joined
Oct 29, 2013
Messages
33
Reaction score
8
First Language
French
Hi everyone,

I've been playing around with QABS and I tried to modify the behavior of the selecttarget by myself to no avail.

I wanted to know if anybody who has had experience with modding Qabs could help me on this.

Here is the code that I want to modify (and that I think needs mod) in the QABS plugin - from line 3248 :
Code:
  Game_CharacterBase.prototype.makeTargetingSkill = function(skill) {
    this._groundTargeting = skill;
    this._selectTargeting = this.constructor === Game_Event ? true : skill.settings.selectTarget;
    var collider = skill.collider;
    var diameter = skill.settings.range * 2;
    skill.targeting = new Circle_Collider(diameter, diameter);
    skill.targeting.moveTo(this.cx() - diameter / 2, this.cy() - diameter / 2);
    ColliderManager.draw(skill.targeting, -1);
    skill.collider = skill.targeting;
    skill.targets = QABSManager.getTargets(skill, this);
    skill.collider = collider;
    skill.picture = new Sprite_SkillCollider(skill.collider);
    if (this._selectTargeting) {
      if (skill.targets.length === 0) {
        return this.onTargetingCancel();
      }
      skill.collider.color = '#00ff00';
      skill.index = 0;
    }
    QABSManager.addPicture(skill.picture);
    return skill;
  };

As it is, everytime a skill that has "selecttarget" in its <abssettings> is used, all the potential targets within the diameter set by the maker (say 500 pixels diameter) will be detected and the selection cursor will ALWAYS appear on the enemy that is at the top left of the currenter diameter (smallest X/Y within the diameter), then you have the ability to move from one target to the other using two keys (pageup/down).
It seems this behaviour of the selection cursor is dictated by skill.index = 0; as if you change it to 1, the selection cursor will FIRST appear on the next event in that same diameter, and so on.

The behaviour I would like to have instead of the current one is the following:
Within all the potential targets within the set diameter, the selection cursor appears FIRST on the NEAREST TARGET. Whether that target corresponds to index.skill = 0 or 3 or 8; after that, you'd still have the ability to move from one target to the other if you want to.

I had a few attempts at it myself, checking the distance between the skill.collider.center.x / y and the player FOR (var i = 0; i < skill.targets.length; i++); in order to get the index.skill number that corresponds to the nearest target and force that into the skill.index = nearest variable.

However not being a coder myself, I guess I reached the limits of my playing around with the existing code.

Don't hesitate to Let me know if my explanations make no sense at all.

Thanks in advance everyone!
 

Latest Threads

Latest Posts

Latest Profile Posts

Title Screen 100% Finished
Evangeline.png
I'm starting to enjoy doing pixel art! Not to mention it's getting easier to do commissions :kaojoy:
I'm having a surprisingly easy time with the wait for Hogwarts Legacy, though I know other gamers are salivating hard.
:awat:What are you two down there doing?
This status is here just to take up space. And to make you read that.

Forum statistics

Threads
124,360
Messages
1,163,020
Members
163,149
Latest member
Warnerfoupe
Top