afxAreaDamage.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  2. // Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
  3. // Copyright (C) 2015 Faust Logic, Inc.
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to
  7. // deal in the Software without restriction, including without limitation the
  8. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. // sell copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. // IN THE SOFTWARE.
  22. //
  23. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  24. #include "afx/arcaneFX.h"
  25. #include "afx/ce/afxAreaDamage.h"
  26. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  27. // afxAreaDamageData
  28. IMPLEMENT_CO_DATABLOCK_V1(afxAreaDamageData);
  29. ConsoleDocClass( afxAreaDamageData,
  30. "@brief A datablock that specifies an Area Damage effect.\n\n"
  31. "An Area Damage effect is useful for assigning area damage with unusual timing that must be synchronized with other "
  32. "effects. Negative damage amounts can be used for healing effects."
  33. "\n\n"
  34. "The primary difference between afxAreaDamageData and afxDamageData, which is also capable of inflicting area damage, "
  35. "is that afxAreaDamageData effects calculate the area damage in C++ code rather than calling out to the script function "
  36. "radiusDamage(). In cases where area damage needs to be inflicted repeatedly or in areas crowded with many targets, "
  37. "afxAreaDamageData is likely to get better performance."
  38. "\n\n"
  39. "@ingroup afxEffects\n"
  40. "@ingroup AFX\n"
  41. "@ingroup Datablocks\n"
  42. );
  43. afxAreaDamageData::afxAreaDamageData()
  44. {
  45. flavor = ST_NULLSTRING;
  46. amount = 0;
  47. radius = 0;
  48. impulse = 0;
  49. notify_damage_src = false;
  50. exclude_cons_obj = false;
  51. }
  52. afxAreaDamageData::afxAreaDamageData(const afxAreaDamageData& other, bool temp_clone) : GameBaseData(other, temp_clone)
  53. {
  54. flavor = other.flavor;
  55. amount = other.amount;
  56. radius = other.radius;
  57. impulse = other.impulse;
  58. notify_damage_src = other.notify_damage_src;
  59. exclude_cons_obj = other.exclude_cons_obj;
  60. }
  61. #define myOffset(field) Offset(field, afxAreaDamageData)
  62. void afxAreaDamageData::initPersistFields()
  63. {
  64. addField("flavor", TypeString, myOffset(flavor),
  65. "An arbitrary string which is passed as an argument to a spell's onDamage() script "
  66. "method. It is used to classify a type of damage such as 'melee', 'magical', or "
  67. "'fire'.");
  68. addField("damage", TypeF32, myOffset(amount),
  69. "An amount of area damage to inflict on a target. Objects within half the radius "
  70. "receive full damage which then diminishes out to the full distance of the specified "
  71. "radius.");
  72. addField("radius", TypeF32, myOffset(radius),
  73. "Radius centered at the effect position in which damage will be applied.");
  74. addField("impulse", TypeF32, myOffset(impulse),
  75. "Specifies an amount of force to apply to damaged objects. Objects within half the "
  76. "radius receive full impulse which then diminishes out to the full distance of the "
  77. "specified radius.");
  78. addField("notifyDamageSource", TypeBool, myOffset(notify_damage_src),
  79. "When true, the onInflictedAreaDamage() method of the damaged object will be called "
  80. "to notify it of the damage. This is useful for starting some effects or action that "
  81. "responds to the damage.");
  82. addField("excludeConstraintObject", TypeBool, myOffset(exclude_cons_obj),
  83. "When true, the object specified as the effect's primary position constraint will not "
  84. "receive any damage.");
  85. Parent::initPersistFields();
  86. }
  87. bool afxAreaDamageData::onAdd()
  88. {
  89. if (Parent::onAdd() == false)
  90. return false;
  91. return true;
  92. }
  93. void afxAreaDamageData::packData(BitStream* stream)
  94. {
  95. Parent::packData(stream);
  96. }
  97. void afxAreaDamageData::unpackData(BitStream* stream)
  98. {
  99. Parent::unpackData(stream);
  100. }
  101. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//