[XP] Rewriting System of PDEF and/or MDEF?

Started by AJNR95, February 08, 2012, 06:13:26 pm

Previous topic - Next topic

AJNR95

Sorry if I've posted in the wrong forum, I just have to pop in real quick because this is probably the only real active forum that is in the RMXP and RMVX Fields and I needed a question to ask out of curiosity and the fact that I have 0% Knowledge of making scripts by scratch.

All I would like to know is:

Can you rewrite the formula for how damage is received by both Player and Enemy?

If you can, are you able to rewrite a new script that has the value of PDEF and/or MDEF reduce the final value of the damage being dealt? Much like Dragon Age: Origin's "Armor" Statistic.

Spoiler: ShowHide

Y=Damage Given, X=PDEF, Z=Damage Taken
Y-X=Z
Ex.
25 Damage Given - 10 PDEF = 15 Damage Taken


I have no interest in changing how damage is generated in RMXP, it's satisfactory, but is there someway to achieve this type of armor system in the game? And a note is that I mainly use the Blizz-ABS, just to add so if anyone comes up with an idea, it'd be nice if it was compatible with the Active Battle System.
Spoiler: ShowHide


by Blizz: Spoilered, because image is 2.6 MB.
by AJNR95: Unspoilered, because fuck you - ¡Viva la Revolución!
by Blizz: Spoilered again, and Banned.

ForeverZer0

It is quite possible to change the way damage is calculated, specifically the "attack_effect" method in Game Battler 2.

Here is the default method:
Spoiler: ShowHide
  #--------------------------------------------------------------------------
 # * Applying Normal Attack Effects
 #     attacker : battler
 #--------------------------------------------------------------------------
 def attack_effect(attacker)
   # Clear critical flag
   self.critical = false
   # First hit detection
   hit_result = (rand(100) < attacker.hit)
   # If hit occurs
   if hit_result == true
     # Calculate basic damage
     atk = [attacker.atk - self.pdef / 2, 0].max
     self.damage = atk * (20 + attacker.str) / 20
     # Element correction
     self.damage *= elements_correct(attacker.element_set)
     self.damage /= 100
     # If damage value is strictly positive
     if self.damage > 0
       # Critical correction
       if rand(100) < 4 * attacker.dex / self.agi
         self.damage *= 2
         self.critical = true
       end
       # Guard correction
       if self.guarding?
         self.damage /= 2
       end
     end
     # Dispersion
     if self.damage.abs > 0
       amp = [self.damage.abs * 15 / 100, 1].max
       self.damage += rand(amp+1) + rand(amp+1) - amp
     end
     # Second hit detection
     eva = 8 * self.agi / attacker.dex + self.eva
     hit = self.damage < 0 ? 100 : 100 - eva
     hit = self.cant_evade? ? 100 : hit
     hit_result = (rand(100) < hit)
   end
   # If hit occurs
   if hit_result == true
     # State Removed by Shock
     remove_states_shock
     # Substract damage from HP
     self.hp -= self.damage
     # State change
     @state_changed = false
     states_plus(attacker.plus_state_set)
     states_minus(attacker.minus_state_set)
   # When missing
   else
     # Set damage to "Miss"
     self.damage = "Miss"
     # Clear critical flag
     self.critical = false
   end
   # End Method
   return true
 end


As you can see, its a bit more complicated than a simple PDEF vs. ATK formula, critical rates, elements, evasion, etc. are factored in as well. If you wanted to create an armor that would apply this effect only when equipped, you could do something like this:

Spoiler: ShowHide

  ARMOR_IDS = [1, 4, 7, 9]

 alias custom_attack_effect attack_effect
 def attack_effect(attacker)
   # If this is a actor and one of the custom armors is equipped,
   # then use the custom formula
   if self.is_a?(Game_Actor) && ARMOR_IDS.include?(self.armor1_id)
     # ADD CUSTOM FORMULA HERE
   else
     # Else just do the default thing...
     custom_attack_effect(attacker)
   end
 end


The question is, do you want elements and criticals to have an effect, or just make it a straight-forward simple formula?
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

AJNR95

February 09, 2012, 04:47:39 pm #2 Last Edit: February 09, 2012, 04:50:18 pm by AJNR95
Quote from: ForeverZer0 on February 08, 2012, 11:29:38 pm
It is quite possible to change the way damage is calculated, specifically the "attack_effect" method in Game Battler 2.


I would've never guessed. I've been tinkering with Game_Battler 3's lines 42-97

