Questions about the combat mechanics

How does Luck affect the probability of a status effect triggering? How does the game recognize a positive status effect or a negative one?


How does Agility determine combat order? Is it in order of highest to lowest or is there a random number thrown in somewhere?


Lastly, I receive no indication in combat that my opponents use TP. Have I just been missing it or do enemies utilize the TP system as well?


Thanks a lot.
1- Ok, first we calculate Luck's value. 1 plus the result of the attacke's luck minus the target's luck divided by a thousand. Result floors at zero.


Math.max(1.0 + (this.subject().luk - target.luk) * 0.001, 0.0)


Now, for debuffs that value is multiplied by the target's debuff rate. 100% is 1, 80% is 0.8, 120% is 1.2...


For states, one added by a skill is multiplied by the chance of the move and the target's state rate. One added by an attack also multiplies it by the attack's chance (you know, just in case you have a weapon that causes sleep at 80% and an attack skill that causes sleep at 80%, you end up with 160%)


Either way, this result is checked against a random number between 0 and 1.
 


2- According to Yanfly, from what I got,  it is in order of highest to lowest in the calculation: agility + attack's speed + random number between 0 and (previous sum plus five divided by four)


agi + Math.randomInt(Math.floor(5 + agi / 4))


3- No, opponents do not use TP. The skills are free-use for them if they only cost it.
@Waterguy you're wrong with your assumption of TP and MP for the enemy.


The mechanics are exactly the same for both actors and enemies - all skills used require the payment of the MP/TP set in the skill database, and if an enemy doesn't have the MP/TP to pay for the skill, then the skill will not be used.


This is the reason why you should always give the enemy at least one skill without cost (like the basic attack), because otherwise it may stop using skills if all points are used up.


@Dragonfolk2000 The only way to use TP is to have a skill that requires TP-cost. Do your enemies have such skills in their attack patterns and don't use them, or how do you determine that they don't use TP? If they have a TP-skill in their attack pattern and don't use it, then either the TP-Cost is too high or something is wrong with the pattern.
Except that enemies can use TP if you set them up that way with a skill cost.  The thing to decide is how much you want to give them at the beginning of battle.  I'm on my phone so can't give the tiny script change which alters this to your liking but can later. 


Ninja'ed by Andar
I see... Did they change this for MV? Because I remember reading once that for VX Ace they didn't need TP for the techniques...
then you read wrong, because that is the way it was always handled, including both Ace and MV
Just for the sake of absolute clarity - you can set it up so that enemies do not use either TP or MP if you want to by setting the skill costs to 0, but you have the choice, as both Andar and I have said.
You can also edit their exparams to make it so that the enemies do not have to pay MP or TP costs if you wish, though you may find players find that way too cheap in the long run (aka why do I have to pay an MP cost and they don't?).
I see.


And there go my plans of some bosses using the same skills as the player when they run out of MP if they also got to charge TP...


Oh well, I can always call the TP skills the same but actually make them different. Maybe it is for the best, I can make the ones that also cost a percentage of hp cost a lesser amount instead.


Thanks for the correction and the info guys!
@Waterguy You can still do what you wanted to with your bosses.  They will be charging up TP in the same way as actors do.  As I said in my earlier post, you can decide how much TP they start with.  If you want to be sure that they have enough, you could set it as high as 100.


I see that you are using MV.  The following is how it is done in Ace.  It might be that, armed with this info, you can find the equivalent point in the default plugin and make the same change.


Game_Battler starting at line 736 reads


# * Initialize TP
#--------------------------------------------------------------------------
def init_tp
self.tp = rand * 25
end


change this to:

Code:
def init_tp
    if self.is_a?(Game_Actor)
      self.tp = rand * 25
    else
      self.tp = whatever you want enemy tp to start at
    end
  end
Ah, I know where it is. I already did change it once, actually. I changed the initial TP to 0, because while I did add stronger skills that cost 70 and above some of them are barely stronger than normal attack, or just steal, things like that, and only cost 10, the amount recovered with one Guard or two attacks.


I just thought that only applied to actors...


Thanks for the idea of making them different with a check of if it is an actor though. I can work with this.
I figured I was wrong about the TP. I'm glad it's confirmed that enemies do use it. The same goes for Agility.


The problem I have though is Luck. Luck doesn't affect a character's ability to resist status effects like Poison. Instead it's used with the built in 'Buff' and 'Debuff' system which I already do not use. I've been using States this whole time because I can control the boost gained much easier. It also seems that you cannot become 'resistant' to States. You are either immune or not.


The problem I'm having now is this: even if I choose to make stats change using the existing buff and debuff system I still do not have Luck influence someone's ability to ignore unfavorable states. What I will likely do is make Luck influence other things, like certain Events or Skills. But I really wanted Luck to be a percentage resistant to bad states.
From the Help file for Ace



Affects chance of adding state or debuffing a parameter





I can't find the equivalent in the MV Help file, but I would assume it is the same.  So LUK does affect inflicting a state, what it appears not to do is avoid being inflicted.  However, I have read posts which say that it does do that.  Perhaps a scripter reading this would confirm this.


As for becoming resistant - do you want resistance to a state to build up by, e.g. being hit by a state x number of times?  If that's what you want, it can be done.  If you mean something else, could you be a bit more explicit and maybe there is a way to do what you want.
@Dragonfolk2000


Oh, maybe I made it a bit too confusing. Both states and debuffs use the luck comparison. The difference is what they are also multiplied by.


But I agree, it is a shame this is all Luck changes. It does not even seem to affect the chance of surprise attacks from either side (Agility does!)? Not even the chance of random drops?


And I mean it, I made a search for luk in all core files and looked at those two's chance codes.


Also, I made the find by myself through experimentarion, there is a difference between giving a target resistance and 0% rate. Maybe not in things like poison, but on Death there is deffinitely a difference (you know, since 0% rate means immune to death attacks and resistance means immortal).
The difference due to luck when it comes to inflicting status aliments in the default system is really minor too. As in, so minor you'd have to have a character with 1 luck vs a character with 999 luck to really see it in action.  Depending on your stats you may want to tweak the luck rate or drop the stat altogether.

Original thread: https://forums.rpgmakerweb.com/threads/questions-about-the-combat-mechanics.69190/