Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static bool HandleCastDestCommand(ChatHandler* handler, char const* args)
- {
- // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
- uint32 spellId = handler->extractSpellIdFromLink((char*)args);
- if (!spellId)
- return false;
- if (!CheckSpellExistsAndIsValid(handler, spellId))
- return false;
- char* arg0 = strtok((char*)args, " ");
- char* arg1 = strtok(NULL, " ");
- float x, y, z, o;
- if (!arg1)
- {
- Player* player = handler->GetSession()->GetPlayer();
- player->GetPosition(x, y, z);
- caster->CastSpell(handler->GetSession()->GetPlayer(), spellId);
- return true;
- }
- else
- {
- char* arg2 = strtok(NULL, " ");
- /* arg1 = strtok(NULL, " ");
- char* arg2 = strtok(NULL, " ");*/
- player->GetPosition(x,y,z);
- Player* player = handler->GetSession()->GetPlayer();
- o = player->GetOrientation();
- /*char dir = arg1;
- float value = float(atof(arg2));*/
- do{
- char* dir = arg1;
- float value = float(atof(arg2));
- switch (dir[0])
- {
- case 'l':
- {
- x = x + cos(o + (M_PI / 2))*value;
- y = y + sin(o + (M_PI / 2))*value;
- }
- break;
- case 'r':
- {
- x = x + cos(o-(M_PI/2))*value;
- y = y + sin(o-(M_PI/2))*value;
- }
- break;
- case 'f':
- {
- x = x + cosf(o)*value;
- y = y + sinf(o)*value;
- }
- break;
- case 'b':
- {
- x = x - cosf(o)*value;
- y = y - sinf(o)*value;
- }
- break;
- case 'u':
- {
- z = z + value;
- }
- break;
- case 'd':
- {
- z = z - value;
- }
- break;
- }
- arg1 = strtok(NULL, " ");
- arg2 = strtok(NULL, " ");
- }while ((arg1 != NULL && arg2 != NULL));
- caster->CastSpell(x, y, z, spellId);
- handler->PSendSysMessage(arg1);
- handler->PSendSysMessage(arg2);
- return true;
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement