(Solved ) How do I make attack formula similar to this...

Status
Not open for further replies.

Uranium

Game Dev, Pixel Artist
Veteran
Joined
Jan 13, 2017
Messages
89
Reaction score
24
First Language
English
Primarily Uses
RMMV
Hey Everyone, I am either very tired and brain dead or I just haven't looked hard enough but im tryign to achieve these formulas in RPG maker mv Attack formula Language...

1. Attack = ((Power × 4/3) + (Weapon × 5/9))

2. Attack = ((Hit + Weapon) × 2/3)

3. Attack = ((Attack/2 * LDHP) * 2) -Exempt if to complex-

*
LDHP reffers to the last digit of HP
 
Last edited:

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
6,748
Reaction score
4,593
First Language
Dutch
Primarily Uses
RMXP

I've moved this thread to MV Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,653
Reaction score
1,105
First Language
EN
Primarily Uses
RMMV
Here are my guesses as to what you mean by the various terms, along with JS equivalents:
  • Power = Attack = ATK param of user
    a.atk
  • Weapon = ATK param (param ID 2) of user's first equipped weapon (0 if no weapon equipped):
    a.isActor() ? (a.weapons()[0] || {params:[]}).params[2] || 0 : 0
  • Hit = the user's hit rate (1 = 100%, 0.8 = 80%, etc) - I imagine you'd want this scaled up somehow:
    a.hit
  • LDHP = units digit of the user's current HP (easy - remainder after division by 10):
    a.hp % 10
So my guesses for your formula requests would be:
  1. (user ATK) * 4/3 + (user weapon 1 ATK) * 5/9
    a.atk * 4/3 + (a.isActor() ? (a.weapons()[0] || {params:[]}).params[2] || 0 : 0) * 5/9
  2. ((user HIT) * 100 + (user weapon 1 ATK)) * 2/3
    (a.hit * 100 + (a.isActor() ? (a.weapons()[0] || {params:[]}).params[2] || 0 : 0)) * 2/3
  3. (user ATK) * (last digit of user HP)
    a.atk * (a.hp % 10)
 

Uranium

Game Dev, Pixel Artist
Veteran
Joined
Jan 13, 2017
Messages
89
Reaction score
24
First Language
English
Primarily Uses
RMMV
Here are my guesses as to what you mean by the various terms, along with JS equivalents:
  • Power = Attack = ATK param of user
    a.atk
  • Weapon = ATK param (param ID 2) of user's first equipped weapon (0 if no weapon equipped):
    a.isActor() ? (a.weapons()[0] || {params:[]}).params[2] || 0 : 0
  • Hit = the user's hit rate (1 = 100%, 0.8 = 80%, etc) - I imagine you'd want this scaled up somehow:
    a.hit
  • LDHP = units digit of the user's current HP (easy - remainder after division by 10):
    a.hp % 10
So my guesses for your formula requests would be:
  1. (user ATK) * 4/3 + (user weapon 1 ATK) * 5/9
    a.atk * 4/3 + (a.isActor() ? (a.weapons()[0] || {params:[]}).params[2] || 0 : 0) * 5/9
  2. ((user HIT) * 100 + (user weapon 1 ATK)) * 2/3
    (a.hit * 100 + (a.isActor() ? (a.weapons()[0] || {params:[]}).params[2] || 0 : 0)) * 2/3
  3. (user ATK) * (last digit of user HP)
    a.atk * (a.hp % 10)
Thank you!! You nailed it after reading your post I realised I was a little vague with how I described it but you nailed it my friend thank you so much. I will try to implement this now! I will edit post with results. ASAP...

@caethyril Question on the on the a.atk part of this code is it calling the actors stat parameter before weapon equip added to the over all attack?

So depending whcin weapon I change the number after a.weapon()?
And what is the params[x] for sorry I misunderstood that part. Im guessing as you stated.. Attack parameter of the weaon is ID 2?
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,653
Reaction score
1,105
First Language
EN
Primarily Uses
RMMV
Great, no rush, hope it works out! :kaothx:

