player.tscript 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. function PlayerData::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
  2. {
  3. if (!isObject(%obj) || %obj.getDamageState() !$= "Enabled" || !%damage)
  4. return;
  5. %rootObj = %obj;
  6. if (%obj.healthFromMount)
  7. %rootObj = findRootObject(%obj);
  8. %rootObj.applyDamage(%damage);
  9. %this.onDamage(%rootObj, %damage);
  10. %this.setDamageDirection(%rootObj, %sourceObject, %position);
  11. // Deal with client callbacks here because we don't have this
  12. // information in the onDamage or onDisable methods
  13. %client = %rootObj.client;
  14. %sourceClient = %sourceObject ? %sourceObject.client : 0;
  15. %location = "Body";
  16. if (isObject(%client))
  17. {
  18. if (%rootObj.getDamageState() !$= "Enabled")
  19. {
  20. callGamemodeFunction("onDeath", %client, %sourceObject, %sourceClient, %damageType, %location);
  21. }
  22. }
  23. }
  24. function PlayerData::onDamage(%this, %obj, %delta)
  25. {
  26. Parent::onDamage(%this, %obj, %delta);
  27. // This method is invoked by the ShapeBase code whenever the
  28. // object's damage level changes.
  29. if (%delta > 0 && %obj.getDamageState() !$= "Destroyed")
  30. {
  31. // If the pain is excessive, let's hear about it.
  32. if (%delta > 10)
  33. %obj.playPain();
  34. }
  35. }