ShinySlowqueen

Veteran
Veteran
Joined
Dec 22, 2015
Messages
49
Reaction score
3
First Language
English
Primarily Uses
RMVXA
I'm trying to come up with a weapon that uses agility instead of strength, without making it have to give the character a whole ton of extra agility.

Say I have a whip, the whip's damage formula is:

Code:
a.agi * 4 - b.def * 2

But I want the whip *itself* to have a strength of 20. If I add +20 to ATK, it doesn't do anything with this formula. If I add +20 to AGI, I outspeed and oneshot everything, plus that +20 doesn't show up in shops.

It seems to me the best solution would be if I could:

Set the whip's ATK to +20.

Then have a damage formula something like:

Code:
(a.atk - (base attack)) + a.agi * 4 - b.def * 2

Where (base attack) is what the character's ATK would be if he weren't equipped with anything. This would shift the +20 ATK of the bow to AGI when attacking. Though I don't know if such a variable or script call even exists?

Alternatively, if there is a variable for the ATK rating of the equipped weapon, I could do this:

Code:
(a.agi + (weapon.atk)) * 4 - b.def * 2

But once again, I don't know if a variable or script call for weapon.atk truly exists.

If I'm totally off the wrong track and y'all can tell me how to do this using things that actually *do* exist, I'm all ears.
 

Shiro-chan

Friendly Neighbourhood Neppy Maid
Veteran
Joined
Aug 7, 2018
Messages
165
Reaction score
49
First Language
German
Primarily Uses
RMVXA
Standard attacks all use the same skill, skill #1. You need a script to change that. I recommend "Set Guard/Attack Skills" by V.M of D.T.
If you then want to use exclusively a character's stats, like ATK or AGI, that's a.atk or a.agi, so put that into the alternate skill. If you want to only use the weapon's strength, write just its exact number into the calculation, say the whip has 50 ATK you write just 50 (- b.def or such if you want).
You can also do it via variable, that would be v[variable index here].
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
600
First Language
Italian
Primarily Uses
RMVXA
But once again, I don't know if a variable or script call for weapon.atk truly exists.
It does not, but you should be able to get that value from your database calling the proper methods. On top of it, what has been said is true: you need a script to change the way your actors attack, their default attack is ALWAYS skill #1. That said, it does not mean that you cannot use something different. As a matter of fact you could even do it with just skill the skill formula. The main issue here is that VX Ace formula box is quite small.

Here is a sample of attack that keeps weapon atk bonus into account for your calculation, even when using AGI to deal damage.
Code:
(a.agi + (a.actor? ? a.equips[0].params[2] : 0)) * 4 - b.def * 2

Of course, you can do something more complex, this just shows you how to extract weapons ATK from database.
 

ShinySlowqueen

Veteran
Veteran
Joined
Dec 22, 2015
Messages
49
Reaction score
3
First Language
English
Primarily Uses
RMVXA
It does not, but you should be able to get that value from your database calling the proper methods. On top of it, what has been said is true: you need a script to change the way your actors attack, their default attack is ALWAYS skill #1. That said, it does not mean that you cannot use something different. As a matter of fact you could even do it with just skill the skill formula. The main issue here is that VX Ace formula box is quite small.

Here is a sample of attack that keeps weapon atk bonus into account for your calculation, even when using AGI to deal damage.
Code:
(a.agi + (a.actor? ? a.equips[0].params[2] : 0)) * 4 - b.def * 2

Of course, you can do something more complex, this just shows you how to extract weapons ATK from database.

So, since I'm trying to figure out how scripts work as I'm doing this, can you tell me what the question marks and the colon: zero do in this particular formula?

