Damage Formula calls to weapon and armor used

voymasa

Veteran
Veteran
Joined
Jul 25, 2013
Messages
124
Reaction score
18
First Language
English
Primarily Uses
I apologize in advance if this topic was previously covered; I couldn't find the answer during searches over the last 3 days. I am running a system similar to D&D for calculations and damage, etcetera, including randomizing the base value of damage from the attack based upon the weapon's attack value, modifying it by either the character's atk or agi (depeding if it falls under melee or ranged weapon), and reducing it by the target's def value (as a percentage). I can't remember how to call the attacker's equipped weapon. My formula is as follows:

(a.weapon[atk]+rand[1...a.weapon[atk]])*(1-(b.def/20))

What is supposed to happen is the basic attack "rolls" a number based upon the weapon's attack value (example: 6) and then adds that base value, resulting in a number between 7 and 12 in my example. The "roll" is then multiplied by the target's defense (as a %), i.e. for every point of defense, they reduce physical attack damage by 5%. Armor values are automatically added to the character's base defense, so I can have a "natural armor" value of 0 for most characters (thus they rely on armor). How should I fix my formula to call the weapon's vase attack value as part of my formula, and to use it to randomize a value?

I plan to add the following between the attack and defense sides (next to the *):

; a.weapontype[simple melee | martial melee | exotic melee]?; v[n]*(1+((a.atk-a.weaponatk)*a.atk/10)); v[n]*(1+((a.atk-a.weaponatk)*a.agi/10));

This, when proper weapon attack power is called and weapon type is called (yes, those are my three melee categories), should take the variable I will need to assign the base damage to, and multiply is by the appropriate modifier (attack or agility) before reducing the damage.

I was thinking of trying a common event workaround, but I believe the damage formula is calculated before any "features" are caused by the skill.

Help is appreciated.

I also have an issue with the damage "roll" for the monster skills I'm putting in, but the intent is the same for the monster "base attack" skills. Example:

(rand[2...8]+4)*(1-(b.body[def]/20))

Thanks, in advance (sorry for the long post).
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
I think it should be a.weapons[0] for the first weapon, and in case of dual wield, a.weapons[1] for the second weapon
 

voymasa

Veteran
Veteran
Joined
Jul 25, 2013
Messages
124
Reaction score
18
First Language
English
Primarily Uses
Would the call to a.weapons[n] give the attack value of the weapon, or just what weapon it was?

I tried a workaround with a call to a common event, but I couldn't figure out how to grab the weapon's attack power (you can grab the character's total attack power, or a specific weapon from the list, but not the weapon's attack power). Hmmmm....

If I had a common event that determined what weapon the character had equipped, and then set a specific weapon attack value (i.e. a Shortsword would be 6) to a variable, and then used that variable in the damage formula, all I would need to do is have the event called before damage is calculated.

Still, more help is needed, please.

Okay, I had an idea, but the crux is based upon the answer to both of the following being a yes:

a) the a.weapon[n] call, does that call the weapon that the attacker has equipped? i.e. if they have weapon 4: longsword, from the weapon list, the a.weapon[3] call would allow you to store that in a variable (v[n]=)