Edit @Uranium: a.atk returns the current ATK value after equips, traits, etc. The default order of calculation is paramBase (from the actor's class) + paramPlus (equips + permanent bonuses), all multiplied by paramRate, which is determined by the active traits and (de)buffs. (Extra and Special params are calculated solely as a sum/product of relevant traits.) You can get the base ATK value like this if you like:
a.paramBase(2)

And yep, params[2] is for getting the ATK value on the weapon. It's just different because of how the data happens to be stored. Basic params are indexed 0~7: MHP, MMP, ATK, DEF, MAT, MDF, AGI, and LUK respectively. This line:
a.isActor() ? (a.weapons()[0] || {params:[]}).params[2] || 0 : 0
...essentially means this:
  • If the user is an actor, then...
    • Get the actor's first equipped weapon or, failing that, an object with an empty params array on it;
    • Then return the value of the third entry (array indices start counting from 0) in the params array on that object; if the array doesn't have a third entry, return 0 instead.
  • If the user is not an actor, then return 0 instead.
Hope that makes sense! :kaojoy:
 
Last edited:

Uranium

Game Dev, Pixel Artist
Veteran
Joined
Jan 13, 2017
Messages
89
Reaction score
24
First Language
English
Primarily Uses
RMMV
Great, no rush, hope it works out! :kaothx:

Edit @Uranium: a.atk returns the current ATK value after equips, traits, etc. The default order of calculation is paramBase (from the actor's class) + paramPlus (equips + permanent bonuses), all multiplied by paramRate, which is determined by the active traits and (de)buffs. (Extra and Special params are calculated solely as a sum/product of relevant traits.) You can get the base ATK value like this if you like:
a.paramBase(2)

And yep, params[2] is for getting the ATK value on the weapon. It's just different because of how the data happens to be stored. Basic params are indexed 0~7: MHP, MMP, ATK, DEF, MAT, MDF, AGI, and LUK respectively. This line:
a.isActor() ? (a.weapons()[0] || {params:[]}).params[2] || 0 : 0
...essentially means this:
  • If the user is an actor, then...
    • Get the actor's first equipped weapon or, failing that, an object with an empty params array on it;
    • Then return the value of the third entry (array indices start counting from 0) in the params array on that object; if the array doesn't have a third entry, return 0 instead.
  • If the user is not an actor, then return 0 instead.
Hope that makes sense! :kaojoy:

Okay thank you for the quick lesson! So I got things almost working but i'am not quiet there yet.

I am trying to mock this system so I think I am missing a few key components to the whole formula. If you could check this webpage out which explains how the system works. This is what I am trying to achieve. (Males, Lucca/Marle, Robo)

I have set my Actor to have 400% Damage in the actor tab and I set the enemy to receive only %50 damage. But i dont think its quiet right... If you could help me mimic the formula used in chrono trigger webpage i sent you that would be amazing. I would not only give you a cookie but the whoolle Jar of cookie!! :kaoluv:

This is what I currently have set up....:
Actor 1:
Base atk = 5 damage
Weapon ID#6 = 3 damage

Formula in the skill for normal attack:
a.atk * 4/3 + (a.isActor() ? (a.weapons()[6] || {params:[]}).params[2] || 0 : 0) * 5/9
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,653
Reaction score
1,105
First Language
EN
Primarily Uses
RMMV
Formula in the skill for normal attack:
a.atk * 4/3 + (a.isActor() ? (a.weapons()[6] || {params:[]}).params[2] || 0 : 0) * 5/9
Wait, this looks wrong. :kaoswt2: In a skill formula a is the skill user. a.weapons()[6] says "the 7th weapon that is equipped by the user right now". Do your actors have 7+ equip slots for weapons? Little explanation:
  • a.weapons() means "get a list of weapons this actor has equipped right now".
  • a.weapons()[0] means "get the first entry in the list a.weapons()".

The "random value" sounds like it could be mimicked by RMMV's damage variance. If you want to manually add randomness, you can use something like Math.randomInt(100) (this will return a random integer from 0~99 inclusive).

Looks like the physical defence stuff goes like "(attack value) * (1 - (target def) / 256)". (Similarly for magical defence except using a magic defence param and a different max value.) So you could add that onto the formula, e.g.
JavaScript:
(a.atk * (a.hp % 10)) * (1 - b.def / 256)
Or just use RPG Maker MV's PDR/MDR parameters like you say; that's probably easier~ :kaophew:

Just to note: you don't have to replicate an existing game's mechanics, partially or completely. Before adding a new feature (e.g. these skill formulae), maybe consider what value they add to the game. Do they make combat more interesting/intuitive/etc for the player? Or easier for you to balance? How will these formulae affect combat/tactics/etc? Just some food for thought~ :kaothx:
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,222
Reaction score
1,127
First Language
English
Primarily Uses
RMMV
(a.weapons()[0] || {params:[]}).params[2] || 0
While you pretty much have this covered, I wanted to poke my nose in and say that, if you want something that can account for dual wielding (or some other odd edge case where multiple weapons can be equipped somehow) this approach might be worth considering instead:

Code:
a.weapons().reduce((acc, obj) => acc + obj.params[2], 0)
So

Code:
a.isActor() ? a.weapons().reduce((acc, obj) => acc + obj.params[2], 0) : 0
For the OP, this returns the total ATK on all equipped weapons, so 0 if there's none or if it's an enemy.
 

Uranium

Game Dev, Pixel Artist
Veteran
Joined
Jan 13, 2017
Messages
89
Reaction score
24
First Language
English
Primarily Uses
RMMV
Yeah haha oh man... :kaodes: I messed that one up big time. I am pretty new with certain things so I mixed that up. Ooops. Thank you for explaining it to me you have helped a lot and I really appreciate everyone taking there time to give advice it is so nice.

Sorry so would this be the correct formula if I'm trying to reach what the actor has equip now?:
a.atk * 4/3 + (a.isActor() ? (a.weapons()[0] || {params:[]}).params[2] || 0 : 0) * 5/9
This give me a basic attack in battle of 22. It is very very close to what I was wanting. But no matter what defence stat i set the enemy to I seem to always to 22 damage?

Edit: Got it... I just need to use the traits section and change physical and magical damage % taken. Got iT! thank you!

And about the battle system I was just trying to achieve something similar for a few reasons. such as Balancing is one forsure, Nostalgic purpose is #1. So I wanted to reach the close to the same/similar for a base starting point and THENN after Add, modify features as required to make it unique in my way.
 
Last edited:

hiddenone

Lurker Extraordinaire
Global Mod
Joined
Feb 19, 2014
Messages
2,387
Reaction score
5,102
First Language
english
Primarily Uses
RMMV

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,217
Reaction score
4,346
First Language
English
Primarily Uses
RMMV

I've unlocked the thread since OP changed his mind and wants to ask additional questions.

 

Uranium

Game Dev, Pixel Artist
Veteran
Joined
Jan 13, 2017
Messages
89
Reaction score
24
First Language
English
Primarily Uses
RMMV
(a.atk * (a.hp % 10)) * (1 - b.def / 256)
Ah I'm sorry this will be my last question at the moment on this topic.

@caethyril May I ask you How/Where do I implement this part of the formula
(a.atk * (a.hp % 10)) * (1 - b.def / 256)
if I wanted to use defense stat instead of the traits Physical/Magical Damage %.
Right now when I change the defence of an enemy is has no effect.
If I wanted to do the "127" defence stat for half damage done etc like in chrono trigger where do I place this formula. Again I am sorry i am quiet new to the whole damage formula part of RPG Maker MV:kaosigh:
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,653
Reaction score
1,105
First Language
EN
Primarily Uses
RMMV
How/Where do I implement this part of the formula
(a.atk * (a.hp % 10)) * (1 - b.def / 256)
if I wanted to use defense stat instead of the traits Physical/Magical Damage %.
Right now when I change the defence of an enemy is has no effect.
If I wanted to do the "127" defence stat for half damage done etc like in chrono trigger where do I place this formula.
:kaohi: It all goes in the skill formula box, same as before. The example you quoted is for the "Crisis Arm" attack formula, just because that one was nice and short compared to the other two. All I've done is put the original formula in brackets, then multiplied it all by a "defence" number between 0 and 1 (assuming the target's DEF is somewhere between 1 and 256). :)

