summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-11-09 19:25:03 +0100
committermadmaxoft <github@xoft.cz>2013-11-09 19:25:03 +0100
commit148f723632e9fb1ee419ac8dd2b2b76543435828 (patch)
treecf93301558b5406bf56525f634737265427e3096
parentAPIDump: Documented the relevant tolua functions. (diff)
downloadcuberite-148f723632e9fb1ee419ac8dd2b2b76543435828.tar
cuberite-148f723632e9fb1ee419ac8dd2b2b76543435828.tar.gz
cuberite-148f723632e9fb1ee419ac8dd2b2b76543435828.tar.bz2
cuberite-148f723632e9fb1ee419ac8dd2b2b76543435828.tar.lz
cuberite-148f723632e9fb1ee419ac8dd2b2b76543435828.tar.xz
cuberite-148f723632e9fb1ee419ac8dd2b2b76543435828.tar.zst
cuberite-148f723632e9fb1ee419ac8dd2b2b76543435828.zip
-rw-r--r--MCServer/Plugins/APIDump/APIDesc.lua34
1 files changed, 29 insertions, 5 deletions
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 3b0beaa2d..9f303ff0e 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -2438,14 +2438,38 @@ end
TakeDamageInfo =
{
- Desc = [[The TakeDamageInfo is a struct that contains the amount of damage, and the entity that caused the damage. It is used in the {{OnTakeDamage|OnTakeDamage}}() hook and in the {{cEntity|cEntity}}'s TakeDamage() function.
-]],
- Functions =
+ Desc = [[
+ This class contains the amount of damage, and the entity that caused the damage. It is used in the
+ {{OnTakeDamage|HOOK_TAKE_DAMAGE}} hook and in the {{cEntity}}'s TakeDamage() function.
+ ]],
+ Variables =
{
+ Attacker = { Type = "{{cEntity}}", Notes = "The entity who is attacking. Only valid if dtAttack." },
+ DamageType = { Type = "eDamageType", Notes = "Source of the damage. One of the dtXXX constants." },
+ FinalDamage = { Type = "number", Notes = " The final amount of damage that will be applied to the Receiver. It is the RawDamage minus any Receiver's armor-protection " },
+ Knockback = { Type = "{{Vector3d}}", Notes = "Vector specifying the amount and direction of knockback that will be applied to the Receiver " },
+ RawDamage = { Type = "number", Notes = "Amount of damage that the attack produces on the Receiver, including the Attacker's equipped weapon, but excluding the Receiver's armor." },
},
- Constants =
+ AdditionalInfo =
{
- },
+ {
+ Header = "",
+ Contents = [[
+ The TDI is passed as the second parameter in the HOOK_TAKE_DAMAGE hook, and can be used to
+ modify the damage before it is applied to the receiver:
+<pre class="prettyprint lang-lua">
+function Plugin:OnTakeDamage(Receiver, TDI)
+ LOG("Damage: Raw ".. TDI.RawDamage .. ", Final:" .. TDI.FinalDamage);
+
+ -- If the attacker is a spider, make it deal 999 points of damage (insta-death spiders):
+ if ((TDI.Attacker ~= nil) and TDI.Attacker:IsA("cSpider")) then
+ TDI.FinalDamage = 999;
+ end
+end
+</pre>
+ ]],
+ },
+ }, -- AdditionalInfo
}, -- TakeDamageInfo
tolua =