afxDamage.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 "console/consoleTypes.h"
  26. #include "core/stream/bitStream.h"
  27. #include "afx/ce/afxDamage.h"
  28. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  29. // afxDamageData
  30. IMPLEMENT_CO_DATABLOCK_V1(afxDamageData);
  31. ConsoleDocClass( afxDamageData,
  32. "@brief A datablock that specifies a Damage effect.\n\n"
  33. "A Damage effect is useful for assigning damage with unusual timing that must be synchronized with other effects. They "
  34. "can be used to deal direct damage, radius damage, and damage over time. Negative damage amounts can be used for "
  35. "healing effects."
  36. "\n\n"
  37. "@ingroup afxEffects\n"
  38. "@ingroup AFX\n"
  39. "@ingroup Datablocks\n"
  40. );
  41. afxDamageData::afxDamageData()
  42. {
  43. label = ST_NULLSTRING;
  44. flavor = ST_NULLSTRING;
  45. amount = 0;
  46. repeats = 1;
  47. ad_amount = 0;
  48. radius = 0;
  49. impulse = 0;
  50. }
  51. afxDamageData::afxDamageData(const afxDamageData& other, bool temp_clone) : GameBaseData(other, temp_clone)
  52. {
  53. label = other.label;
  54. flavor = other.flavor;
  55. amount = other.amount;
  56. repeats = other.repeats;
  57. ad_amount = other.ad_amount;
  58. radius = other.radius;
  59. impulse = other.impulse;
  60. }
  61. #define myOffset(field) Offset(field, afxDamageData)
  62. void afxDamageData::initPersistFields()
  63. {
  64. addField("label", TypeString, myOffset(label),
  65. "An arbitrary string which is passed as an argument to a spell's onDamage() script "
  66. "method. It can be used to identify which damage effect the damage came from in "
  67. "cases where more than one damage effect is used in a single spell.");
  68. addField("flavor", TypeString, myOffset(flavor),
  69. "An arbitrary string which is passed as an argument to a spell's onDamage() script "
  70. "method. It is used to classify a type of damage such as 'melee', 'magical', or "
  71. "'fire'.");
  72. addField("directDamage", TypeF32, myOffset(amount),
  73. "An amount of direct damage to inflict on a target.");
  74. addField("directDamageRepeats", TypeS8, myOffset(repeats),
  75. "The number of times to inflict the damage specified by directDamage. Values "
  76. "greater than 1 inflict damage over time, with the amount of directDamage "
  77. "repeatedly dealt at evenly spaced intervals over the lifetime of the effect.");
  78. addField("areaDamage", TypeF32, myOffset(ad_amount),
  79. "An amount of area damage to inflict on a target. Objects within half the radius "
  80. "receive full damage which then diminishes out to the full distance of "
  81. "areaDamageRadius.");
  82. addField("areaDamageRadius", TypeF32, myOffset(radius),
  83. "Radius centered at the effect position in which damage will be applied.");
  84. addField("areaDamageImpulse", TypeF32, myOffset(impulse),
  85. "Specifies an amount of force to apply to damaged objects. Objects within half the "
  86. "radius receive full impulse which then diminishes out to the full distance of "
  87. "areaDamageRadius.");
  88. Parent::initPersistFields();
  89. }
  90. bool afxDamageData::onAdd()
  91. {
  92. if (Parent::onAdd() == false)
  93. return false;
  94. return true;
  95. }
  96. void afxDamageData::packData(BitStream* stream)
  97. {
  98. Parent::packData(stream);
  99. stream->writeString(label);
  100. stream->writeString(flavor);
  101. stream->write(amount);
  102. stream->write(repeats);
  103. stream->write(ad_amount);
  104. stream->write(radius);
  105. stream->write(impulse);
  106. }
  107. void afxDamageData::unpackData(BitStream* stream)
  108. {
  109. Parent::unpackData(stream);
  110. label = stream->readSTString();
  111. flavor = stream->readSTString();
  112. stream->read(&amount);
  113. stream->read(&repeats);
  114. stream->read(&ad_amount);
  115. stream->read(&radius);
  116. stream->read(&impulse);
  117. }
  118. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//