PS I'm using Yanfly's Weapon Attack Replace to replace Skill #1 for the special weapons. :)
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
600
First Language
Italian
Primarily Uses
RMVXA
PS I'm using Yanfly's Weapon Attack Replace to replace Skill #1 for the special weapons.
Good, this should already solve the issue of having multiple attack skills tied to different weapons.
The "? :" syntax is called "Ternary Operator" and works this way:
Code:
<Expression A> ? <Expression B> : <Expression C>
# it is the same as writing this
if <Expression A>
  <Expression B>
else
  <Expression C>
end
When the first expression is true, the part between "?" and ":" is executed, when false, the part after ":" is executed instead.
If you want to learn more about coding in ruby you could take a look at the manual (press F1 in the engine) and browse RGSS manual > Ruby Syntax.

Basically it checks if the user is an actor, if it is not, it adds 0, otherwise it adds the weapon ATK value. It is important to only do that for actors since enemies cannot use weapons, and there is no equips method for enemies; calling it on enemies would throw an error.
 
Last edited:

ShinySlowqueen

Veteran
Veteran
Joined
Dec 22, 2015
Messages
49
Reaction score
3
First Language
English
Primarily Uses
RMVXA
Good, this should already solve the issue of having multiple attack skills tied to different weapons.
The "? :" syntax is called "Ternary Operator" and works this way:
Code:
<Expression A> ? <Expression B> : <Expression C>
# it is the same as writing this
if <Expression A>
  <Expression B>
else
  <Expression C>
end
When the first expression is true, the part between "?" and ":" is executed, when false, the part after ":" is executed instead.
If you want to learn more about coding in ruby you could take a look at the manual (press F1 in the engine) and browse RGSS manual > Ruby Syntax.

Basically it checks if the user is an actor, if it is not, it adds 0, otherwise it adds the weapon ATK value. It is important to only do that for actors since enemies cannot use weapons, and there is no equips method for enemies; calling it on enemies would throw an error.

Ah. So if this were a skill that could *only* be used by actors and never enemies, could you shorten the bill to just:

Code:
(a.agi + (a.equips[0].params[2])) * 4 - b.def * 2

?

a.equips[0].params[2] seems to be exactly what I was looking for, though. I'm guessing the 0 in "equips[0]" is because the Weapon is the topmost thing on the equipment list, and you could make it 1 for shields, 2 for headgear etc. The 2 in "params[2]" must correspond to the weapon's ATK. Is there a list of all the params somewhere that I could check out? I know I'm going to be using this again somewhere.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
600
First Language
Italian
Primarily Uses
RMVXA
@pathos precisely, you could shorten it to just that if no enemy is supposed to use that skill. I used the extra check to be sure that nothing wrong would happen when someone else - you in this case - was using it (since I cannot know exactly how people are going to use the code I write, better safe than sorry).

I'm guessing the 0 in "equips[0]" is because the Weapon is the topmost thing on the equipment list, and you could make it 1 for shields, 2 for headgear etc.
You hit the mark once again. Would you ever forget about the order, you can check in the database, the order is the same as the one in your actors tab so it is easy to check.

The 2 in "params[2]" must correspond to the weapon's ATK. Is there a list of all the params somewhere that I could check out? I know I'm going to be using this again somewhere.
You can find the list in the Help window. Press F1, go to the "Index" tab, then look for RPG::EquipItem, the position of each statistic in the params array is documented there. The order is the same for all items, not just weapons (shields, accessories, armors, all share the same order).
 

Latest Threads

Latest Posts

Latest Profile Posts


No water this time, just trying for a majestic cliffside... The cave snuck in because I liked it. Now I guess I need a mini cave map or "secret" for it. :kaoswt:
Revamped the crew for my VN about thirty times. Only character that's stayed constant has been the fungus character. Guess it really grew on me...
I want to work on my reboot, but I don't have time to do it. ;_;
4y195n.png
big image so i posted it as a spoiler
Just a reminder to back your projects up. Do it now! :yamero:

Forum statistics

Threads
111,272
Messages
1,059,809
Members
144,569
Latest member
WideMouthInk
Top