Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using ImpactGaming.Game;
namespace ImpactGaming.Features
{
public unsafe class SkillsClass
{
public enum ExtraEffect : byte
{
None,
Stigma,
MagicShield,
Accuracy,
Superman,
Cyclone,
Invisibility,
Revive,
Poison,
Fly,
Transform,
Summon,
FatalStrike,
ShurikenVortex,
RemoveFly,
FlashStep,
Ride,
UnMount,
NoPots,
Scapegoat,
BlessPray
}
public enum TargetType : byte
{
Single,
FromSingle,
FromPoint,
Range,
Sector,
Linear
}
public enum DamageType : byte
{
Magic,
Ranged,
Melee,
HealHP,
HealMP,
Percent
}
public struct SkillInfo
{
public ushort ID;
public byte Level;
public ushort ManaCost;
public byte StaminaCost;
public byte ArrowsCost;
public bool EndsXPWait;
public byte UpgReqLvl;
public uint UpgReqExp;
public uint Damage;
public TargetType Targetting;
public DamageType Damageing;
public ExtraEffect ExtraEff;
public ushort EffectLasts;
public float EffectValue;
public byte ActivationChance;
public byte MaxDist;
public byte SectorSize;
public void LoadThis(BinaryReader BR)
{
ID = BR.ReadUInt16();
Level = BR.ReadByte();
ManaCost = BR.ReadUInt16();
StaminaCost = BR.ReadByte();
ArrowsCost = BR.ReadByte();
EndsXPWait = BR.ReadBoolean();
UpgReqLvl = BR.ReadByte();
UpgReqExp = BR.ReadUInt32();
Damage = BR.ReadUInt32();
Targetting = (TargetType)BR.ReadByte();
Damageing = (DamageType)BR.ReadByte();
ExtraEff = (ExtraEffect)BR.ReadByte();
EffectLasts = BR.ReadUInt16();
EffectValue = BR.ReadSingle();
ActivationChance = BR.ReadByte();
MaxDist = BR.ReadByte();
SectorSize = BR.ReadByte();
}
public void SaveThis(BinaryWriter BW)
{
BW.Write(ID);
BW.Write(Level);
BW.Write(ManaCost);
BW.Write(StaminaCost);
BW.Write(ArrowsCost);
BW.Write(EndsXPWait);
BW.Write(UpgReqLvl);
BW.Write(UpgReqExp);
BW.Write(Damage);
BW.Write((byte)Targetting);
BW.Write((byte)Damageing);
BW.Write((byte)ExtraEff);
BW.Write(EffectLasts);
BW.Write(EffectValue);
BW.Write(ActivationChance);
BW.Write(MaxDist);
BW.Write(SectorSize);
}
}
public struct SkillUse
{
public SkillInfo Info;
public Hashtable MobTargets;
public Hashtable PlayerTargets;
public Hashtable NPCTargets;
public Hashtable MiscTargets;
public Game.Character User;
public ushort AimX;
public ushort AimY;
public void Init(Game.Character C, ushort SkillID, byte SkillLvl, ushort AimX, ushort AimY)
{
try
{
User = C;
Info = (SkillInfo)SkillsClass.SkillInfos[SkillID + " " + SkillLvl];
this.AimX = AimX;
this.AimY = AimY;
MobTargets = new Hashtable();
PlayerTargets = new Hashtable();
NPCTargets = new Hashtable();
MiscTargets = new Hashtable();
}
catch (Exception Exc) { Program.WriteLine(Exc); }
}
public void GetTargets(uint Single)
{
try
{
GetMobTargets(Single);
GetPlayerTargets(Single);
GetNPCTargets(Single);
GetMiscTargets(Single);
}
catch (Exception Exc) { Program.WriteLine(Exc); }
}
void GetMiscTargets(uint Single)
{
if (Info.ExtraEff == ExtraEffect.Ride || Info.ExtraEff == ExtraEffect.UnMount) return;
if (Info.Targetting == TargetType.Single)
{
if (Single == 6700 && GuildWars.War && User.MyGuild != null && User.MyGuild != GuildWars.LastWinner)
MiscTargets.Add(Single, GetDamage(GuildWars.ThePole.CurHP));
else if (Single == 6701 && !GuildWars.TheLeftGate.Opened && GuildWars.War)
MiscTargets.Add(Single, GetDamage(GuildWars.TheLeftGate.CurHP));
else if (Single == 6702 && !GuildWars.TheRightGate.Opened && GuildWars.War)
MiscTargets.Add(Single, GetDamage(GuildWars.TheRightGate.CurHP));
}
else
{
bool RangeFromChar = true;
if (Info.Targetting == TargetType.FromSingle)
{
if (Single == 6700 && GuildWars.War && User.MyGuild != null && User.MyGuild != GuildWars.LastWinner)
{
MiscTargets.Add(Single, GetDamage(GuildWars.ThePole.CurHP));
AimX = GuildWars.ThePole.Loc.X;
AimY = GuildWars.ThePole.Loc.Y;
}
else if (Single == 6701 && !GuildWars.TheLeftGate.Opened && GuildWars.War)
{
MiscTargets.Add(Single, GetDamage(GuildWars.TheLeftGate.CurHP));
AimX = GuildWars.TheLeftGate.Loc.X;
AimY = GuildWars.TheLeftGate.Loc.Y;
}
else if (Single == 6702 && !GuildWars.TheRightGate.Opened && GuildWars.War)
{
MiscTargets.Add(Single, GetDamage(GuildWars.TheRightGate.CurHP));
AimX = GuildWars.TheRightGate.Loc.X;
AimY = GuildWars.TheRightGate.Loc.Y;
}
}
else if (Info.Targetting != TargetType.Sector && Info.Targetting != TargetType.Linear && Info.Targetting != TargetType.Range && Info.Targetting != TargetType.FromPoint)
{
AimX = User.Loc.X;
AimY = User.Loc.Y;
RangeFromChar = true;
}
else
RangeFromChar = false;
List<Coordinate> Line = new List<Coordinate>(5);
if (Info.Targetting == TargetType.Linear)
Line = MyMath.LineCoords(User.Loc.X, User.Loc.Y, AimX, AimY, 10);
if ((!RangeFromChar && MyMath.PointDistance(AimX, AimY, GuildWars.ThePole.Loc.X, GuildWars.ThePole.Loc.Y) <= Info.MaxDist || MyMath.PointDistance(User.Loc.X, User.Loc.Y, GuildWars.ThePole.Loc.X, GuildWars.ThePole.Loc.Y) <= Info.MaxDist) && GuildWars.War && User.MyGuild != GuildWars.LastWinner)
if (Info.Targetting == TargetType.Sector && InSector(GuildWars.ThePole.Loc.X, GuildWars.ThePole.Loc.Y) || Info.Targetting != TargetType.Sector)
if (Info.Targetting == TargetType.Linear && Line.Contains(new Coordinate(GuildWars.ThePole.Loc.X, GuildWars.ThePole.Loc.Y)) || Info.Targetting != TargetType.Linear)
MiscTargets.Add(GuildWars.ThePole.EntityID, GetDamage(GuildWars.ThePole.CurHP));
if (GuildWars.War && !GuildWars.TheRightGate.Opened && (!RangeFromChar && MyMath.PointDistance(AimX, AimY, GuildWars.TheRightGate.Loc.X, GuildWars.TheRightGate.Loc.Y) <= Info.MaxDist || MyMath.PointDistance(User.Loc.X, User.Loc.Y, GuildWars.TheRightGate.Loc.X, GuildWars.TheRightGate.Loc.Y) <= Info.MaxDist))
if (Info.Targetting == TargetType.Sector && InSector(GuildWars.TheRightGate.Loc.X, GuildWars.TheRightGate.Loc.Y) || Info.Targetting != TargetType.Sector)
if (Info.Targetting == TargetType.Linear && Line.Contains(new Coordinate(GuildWars.TheRightGate.Loc.X, GuildWars.TheRightGate.Loc.Y)) || Info.Targetting != TargetType.Linear)
MiscTargets.Add(GuildWars.TheRightGate.EntityID, GetDamage(GuildWars.TheRightGate.CurHP));
if (GuildWars.War && !GuildWars.TheLeftGate.Opened && (!RangeFromChar && MyMath.PointDistance(AimX, AimY, GuildWars.TheLeftGate.Loc.X, GuildWars.TheLeftGate.Loc.Y) <= Info.MaxDist || MyMath.PointDistance(User.Loc.X, User.Loc.Y, GuildWars.TheLeftGate.Loc.X, GuildWars.TheLeftGate.Loc.Y) <= Info.MaxDist))
if (Info.Targetting == TargetType.Sector && InSector(GuildWars.TheLeftGate.Loc.X, GuildWars.TheLeftGate.Loc.Y) || Info.Targetting != TargetType.Sector)
if (Info.Targetting == TargetType.Linear && Line.Contains(new Coordinate(GuildWars.TheLeftGate.Loc.X, GuildWars.TheLeftGate.Loc.Y)) || Info.Targetting != TargetType.Linear)
MiscTargets.Add(GuildWars.TheLeftGate.EntityID, GetDamage(GuildWars.TheLeftGate.CurHP));
}
}
void GetMobTargets(uint Single)
{
if (Info.ExtraEff == ExtraEffect.Ride || Info.ExtraEff == ExtraEffect.UnMount) return;
if (Info.Targetting == TargetType.Single)
{
if (World.H_Mobs.Contains(User.Loc.Map))
{
Mob M = (Mob)((Hashtable)(World.H_Mobs[User.Loc.Map]))[Single];
if (M != null && M.Alive)
MobTargets.Add(M, GetDamage(M));
}
}
else
{
bool RangeFromChar = true;
if (Info.Targetting == TargetType.FromSingle)
{
Mob M = (Mob)((Hashtable)(World.H_Mobs[User.Loc.Map]))[Single];
if (M != null && M.Alive)
{
MobTargets.Add(M, GetDamage(M));
AimX = M.Loc.X;
AimY = M.Loc.Y;
RangeFromChar = false;
}
}
else if (Info.Targetting != TargetType.Sector && Info.Targetting != TargetType.Linear && Info.Targetting != TargetType.Range && Info.Targetting != TargetType.FromPoint)
{
AimX = User.Loc.X;
AimY = User.Loc.Y;
RangeFromChar = true;
}
else
RangeFromChar = false;
Hashtable MapMobs = (Hashtable)World.H_Mobs[User.Loc.Map];
List<Coordinate> Line = new List<Coordinate>(5);
if (Info.Targetting == TargetType.Linear)
Line = MyMath.LineCoords(User.Loc.X, User.Loc.Y, AimX, AimY, 10);
if (MapMobs != null)
foreach (Mob M in MapMobs.Values)
{
if (M.Alive)
{
if ((!RangeFromChar && MyMath.PointDistance(AimX, AimY, M.Loc.X, M.Loc.Y) <= Info.MaxDist) || MyMath.PointDistance(User.Loc.X, User.Loc.Y, M.Loc.X, M.Loc.Y) <= Info.MaxDist)
if (Info.Targetting == TargetType.Sector && InSector(M.Loc.X, M.Loc.Y) || Info.Targetting != TargetType.Sector)
if (Info.Targetting == TargetType.Linear && Line.Contains(new Coordinate(M.Loc.X, M.Loc.Y)) || Info.Targetting != TargetType.Linear)
if (User.PKMode == PKMode.PK || !M.NeedsPKMode && !MobTargets.Contains(M))
MobTargets.Add(M, GetDamage(M));
}
}
}
}
void GetPlayerTargets(uint Single)
{
if (Info.ExtraEff == ExtraEffect.FlashStep || Info.ExtraEff == ExtraEffect.Ride || Info.ExtraEff == ExtraEffect.Scapegoat)
{
PlayerTargets.Add(User, (uint)0);
return;
}
if (Info.Targetting == TargetType.Single)
{
Character C = (Character)World.H_Chars[Single];
if (C != null && C.Alive)
PlayerTargets.Add(C, GetDamage(C));
}
else
{
bool RangeFromChar = true;
if (Info.Targetting == TargetType.FromSingle)
{
Character C = (Character)World.H_Chars[Single];
if (C != null && C.Alive)
{
PlayerTargets.Add(C, GetDamage(C));
AimX = C.Loc.X;
AimY = C.Loc.Y;
RangeFromChar = false;
}
}
else if (Info.Targetting != TargetType.Sector && Info.Targetting != TargetType.Linear && Info.Targetting != TargetType.Range && Info.Targetting != TargetType.FromPoint)
{
AimX = User.Loc.X;
AimY = User.Loc.Y;
RangeFromChar = true;
}
else
RangeFromChar = false;
List<Coordinate> Line = new List<Coordinate>(5);
if (Info.Targetting == TargetType.Linear)
Line = MyMath.LineCoords(User.Loc.X, User.Loc.Y, AimX, AimY, 10);
foreach (Character C in World.H_Chars.Values)
{
if (C.Alive && (C != User || Info.Damageing == DamageType.HealHP || Info.Damageing == DamageType.HealMP))
{
if ((!RangeFromChar && MyMath.PointDistance(AimX, AimY, C.Loc.X, C.Loc.Y) <= Info.MaxDist) || MyMath.PointDistance(User.Loc.X, User.Loc.Y, C.Loc.X, C.Loc.Y) <= Info.MaxDist)
if (Info.Targetting == TargetType.Sector && InSector(C.Loc.X, C.Loc.Y) || Info.Targetting != TargetType.Sector)
if (Info.Targetting == TargetType.Linear && Line.Contains(new Coordinate(C.Loc.X, C.Loc.Y)) || Info.Targetting != TargetType.Linear)
if (C.PKAble(User.PKMode, User) && !PlayerTargets.Contains(C) && !World.NoPKMaps.Contains(User.Loc.Map) || Info.ExtraEff == ExtraEffect.UnMount)
if (Game.World.NoPKMaps.Contains(User.Loc.Map) && GetDamage(C) == 0 || !Game.World.NoPKMaps.Contains(User.Loc.Map) || (Info.ExtraEff == ExtraEffect.UnMount && C.StatEff.Contains(StatusEffectEn.Ride)) && C.Equips.Steed.Plus < User.Equips.Steed.Plus)
if (true)
PlayerTargets.Add(C, GetDamage(C));
}
}
}
}
void GetNPCTargets(uint Single)
{
if (Info.ExtraEff == ExtraEffect.Ride || Info.ExtraEff == ExtraEffect.UnMount) return;
if (Info.Targetting == TargetType.Single)
{
NPC C = (NPC)World.H_NPCs[Single];
if (C != null)
NPCTargets.Add(C, GetDamage(C));
}
else
{
bool RangeFromChar = true;
if (Info.Targetting == TargetType.FromSingle)
{
NPC C = (NPC)World.H_NPCs[Single];
if (C != null)
{
NPCTargets.Add(C, GetDamage(C));
AimX = C.Loc.X;
AimY = C.Loc.Y;
RangeFromChar = false;
}
}
else if (Info.Targetting != TargetType.Sector && Info.Targetting != TargetType.Linear && Info.Targetting != TargetType.Range && Info.Targetting != TargetType.FromPoint)
{
AimX = User.Loc.X;
AimY = User.Loc.Y;
RangeFromChar = true;
}
else
RangeFromChar = false;
List<Coordinate> Line = new List<Coordinate>(5);
if (Info.Targetting == TargetType.Linear)
Line = MyMath.LineCoords(User.Loc.X, User.Loc.Y, AimX, AimY, 10);
foreach (NPC C in World.H_NPCs.Values)
{
if ((C.Flags == 21 || C.Flags == 22) && User.Level >= C.Level)
{
if ((!RangeFromChar && MyMath.PointDistance(AimX, AimY, C.Loc.X, C.Loc.Y) <= Info.MaxDist) || MyMath.PointDistance(User.Loc.X, User.Loc.Y, C.Loc.X, C.Loc.Y) <= Info.MaxDist)
if (Info.Targetting == TargetType.Sector && InSector(C.Loc.X, C.Loc.Y) || Info.Targetting != TargetType.Sector)
if (Info.Targetting == TargetType.Linear && Line.Contains(new Coordinate(C.Loc.X, C.Loc.Y)) || Info.Targetting != TargetType.Linear)
if (!NPCTargets.Contains(C))
NPCTargets.Add(C, GetDamage(C));
}
}
}
}
public bool InSector(ushort X, ushort Y)
{
double Aim = MyMath.PointDirecton2(User.Loc.X, User.Loc.Y, AimX, AimY);
double MobAngle = MyMath.PointDirecton2(User.Loc.X, User.Loc.Y, X, Y);
if (Aim - Info.SectorSize / 2 < MobAngle)
if (Aim + Info.SectorSize / 2 > MobAngle)
return true;
return false;
}
public static uint x = 2;
public uint GetDamage(Character C)
{
if (Info.ID == 5030 || Info.ID == 1290 || Info.ID ==
5040 || Info.ID == 7000 || Info.ID ==
7010 || Info.ID == 7030)
{ Info.ExtraEff = ExtraEffect.None; }
if (Info.ID == 6004)
if (C.Potency <= User.Potency)
{ return (uint)(C.CurHP * 10 / 100); }
if (Info.ExtraEff != ExtraEffect.None)
return 0;
uint Damage = 1;
if (C.Protection)
return 0;
if (Info.ExtraEff == ExtraEffect.NoPots || Info.ExtraEff == ExtraEffect.RemoveFly)
return 1;
switch (Info.Damageing)
{
case DamageType.Percent:
{
if (Game.World.NoPKMaps.Contains(User.Loc.Map))
if (Info.ExtraEff == ExtraEffect.None)
return 0;
Damage = (uint)(C.CurHP * Info.EffectValue);
Damage = (uint)((double)Damage * (100 - C.EqStats.TotalBless) / 100);
break;
}
case DamageType.Melee:
{
if (Game.World.NoPKMaps.Contains(User.Loc.Map))
if (Info.ExtraEff == ExtraEffect.None)
return 0;
if (User.BuffOf(ExtraEffect.Fly).Eff == ExtraEffect.Fly)
return 0;
ushort Def = C.EqStats.defense;
Buff Shield = C.BuffOf(SkillsClass.ExtraEffect.MagicShield);
if (Shield.Eff == SkillsClass.ExtraEffect.MagicShield)
Def = (ushort)(Def * Shield.Value);
Damage = User.PrepareAttack(2, false);
Damage = (uint)(Damage * Info.EffectValue);
Damage += Info.Damage;
if (Def >= Damage)
Damage = 1;
else
Damage -= Def;
Damage = (uint)((double)Damage * (100 - C.EqStats.TotalBless) / 100);
Damage += User.EqStats.MeleeDamageIncrease;
if (C.EqStats.MeleeDamageDecrease >= Damage)
Damage = 1;
else
Damage -= C.EqStats.MeleeDamageDecrease;
break;
}
case DamageType.Ranged:
{
if (Game.World.NoPKMaps.Contains(User.Loc.Map))
if (Info.ExtraEff == ExtraEffect.None)
return 0;
if (User.BuffOf(ExtraEffect.Fly).Eff == ExtraEffect.Fly)
return 0;
Damage = User.PrepareAttack(25, false);
Damage = (uint)(Damage * Info.EffectValue);
Damage += Info.Damage;
Damage = (uint)((Damage * (((double)(110 - C.EqStats.Dodge)) / 100)) / 8);
Damage = (uint)((double)Damage * (100 - C.EqStats.TotalBless) / 100);
Damage += User.EqStats.MeleeDamageIncrease;
if (C.EqStats.MeleeDamageDecrease >= Damage)
Damage = 1;
else
Damage -= C.EqStats.MeleeDamageDecrease;
break;
}
case DamageType.Magic:
{
if (Game.World.NoPKMaps.Contains(User.Loc.Map))
if (Info.ExtraEff == ExtraEffect.None)
return 0;
Damage = User.PrepareAttack(21, false);
Damage = (uint)(Damage * Info.EffectValue);
Damage += Info.Damage;
Damage = (uint)((double)Damage * (((double)(100 - C.EqStats.MDef1) / 100)));
if (C.EqStats.MDef2 >= Damage)
Damage = 1;
else
Damage -= C.EqStats.MDef2;
Damage = (uint)((double)Damage * (100 - C.EqStats.TotalBless) / 100);
Damage += User.EqStats.MagicDamageIncrease;
if (C.EqStats.MagicDamageDecrease >= Damage)
Damage = 1;
else
Damage -= C.EqStats.MagicDamageDecrease;
break;
}
case DamageType.HealHP:
{
Damage = Info.Damage;
C.CurHP += (ushort)Info.Damage;
if (C.CurHP > C.MaxHP)
C.CurHP = C.MaxHP;
break;
}
case DamageType.HealMP:
{
Damage = Info.Damage;
C.CurMP += (ushort)Info.Damage;
if (C.CurMP > C.MaxMP)
C.CurMP = C.MaxMP;
break;
}
}
return Damage;
}
public uint GetDamage(NPC C)
{
uint Damage = 1;
switch (Info.Damageing)
{
case DamageType.Percent:
{
Damage = (uint)(C.CurHP * Info.EffectValue);
break;
}
case DamageType.Melee:
{
Damage = User.PrepareAttack(2, false);
Damage = (uint)(Damage * Info.EffectValue);
Damage += Info.Damage;
Damage += User.EqStats.MeleeDamageIncrease;
break;
}
case DamageType.Ranged:
{
Damage = User.PrepareAttack(25, false);
Damage = (uint)(Damage * Info.EffectValue);
Damage += Info.Damage;
Damage += User.EqStats.MeleeDamageIncrease;
break;
}
case DamageType.Magic:
{
Damage = User.PrepareAttack(21, false);
Damage = (uint)(Damage * Info.EffectValue);
Damage += Info.Damage;
Damage += User.EqStats.MagicDamageIncrease;
break;
}
case DamageType.HealHP:
{
Damage = Info.Damage;
C.CurHP += (ushort)Info.Damage;
if (C.CurHP > C.MaxHP)
C.CurHP = C.MaxHP;
break;
}
}
if (C.Flags == 21) Damage = (uint)((double)Damage * 0.75);
return Damage;
}
public uint GetDamage(Mob M)
{
uint Damage = 1;
switch (Info.Damageing)
{
case DamageType.Percent:
{
Damage = (uint)(M.CurrentHP * Info.EffectValue);
break;
}
case DamageType.Melee:
{
Damage = User.PrepareAttack(2, false);
Damage = (uint)(Damage * Info.EffectValue);
Damage += Info.Damage;
if (M.Defense >= Damage)
Damage = 1;
else
Damage -= M.Defense;
Damage = (uint)(Damage * MyMath.LevelDifference(User.Level, M.Level));
Damage += User.EqStats.MeleeDamageIncrease;
break;
}
case DamageType.Ranged:
{
Damage = User.PrepareAttack(28, false);
Damage = (uint)(Damage * Info.EffectValue);
Damage += Info.Damage;
Damage = (uint)((Damage * (((double)(200 - M.Dodge)) / 100)));
Damage = (uint)(Damage * MyMath.LevelDifference(User.Level, M.Level));
Damage += User.EqStats.MeleeDamageIncrease;
break;
}
case DamageType.Magic:
{
Damage = User.PrepareAttack(21, false);
Damage = (uint)(Damage * Info.EffectValue);
Damage += Info.Damage;
if (M.MDef >= Damage)
Damage = 1;
else
Damage -= M.MDef;
Damage = (uint)(Damage * MyMath.LevelDifference(User.Level, M.Level));
Damage += User.EqStats.MagicDamageIncrease;
break;
}
case DamageType.HealHP:
{
Damage = Info.Damage;
M.CurrentHP += Info.Damage;
if (M.CurrentHP > M.MaxHP)
M.CurrentHP = M.MaxHP;
break;
}
}
Damage = (uint)(Damage / M.DmgReduceTimes);
return Damage;
}
public uint GetDamage(uint CurHP)
{
uint Damage = 1;
switch (Info.Damageing)
{
case DamageType.Percent:
{
Damage = (uint)(CurHP * Info.EffectValue);
break;
}
case DamageType.Melee:
{
Damage = User.PrepareAttack(2, false);
Damage = (uint)(Damage * Info.EffectValue);
Damage += Info.Damage;
Damage += User.EqStats.MeleeDamageIncrease;
break;
}
case DamageType.Ranged:
{
Damage = User.PrepareAttack(25, false);
Damage = (uint)(Damage * Info.EffectValue);
Damage += Info.Damage;
Damage += User.EqStats.MeleeDamageIncrease;
break;
}
case DamageType.Magic:
{
Damage = User.PrepareAttack(21, false);
Damage = (uint)(Damage * Info.EffectValue);
Damage += Info.Damage;
Damage += User.EqStats.MagicDamageIncrease;
break;
}
}
return Damage;
}
public void Use()
{
try
{
uint Exp = 0;
foreach (DictionaryEntry DE in MiscTargets)
{
uint EntityID = (uint)DE.Key;
uint Damage = (uint)DE.Value;
if (EntityID == 6700)
GuildWars.ThePole.TakeAttack(User, Damage, 21);
if (EntityID == 6701)
GuildWars.TheLeftGate.TakeAttack(User, Damage, 21);
if (EntityID == 6702)
GuildWars.TheRightGate.TakeAttack(User, Damage, 21);
}
Hashtable TempHash = new Hashtable();
foreach (DictionaryEntry DE in MobTargets)
{
Mob M = (Mob)DE.Key;
uint Damage = (uint)DE.Value;
if (Info.Damageing != DamageType.HealHP)
{
if (Info.Damageing == DamageType.Ranged)
Exp += M.TakeAttack(User, ref Damage, AttackType.Ranged, true);
else if (Info.Damageing == DamageType.Melee)
Exp += M.TakeAttack(User, ref Damage, AttackType.Melee, true);
else
Exp += M.TakeAttack(User, ref Damage, AttackType.Magic, true);
}
else
{
Exp += Damage;
M.CurrentHP += Damage;
if (M.CurrentHP > M.MaxHP) M.CurrentHP = M.MaxHP;
}
TempHash.Add(M, Damage);
}
MobTargets = TempHash;
foreach (DictionaryEntry DE in NPCTargets)
{
NPC N = (NPC)DE.Key;
uint Damage = (uint)DE.Value;
if (Info.Damageing != DamageType.HealHP)
{
if (Info.Damageing == DamageType.Ranged)
Exp += N.TakeAttack(User, Damage, AttackType.Ranged, true);
else if (Info.Damageing == DamageType.Melee)
Exp += N.TakeAttack(User, Damage, AttackType.Melee, true);
else
Exp += N.TakeAttack(User, Damage, AttackType.Magic, true);
}
else
{
N.CurHP += Damage;
if (N.CurHP > N.MaxHP) N.CurHP = N.MaxHP;
Exp += Damage / 10;
}
}
foreach (DictionaryEntry DE in PlayerTargets)
{
Character C = (Character)DE.Key;
uint Damage = (uint)DE.Value;
if (Info.Damageing != DamageType.HealHP && Info.Damageing != DamageType.HealMP)
{
if (Info.ExtraEff == ExtraEffect.None || Info.ExtraEff == ExtraEffect.RemoveFly)
{
if (Info.Damageing == DamageType.Ranged)
C.TakeAttack(User, Damage, AttackType.Ranged, true);
else if (Info.Damageing == DamageType.Melee)
C.TakeAttack(User, Damage, AttackType.Melee, true);
else
C.TakeAttack(User, Damage, AttackType.Magic, true);
}
}
switch (Info.ExtraEff)
{
case ExtraEffect.BlessPray:
{
Buff B = new Buff();
B.Eff = Info.ExtraEff;
B.Lasts = Info.EffectLasts;
B.Value = Info.EffectValue;
B.Started = DateTime.Now;
B.StEff = StatusEffectEn.Pray;
C.AddBuff(B);
C.Prayer = true;
C.PrayDT = DateTime.Now;
C.GettingLuckyTime = true;
break;
}
case ExtraEffect.UnMount:
{
if (C.Equips.Steed.Plus < User.Equips.Steed.Plus)
{
C.StatEff.Remove(StatusEffectEn.Ride);
}
break;
}
case ExtraEffect.Scapegoat:
{
Buff B = new Buff();
B.Eff = Info.ExtraEff;
B.Lasts = Info.EffectLasts;
B.Value = Info.EffectValue;
B.Started = DateTime.Now;
B.StEff = StatusEffectEn.Normal;
C.AddBuff(B);
break;
}
case ExtraEffect.NoPots:
{
C.UnableToUseDrugsFor = Info.EffectLasts;
C.UnableToUseDrugs = DateTime.Now;
break;
}
case ExtraEffect.Ride:
{
if (!User.StatEff.Contains(StatusEffectEn.Ride))
User.StatEff.Add(StatusEffectEn.Ride);
else
User.StatEff.Remove(StatusEffectEn.Ride);
User.Vigor = User.MaxVigor;
break;
}
case ExtraEffect.Summon:
{
if (User.MyCompanion != null) User.MyCompanion.Dissappear();
User.MyCompanion = new Game.Companion(User, Info.Damage);
break;
}
case ExtraEffect.RemoveFly:
{
Buff B = C.BuffOf(ExtraEffect.Fly);
if (B.Eff == ExtraEffect.Fly && C.Potency < User.Potency)
C.RemoveBuff(B);
break;
}
case ExtraEffect.Transform:
{
Buff B = new Buff();
B.Eff = Info.ExtraEff;
B.Lasts = Info.EffectLasts;
B.Value = Info.EffectValue;
B.Transform = Info.Damage;
B.Started = DateTime.Now;
B.StEff = StatusEffectEn.Normal;
C.AddBuff(B);
break;
}
case ExtraEffect.Fly:
{
/// <summary>
/// fix for "fly with horse"
/// </summary>
if (C.StatEff.Contains(StatusEffectEn.Ride))
{
C.StatEff.Remove(StatusEffectEn.Ride);
}//end.
Buff B = new Buff();
B.Eff = Info.ExtraEff;
B.Lasts = Info.EffectLasts;
B.Value = Info.EffectValue;
B.Started = DateTime.Now;
B.StEff = StatusEffectEn.Fly;
C.AddBuff(B);
break;
}
case ExtraEffect.Revive:
{
C.Ghost = false;
C.BlueName = false;
C.CurHP = (ushort)C.MaxHP;
C.Alive = true;
C.StatEff.Clear();
C.PKPoints = C.PKPoints;
C.Body = C.Body;
C.Hair = C.Hair;
C.Equips.Send(C.MyClient, false);
World.Spawn(C, false);
break;
}
case ExtraEffect.FatalStrike:
{
Buff B = new Buff();
B.Eff = Info.ExtraEff;
B.Lasts = Info.EffectLasts;
B.Value = Info.EffectValue;
B.Started = DateTime.Now;
B.StEff = StatusEffectEn.FatalStrike;
C.AddBuff(B);
break;
}
case ExtraEffect.ShurikenVortex:
{
Buff B = new Buff();
B.Eff = Info.ExtraEff;
B.Lasts = Info.EffectLasts;
B.Value = Info.EffectValue;
B.Started = DateTime.Now;
B.StEff = StatusEffectEn.ShurikenVortex;
C.AddBuff(B);
C.VortexOn = true;
C.LastVortexAttk = DateTime.Now;
break;
}
case ExtraEffect.Stigma:
{
Buff B = new Buff();
B.Eff = Info.ExtraEff;
B.Lasts = Info.EffectLasts;
B.Value = Info.EffectValue;
B.Started = DateTime.Now;
B.StEff = StatusEffectEn.Stigma;
C.AddBuff(B);
break;
}
case ExtraEffect.MagicShield:
{
Buff B = new Buff();
B.Eff = Info.ExtraEff;
B.Lasts = Info.EffectLasts;
B.Value = Info.EffectValue;
B.Started = DateTime.Now;
B.StEff = StatusEffectEn.Shield;
C.AddBuff(B);
break;
}
case ExtraEffect.Invisibility:
{
Buff B = new Buff();
B.Eff = Info.ExtraEff;
B.Lasts = Info.EffectLasts;
B.Value = Info.EffectValue;
B.Started = DateTime.Now;
B.StEff = StatusEffectEn.Invisible;
C.AddBuff(B);
break;
}
case ExtraEffect.Accuracy:
{
Buff B = new Buff();
B.Eff = Info.ExtraEff;
B.Lasts = Info.EffectLasts;
B.Value = Info.EffectValue;
B.Started = DateTime.Now;
B.StEff = StatusEffectEn.Accuracy;
C.AddBuff(B);
break;
}
case ExtraEffect.Cyclone:
{
Buff B = new Buff();
B.Eff = Info.ExtraEff;
B.Lasts = Info.EffectLasts;
B.Value = Info.EffectValue;
B.Started = DateTime.Now;
B.StEff = StatusEffectEn.Cyclone;
C.AddBuff(B);
break;
}
case ExtraEffect.Superman:
{
Buff B = new Buff();
B.Eff = Info.ExtraEff;
B.Lasts = Info.EffectLasts;
B.Value = Info.EffectValue;
B.Started = DateTime.Now;
B.StEff = StatusEffectEn.SuperMan;
C.AddBuff(B);
break;
}
case ExtraEffect.FlashStep:
{
C.Shift(AimX, AimY);
break;
}
}
}
if (User.Loc.Map != 1039)
{
User.IncreaseExp(Exp, false);
User.AddSkillExp(Info.ID, Exp);
User.AddSkillExp(Info.ID, 1000);
}
else
{
User.IncreaseExp(Exp / 10, false);
User.AddSkillExp(Info.ID, Exp / 10);
User.AddSkillExp(Info.ID, 100);
}
Game.World.Action(User, Packets.SkillUse(this).Get);
}
catch (Exception Exc) { Program.WriteLine(Exc); }
}
}
public static Hashtable SkillInfos = new Hashtable();
public static Hashtable WepSkillIDs = new Hashtable();
public static void Load()
{
if (File.Exists(@"C:\OldCODB\Skills.dat"))
{
FileStream FS = new FileStream(@"C:\OldCODB\Skills.dat", FileMode.Open);
BinaryReader BR = new BinaryReader(FS);
int SkillCount = BR.ReadInt32();
for (int i = 0; i < SkillCount; i++)
{
SkillInfo S = new SkillInfo();
S.LoadThis(BR);
SkillInfos.Add(S.ID + " " + S.Level, S);
}
BR.Close();
FS.Close();
}
WepSkillIDs.Add((ushort)480, (ushort)7020);
WepSkillIDs.Add((ushort)420, (ushort)5030);
WepSkillIDs.Add((ushort)421, (ushort)5030);
WepSkillIDs.Add((ushort)510, (ushort)1250);
WepSkillIDs.Add((ushort)530, (ushort)5050);
WepSkillIDs.Add((ushort)561, (ushort)5010);
WepSkillIDs.Add((ushort)560, (ushort)1260);
WepSkillIDs.Add((ushort)721, (ushort)1290);
WepSkillIDs.Add((ushort)460, (ushort)5040);
WepSkillIDs.Add((ushort)540, (ushort)1300);
WepSkillIDs.Add((ushort)430, (ushort)7000);
WepSkillIDs.Add((ushort)450, (ushort)7010);
WepSkillIDs.Add((ushort)481, (ushort)7030);
WepSkillIDs.Add((ushort)440, (ushort)7040);
WepSkillIDs.Add((ushort)580, (ushort)5020);
if (File.Exists(@"C:\OldCODB\MagicType.txt"))
{
string[] Lines = File.ReadAllLines(@"C:\OldCODB\MagicType.txt");
foreach (string Line in Lines)
{
string[] Info = Line.Split(' ');
SkillsClass.SkillInfo S = new SkillInfo();
S.ID = ushort.Parse(Info[0]);
if (((Extra.SkillIDs)S.ID) == Extra.SkillIDs.CounterKill)
{
S.Level = byte.Parse(Info[7]);
S.ActivationChance = byte.Parse(Info[11]);
S.Damageing = DamageType.Magic;
S.Targetting = TargetType.Single;
S.ExtraEff = ExtraEffect.None;
if (Info[1] == "5")
{
if (S.ID == 1165 || S.ID == 1125 || S.ID == 5001 || S.ID == 1010 || S.ID == 8030)
S.Targetting = TargetType.FromSingle;
else
S.Targetting = TargetType.Range;
}
else if (Info[1] == "30")
{
S.ExtraEff = ExtraEffect.UnMount;
S.Targetting = TargetType.Single;
}
else if (Info[1] == "31")
{
S.ExtraEff = ExtraEffect.UnMount;
S.Targetting = TargetType.Range;
}
else if (Info[1] == "32")
{
S.ExtraEff = ExtraEffect.Ride;
S.Targetting = TargetType.Single;
}
else if (Info[1] == "19")
S.ExtraEff = ExtraEffect.Transform;
else if (Info[1] == "23")
S.ExtraEff = ExtraEffect.Summon;
else if (Info[1] == "4" || Info[1] == "14")
S.Targetting = TargetType.Sector;
else if (Info[1] == "7")
S.ExtraEff = ExtraEffect.Revive;
else if (Info[1] == "16")
{
S.Targetting = TargetType.Single;
S.Damageing = DamageType.Melee;
}
ushort dmg = ushort.Parse(Info[33]);
if (dmg >= 400 && dmg <= 499)
S.Damageing = DamageType.Melee;
else if (dmg >= 800 && dmg <= 899)
S.Damageing = DamageType.Ranged;
else if (dmg >= 900 && dmg <= 999)
S.Damageing = DamageType.Magic;
if (int.Parse(Info[9]) > 0)
{
if (int.Parse(Info[9]) >= 30000)
S.EffectValue = (float)(int.Parse(Info[9]) - 30000) / 100;
else
{
S.EffectValue = 1;
S.Damage = uint.Parse(Info[9]);
}
}
S.ManaCost = ushort.Parse(Info[8]);
S.UpgReqExp = uint.Parse(Info[17]);
S.UpgReqLvl = byte.Parse(Info[18]);
S.MaxDist = byte.Parse(Info[13]);
Game.StatusEffectEn Eff = (Game.StatusEffectEn)ulong.Parse(Info[15]);
if (Eff == StatusEffectEn.SuperMan)
S.ExtraEff = ExtraEffect.Superman;
else if (Eff == StatusEffectEn.Cyclone)
S.ExtraEff = ExtraEffect.Cyclone;
else if (Eff == StatusEffectEn.Invisible)
S.ExtraEff = ExtraEffect.Invisibility;
else if (Eff == StatusEffectEn.Accuracy)
S.ExtraEff = ExtraEffect.Accuracy;
else if (Eff == StatusEffectEn.Fly)
S.ExtraEff = ExtraEffect.Fly;
else if (Eff == StatusEffectEn.Stigma)
S.ExtraEff = ExtraEffect.Stigma;
else if (Eff == StatusEffectEn.Shield)
S.ExtraEff = ExtraEffect.MagicShield;
else if (Eff == StatusEffectEn.FatalStrike)
S.ExtraEff = ExtraEffect.FatalStrike;
else if (Eff == StatusEffectEn.ShurikenVortex)
S.ExtraEff = ExtraEffect.ShurikenVortex;
S.EffectLasts = ushort.MaxValue;//ushort.Parse(Info[12]);
if (S.ID == 8001)
S.SectorSize = (byte)(105 + S.Level * 15);
else
S.SectorSize = (byte)(90 + S.Level * 5);
if (S.ID == 1045 || S.ID == 1046)
S.Targetting = TargetType.Linear;
S.StaminaCost = byte.Parse(Info[27]);
S.ExtraEff = ExtraEffect.Scapegoat;
if (SkillInfos.Contains(S.ID.ToString() + " " + S.Level.ToString()))
SkillInfos.Remove(S.ID.ToString() + " " + S.Level.ToString());
SkillInfos.Add(S.ID.ToString() + " " + S.Level.ToString(), S);
}
}
}
}
public static void Save()
{
FileStream FS = new FileStream(@"C:\OldCODB\Skills.dat", FileMode.OpenOrCreate);
BinaryWriter BW = new BinaryWriter(FS);
BW.Write(SkillInfos.Count);
foreach (SkillInfo S in SkillInfos.Values)
S.SaveThis(BW);
BW.Close();
FS.Close();
}
}
}
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ImpactGaming
{
public struct Coordinate
{
public int X;
public int Y;
public Coordinate(int x, int y)
{
this.X = x;
this.Y = y;
}
}
public static class MyMath
{
public static bool Contains(this Coordinate[] Coords, Coordinate Check)
{
foreach (Coordinate Coord in Coords)
if (Coord.X == Check.X && Check.Y == Coord.Y)
return true;
return false;
}
public static List<Coordinate> LineCoords(ushort userx, ushort usery, ushort shotx, ushort shoty, byte length)
{
double dir = Math.Atan2(shoty - usery, shotx - userx);
double f_x = (Math.Cos(dir) * length) + userx;
double f_y = (Math.Sin(dir) * length) + usery;
return lineBresenham(userx, usery, (int)f_x, (int)f_y);
}
public static void Add(this List<Coordinate> Coords, int x, int y)
{
Coordinate add = new Coordinate((ushort)x, (ushort)y);
if (!Coords.Contains(add))
Coords.Add(add);
}
public static List<Coordinate> lineBresenham(int x0, int y0, int x1, int y1)
{
List<Coordinate> Line = new List<Coordinate>();
int dy = y1 - y0;
int dx = x1 - x0;
int stepx, stepy;
if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; }
if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; }
dy <<= 1; // dy is now 2*dy
dx <<= 1; // dx is now 2*dx
Line.Add(x0, y0);
if (dx > dy)
{
int fraction = dy - (dx >> 1); // same as 2*dy - dx
while (x0 != x1)
{
if (fraction >= 0)
{
y0 += stepy;
fraction -= dx; // same as fraction -= 2*dx
}
x0 += stepx;
fraction += dy; // same as fraction -= 2*dy
Line.Add(x0, y0);
}
}
else
{
int fraction = dx - (dy >> 1);
while (y0 != y1)
{
if (fraction >= 0)
{
x0 += stepx;
fraction -= dy;
}
y0 += stepy;
fraction += dx;
Line.Add(x0, y0);
}
}
return Line;
}
static Random Rnd = new Random();
public static double LevelDifference(byte Lev1, byte Lev2)
{
if (Lev1 > Lev2)
{
double Rt = (Lev1 - Lev2 + 7) / 5;
return Rt = ((Rt - 1) * 0.8) + 1;
}
return 1;
}
public static bool ChanceSuccess(double Chance)
{
int e = Rnd.Next(10000000);
double a = ((double)e / (double)10000000) * 100;
return Chance >= a;
}
public static double PointDirecton(double x1, double y1, double x2, double y2)
{
double direction = 0;
double AddX = x2 - x1;
double AddY = y2 - y1;
double r = (double)Math.Atan2(AddY, AddX);
if (r < 0) r += (double)Math.PI * 2;
direction = 360 - (r * 180 / (double)Math.PI);
return direction;
}
public static double PointDirectonRad(double x1, double y1, double x2, double y2)
{
double AddX = x2 - x1;
double AddY = y2 - y1;
double r = (double)Math.Atan2(AddY, AddX);
return r;
}
public static double PointDirecton2(double x1, double y1, double x2, double y2)
{
double direction = 0;
double AddX = x2 - x1;
double AddY = y2 - y1;
double r = (double)Math.Atan2(AddY, AddX);
direction = (r * 180 / (double)Math.PI);
return direction;
}
public static double RadianToDegree(double r)
{
if (r < 0) r += (double)Math.PI * 2;
double direction = 360 - (r * 180 / (double)Math.PI);
return direction;
}
public static double DegreeToRadian(double degr)
{
return degr * Math.PI / 180;
}
public static int PointDistance(double x1, double y1, double x2, double y2)
{
return (int)Math.Sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
}
public static bool InBox(double x1, double y1, double x2, double y2, byte Range)
{
return (Math.Max(Math.Abs(x1 - x2), Math.Abs(y1 - y2)) <= Range);
}
}
}







