[Mini-Guide] Fixing AOE attack calculations in 4267 source

12/11/2009 08:46 pro4never#1
Ok so not a huge release but figured I'd explain how to fix the magic aoe attacks. Best viewed as a way to fix voids yourself but w/e, I know no one will really pay that much attention to it.


Problem in source: Area attacks do not have any damage type in their attack void (by default they are all physical damage). because of this slight oversight, fire circle/pervade and other area attacks all calculate as PH dmg and therefor are vastly wrong (although using pervade on a tro is rather funny xD)

Steps to fix it:

Modify the attack void:

The original AreaTargets attack void will start something like this...
Code:
static void AreaTargets(COClient Client, int Distance, ref Dictionary<uint, int> Targets, Struct.CharSkill Spell)
This is all well and good but notice there is no attack type used. We want to change it to look something like...


Code:
static void AreaTargets(COClient Client, int Distance, ref Dictionary<uint, int> Targets, Struct.CharSkill Spell, int Type)
Notice at the very end we have added int Type. This name is arbitrary and could be anything you want but type kinda makes sense so we'll go with that.

Look further down in that code and simply change it to have damage type.

Code:
int Damage = Calculation.Damage(Client.Char, AClient.Char, 2, Spell.ID, Spell.Level);
This simply needs to be replaced so that it's not hard coded to be physical damage (the 2)

with...
Code:
int Damage = Calculation.Damage(Client.Char, AClient.Char, Type, Spell.ID, Spell.Level);
This means we are using the Type input into the attack void and putting it into the damage calculation.


Modify the individual skills to conform to the new void:
Handler>Attack.cs contains the data for attack calculations.

In this case

Code:
case 3090:
                case 1120:
                    {
                        #region FireCircle n Pervade
                        Dictionary<uint, int> Targets = new Dictionary<uint, int>();
                        AreaTargets(Client, Spell.Level + 10, ref Targets, Spell);
                        ConquerPacket.ToLocal(ConquerPacket.MagicAttack(Client.Char.ID, Spell.ID, Spell.Level, Targets, Client.Char.X, Client.Char.Y), Client.Char.X, Client.Char.Y, (int)Client.Char.Map, 0, 0);
                        break;
                        #endregion
                    }
This is the original code for pervade and fire circle (3090 and 1120)

In the end it will look something like this (yay copypaste?!)

Code:
case 3090:
                case 1120:
                    {
                        #region FireCircle n Pervade
                        Dictionary<uint, int> Targets = new Dictionary<uint, int>();
                        AreaTargets(Client, Spell.Level + 10, ref Targets, Spell, 21);
                        ConquerPacket.ToLocal(ConquerPacket.MagicAttack(Client.Char.ID, Spell.ID, Spell.Level, Targets, Client.Char.X, Client.Char.Y), Client.Char.X, Client.Char.Y, (int)Client.Char.Map, 0, 0);
                        break;
                        #endregion

                    }
The only real difference here is AreaTargets(Client, Spell.Level + 10, ref Targets, Spell, 21);. That simply means it is using the AreaTargets void to calculate damage. In this case it is using attack type 21 (magic attack) this can be changed to physical damage or archer damage depending on how you want the skill to be calculated.



And that's really all there is to it. you will need to modify every AreaTargets attack in the source by adding attack type to the end of the string (exactly like we did for fire circle/pervade)


Hope that helps some people. Not super complicated and not a ton of people using the 1.0 source but still somewhat useful to know how to do.


[Minor Note]

Attack types: 2 = Physical, 21 = Magical, 25 = bow.

Mana cost for spells are stored in Calculation.cs

Eg for fire circle

Code:
case 1120://FireCircle - MP Check
                    {
                        int ManaCost = 0;
                        if (MagicLevel == 0)
                            ManaCost = 150;
                        else if (MagicLevel == 1)
                            ManaCost = 170;
                        else if (MagicLevel == 2)
                            ManaCost = 190;
                        else if (MagicLevel == 3)
                            ManaCost = 210;
                        if (Client.Char.CurrentMP < ManaCost)
                        {

                            return false;
                        }
                        else
                        {
                            Client.Char.CurrentMP -= ManaCost;
                            Client.SendData(ConquerPacket.Status(Client, Client.Char.CurrentMP, Struct.StatusTypes.Mp));
                            return true;
                        }
                    }

Also in calculation.cs is the code controlling magic dmg boost from spells. (higher lvl nado does more dmg etc)

Eg: Fire circle
Code:
case 1120: //Fire Circle
                    {
                        if (Level == 0)
                            return 540;
                        if (Level == 1)
                            return 650;
                        if (Level == 2)
                            return 720;
                        if (Level == 3)
                            return 770;
                        break;
                    }

Again, hope it helps some.
12/11/2009 09:12 Sp!!ke#2
nice pro ! good work
12/11/2009 09:58 L1nk1n*P4rK#3
Good Work :D