[Help] Triple Attack

01/11/2014 23:18 littlechris95#1
How should I do to work perfectly Triple Attack? any ideas? any examples?

This is my current code:

Code:
case 10490:
                                    {
                                        if (CanUseSpell(spell, attacker.Owner))
                                        {
                                            PrepareSpell(spell, attacker.Owner);

                                            SpellUse suse = new SpellUse(true);
                                            suse.Attacker = attacker.UID;
                                            suse.SpellID = spell.ID;
                                            suse.SpellLevel = spell.Level;
                                            suse.X = X;
                                            suse.Y = Y;
                                            if (Kernel.GetDistance(attacker.X, attacker.Y, X, Y) <= attacker.AttackRange + 1)
                                            {
                                                if (attackedsob != null)
                                                {
                                                    if (CanAttack(attacker, attackedsob, spell))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);
                                                        for (int count = 0; count < 4; count++)
                                                        {
                                                            attack.Effect1 = Attack.AttackEffects1.None;
                                                            uint damage = Math.Max(1, Calculate.Melee(attacker, attackedsob, ref attack) / 3);
                                                            suse.Effect1 = attack.Effect1;
                                                            ReceiveAttack(attacker, attackedsob, attack, damage, spell);
                                                            suse.AddTarget(attackedsob.UID, damage, attack);
                                                            attacker.Owner.SendScreen(suse, true);
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    if (CanAttack(attacker, attacked, spell, attack.AttackType == Attack.Melee))
                                                    {
                                                        PrepareSpell(spell, attacker.Owner);

                                                        for (int count = 0; count < 4; count++)
                                                        {        
                                                            attack.Effect1 = Attack.AttackEffects1.None;
                                                            uint damage = Math.Max(1, Calculate.Melee(attacker, attackedsob, ref attack) / 3);
                                                            suse.Effect1 = attack.Effect1;
                                                            ReceiveAttack(attacker, attacked, attack, damage, spell);
                                                            suse.AddTarget(attacked.UID, damage, attack);
                                                            attacker.Owner.SendScreen(suse, true);
                                                            if (attacked.Dead) break;
                                                        }
                                                        
                                                    }
                                                }
                                                attacker.AttackPacket = null;
                                            }
                                            else
                                            {
                                                attacker.AttackPacket = null;
                                            }
                                                
                                        }
                                        attacker.AttackPacket = null;
                                        break;
                                    }
01/13/2014 16:38 drakejoe67#2
you're defining it 3 times, while what you have to do is to make sure Damage dealt to enemy is done 3 times, aswell as packet send 3 times.

From what I can see, I can see, you're not including the whole thing here. Referring to "attacker.AttackPAcket = null;" you'll have to see below it, and the whole thing has to be looped if you want it to calculate individually. Or else you can just create a "AttackCount" loop where the packet is sent.