Another example for clarity...let's say you want to apply the same process to this formula:
JavaScript:
a.atk * 4/3 + (a.isActor() ? (a.weapons()[0] || {params:[]}).params[2] || 0 : 0) * 5/9
It's longer, but it's still just an "attack" value...there's no references to the target's DEF or anything. So consider a second formula, e.g. something like this:
JavaScript:
1 - b.def / 256
This says "get the target's DEF, divide it by 256, then subtract the result from 1". If the target has 127 DEF, this yields 1 - 127/256, which is almost 0.5, i.e. 50%. High DEF gives a low result and vice-versa...all looks good! Now we just have to multiply these two parts together~
JavaScript:
(a.atk * 4/3 + (a.isActor() ? (a.weapons()[0] || {params:[]}).params[2] || 0 : 0) * 5/9) * (1 - b.def / 256)
This is the skill's new formula! :kaopride:

(Obviously you can try out your own formulae, these are just suggestions~)
 

Uranium

Game Dev, Pixel Artist
Veteran
Joined
Jan 13, 2017
Messages
89
Reaction score
24
First Language
English
Primarily Uses
RMMV
:kaohi: It all goes in the skill formula box, same as before. The example you quoted is for the "Crisis Arm" attack formula, just because that one was nice and short compared to the other two. All I've done is put the original formula in brackets, then multiplied it all by a "defence" number between 0 and 1 (assuming the target's DEF is somewhere between 1 and 256). :)