B) can I call a common event from the damage formula box, i.e. set the variable to the weapon they have equipped (since I can't find a way via eventing, right now, to do so), call a common event to determine what the weapon's base attack power would be, using conditional branches, etcetera, and set that value to a second variable (using the random variable assignment event), determine ranged or melee in said event, and then in the rest of the DF (after the common event call) have my damage formula (or even do most of the math in the common event)?

Example: You have a shortsword equipped, with a base power of 6. I want the weapon to have a base damage value of 7-12 before modifiers. The initial DF would call that weapon and store that it is a shortsword into a variable. Then it would call a common event, which would check it against a conditional branch and set a random value between 7 and 12 to a second variable. The common event would then check via a conditional branch, whether the shortsword is a melee or ranged weapon (by checking against it's weapon type; in this case martial melee). The event would then multiply the second variable (base damage between 7 and 12) by the 1+actor's attack/10.0 (for bonus damage). Finally, the event would multiply the modified value by 1-defender's defense/20.0 (5% reduction per point of defense), and output a textbox message at the bottom: Deals v[n] damage! where n is the variable that the final amount is stored in.

An alternative, which I thought after reading the above response, would be to remove the defense value from the formula, and use the element.rate parameters set to each monster (and on each armor), and use the a.def value as a base "strength" to modify the damage, and have a.atk as 0 for actor's (I use a different set of attack skills for monster's, b/c they don't have equipped weapons), so that the weapon's attack value is the only contributor to a.atk, other than other equipment. Example:

Shortsword with attack of 6, and the actor's base "strength" is 15 (i.e. a.def is 15). The target has a damage reduction of 10% vs physical types (i.e. slashing, piercing, and bludgeoning; element.rate of 90%). I would have to place the weapons on the weapon list according to type (i.e. 1 to x are melee weapons and y to z are ranged weapons), I would use something like this:

c=rand(a.atk)+a.atk+1;a.weapon[1...x]?c*(a.def/10.0):c*(a.agi/10.0)

I think this formula could work. What do you all think?

Grrr.... So, I've used the following two formulas and they are passing no damage back and forth when I battle test:

Skill:Attack>  v[1]=1+a.atk+rand(a.atk);a.weaponid[0...3]?v[1]*(a.def/10.0):v[1]*(a.agi/10.0)

Skill:MonsterBite>  v[1]=1+rand(8);(v[1]+4)*(a.tk/10.0)

v[1] is a simple variable I called base damage, which I think can freely be passed back and forth to whomever uses it. Am I using the weapon type call right? Also, I don't see how the bite skill could be passing 0.... hold on, one moment....

Okay.... the monster bite skill was a simple typo (notice the a.atk isn't spelled right), but I haven't figured out where my call is wrong with the Attack skill. Am I close? Help.
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
a.weapons[0] would give you the weapon object


so doing a.weapons[0].atk should give you the attack stat of that weapon (I think so)
 

voymasa

Veteran
Veteran
Joined
Jul 25, 2013
Messages
124
Reaction score
18
First Language
English
Primarily Uses
a.weapons[0] would give you the weapon object

so doing a.weapons[0].atk should give you the attack stat of that weapon (I think so)
Thanks. I was trying this but didn't notice the "s" on weapons, so I was getting no damage. Now my formula works:

c=1+a.atk+rand(a.atk);a.weapons[0].id<3? c*(1.0)*(a.def/10.0):c*(1.0)*(a.agi/10.0)

The id number is arbitrary, but if I organize my weapons list by melee and ranged, and set the corresponding id, it will work fine.

I also added ammunition functionality by adding an armor type called ammunition, and set it to the shield slot. The only downside is that I still have to allow them to equip a shield while the ammunition-using weapon is equipped (which is illogical for two-handed weapons).

Okay..... new problem. I wanted to add ammunition selection for the player whenever they use a bow, crossbow, etcetera. I have the following:

v[3]=a.atk;a.addevent[1];c=v[3];d=1+c+rand©;a.addelement(v[5]);d*(1.0)*(a.agi/10);b.addstate[v[4]]

I have a common event (#1) called SHOT. I initially pass the attack value to a variable (base damage) and then run the event via the DF because I don't want there to be a continuous "no damage" statement before the player then selects their ammo and actually attacks (it would look odd, etcetera). I call the event within the DF so I can then select the ammo type and change the actual damage by ammo (as well as element and add states). v[3] is base damage, 4 is the added state's number, and 5 is the added element's number. When I use the shot skill it passes no damage and runs as though no damage is being done. HELP!!!!
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
the last part of your damage formula was adding a state...


and the way it works, damage is always the last part of the formula, in this case the damage is the adding of the state, so that would really return 0 damage.
 

voymasa

Veteran
Veteran
Joined
Jul 25, 2013
Messages
124
Reaction score
18
First Language
English
Primarily Uses
the last part of your damage formula was adding a state...

and the way it works, damage is always the last part of the formula, in this case the damage is the adding of the state, so that would really return 0 damage.
I tried moving the damage part to the end. Could you check to see if i'm writing my calls correctly?

v[3]=a.atk;add.event[1];c=v[3];d=1+c+rand©;add.state[v[4]];add.element[v[5]];d*(1.0)*(a.agi/10)
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
as far as I'm concerned, there's no use for the c variable since you could just use v[3] anyways.


Assuming all of those calls are valid, it seems fine. If it's still returning 0 then that would mean that somewhere along those codes is a part that returns an error. Whenever there's an error in the damage formula, the game just terminates the computation and returns 0
 

BoluBolu

Veteran
Veteran
Joined
Apr 24, 2014
Messages
452
Reaction score
117
Primarily Uses
This turns out to be really complicated huh?

v[3]=a.atk     <= why ?

c=v[3]          <= why ?

why don't just c = a.atk  ? But then

  d=1+c+rand©   <= why ??

why don't just like this >>>     d = 1 + a.atk + rand(a.atk)

or perhaps the c used for shortening thing, so

c = a.atk

d = 1 + c + rand©

But I don't understand why you assign the a.atk to v[3]. Or variable 3 will be used for something in the future?

Then this

add.event[1]

add.state[v[4]]

add.element[v[5]]

Were those command is really available in Damage Formula?

I somewhat confused.. because the eval method will rescue the damage into 0 if the damage formula is error, for example an odd command(I think)

EDIT : Wew, miko has tells what I wanted to tell, I'm late 1 minute XD lol.
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
yeah, I'm really concerned about where he got those add.whatever calls...
 

voymasa

Veteran
Veteran
Joined
Jul 25, 2013
Messages
124
Reaction score
18
First Language
English
Primarily Uses
This turns out to be really complicated huh?

 v[3]=a.atk     <= why ?

 c=v[3]          <= why ?

why don't just c = a.atk  ? But then

  d=1+c+rand©   <= why ??

why don't just like this >>>     d = 1 + a.atk + rand(a.atk)

or perhaps the c used for shortening thing, so

c = a.atk

d = 1 + c + rand©

But I don't understand why you assign the a.atk to v[3]. Or variable 3 will be used for something in the future?

Then this

add.event[1]

add.state[v[4]]

add.element[v[5]]

Were those command is really available in Damage Formula?

I somewhat confused.. because the eval method will rescue the damage into 0 if the damage formula is error, for example an odd command(I think)

EDIT : Wew, miko has tells what I wanted to tell, I'm late 1 minute XD lol.
I'll try to cover all of the questions.

v[3]=a.atk is to pass the atk value to variable 3 (base damage) in order to manipulate it in the common event I'm attempting to call in the DF.

c=v[3] is to save space b/c the DF is limited in characters

d=1+c+rand© (again, a space save) is to set a damage value to be modified later by a percentage of the agility score (a.agi/10)

doing c=a.atk wouldn't work because the a.atk is supposed to be modified within the common event, via v[3], so I can pass the modified (by ammo "type" in the common) value to the DF and use the new value for my damage

add.state and add.element are incorrect on my part. I believe in another thread they use add_state and add_element to add state or elements to the attack when it varies. The reason I use them (with two variables, 4 and 5, from the common event) in the DF is because the added status effects (state) and elements would vary based upon the ammo selected in the common event.

as for add.event (or maybe add_event would work). Common events added via the features box, would run after the DF is calculated, but what I want to do is allow the player to select what ammo they are using for the shot and modify that attack with said ammo, thus I am trying to make a call to the common event (number 1 for my purposes) in order to "interrupt" the DF and allow the player to select their ammo for the attack.

I was trying to creatively allow the player to choose their ammo for shooting attacks (bows, crossbows, etcetera), via eventing, rather than adding new scripts. (Script calls in the DF are the limit of my abilities right now). My only other idea is to add another skill called "Load/Load Weapon" which would call the common event, but that would require the player to use their turn to "reload" their ranged weapon. Increase in realism, yes, but inconvenient and not necessarily fun or they play (plus it becomes an eventing nightmare to "reset" the ammo and not get compounding when switching between ammo types.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
AFAIK unless you explicitly run the common event before the DF, it won't really run even if you add it thru the DF.
 

BoluBolu

Veteran
Veteran
Joined
Apr 24, 2014
Messages
452
Reaction score
117
Primarily Uses
I see so you want the BASE damage can be manipulated from the common event. But..

uhh.. Maybe I'm a dumb, but again your add_element, add_state, and add_event were those really legal to be called via DF? Why I never knew this before?

And for the add_element, evenly inside the RGSS3 Library, I have never come across that method, the same goes  with add_event, but the add_state is exist, and yes it's for adding a state to a battler, but again is that really legal to be called in DF? I don't mean to be an assho#$ but AFAIK, DF is not a script call box, and to call a script it is necessary for you to really know what should be called, what it is and what it will do, does it legal to call it from here? and etc, not to just calling something without knowing the flow work like your add_element and add_event. Even it will throw you an error if you called it from script box but it's appear that it's an undefined method or variable. I'm sorry but it looks like you're calling that command at your own instant will.

Now we know computer is a dumb thing, they won't really know what to do unless we specifically tell it to do something properly. And if you tell them to do something without taught it first how to it, the computer will yell at you and crash your game, it is fact.

And yes as miko have said to run a common event it needs a specific trigger to, not just add it, add means simply add, you don't tell the computer to run it? Then it won't run it(again he(computer) is dumb), that's also if you succeed in adding the common event from the DF.

There's nothing wrong with your game mechanic design and yes it's very good, but to implement it I do know it's a no easy thing, especially without a whole new script. I even imagine that you need to make a new bullet class, and probably a window popout that give option to the character to choose bullet after choosing attack command and then make some new calculating damage based on what bullet type the character has choose. This is I believe need a whole new script that almost like new system, sorry if I'm wrong at somewhere or did I offended you? Really sorry I don't mean that, be aware that I'm not yelling at you, I type with smiling =)
 

PencilCase27

So, I can write anything I want here... right?
Veteran
Joined
Jun 5, 2014
Messages
33
Reaction score
13
First Language
German
Primarily Uses
DF is a script call box in every sense. You can even define methods and pass them in the DF. Someone called Formar wrote a good guide about this. a/b.add_state(x) is fine.

add_element and add_event however I have never heard of. They give you an error if you use them outside of the damage box, so I assume they don't exist.

Also, it's add_state(x) and not add_state[x]. add_state is a method and not an array.
 

voymasa

Veteran
Veteran
Joined
Jul 25, 2013
Messages
124
Reaction score
18
First Language
English
Primarily Uses
I tried a.weapons[0].atk, but it only returns no damage. a.weapons[0].id returns the id number, but I want the weapon's attack power.

Figured it out. I looked in the Help file under RPG Maker Data Structures. Under weapons it references by params (i.e. parameters, as in the parameter section of the weapons list), so params[2] will give you the attack bonus of the weapons[0].

Final call that works: a.weapons[0].params[2]

This will reference the attack parameter of the weapon that the attacker has equipped. Usable in the Damage Formula bar.
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
ah, so it isn't structured like battlers where they made wrappers for the params call which was why we could use things like .atk, .mdf and so on with actors and enemies... :)
 

voymasa

Veteran
Veteran
Joined
Jul 25, 2013
Messages
124
Reaction score
18
First Language
English
Primarily Uses
ah, so it isn't structured like battlers where they made wrappers for the params call which was why we could use things like .atk, .mdf and so on with actors and enemies... :)
The wrappers would have been convenient, but I thoroughly checked my spelling and all, and it repeatedly returned no damage until I looked it up in the data structures and made the call to params[2] (attack). For convenience, I'll list all of the params values from that data structure (under RGSS Reference Materials: RPG BaseItem: EquipItem).

Params:

0 - Max HP

1 - Max MP

2 - Attack

3 - Defense

4 - Magic Attack

5 - Magic Defense

6 - Agility

7 - Luck
 

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

Latest Threads

Latest Posts

Latest Profile Posts

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'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,018
Members
137,563
Latest member
MinyakaAeon
Top