Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. static bool HandleCastDestCommand(ChatHandler* handler, char const* args)
  2. {
  3. // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
  4. uint32 spellId = handler->extractSpellIdFromLink((char*)args);
  5. if (!spellId)
  6. return false;
  7.  
  8. if (!CheckSpellExistsAndIsValid(handler, spellId))
  9. return false;
  10. char* arg0 = strtok((char*)args, " ");
  11. char* arg1 = strtok(NULL, " ");
  12.  
  13. float x, y, z, o;
  14. if (!arg1)
  15. {
  16. Player* player = handler->GetSession()->GetPlayer();
  17. player->GetPosition(x, y, z);
  18. caster->CastSpell(handler->GetSession()->GetPlayer(), spellId);
  19. return true;
  20. }
  21.  
  22. else
  23. {
  24. char* arg2 = strtok(NULL, " ");
  25. /* arg1 = strtok(NULL, " ");
  26. char* arg2 = strtok(NULL, " ");*/
  27. player->GetPosition(x,y,z);
  28. Player* player = handler->GetSession()->GetPlayer();
  29. o = player->GetOrientation();
  30.  
  31. /*char dir = arg1;
  32. float value = float(atof(arg2));*/
  33.  
  34. do{
  35. char* dir = arg1;
  36. float value = float(atof(arg2));
  37.  
  38. switch (dir[0])
  39. {
  40. case 'l':
  41. {
  42.  
  43. x = x + cos(o + (M_PI / 2))*value;
  44. y = y + sin(o + (M_PI / 2))*value;
  45.  
  46. }
  47. break;
  48. case 'r':
  49. {
  50. x = x + cos(o-(M_PI/2))*value;
  51. y = y + sin(o-(M_PI/2))*value;
  52.  
  53. }
  54. break;
  55. case 'f':
  56. {
  57. x = x + cosf(o)*value;
  58. y = y + sinf(o)*value;
  59. }
  60. break;
  61. case 'b':
  62. {
  63. x = x - cosf(o)*value;
  64. y = y - sinf(o)*value;
  65. }
  66. break;
  67. case 'u':
  68. {
  69. z = z + value;
  70. }
  71. break;
  72. case 'd':
  73. {
  74. z = z - value;
  75. }
  76. break;
  77. }
  78. arg1 = strtok(NULL, " ");
  79. arg2 = strtok(NULL, " ");
  80. }while ((arg1 != NULL && arg2 != NULL));
  81.  
  82. caster->CastSpell(x, y, z, spellId);
  83. handler->PSendSysMessage(arg1);
  84. handler->PSendSysMessage(arg2);
  85.  
  86. return true;
  87. }
  88. }
  89. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement