[RESOLVED] Multiple Attributes

Started by Alyon93, March 08, 2015, 08:37:19 am

Previous topic - Next topic

Alyon93

March 08, 2015, 08:37:19 am Last Edit: March 08, 2015, 06:28:56 pm by Alyon93
Hi guys, I'm new here! Thanks for this awesome place, I hope I'll find a lot of good people. Before starting I must say that English isn't my native language so if I make some mistakes I hope you will understand.

So here I am for a strange question. I already searched in the "search" box, but I couldn't find anything, basically because I don't know what to search too.
Let's start from saying that I don't have any idea if what I'm looking for is a script or some hidden option in the database. Here's the problem:
I wanted to rebuild all my game's gameplay(leaving the standard battle system). What I wanted to modify were the attributes and enemies resistances. In particular I removed those attributes like "Vs Human", "Vs Ogre" and so on, that, in my opinion, didn't have any likelyhood in real life. I mean, having a Holy attribute which is stronger against Un-Deads or a "insectidice" attribute stronger against insects, make sense, but having something like "Vs Beasts" I don't think make any sense. So I removed all those attributes and added the weapons attributes: "Piercing", "Slash" and "Blunt". For instance, fighting a stone enemy(like a Gargoyle) make sense that Piercing and Slash attacks are almost useless, while Blunt attacks should deal a massive amount of damage. Unfortunately RMXP attributes management doesn't provide a further control on multiple attributes. Here's the situation:
I have an Angel which has F for "Light" damage, which means that he absorbs Light attacks. In my game, Light and Holy are the same thing, so, Cross-Blade the first skill of warriors, inflicts Light damage, but it's still a physical attack, so it has the "slash" attributes like swords base attack. This Angel has C to slash damage so base one.
Now. What I'm expecting is that a Cross-Blade on an enemy with F in Light and C in slash, has a damage output almost or equal to zero, instead it seems that it only calculates the base damage granted by Slash and ignore the Light one and I don't have idea what king of operation does it do.
I understood that to solve the problem, it would be enough to create an attribute for the enemy for the double type "slash/light", but this would mean creating "N" attributes for "N" skills, which, even if possible, it doesn't seem very efficient, yet elegant.
Another example, maybe more comprehensible, is the battle with a Kraken. In my game it has resistance D to blunt e weakness B to slash(in my thoughts, a giant tentacle would be easier to "cut" than "smash"). Axes which are, always in my opinion, an hybrid "Slash/Blunt" should deal a damage similar to base one "C". That is, if my attack deals 500 base damage, it would deal 750 damage for B attribute and 250 damage for D attribute. Adding them and then dividing for the number of attributes the attack have(in this example 2) should deal exactly 500 damage. (750+250)/2=1000/2=500.

Now, after this long introduction, that I hope it's understandable(I'm willing to explain better in any case), what I would ask is if there is a way, a script, an option in the database and so on, which can solve this problem, that is, a further control on the attributes which calculates the exact amount of damage.
As always, thanks in advance to those who will read this long text and will be willing to answer.  :^_^':

Alyon93

finalholylight

Hmm, I remember this small script, it's in Blizz's tons of add-ons

class Game_Battler
  def elements_correct(elements)
    multiplier = size = 0
    elements.each {|i|
       multiplier += self.element_rate(i)
       size += 1
    }
    return (size == 0 ? 100 : multiplier / size)
  end
end

Credit : Thanks to Blizzard.

Like you said, a skill with slash/light, C slash, F light, by this calculation,  (100 + 0)/2 = 50% damage deals to enemy, if you have 500 base damage, then it should be 500 for C, 0 for F, and then the result is
(500 + 0) / 2 = 250.

Alyon93

March 08, 2015, 12:39:37 pm #2 Last Edit: March 08, 2015, 01:54:52 pm by Alyon93
Thanks for the tempestive answer I will try it right away. Do I have to put it in another class above main or in the class Game_Battler? In this case I have to replace some lines for these or do I have to put them any where I want?
However I have to correct you: F shouldn't mean 0% (that is E). F mean -100% does this formula calculates also absorbing damage?

EDIT: I tried it and it seems to work well, the only thing I'd like would be to get the attribute from the weapon itself.  So for instance, if I have a sword with Slash attribute and I use Cross-Blade, I would have Light+Slash damage, but if I equip a sword with Slash and Fire attributes and then I use Cross-Blade I would like to do Light+Slash+Fire damage, while now it depends only on the attributes of the skill(which means that if I put a flame sword I would have to recreate every skill with the added attribute). Thanks anyway for the answer it's a very good start!

KK20

In case of the Light/Slash problem:
Light = F = -100
Slash = C = 100

The result of the script: (100 - 100) / 2 = 0. Thus, the attack would always do zero damage.

You only need to place the script below Scene_Base as very few scripts modify 'elements_correct'.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Alyon93

Thanks for the answer KK20. That's exactly what I wanted.
I edited my previous post before reading yours.
Can you check out on it?

KK20

Replace it with this

