/RunesDataBase/TableObjects/SpellObject.cs

https://gitlab.com/RawRCoder/rom_db_editor · C# · 347 lines · 310 code · 37 blank · 0 comment · 4 complexity · c7fdc2fcfac2c5e8d2ab1a9e11f92957 MD5 · raw file

  1. using System.ComponentModel;
  2. using System.Drawing;
  3. using Runes.Net.Db;
  4. using Runes.Net.Shared;
  5. namespace RunesDataBase.TableObjects
  6. {
  7. public class SpellObject : BasicVisualTableObject
  8. {
  9. public SpellObject(BasicObject obj) : base(obj) { }
  10. [Category("Spell Properties")]
  11. [DisplayName("Magic Level")]
  12. [Description("Some kind of a level (?)")]
  13. public int MagicLv
  14. {
  15. get { return DbObject.GetFieldAsInt("magiclv"); }
  16. set { DbObject.SetField("magiclv", value); }
  17. }
  18. [Category("Spell Properties")]
  19. [DisplayName("Effect type")]
  20. [Description("Type of the effect, that spell does")]
  21. public SpellEffectType EffectType
  22. {
  23. get { return (SpellEffectType) DbObject.GetFieldAsInt("effecttype"); }
  24. set { DbObject.SetField("effecttype", (int) value); }
  25. }
  26. [Category("Spell Properties")]
  27. [DisplayName("Target type")]
  28. [Description("Type of the target")]
  29. public Relation TargetType
  30. {
  31. get { return (Relation)DbObject.GetFieldAsInt("targettype"); }
  32. set { DbObject.SetField("targettype", (int)value); }
  33. }
  34. [Category("Spell Properties")]
  35. [DisplayName("Attack distance")]
  36. [Description("Maxmum range between caster and target")]
  37. public int AttackDistance
  38. {
  39. get { return DbObject.GetFieldAsInt("attackdistance"); }
  40. set { DbObject.SetField("attackdistance", value); }
  41. }
  42. [Category("AOE Spell Properties")]
  43. [DisplayName("Effect range")]
  44. [Description("Maxmum range between main target and other targets (?)")]
  45. public int EffectRange
  46. {
  47. get { return DbObject.GetFieldAsInt("effectrange"); }
  48. set { DbObject.SetField("effectrange", value); }
  49. }
  50. [Category("AOE Spell Properties")]
  51. [DisplayName("Effect range type")]
  52. [Description("Type of the effect range (?)")]
  53. public EffectRangeType RangeType
  54. {
  55. get { return (EffectRangeType)DbObject.GetFieldAsInt("rangetype"); }
  56. set { DbObject.SetField("rangetype", (int)value); }
  57. }
  58. [Category("AOE Spell Properties")]
  59. [DisplayName("Effect selection type")]
  60. [Description("Describes how to select targets in range")]
  61. public SpellSellectType SelectType
  62. {
  63. get { return (SpellSellectType)DbObject.GetFieldAsInt("rangeselecttype"); }
  64. set { DbObject.SetField("rangeselecttype", (int)value); }
  65. }
  66. [Category("AOE Spell Properties")]
  67. [DisplayName("Targets count")]
  68. [Description("Maximum amount of victims of the effect")]
  69. public int TargetsCount
  70. {
  71. get { return DbObject.GetFieldAsInt("effectcount"); }
  72. set { DbObject.SetField("effectcount", value); }
  73. }
  74. [Category("Uncategorized Spell Properties")]
  75. [DisplayName("Hitrate function")]
  76. [Description("Not sure how it works")]
  77. public HitRateFunc HitRate
  78. {
  79. get { return (HitRateFunc)DbObject.GetFieldAsInt("hitratefunc"); }
  80. set { DbObject.SetField("hitratefunc", (int)value); }
  81. }
  82. [Category("Uncategorized Spell Properties")]
  83. [DisplayName("Hitrate function argument [0]")]
  84. [Description("Not sure how it works")]
  85. public float HitRateArg1
  86. {
  87. get { return DbObject.GetFieldAsFloat("hitratearg1"); }
  88. set { DbObject.SetField("hitratearg1", value); }
  89. }
  90. [Category("Uncategorized Spell Properties")]
  91. [DisplayName("Hitrate function argument [1]")]
  92. [Description("Not sure how it works")]
  93. public float HitRateArg2
  94. {
  95. get { return DbObject.GetFieldAsFloat("hitratearg2"); }
  96. set { DbObject.SetField("hitratearg2", value); }
  97. }
  98. [Category("Spell Properties")]
  99. [DisplayName("Cost[0]")]
  100. [Description("How and what it costs to cast this spell")]
  101. public SpellCost SpellCost1
  102. => new SpellCost(this, 0);
  103. [Category("Spell Properties")]
  104. [DisplayName("Cost[1]")]
  105. [Description("How and what it costs to cast this spell")]
  106. public SpellCost SpellCost2
  107. => new SpellCost(this, 1);
  108. [Category("Spell Properties")]
  109. [DisplayName("Magic")]
  110. [Description("Magic the spell does")]
  111. public SpellMagic[] Magic
  112. {
  113. get
  114. {
  115. var a = new SpellMagic[12];
  116. for (var i = 0; i < 12; ++i)
  117. a[i] = new SpellMagic(this, i);
  118. return a;
  119. }
  120. }
  121. [Category("Spell Properties")]
  122. [DisplayName("Need[0]")]
  123. [Description("Requirements for spell")]
  124. public SpellNeed SpellNeed1
  125. => new SpellNeed(this, 0);
  126. [Category("Spell Properties")]
  127. [DisplayName("Need[1]")]
  128. [Description("Requirements for spell")]
  129. public SpellNeed SpellNeed2
  130. => new SpellNeed(this, 1);
  131. [Category("Cooldown")]
  132. [DisplayName("Cooldown class")]
  133. public CooldownClass CoolDownClass
  134. {
  135. get { return (CooldownClass)DbObject.GetFieldAsInt("coldownclass"); }
  136. set { DbObject.SetField("coldownclass", (int)value); }
  137. }
  138. [Category("Cooldown")]
  139. [DisplayName("Cooldown type")]
  140. public int CoolDownType
  141. {
  142. get { return DbObject.GetFieldAsInt("coldowntype"); }
  143. set { DbObject.SetField("coldowntype", value); }
  144. }
  145. [Category("Cooldown")]
  146. [DisplayName("Cooldown time")]
  147. public int CoolDownTime
  148. {
  149. get { return DbObject.GetFieldAsInt("coldowntime"); }
  150. set { DbObject.SetField("coldowntime", value); }
  151. }
  152. [Category("Cooldown")]
  153. [DisplayName("Cooldown time (global)")]
  154. public int CoolDownTimeAllMagic
  155. {
  156. get { return DbObject.GetFieldAsInt("coldowntimeallmagic"); }
  157. set { DbObject.SetField("coldowntimeallmagic", value); }
  158. }
  159. [Category("Spell Properties")]
  160. [DisplayName("Flags")]
  161. public SpellFlags Flags
  162. {
  163. get { return (SpellFlags)DbObject.GetFieldAsInt("flag"); }
  164. set { DbObject.SetField("flag", (int)value); }
  165. }
  166. [Category("Spell Properties")]
  167. [DisplayName("Cast time")]
  168. [Description("Requirements for spell")]
  169. public float SpellTime
  170. {
  171. get { return DbObject.GetFieldAsFloat("spelltime"); }
  172. set { DbObject.SetField("spelltime", value); }
  173. }
  174. [Category("Spell Properties")]
  175. [DisplayName("Magic attack delay")]
  176. [Description("??")]
  177. public float MagicAttackDelay
  178. {
  179. get { return DbObject.GetFieldAsFloat("magicattackdelay"); }
  180. set { DbObject.SetField("magicattackdelay", value); }
  181. }
  182. [Category("Spell Properties")]
  183. [DisplayName("Spell count")]
  184. [Description("??")]
  185. public int SpellCount
  186. {
  187. get { return DbObject.GetFieldAsInt("spellcount"); }
  188. set { DbObject.SetField("spellcount", value); }
  189. }
  190. [Category("Spell Properties")]
  191. [DisplayName("Limit Level")]
  192. [Description("Max char level?")]
  193. public int LimitLevel
  194. {
  195. get { return DbObject.GetFieldAsInt("limitlv"); }
  196. set { DbObject.SetField("limitlv", value); }
  197. }
  198. [Category("Spell Properties")]
  199. [DisplayName("Max spell level")]
  200. [Description("Max spell level")]
  201. public int MaxLevel
  202. {
  203. get { return DbObject.GetFieldAsInt("maxskilllv"); }
  204. set { DbObject.SetField("maxskilllv", value); }
  205. }
  206. [Category("Spell Properties")]
  207. [DisplayName("Next spell time")]
  208. [Description("??")]
  209. public float NextSpellTime
  210. {
  211. get { return DbObject.GetFieldAsFloat("nextspelltime"); }
  212. set { DbObject.SetField("nextspelltime", value); }
  213. }
  214. public override string GetDescription()
  215. {
  216. return ("" + ShortNote);
  217. }
  218. public override Color GetColor()
  219. {
  220. return Color.Aqua;
  221. }
  222. public override string GetIconName() { return "spell"; }
  223. }
  224. public class SpellCost : StructuredField
  225. {
  226. private int _id;
  227. [DisplayName("Cost type")]
  228. public SpellCostType CostType
  229. {
  230. get { return (SpellCostType)Object.GetFieldAsInt(_id > 0 ? "costtype1" :"costtype"); }
  231. set { Object.SetField(_id > 0 ? "costtype1" : "costtype", (int)value); }
  232. }
  233. [DisplayName("Value")]
  234. public int Value
  235. {
  236. get { return Object.GetFieldAsInt(_id > 0 ? "costvalue1" : "costvalue"); }
  237. set { Object.SetField(_id > 0 ? "costvalue1" : "costvalue", (int)value); }
  238. }
  239. public SpellCost(BasicTableObject o, int i) : base(o)
  240. {
  241. _id = i;
  242. }
  243. public override string ToString()
  244. {
  245. return Value + " of " + CostType;
  246. }
  247. }
  248. public class SpellNeed : StructuredField
  249. {
  250. private int _id;
  251. [DisplayName("Need type")]
  252. public SpellNeedType NeedType
  253. {
  254. get { return (SpellNeedType)Object.GetFieldAsInt(_id > 0 ? "needtype2" : "needtype1"); }
  255. set { Object.SetField(_id > 0 ? "needtype2" : "needtype1", (int)value); }
  256. }
  257. [DisplayName("Value")]
  258. public int Value
  259. {
  260. get { return Object.GetFieldAsInt(_id > 0 ? "needvalue2" : "needvalue1"); }
  261. set { Object.SetField(_id > 0 ? "needvalue2" : "needvalue1", (int)value); }
  262. }
  263. public SpellNeed(BasicTableObject o, int i) : base(o)
  264. {
  265. _id = i;
  266. }
  267. public override string ToString()
  268. => NeedType == SpellNeedType.None
  269. ? "<empty>"
  270. : $"{Value} of {NeedType}";
  271. }
  272. public class SpellMagic : StructuredField
  273. {
  274. private int _id;
  275. [DisplayName("Check function type")]
  276. public MagicCheckFunction CheckFuncType
  277. {
  278. get { return (MagicCheckFunction)Object.GetFieldAsInt("magiccheckfunctype" + (_id + 1)); }
  279. set { Object.SetField("magiccheckfunctype" + (_id + 1), (int)value); }
  280. }
  281. [DisplayName("Magic base GUID")]
  282. public int MagicBaseID
  283. {
  284. get { return Object.GetFieldAsInt("magicbaseid" + (_id + 1)); }
  285. set { Object.SetField("magicbaseid" + (_id + 1), value); }
  286. }
  287. [DisplayName("Argument[0]")]
  288. public int Arg0
  289. {
  290. get { return Object.GetFieldAsInt("magiccheckarg1" + (_id + 1)); }
  291. set { Object.SetField("magiccheckarg1" + (_id + 1), value); }
  292. }
  293. [DisplayName("Argument[1]")]
  294. public int Arg1
  295. {
  296. get { return Object.GetFieldAsInt("magiccheckarg2" + (_id+1)); }
  297. set { Object.SetField("magiccheckarg2" + (_id + 1), value); }
  298. }
  299. public SpellMagic(BasicTableObject o, int i) : base(o)
  300. {
  301. _id = i;
  302. }
  303. public override string ToString()
  304. {
  305. if (CheckFuncType == MagicCheckFunction.None)
  306. return MagicBaseID.ToString();
  307. return $"{MagicBaseID}, checkfunc: {CheckFuncType}({Arg0}, {Arg1})";
  308. }
  309. }
  310. }