utility.tscript 791 B

12345678910111213141516171819202122232425262728293031323334
  1. function findRootObject(%obj)
  2. { if (!isObject(%obj)) return -1;
  3. %ret = %obj;
  4. if (isObject(%obj.getObjectMount()))
  5. %ret = findRootObject(%obj.getObjectMount());
  6. return %ret;
  7. }
  8. function deleteMountchain(%obj)
  9. {
  10. if (!isObject(%obj)) return;
  11. %count = %obj.getMountedObjectCount();
  12. for (%i=%count; %i>=0; %i--)
  13. {
  14. if (isObject(%obj.getMountedObject(%i)))
  15. deleteMountchain(%obj.getMountedObject(%i));
  16. }
  17. if (%obj.isMounted())
  18. %obj.delete();
  19. }
  20. function setMountChainDamage(%obj,%damagePercent)
  21. {
  22. if (!isObject(%obj)) return;
  23. %count = %obj.getMountedObjectCount();
  24. for (%i=0; %i<%count; %i++)
  25. {
  26. if (isObject(%obj.getMountedObject(%i)))
  27. setMountChainDamage(%obj.getMountedObject(%i),%damagePercent);
  28. }
  29. %obj.setDamageLevel(%obj.getMaxDamage()*%damagePercent);
  30. }