module Config
  # Put the Skill IDs in this array for skills that you want the actor/enemy's
  # elements set to be included with the Skill's element set
  USE_WEAPON_ELEMENTS = [57, 63] # Cross Slash and Thunder Pierce
end

class RPG::Skill
  alias original_element_set element_set
  def element_set
    if Config.USE_WEAPON_ELEMENTS.include?(self.id)
      return [true] + original_element_set
    else
      return original_element_set
    end
  end
end

class Game_Battler
  def elements_correct(elements)
    if elements[0] == true
      elements.delete_at(0)
      elements += element_set
    end
    multiplier = size = 0
    elements.each {|i|
       multiplier += self.element_rate(i)
       size += 1
    }
    return (size == 0 ? 100 : multiplier / size)
  end
end





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Alyon93

I tried your solution KK20 but nothing has changed: it only calculates the attributes' skill, not counting those in the weapons. I included all my physical skills(those who are executed with the weapon itself) in the array, so everyone between 57 and 80 for standard database but it still doesn't work. Let me know if you find out any other way.
Thanks a lot for trying anyway. I really appreciate it!

KK20

I refuse to sound like I failed in something easy.


module Config
  # Put the Skill IDs in this array for skills that you want the actor/enemy's
  # elements set to be included with the Skill's element set
  USE_WEAPON_ELEMENTS = [57, 63] # Cross Slash and Thunder Pierce
end

class RPG::Skill
  alias original_element_set element_set
  def element_set
    if Config::USE_WEAPON_ELEMENTS.include?(self.id)
      return [true] + original_element_set
    else
      return original_element_set
    end
  end
end

class Game_Battler
 
  alias remember_user_of_skill skill_effect
  def skill_effect(user, skill)
    $skill_user_battler = user
    return remember_user_of_skill(user, skill)
  end
 
  def elements_correct(elements)
    if elements[0] == true
      elements.delete_at(0)
      elements += $skill_user_battler.element_set
    end
    multiplier = size = 0
    elements.each {|i|
       multiplier += self.element_rate(i)
       size += 1
    }
    return (size == 0 ? 100 : multiplier / size)
  end
end

Mistake was that I assumed element_set was getting the attacker's element_set when it is actually the defender's. Popped in a global variable (cuz I don't want to modify skill_effect since that thing gets overwritten to hell) and all is good.
I even tested it this time.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Alyon93

Quote from: KK20 on March 08, 2015, 04:54:48 pm
I refuse to sound like I failed in something easy.

I didn't meant to sound like that... I assume errors happen to anyone sometime, at least you know a thing or two where to change things. I would never make it without you!

Quote from: KK20 on March 08, 2015, 04:54:48 pm
Mistake was that I assumed element_set was getting the attacker's element_set when it is actually the defender's. Popped in a global variable (cuz I don't want to modify skill_effect since that thing gets overwritten to hell) and all is good.
I even tested it this time.


Yet it still doesn't work...  :^_^': ...and I don't know what to say. I mean if you tried it in the way I mean to use it and it worked, it is for sure a problem of my project. Maybe some compatibility or version issue? Or do you have any script I might not have? Yet I'm pretty sure that you tried in a completely new project and if it was a compatibility issue, the test battle shouldn't have started at all. My version is 1.01 in case it might be a different version(but I'm pretty sure it isn't).
If it might help you, I can make some screenshots to see if your database settings are similar to mine.
Thanks a lot friend, you really are helping me out on this!

KK20

Version 1.01 as in your RMXP version? I don't think there are significant differences between them. You're not using any other scripts, right? And yes, I tested this in a blank project.

You could always upload a demo so I can see everything for myself. I think it's a script issue, so even the Scripts.rxdata file would probably be enough for me.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Alyon93

I'm using a lot of Scripts  :^_^': One for all is the SDK which I know it gives issues sometime. I'm willing to remove it if that's the issue since I use it only for a couple of scripts and they aren't really all that matter. Other scripts shouldn't modify in any way at all the fight formulas and something. However I'm going to upload the scripts.rxdata if you tell me how to upload an attachment, I couldn't find the proper command and I searched the FAQ's too...

KK20

Host it on a different website like Mediafire or get Dropbox.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Alyon93


KK20

You can move the script below 'Counterattack' and it seems to work.
SDK does rewrite a ton of things, so other people's scripts should be placed below the SDK scripts. That was the reason why my script wasn't working--SDK was ignoring my 'skill_use' edit.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Alyon93

Oh year sorry about that I was trying if it was SDK's fault and I put your script up there then I forgot to edit it again  :facepalm:

Anyway IT WORKS NOW!!! Thanks a lot KK20 I'm crediting you in that script! Is there any way to thank you? Karma or things like this?

KK20

CP's karma system is the Level stat that appears under our names. You can level up or down someone anonymously.
Glad to have helped :)





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Alyon93

March 08, 2015, 06:26:41 pm #16 Last Edit: March 08, 2015, 06:28:10 pm by Alyon93
Once I reach my tenth post I will be glad to give you a level. I'm pretty sure you will see me a lot of times from now on, so take it has a thank in advance! Cheers!