void Player_Effect_CallBack(object e) { try { StopEffectTimer((byte)e); targetObject thisObject = new targetObject(this, null); foreach (KeyValuePair<string, int> p in Data.SkillBase[this.Character.Action.DeBuff.Effect.SkillID[(byte)e]].Properties1) { switch (p.Key) { case "fb": DarkEmu_GameServer.Effect.DeleteEffect_fb(thisObject, (byte)e); break; case "bu": break; case "fz": DarkEmu_GameServer.Effect.DeleteEffect_fz(thisObject, (byte)e); break; } } } catch (Exception ex) { Systems.Debugger.Write(ex); Console.WriteLine("Player_Effect_CallBack() error.."); } }
void StartsWaitTimer(int time, targetObject[] t, int[,] p_dmg, byte[] status) { if (Timer.sWait != null) { Timer.sWait.Dispose(); } Timer.sWait = new Timer(new TimerCallback(Player_sWait_Attack_CallBack), new object[] { t, p_dmg, status }, time, 0); }
void AmountControl() { try { Character.Action.Skill.FoundID[Character.Action.Skill.Found] = Character.Action.Target; Character.Action.Skill.Found++; if (Character.Action.Skill.Tdistance > 1) { object mainObject = GetObjects(Character.Action.Target); if (mainObject == null) return; targetObject target = new targetObject(mainObject, this); float x = target.x - Character.Action.Skill.Tdistance; float y = target.y - Character.Action.Skill.Tdistance; for (int i = 0; i < Systems.Objects.Count; i++) { if (Character.Action.Skill.Found == Character.Action.Skill.Tdistance) return; if (Systems.Objects[i] != null) { obj o = Systems.Objects[i]; if (!o.Die && o.LocalType == 1) { if (o.x >= x && o.x <= (x + (Character.Action.Skill.Tdistance * 2)) && o.y >= y - Character.Action.Skill.Tdistance && o.y <= (y + (Character.Action.Skill.Tdistance * 2)) && o.UniqueID != Character.Action.Target) { if (o.Agro == null) o.Agro = new List<_agro>(); Character.Action.Skill.FoundID[Character.Action.Skill.Found] = o.UniqueID; Character.Action.Skill.Found++; } } } } lock (Systems.clients) { for (int i = 0; i < Systems.clients.Count; i++) { try { if (Character.Action.Skill.Found == Character.Action.Skill.Tdistance) return; if (Systems.clients[i] != null) { Systems sys = Systems.clients[i]; if (sys.Character.Information.PvP && sys != this && !sys.Character.State.Die) if (sys.Character.Information.UniqueID != Character.Action.Target && Character.Information.UniqueID != Character.Action.Target) { if (sys.Character.Position.x >= x && sys.Character.Position.x <= (x + (Character.Action.Skill.Tdistance * 2)) && sys.Character.Position.y >= y && sys.Character.Position.y <= (y + (Character.Action.Skill.Tdistance * 2))) { Character.Action.Skill.FoundID[Character.Action.Skill.Found] = sys.Character.Information.UniqueID; Character.Action.Skill.Found++; } } } } catch (Exception ex) { Console.WriteLine("AmountControl Error on index {1}/{2}: {0}", ex, i, Systems.clients.Count); Systems.Debugger.Write(ex); } } } target = null; } } catch (Exception ex) { Console.WriteLine("Distance error: " + ex); } }
void MainSkill_Attack(List<int> list) { if (!Character.Action.sAttack) return; try { AmountControl(); int[,] p_dmg = new int[Character.Action.Skill.Found, Character.Action.Skill.NumberOfAttack]; int[] statichp = new int[Character.Action.Skill.Found]; PacketWriter Writer = new PacketWriter(); Writer.Create(Systems.SERVER_SKILL_DATA); Writer.Byte(1); Writer.DWord(Character.Action.Skill.MainCasting); Writer.DWord(Character.Action.Target); Writer.Byte(1); Writer.Byte(Character.Action.Skill.NumberOfAttack); Writer.Byte(Character.Action.Skill.Found); byte[] status; status = new byte[Character.Action.Skill.Found]; targetObject[] target = new targetObject[Character.Action.Skill.Found]; for (byte f = 0; f < Character.Action.Skill.Found; f++) { if (Character.Action.Skill.FoundID[f] != 0) { Writer.DWord(Character.Action.Skill.FoundID[f]); target[f] = new targetObject(GetObjects(Character.Action.Skill.FoundID[f]), this); if (target[f].sys == null && target[f].os == null) { } else { statichp[f] = target[f].GetHp; for (byte n = 0; n < Character.Action.Skill.NumberOfAttack; n++) { bool block = false; /*if (Character.Information.Item.sID != 0 && Character.Information.Item.sID != 62) { if (Global.RandomID.GetRandom(0, 25) < 10) block = true; }*/ if (!block) { byte crit = 1; p_dmg[f, n] = 1; if (Character.Action.Skill.P_M) // for magic damage { p_dmg[f, n] = (int)Formule.gamedamage((Character.Stat.MaxMagAttack + Data.SkillBase[Character.Action.Skill.SkillID[n]].MaxAttack), MasteryGetPower(Character.Action.Skill.SkillID[n]), target[f].AbsrobMag, target[f].MagDef, this.Character.Information.Mag_Balance, (Data.SkillBase[Character.Action.Skill.SkillID[n]].MagPer + Character.Stat.UpdatededMagAttack)); if (Character.Action.ImbueID != 0) p_dmg[f, n] += (int)Formule.gamedamage((Character.Stat.MinMagAttack + Data.SkillBase[Character.Action.ImbueID].MaxAttack), MasteryGetPower(Character.Action.ImbueID), 0, target[f].MagDef, Character.Information.Mag_Balance, Character.Stat.UpdatededMagAttack); } else // for phy damage { p_dmg[f, n] = (int)Formule.gamedamage((Character.Stat.MaxPhyAttack + Data.SkillBase[Character.Action.Skill.SkillID[n]].MaxAttack), MasteryGetPower(Character.Action.Skill.SkillID[n]), target[f].AbsrobPhy, target[f].PhyDef, this.Character.Information.Phy_Balance, Character.Stat.UpdatededPhyAttack + Data.SkillBase[Character.Action.Skill.SkillID[n]].MagPer); if (Character.Action.ImbueID != 0) p_dmg[f, n] += (int)Formule.gamedamage((Character.Stat.MinMagAttack + Data.SkillBase[Character.Action.ImbueID].MaxAttack), MasteryGetPower(Character.Action.ImbueID), 0, target[f].MagDef, Character.Information.Mag_Balance, Character.Stat.UpdatededMagAttack); if (rnd.Next(16) < 5) { p_dmg[f, n] *= 2; crit = 2; } } if (f > 0) p_dmg[f, n] = (p_dmg[f, n] * (100 - (f * 10))) / 100; if (Character.Information.Berserking) p_dmg[f, n] = (p_dmg[f, n] * Character.Information.BerserkOran) / 100; if (p_dmg[f, n] <= 0) p_dmg[f, n] = 1; else { if (target[f].mAbsorb() > 0) { int static_dmg = (p_dmg[f, n] * (100 - (int)target[f].mAbsorb())) / 100; target[f].MP(static_dmg); p_dmg[f, n] = static_dmg; } p_dmg[f, n] += rnd.Next(0, p_dmg.ToString().Length); } statichp[f] -= p_dmg[f, n]; if (statichp[f] < 1) { status[f] = 128; target[f].GetDead(); } if (Character.Action.Skill.OzelEffect == 4 && status[f] != 128) { if (rnd.Next(10) > 5) status[f] = 4; } Writer.Byte(status[f]); // so here we add status same opcode Writer.Byte(crit); Writer.DWord(p_dmg[f, n]); Writer.Byte(0); Writer.Word(0); if (status[f] == 4) // if status was knockdown just add the new position of the mob where it should be knocked down { Writer.Byte(target[f].xSec); Writer.Byte(target[f].ySec); Writer.Word(Formule.packetx(target[f].x + 0.1f, target[f].xSec)); Writer.Word(0); Writer.Word(Formule.packety(target[f].y - 0.1f, target[f].ySec)); Writer.Word(0); Writer.Word(0); Writer.Word(0); } } else Writer.Byte(2); } } } } Send(list, Writer.GetBytes()); for (byte f = 0; f < Character.Action.Skill.Found; f++) { if (target[f].sys == null && target[f].os == null) { } else { if (target[f].sys != null && target[f].os == null) // player DarkEmu_GameServer.Effect.EffectMain(target[f].sys, Character.Action.Skill.MainSkill); if (target[f].sys == null && target[f].os != null) // mob DarkEmu_GameServer.Effect.EffectMain(target[f].os, Character.Action.Skill.MainSkill); } } Character.Action.sCasting = true; Character.Action.sAttack = false; if (Data.SkillBase[Character.Action.Skill.MainSkill].AttackTime == 0) Data.SkillBase[Character.Action.Skill.MainSkill].AttackTime = 150; StartsWaitTimer(Data.SkillBase[Character.Action.Skill.MainSkill].AttackTime, target, p_dmg, status); } catch (Exception ex) { Systems.Debugger.Write(ex); } }
void ActionAttack() { try { //Predefined info needs work! #region Predefined info byte AttackAmount = 2; int AttackID = 1; int[] found = new int[3]; byte numbert = 1; int PhysicalDamage = 0; byte status = 0, crit = 1; #endregion targetObject TargetObject = new targetObject(Character.Action.Object, this); if (TargetObject != null) { client.Send(Packet.ActionState(1, 1)); //Bow information #region Arrow for bow if (Character.Information.Item.wID != 0) { if (Data.ItemBase[Character.Information.Item.wID].Itemtype == Global.item_database.ItemType.BOW || Data.ItemBase[Character.Information.Item.wID].Itemtype == Global.item_database.ItemType.EU_CROSSBOW) { if (Character.Information.Item.sID == 0) { if (!ItemCheckArrow()) { Character.Action.nAttack = false; client.Send(Packet.ActionPacket(2, 0x0e)); StopAttackTimer(); return; } } else { Character.Information.Item.sAmount--; client.Send(Packet.Arrow(Character.Information.Item.sAmount)); if (Character.Information.Item.sAmount <= 0) { Character.Information.Item.sID = 0; MsSQL.UpdateData("delete from char_items where itemnumber='item" + 7 + "' AND owner='" + Character.Information.CharacterID + "'"); if (!ItemCheckArrow()) { Character.Action.nAttack = false; client.Send(Packet.ActionPacket(2, 0x0e)); StopAttackTimer(); return; } } else { MsSQL.InsertData("UPDATE char_items SET quantity='" + Character.Information.Item.sAmount + "' WHERE itemnumber='" + "item" + 7 + "' AND owner='" + Character.Information.CharacterID + "' AND itemid='" + Character.Information.Item.sID + "'"); } } } } #endregion if (Character.Action.ImbueID != 0 && Data.SkillBase[Character.Action.ImbueID].Series.Remove(Data.SkillBase[Character.Action.ImbueID].Series.Length - 2) == "SKILL_CH_LIGHTNING_GIGONGTA") { numbert = ActionGetObject(ref found, 2, TargetObject.x, TargetObject.y, Character.Action.Target, 5); } else found[1] = Character.Action.Target; if (Character.Information.Item.wID != 0) { switch (Data.ItemBase[Character.Information.Item.wID].Class_C) { //Chinese base skills case 2: //One handed sword case 3: AttackAmount = 2; AttackID = 2; break; case 4: //Spear attack + glavie case 5: AttackAmount = 1; AttackID = 40; break; case 6: //Bow attack AttackAmount = 1; AttackID = 70; break; //Europe Base skills case 7: AttackAmount = 1; AttackID = 7127; // One handed sword break; case 8: AttackAmount = 1; AttackID = 7128; // Two handed sword break; case 9: AttackAmount = 2; AttackID = 7129; // Axe basic attack break; case 10: AttackAmount = 1; AttackID = 9069; // Warlock base break; case 11: AttackAmount = 1; AttackID = 8454; // Staff / Tstaff break; case 12: AttackAmount = 1; AttackID = 7909; // Crossbow base break; case 13: AttackAmount = 2; //Dagger AttackID = 7910; break; case 14: AttackAmount = 1; AttackID = 9606; // Harp base break; case 15: AttackAmount = 1; AttackID = 9970; // Light staff cleric break; case 16: AttackAmount = 1; AttackID = Data.SkillBase[Character.Action.UsingSkillID].ID; break; default: Console.WriteLine("Action attack case: {0} , SkillID = {1}" + Data.ItemBase[Character.Information.Item.wID].Class_C, Data.SkillBase[Character.Action.UsingSkillID].ID); break; } } else { //Punch attack AttackAmount = 1; AttackID = 1; } //Get casting id Character.Action.AttackingID = Character.Ids.GetCastingID(); //Create new packet writer PacketWriter Writer = new PacketWriter(); Writer.Create(Systems.SERVER_ACTION_DATA); Writer.Byte(1); Writer.Byte(2); Writer.Byte(0x30); Writer.DWord(AttackID); Writer.DWord(Character.Information.UniqueID); Writer.DWord(Character.Action.AttackingID); Writer.DWord(Character.Action.Target); Writer.Bool(true); Writer.Byte(AttackAmount); Writer.Byte(numbert); for (byte t = 1; t <= numbert; t++) { Writer.DWord(found[t]); for (byte n = 1; n <= AttackAmount; n++) { PhysicalDamage = 0; status = 0; crit = 1; if (t == 2) //for light skill { TargetObject = new targetObject(GetObjects(found[t]), this); if (Character.Action.ImbueID != 0) { PhysicalDamage = (int)Formule.gamedamage((Data.SkillBase[Character.Action.ImbueID].tmpProp), MasteryGetPower(Character.Action.ImbueID), 0, 0, Character.Information.Mag_Balance, Character.Stat.UpdatededMagAttack); PhysicalDamage += rnd.Next(0, PhysicalDamage.ToString().Length); } else PhysicalDamage = 1; if (status != 128) status = TargetObject.HP((int)PhysicalDamage); else TargetObject.GetDead(); } else if (t == 1) { PhysicalDamage = (int)Formule.gamedamage(Character.Stat.MaxPhyAttack, Character.Stat.AttackPower + MasteryGetPower(AttackID), 0, (double)TargetObject.PhyDef, Character.Information.Phy_Balance, Character.Stat.UpdatededPhyAttack); if (Character.Action.ImbueID != 0) PhysicalDamage += (int)Formule.gamedamage((Character.Stat.MinMagAttack + Data.SkillBase[Character.Action.ImbueID].tmpProp), MasteryGetPower(Character.Action.ImbueID), 0, TargetObject.MagDef, Character.Information.Mag_Balance, Character.Stat.UpdatededMagAttack); PhysicalDamage /= AttackAmount; if (rnd.Next(15) <= 5) { PhysicalDamage *= 2; crit = 2; } if (Character.Information.Berserking) PhysicalDamage = (PhysicalDamage * Character.Information.BerserkOran) / 100; if (PhysicalDamage <= 0) PhysicalDamage = 1; else { if (TargetObject.mAbsorb() > 0) { int static_dmg = (PhysicalDamage * (100 - (int)TargetObject.mAbsorb())) / 100; TargetObject.MP((static_dmg)); PhysicalDamage = static_dmg; } PhysicalDamage += rnd.Next(0, PhysicalDamage.ToString().Length); } if (status != 128) { status = TargetObject.HP((int)PhysicalDamage); } else TargetObject.GetDead(); } Writer.Byte(status); Writer.Byte(crit); Writer.DWord(PhysicalDamage); Writer.Byte(0); Writer.Word(0); } } Send(Writer.GetBytes()); client.Send(Packet.ActionState(2, 0)); } } catch (Exception ex) { Console.WriteLine("ActionAttack Error {0}", ex); Systems.Debugger.Write(ex); } }