I only have 2 cases and a default which looks a bit weird TBH.
- switch(skill->formula)//Magical Or Weapon Type Skill?
- {
- case 1://Weapon type dmg
- {
- skillpower += skill->atkpower +(long int)floor((double)GetSen( )/2);
- skillpower += skillpower *GetSen( ) / 10000;
- skillpower -= skillpower * Stats->Defense / 10000;
- skillpower -= Stats->Defense * 5 / 100;
- Log(MSG_INFO,"%i cast Weapon Dmg Skill with %i sen, Attack power %u, skillpower %li, Deff %u, level diff %li, to %i",clientid,GetSen( ),skill->atkpower,skillpower,Enemy->Stats->Defense,level_diff,Enemy->clientid);
- }
- break;
- case 2://Magical type dmg
- {
- skillpower += skill->atkpower +(long int)floor((double)GetInt( )/2);
- skillpower += skillpower*GetInt( ) / 10000;
- skillpower -= skillpower*Stats->Magic_Defense / 10000;
- skillpower -= Stats->Magic_Defense * 5 / 100;
- Log(MSG_INFO,"%i cast Magical Dmg Skill with %i int, Attack power %u, skillpower %li, MDeff %u, level diff %li, to %i",clientid,GetInt( ),skill->atkpower,skillpower,Enemy->Stats->Magic_Defense,level_diff,Enemy->clientid);
- }
- break;
- default:
- {
- skillpower += 5;
- Log(MSG_INFO,"%i cast Unknown Formula Skill (%i), Attack power %u, skillpower %li, Deff %u,MDeff %u, level diff %li, to %i",clientid,skill->formula,skill->atkpower,skillpower,Enemy->Stats->Defense,Enemy->Stats->Magic_Defense,level_diff,Enemy->clientid);
- }
- break;
- }
This is definitely all kinds of wrong and needs to be recoded.
There are a number of different skill->formula values in the STB. We should probably build out on those.
Examples below are just a few of the list. Not all of them.Soldiers -> Most skills use 1 which we can associate with STR perhaps. There are a few that use 4 though. (shield stun, soul wreck, voltage crash)
Muse -> Most skills use 2 which we can associate with INT perhaps. Some use 5. (ALL AOE skills + Voltage Jolt, permafrost, hellfire)
Hawker -> Most skills use 1 (STR again) and a few use 4 (stun arrow, venom knife, flame hawk, spiral kick)
Dealer -> Most skills use 1 (STR doesn't make sense here) and some use 4 (rapidfire triple shot, hypno shot)
At first I thought maybe the exceptions are using status effects but that isn't it. I just don't see any reason for these things to be anything but 1 or 2.
We already have a field that denotes AOEs plus many of the exceptions aren't AOE anyhow.
I'm wondering if the best option might be to change the values in the STB to just show magic attack or normal. Or treat 5 as magic and 4 as non_magic.
We already calculate attack power based on class and weapon type etc. so lets just use AP as a base and the STB skill power as a modifier in some way.
Maybe base AP + skillpower? (eg. AP = 200: STB skillpower = 120: so skill attack power would be 200 + 120 = 220)
maybe base AP + a percentage (eg. AP = 200 STB skillpower = 120 so skill attack power would be 200 + (200 * 120%) = 440) Could get crazy big with skills like Soul Wreck....
Maybe we just use the value from the STB unmodified by anything? Downside of that is that as your AP gets bigger, skills would become less useful and would fall behind.
The first way would certainly be by far the easiest to code. Just add the STB value directly to your calculated AP
The magic or not_magic aspect only comes into it when deciding which defense to apply DEF or MDEF
the code would come out looking something like this
-
- switch(skill->formula)//Magical Or Weapon Type Skill?
- {
- case 1: case 4://Weapon type dmg
- {
- skillpower = skill->atkpower + skill->atkpower;
- unsigned int totalpower = skillpower + Enemy->Stats->Defense;
- double hitmod = skillpower *100 / totalpower; //percentage of skillpower to use
- skillpower = (unsigned int)floor((double)(skillpower * hitmod / 100));
- }
- break;
- case 2: case 5://Magical type dmg
- {
- skillpower = skill->atkpower + skill->atkpower;
- unsigned int totalpower = skillpower + Enemy->Stats->Magic_Defense;
- double hitmod = skillpower *100 / totalpower; //percentage of skillpower to use
- skillpower = (unsigned int)floor((double)(skillpower * hitmod / 100));
- }
- break;
- default:
- {
- skillpower = 0;
- Log(MSG_INFO,"%i cast Unknown Formula Skill (%i), Attack power %u, skillpower %li, Deff %u,MDeff %u, level diff %li, to %i",clientid,skill->formula,skill->atkpower,skillpower,Enemy->Stats->Defense,Enemy->Stats->Magic_Defense,level_diff,Enemy->clientid);
- }
- break;
If you like the look of this then please give it a test run and see how it works out. I don't have the time to test it myself right now.
the definition of skillpower here will overwrite all the previous definitions in this function so if it works out then we can pare down the rest of the code.
Not sure how it will work for monsters though.... Haven't checked their skills yet so we might need some extra cases for them
I'm trying to get rid of all the leveldif crap altogether. I don't like it. I think it makes combat unrealistic.
My formulas are based entirely on attack and defense.
First we add our attack to the enemy's defense (choosing which def type to use) making a total value
Then we determine what percentage of that total is represented by our attack power.
Then we apply that same percentage of the attack power as the damage done.
Example: We have 100 AP. Enemy has 100 DEF. Total = 200. Our attack is exactly 50% of this so half of our damage gets through his defense. We do 50 damage.
This method is infinitely variable and will ALWAYS result in a small amount of damage getting through no matter how big the difference between attack and defense.
The method is also very robust and
cannot ever return a negative value as so many previously used formulas do