1. struct
  2. {
  3. uint32 healthpoint;
  4. uint32 healthpointmod;
  5. int32 healthpointpercent;
  6. } sethealthpointorpercent;
  7. case SMART_ACTION_SET_HEALTH:
  8. {
  9. ObjectList* targets = GetTargets(e, unit);
  10. if (!targets)
  11. break;
  12. for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
  13. {
  14. if (IsUnit(*itr))
  15. {
  16. if (e.action.sethealthpointorpercent.healthpointmod == 0)
  17. {
  18. int32 healthpct = int32(e.action.sethealthpointorpercent.healthpointpercent);
  19. (*itr)->ToUnit()->ModifyHealth(int32((*itr)->ToUnit()->CountPctFromMaxHealth(healthpct)));
  20. }
  21. else if (e.action.sethealthpointorpercent.healthpointmod == 1)
  22. {
  23. int32 missingHealth = int32((*itr)->ToUnit()->GetMaxHealth() - (*itr)->ToUnit()->GetHealth());
  24. (*itr)->ToUnit()->ModifyHealth(missingHealth);
  25. }
  26. else if (e.action.sethealthpointorpercent.healthpointmod == 2)
  27. (*itr)->ToUnit()->SetHealth(me->GetHealth());
  28. else if (e.action.sethealthpointorpercent.healthpointmod == 3)
  29. me->SetHealth((*itr)->ToUnit()->GetHealth());
  30. else if (e.action.sethealthpointorpercent.healthpointmod == 4)
  31. (*itr)->ToUnit()->SetMaxHealth(me->GetMaxHealth());
  32. else if (e.action.sethealthpointorpercent.healthpointmod == 5)
  33. me->SetMaxHealth((*itr)->ToUnit()->GetMaxHealth());
  34. else if (e.action.sethealthpointorpercent.healthpointmod == 6)
  35. {
  36. uint32 health = uint32(e.action.sethealthpointorpercent.healthpoint);
  37. (*itr)->ToUnit()->SetMaxHealth(health);
  38. }
  39. else if (e.action.sethealthpointorpercent.healthpointmod == 7)
  40. {
  41. uint32 health = uint32(e.action.sethealthpointorpercent.healthpoint);
  42. (*itr)->ToUnit()->SetHealth(health);
  43. }
  44. else
  45. {
  46. TC_LOG_ERROR("sql.sql", "SmartScript: Invalid type for SMART_ACTION_SET_HEALTH, skipping");
  47. break;
  48. }
  49. }
  50. }
  51. delete targets;
  52. break;
  53. }

SMART_ACTION_SET_HEALTH