Another example for clarity...let's say you want to apply the same process to this formula:
JavaScript:
a.atk * 4/3 + (a.isActor() ? (a.weapons()[0] || {params:[]}).params[2] || 0 : 0) * 5/9
It's longer, but it's still just an "attack" value...there's no references to the target's DEF or anything. So consider a second formula, e.g. something like this:
JavaScript:
1 - b.def / 256
This says "get the target's DEF, divide it by 256, then subtract the result from 1". If the target has 127 DEF, this yields 1 - 127/256, which is almost 0.5, i.e. 50%. High DEF gives a low result and vice-versa...all looks good! Now we just have to multiply these two parts together~
JavaScript:
(a.atk * 4/3 + (a.isActor() ? (a.weapons()[0] || {params:[]}).params[2] || 0 : 0) * 5/9) * (1 - b.def / 256)
This is the skill's new formula! :kaopride:

(Obviously you can try out your own formulae, these are just suggestions~)

Ahhh!!! I got it now!!! Lol thank you again for your help you have been the best!

I was mixing up a few things but I am clear on it now. Thank you! I feel a little dumb for not understanding the first time. I appreciate your kindness.

I am going to wrap this up with a Solid Solved!!! Thank you to everyone again. And I will definitely be looking at the duel wield formula @Aesica Thank you caethyril,Aesica

You have given me the knowledge to feel confidant to start playing with formuals thank you!!!!!! :kaoblush:
 
Last edited:

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
6,748
Reaction score
4,593
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Profile Posts

// Looks at Elfkisser, realizes he'd have to either install Windows 10 or compile it for Linux
// Didn't install Elfkisser.
Too much effort for a curiosity. :popcorn:
I was just high-fiving myself for all I've learnt in the engine, and how far I've come, only to forget to remove the Immortal state from a semi-scripted battle. Now the enemy never dies and I feel so smart >.>
Playtest your stuff. Always playtest.
just spent FOREVER troubleshooting an issue with my keyboard... turns out the cord was just loose OTL
I count on someone one time, I let them promise something to me, and one week later it's complete silence as I'm completely let down. I hate everything.

Forum statistics

Threads
99,224
Messages
963,218
Members
130,813
Latest member
Gremter
Top