MV - SRPG Engine MV - Plugins for creating Tactical Battle System

● ARCHIVED · READ-ONLY
Started by RyanBram 3313 posts Page 81 of 166 View original ↗
  1. Brother_Fox said:
    Good day. I'm trying to figure out how SRPG_AIControl works. The script contains target formulas and move formulas. If everything is clear with the first ones, then I cannot figure out the move formulas.
    Tell me with an example, what am I doing wrong?

    the formula itself is in the enemy's comment:
    <aiMove: a.hpRate ()> 0.5? nearestOpponent: nearestFlag ['heal']>

    <aiFlag: heal> - is in the comment of the event.

    In theory, as soon as the enemy takes more than 50% of the damage, he should run back to the flag, but he does not run away. What am I doing wrong?

    The problem is that Move AI only applies when there are no targetable enemies around. Otherwise it will always attack like in normal mode.
    You can try my MoveMethod plugin which allows you to define some modes that will skip enemy searching just like mode absregionup.

    Another problem is that your:
    <aiMove: a.hpRate ()> 0.5? ....
    the > will be recognized as a bracket:
    <aiMove: a.hpRate ()>
    which doesn't make sense.
    Its a problem that comes with rpgmaker. You can either use < to compare or try to write some simple code with my move Method plugin.
  2. Shoukang said:
    The problem is that Move AI only applies when there are no targetable enemies around. Otherwise it will always attack like in normal mode.
    You can try my MoveMethod plugin which allows you to define some modes that will skip enemy searching just like mode absregionup.

    Another problem is that your:
    <aiMove: a.hpRate ()> 0.5? ....
    the > will be recognized as a bracket:
    <aiMove: a.hpRate ()>
    which doesn't make sense.
    Its a problem that comes with rpgmaker. You can either use < to compare or try to write some simple code with my move Method plugin.
    I tried using the Move AI plugin, but I'm probably doing something wrong and I can't get the desired result. Since I am poorly versed in js, I ask you, if it does not complicate, give specific examples of formulas for the following cases:

    - when Hp of 50% falls, instead of an attack, it runs back to the flag N, regardless of whether there are enemies nearby or not.

    - moves to a certain point on the map, regardless of whether there are enemies nearby or not; upon reaching it does not leave under any circumstances, uses a ranged attack

    By analogy with them, I can do the rest that I need.
  3. boomy said:
    @Reanimunculus

    I made a script for 1 vs Many AoE animations for side-view battles
    Ready for testing
    Wow, that was fast, you guys are fantastic. I'll give it some testing.
  4. boomy said:
    I thought i fixed that bug, try the new version
    Worked almost perfectly! tried it with the different srpg ranges, different skills and states. Works perfectly in my initial testing. I'll keep you updated as I go if I run into any issues during development.

    Edit:
    I did find this one bug when using it on 4 enemies on the reference map of the srpg demo

    1623161116049.png
  5. Reanimunculus said:
    Worked almost perfectly! tried it with the different srpg ranges, different skills and states. Works perfectly in my initial testing. I'll keep you updated as I go if I run into any issues during development.

    Edit:
    I did find this one bug when using it on 4 enemies on the reference map of the srpg demo

    View attachment 191697
    Says the error is coming from SRPG_core


    Code:
        var _SRPG_AAP_Game_Action_speed = Game_Action.prototype.speed;
        Game_Action.prototype.speed = function() {
            if ($gameSystem.isSRPGMode() == true && _srpgUseAgiAttackPlus == 'true') {
                return this.subject().agi;
            } else {
                return _SRPG_AAP_Game_Action_speed.call(this);
            }
        };

    Not sure if you can replicate the bug but seems to be an issue with AgiAttackPlus addon. If its disabled (no double-attack with speed is higher) then the error should not occur.

    Alternatively you could change the conditional to:
    if(this !== undefined) {
    if ($gameSystem.isSRPGMode() == true && _srpgUseAgiAttackPlus == 'true') {
    return this.subject().agi;
    }
    }
  6. boomy said:
    Says the error is coming from SRPG_core


    Code:
        var _SRPG_AAP_Game_Action_speed = Game_Action.prototype.speed;
        Game_Action.prototype.speed = function() {
            if ($gameSystem.isSRPGMode() == true && _srpgUseAgiAttackPlus == 'true') {
                return this.subject().agi;
            } else {
                return _SRPG_AAP_Game_Action_speed.call(this);
            }
        };

    Not sure if you can replicate the bug but seems to be an issue with AgiAttackPlus addon. If its disabled (no double-attack with speed is higher) then the error should not occur.

    Alternatively you could change the conditional to:
    if(this !== undefined) {
    if ($gameSystem.isSRPGMode() == true && _srpgUseAgiAttackPlus == 'true') {
    return this.subject().agi;
    }
    }
    yeah, i was able to replicate the bug consistently. i changed the conditional and it threw this error

    when i turn agiattackplus off in the srpg core it throws the same error
    seems to be only if theres more than 3 units in the array


    1623167959735.png
  7. Not working with me- I'm getting up the scene with all the enemies come up, but only the main target is affected by the skill with this plug-in on.


    MetalKing11417 said:
    So he forgot to put a + 1 at the end?
    So this:
    (a.atk - b.def) / (Math.abs($gamePlayer.posX()- b.event().posX()) + Math.abs($gamePlayer.posY() - b.event().posY()) + 1)
    OK that works.
    Also this formula isn't as compatible with aoe as I thought- the positioning part of the formula only seems to go through once, and then applies itself to all the targets, making it so that all targets of the spell are treated as being the same distance from the AOE's center.
  8. boomy said:
    Says the error is coming from SRPG_core


    Code:
        var _SRPG_AAP_Game_Action_speed = Game_Action.prototype.speed;
        Game_Action.prototype.speed = function() {
            if ($gameSystem.isSRPGMode() == true && _srpgUseAgiAttackPlus == 'true') {
                return this.subject().agi;
            } else {
                return _SRPG_AAP_Game_Action_speed.call(this);
            }
        };

    Not sure if you can replicate the bug but seems to be an issue with AgiAttackPlus addon. If its disabled (no double-attack with speed is higher) then the error should not occur.

    Alternatively you could change the conditional to:
    if(this !== undefined) {
    if ($gameSystem.isSRPGMode() == true && _srpgUseAgiAttackPlus == 'true') {
    return this.subject().agi;
    }
    }
    another bug i didnt notice before, is that if an enemy dies in the aoe other than the primary target, they wont actually die until they are attacked again. The death seems to be delayed.
  9. Reanimunculus said:
    another bug i didnt notice before, is that if an enemy dies in the aoe other than the primary target, they wont actually die until they are attacked again. The death seems to be delayed.
    I have fixed the bug where non primary targets do not disappear when dead. I've also reworked how the script works; perhaps that will also fix the undefined error you are getting though I cannot replicate it with my fat yanfly + srpg+core build or a vanilla build of srpg_core + yanfly. Update here

    MetalKing11417 said:
    Not working with me- I'm getting up the scene with all the enemies come up, but only the main target is affected by the skill with this plug-in on.



    Also this formula isn't as compatible with aoe as I thought- the positioning part of the formula only seems to go through once, and then applies itself to all the targets, making it so that all targets of the spell are treated as being the same distance from the AOE's center.
    Hmm, I tried it myself and it seems to work fine for me (I'm using the 'official' demo + yanfly battle engine core). Does the formula not work when AoEAnimation.js is active?

    AreaEffect.gif
  10. I think I know what I got wrong- I set it to 1 enemy as opposed to All enemies.
  11. boomy said:
    I have fixed the bug where non primary targets do not disappear when dead. I've also reworked how the script works; perhaps that will also fix the undefined error you are getting though I cannot replicate it with my fat yanfly + srpg+core build or a vanilla build of srpg_core + yanfly. Update here


    Hmm, I tried it myself and it seems to work fine for me (I'm using the 'official' demo + yanfly battle engine core). Does the formula not work when AoEAnimation.js is active?

    AreaEffect.gif
    works great now, i tried it with like 15 enemies and it worked perfectly as far as I could tell.
  12. I set one enemy to use only buffs skills in others enemys, but nothing happening. Someone can help me?
  13. Hey, Shokang, may I suggest an edit to your battle prepare- sometimes a user might want to artificially limit certain types of units from the battlefield- like say you want to make it so there are only 2 tanks/mechs on a map at any one time and you can only have the player put them in certain spots (but any of the units fulfilling said conditions can be put in those locations). Is it possible to put such a thing in game (I know it is possible to designate an actor for a location)?
  14. MetalKing11417 said:
    Hey, Shokang, may I suggest an edit to your battle prepare- sometimes a user might want to artificially limit certain types of units from the battlefield- like say you want to make it so there are only 2 tanks/mechs on a map at any one time and you can only have the player put them in certain spots (but any of the units fulfilling said conditions can be put in those locations). Is it possible to put such a thing in game (I know it is possible to designate an actor for a location)?
    Hi MetalKing, I think it's possible. Somehow I'm very busy recently, as I plan to change my major to computer science. I may not be able to make any updates for months. If anyone is interested please feel free to edit my plugins.
    Brother_Fox said:
    I tried using the Move AI plugin, but I'm probably doing something wrong and I can't get the desired result. Since I am poorly versed in js, I ask you, if it does not complicate, give specific examples of formulas for the following cases:

    - when Hp of 50% falls, instead of an attack, it runs back to the flag N, regardless of whether there are enemies nearby or not.

    - moves to a certain point on the map, regardless of whether there are enemies nearby or not; upon reaching it does not leave under any circumstances, uses a ranged attack

    By analogy with them, I can do the rest that I need.
    I'm confused, did you try my movemethod plugin or move AI plugin? It's impossible to get the result you want with the move AI plugin. If you tried my move method plugin, you can refer to my aimove: 'timid', then aimove: 'escape'. (trace them in my code to see how they work). If you want to edit directly on the 'timid' method, you need to change line 359:
    if (a.hpRate() > 0.8) return 'nearestOpponent';
    to: if (a.hpRate() > 0.5) return 'nearestOpponent';
    and change line 394:
    this.setBattleMode('nearestFriend')
    to: this.setBattleMode("nearestFlag['N']")
    Or you can write some new modes for this.

    About the move to a certain position and not leave, use <mode:absPosition x y> with my move method. Then my plugin cannot help, but you can write some scripts in the game:
    If it reaches the desired position, set battle mode to nearestOpponent(use $gameSystem.EventToUnit(Id)[1].setBattleMode(....)), create a buff that slows down units(to 0 move), and add the buff.
    I wrote this instruction without testing. Hope there is no bugs...
  15. Hi @Shoukang, your plugins for the engine are great! Just a question:
    for BattlePrepare, is there a way to skip the Battle Preparation Phase entirely?

    The plugin command "DisableSRPGPrepare" only disables the Prepare command in the menu, and it'd be cool if there are battles where you can't prepare- Tutorial battles, for example.

    Thanks for your work on the plugins nonetheless! :)
  16. SRPG_RangeControl has an option to set weights for each terrain type, but can we make different classes be affected by terrain differently?
    There's a 'Ignore Terrain Tag' but that ignores all terrain types smaller than that tag, so I can only see ground and flying units (all terrain cost 1).
    Something like Sand tiles that cost 3 for cavaliers, 2 for infantry and 1 for thieves, or Water tiles having 99 cost for everyone except crocodile riders, who walk through water at a 2 cost.

    I'm asking this beforehand as the terrain options kinda dictate what classes I want to have.
  17. NatePlays said:
    SRPG_RangeControl has an option to set weights for each terrain type, but can we make different classes be affected by terrain differently?
    There's a 'Ignore Terrain Tag' but that ignores all terrain types smaller than that tag, so I can only see ground and flying units (all terrain cost 1).
    Something like Sand tiles that cost 3 for cavaliers, 2 for infantry and 1 for thieves, or Water tiles having 99 cost for everyone except crocodile riders, who walk through water at a 2 cost.

    I'm asking this beforehand as the terrain options kinda dictate what classes I want to have.
    Shoukang lightly explained their approached this problem (but for a different problem) by editing SRPG_RangeControl.js (Shoukang wanted units to be able to move to a tile if they have enough moveCost to complete the movement; default movement style is that a unit can move to a tile if it reach the tile).

    If you want to extend this function to allow certain units to have different moveCost amongst different terrains then I present you the following function rewrites the makeMoveTable and srpgMoveCost functions in SRPG_RangeControl.js:

    Code:
        // breadth-first search for movement
        Game_CharacterBase.prototype.makeMoveTable = function (x, y, move, unused, tag) {
            var edges = [];
            if (move > 0) edges = [[x, y, move, [0]]];
            $gameTemp.setMoveTable(x, y, move, [0]);
            $gameTemp.pushMoveList([x, y, false]);
            $gameMap.makeSrpgZoCTable(this.isType() == 'actor' ? 'enemy' : 'actor', this.throughZoC());
            while (edges.length > 0) {
                var cell = edges.shift();
                for (var d = 2; d < 10; d += 2) {
                    if (!this.srpgMoveCanPass(cell[0], cell[1], d, tag)) continue;
                    var dx = $gameMap.roundXWithDirection(cell[0], d);
                    var dy = $gameMap.roundYWithDirection(cell[1], d);
                    //Shoukang edit - Terrain passability (original function is if there is movement available, all squares can be moved to regardless of terrain move cost
                    //This edit means movement must equal terrain move cost for a square to be a valid movement option
                    var movecost = 1;
                    if (tag < $gameMap.terrainTag(dx, dy)) {
                        movecost = _terrainCost[$gameMap.terrainTag(dx, dy)];
                        //Add notetag to modify terrainCost by states - Boomy Edit
                        $gameSystem.EventToUnit($gameTemp.activeEvent().eventId())[1].states().forEach(function (item) { //check all states
                            if (item.meta["SRPGTerrainCost" + $gameMap.terrainTag(dx, dy)]) {
                                movecost = Number(item.meta["SRPGTerrainCost" + $gameMap.terrainTag(dx, dy)]);
                            }
                        });
                        //Add notetag to modify terrainCost by Class - Boomy Edit
                        if ($gameSystem.EventToUnit($gameTemp.activeEvent().eventId())[1].isActor()) {
                            if ($gameSystem.EventToUnit($gameTemp.activeEvent().eventId())[1].currentClass().meta["SRPGTerrainCost" + $gameMap.terrainTag(dx, dy)]) {
                                movecost = Number($gameSystem.EventToUnit($gameTemp.activeEvent().eventId())[1].currentClass().meta["SRPGTerrainCost" + $gameMap.terrainTag(dx, dy)]);
                            }
                        }
                    }
                    // if ($gameTemp.MoveTable(dx, dy)[0] >= 0) continue;
                    if ($gameTemp.MoveTable(dx, dy)[0] >= 0 || (cell[2] - movecost < 0)) continue;
                    var dmove = Math.max(cell[2] - $gameMap.srpgMoveCost(dx, dy), 0);
                    var route = cell[3].concat(d);
                    $gameTemp.setMoveTable(dx, dy, dmove, route);
                    $gameTemp.pushMoveList([dx, dy, false]);
                    if (dmove > 0 && !$gameMap._zocTable[dx + ',' + dy]) {
                        edges.push([dx, dy, dmove, route]);
                        edges.sort(function (a, b) {
                            return b[2] - a[2];
                        });
                    }
                }
            }
        }
        // get the cost of moving through a given space
        Game_Map.prototype.srpgMoveCost = function (x, y) {
            var terrain = this.terrainTag(x, y);
            var stateTerrainCost = -1;
            // state tags  - Boomy Edit
            $gameSystem.EventToUnit($gameTemp.activeEvent().eventId())[1].states().forEach(function (item) { //check all states
                if (item.meta["SRPGTerrainCost" + $gameMap.terrainTag(x, y)]) {
                    stateTerrainCost = Number(item.meta["SRPGTerrainCost" + $gameMap.terrainTag(x, y)]);
                }
            });
            // class tags  - Boomy Edit
            if ($gameSystem.EventToUnit($gameTemp.activeEvent().eventId())[1].isActor()) {
                if ($gameSystem.EventToUnit($gameTemp.activeEvent().eventId())[1].currentClass().meta["SRPGTerrainCost" + $gameMap.terrainTag(x, y)]) {
                    stateTerrainCost = Number($gameSystem.EventToUnit($gameTemp.activeEvent().eventId())[1].currentClass().meta["SRPGTerrainCost" + $gameMap.terrainTag(x, y)]);
                }
            }
            if (stateTerrainCost > 0) {
                return stateTerrainCost;
            }
            // map tags
            if ($dataMap.meta["srpgTerrain" + terrain + "Cost"]) {
                return Number($dataMap.meta["srpgTerrain" + terrain + "Cost"] || 1);
            }
            // tileset tags
            if (this.tileset().meta["srpgTerrain" + terrain + "Cost"]) {
                return Number(this.tileset().meta["srpgTerrain" + terrain + "Cost"] || 1);
            }
            // plugin parameters
            return _terrainCost[terrain];
        };

    Usage is <srpgTerrainCostX:Y> Where X is the terrain Tag (0-7) and Y is the movement cost (1 for normal, 2+ for restricted movement)
    Class tags override state tags
  18. boomy said:
    If you want to extend this function to allow certain units to have different moveCost amongst different terrains then I present you the following function rewrites the makeMoveTable and srpgMoveCost functions in SRPG_RangeControl.js:

    Usage is <srpgTerrainCostX:Y> Where X is the terrain Tag (0-7) and Y is the movement cost (1 for normal, 2+ for restricted movement)
    Class tags override state tags
    I don't know if I'm doing something wrong. I deleted the old makeMoveTable() and srpgMoveCost and pasted those inside there (I think it's right, this is not my first time messing with writing plugins). I'm placing the tags inside the class being used, but it is still using the default costs inside RangeControl.
    If I make tag 4, blue tile, unpassable (99 cost) and give someone <srpgTerrainCost4:2> it stays unpassable.
    Conversely, if I make tag 1, dark green tile, passable normally and give someone <srpgTerrainCost1:2> they still go through it at normal cost.
    1624471104893.png1624471185749.png1624471138385.png1624471025467.png
    As from the images, Al should move 5 spaces on light green, 5 on yellow and 5 on blue, but he moves 10 in green and yellow, and none on blue.