Quote from: ForeverZer0 on February 08, 2012, 11:29:38 pm
The question is, do you want elements and criticals to have an effect, or just make it a straight-forward simple formula?


Criticals I've set to do x3 the normal damage so I guess that can be set to the side.

To tell you now, the parameters follow the curve of TESV: Skyrim. Being the Health and Stamina/Mana being at intervals
of 10 and the parameters having a much smaller amount. I assume that RMXP is comfortable with higher statistics versus
smaller statistics, sadly I use the smaller statistics system. But I've always seen the system being either of Attack and Armor
being too powerful or too weak, which is why I disagree with the damage formula.

Elemental Effects I would like to have in the game, if that isn't a problem.
Element Damage: ShowHide

A = 200%
B = 150%
C = 100%
D = 50%
E = 0%
F = -100%

I think this is the default percentage for the elements, so it doesn't need to be changed.

Elements: ShowHide

001: Fire
002: Ice
003: Electric
004: Nature
005: Spirit
006: Heavy / 2-Handed
007: Light / 1-Handed


Quote from: ForeverZer0 on February 08, 2012, 11:29:38 pm
As you can see, its a bit more complicated than a simple PDEF vs. ATK formula, critical rates, elements, evasion, etc. are factored in as well. If you wanted to create an armor that would apply this effect only when equipped, you could do something like this:


Well in general view, I would like to formula to be like:
Physical Attack: Damage + (Strength/3) - PDEF (Armor) = Final Value
Magical Attack: Spell Damage + (Intelligence/3) - MDEF (Ward) = Final Value

And if the Final Value is a negative value because the Armor/Ward is much higher than
the Attack, then the value should just be set to 1, I don't believe in "0 Damage".

Looking something like
Physical Damage

     # Calculate basic damage
     atk = [attacker.atk + attacker.str / 3, 0].max # Is there someway to make the attacker.atk not be effect by the dividing of 3?
     arm = [self.pdef]
     self.damage = atk - arm


It'd be a lot easier if the Enemy's Attack is the incoming attack increased by 33% of his Strength, this would make the Enemy
creation easier for me so that the player doesn't take too much damage from a higher level enemy but doesn't take no damage
from a lower level enemy. I hate the fact that most RPG games let enemies that are far ahead of you kill you quickly. Skyrim does
a great job of allowing the player to fight at any level and Dragon Age giving the Levels a tight system and prolonged battle duration.
And that it also makes a giant distinction between Clothing, Light Armor, and Heavy Armor, showing that Heavy is much useful for
absorbing damage, but reducing Evasion and Light Armor doing vice versa of Extra Evasion and less Damage Absorption.
I'm sorry if my reply was irrelevant or immature because I can't fully grasp the concept of this whole situation at the moment.
But please tell me what I do need to tell you, I'm really eager to get some help. Thank you Zer0.
Spoiler: ShowHide


by Blizz: Spoilered, because image is 2.6 MB.
by AJNR95: Unspoilered, because fuck you - ¡Viva la Revolución!
by Blizz: Spoilered again, and Banned.

Aqua

     # Calculate basic damage
     atk = [attacker.atk + attacker.str / 3, 1].max # Is there someway to make the attacker.atk not be effect by the dividing of 3?
     arm = [self.pdef]
     self.damage = atk - arm


You want that 0 to be a 1, since you don't believe in "0 damage."
And RGSS follows PEMDAS, so only the attacker's strength is being divided by 3.


Oh... this is my 2500th post...

ForeverZer0

# Calculate basic damage
atk = attacker.atk + (attacker.str / 3)
self.damage = [atk - self.pdef, 1].max
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Aqua

Oops... totally wasn't paying attention... lol

Did you want the critical strike's 3x damage modifier to kick in before or after defense is applied?

AJNR95

Quote from: ForeverZer0 on February 09, 2012, 11:14:03 pm
# Calculate basic damage
atk = attacker.atk + (attacker.str / 3)
self.damage = [atk - self.pdef, 1].max



Thank You! I'm mad it was that easy

Quote from: Aqua on February 10, 2012, 09:15:39 am
Oops... totally wasn't paying attention... lol

Did you want the critical strike's 3x damage modifier to kick in before or after defense is applied?


Before the effect. That was a point I would've never brought up, but now that you did, Before. :)

I think my MDEF system is good for now. Thank you all so much :D
Spoiler: ShowHide


by Blizz: Spoilered, because image is 2.6 MB.
by AJNR95: Unspoilered, because fuck you - ¡Viva la Revolución!
by Blizz: Spoilered again, and Banned.