Target Core: Prime Numbers and Lowest/Highest Attributes

DietAmbrosia

Warper
Member
Joined
Aug 25, 2014
Messages
3
Reaction score
0
Primarily Uses
Hello all! I am making a class based off the Arithmetician class from Final Fantasy Tactics. I had a couple questions regarding target conditions:

1) What tags would allow a skill to target any unit with a level that is a prime number? (i.e., 2, 3, 5, 7, 11, 13, 17, 19, 23, etc).

2) I suspect this one is more challenging... I want to create the following spells:

- Warp: Increases the Agility of the unit(s) with lowest Agility by 25%.
- Dilate: Decreases the Agility of the unit(s) with the highest Agility by 25%.

How would I create a condition that hits the target(s) with the lowest parameters for a specific stat, if at all possible?
 
Last edited:

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,591
Reaction score
1,168
First Language
English
Primarily Uses
RMMV
I guess an inefficient way would be to simply list all the prime levels outright, up to your game's level cap. Not the most elegant solution, but at least it'd work.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,087
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
I think it'd be quicker (more "efficient") to list all primes below max level, rather than applying the Sieve every time you use the skill. :kaoswt:

Link to Yanfly's Target Core plugin, for reference:
Suggested <Custom Target Eval> notetags, based on the example on that page (untested):
  1. Target all alive opponents with prime-numbered level (assuming max level is 99):
    JavaScript:
    var primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97];
    foes.aliveMembers().forEach(function(m) {
      if (primes.contains(m.level)) {
        targets.push(m);
      }
    });
    Note that if you want actors to use this skill, you'll need some kind of plugin to add levels to enemies.

  2. Target lowest-AGI alive ally:
    JavaScript:
    var v = 10000;      // min value tracker
    var x = friends.aliveMembers().reduce(function(a, c, n) {
      if (c.agi < v) {  // new min value?
        v = c.agi;      // update min value
        return n;       // store current index
      }
      return a;         // retain index
    }, 0);  // start with index 0
    targets.push(friends.aliveMembers()[x]);
    Target highest-AGI alive opponent:
    JavaScript:
    var v = -1;         // max value tracker
    var x = foes.aliveMembers().reduce(function(a, c, n) {
      if (c.agi > v) {  // new max value?
        v = c.agi;      // update max value
        return n;       // store current index
      }
      return a;         // retain index
    }, 0);  // start with index 0
    targets.push(foes.aliveMembers()[x]);
Hope those work as planned and/or give you enough to work with to figure things out~ :kaothx:

In case you're interested, here's a link to some technical info on that "reduce" thing I've used:
 

DietAmbrosia

Warper
Member
Joined
Aug 25, 2014
Messages
3
Reaction score
0
Primarily Uses
I think it'd be quicker (more "efficient") to list all primes below max level, rather than applying the Sieve every time you use the skill. :kaoswt:
Thank you so much! These all appear to be working. :) Do you know if there is a way to make it cycle through all the targets on the battlefield, instead of just friends. or foes. ? I tried using battlers. and members. but didn't have any luck.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,087
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
Thank you so much! These all appear to be working. :) Do you know if there is a way to make it cycle through all the targets on the battlefield, instead of just friends. or foes. ? I tried using battlers. and members. but didn't have any luck.
Instead of just friends or foes you could try friends.concat(foes) (or vice-versa), e.g.
JavaScript:
var primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97];
foes.concat(friends).aliveMembers().forEach(function(m) {
  if (primes.contains(m.level)) {
    targets.push(m);
  }
});
concat just merges arrays, details here~
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,047
Members
137,569
Latest member
Shtelsky
Top