HelmedRaven

FauxAttack Command (SWGEmu)

Oct 24th, 2020
1,127
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.                 Copyright <SWGEmu>
  3.         See file COPYING for copying conditions.*/
  4.  
  5. #ifndef FAUXATTACKCOMMAND_H_
  6. #define FAUXATTACKCOMMAND_H_
  7.  
  8. #include "server/zone/objects/scene/SceneObject.h"
  9. #include "server/zone/objects/creature/commands/sovrp/sovrpfunc.h"
  10.  
  11. class FauxAttackCommand : public CombatQueueCommand {
  12. public:
  13.  
  14.     FauxAttackCommand(const String& name, ZoneProcessServer* server)
  15.         : CombatQueueCommand(name, server) {
  16.  
  17.     }
  18.  
  19.     int doQueueCommand(CreatureObject* creature, const uint64& target, const UnicodeString& arguments) const {
  20.         if (!checkStateMask(creature))
  21.             return INVALIDSTATE;
  22.  
  23.         if (!checkInvalidLocomotions(creature))
  24.             return INVALIDLOCOMOTION;
  25.  
  26.         ManagedReference<SceneObject*> object = server->getZoneServer()->getObject(target);
  27.  
  28.         CreatureObject* targetCreature = cast<CreatureObject*>( object.get());
  29.  
  30.         if (targetCreature == NULL)
  31.             return INVALIDTARGET;
  32.  
  33.         Locker clocker(targetCreature, creature);
  34.  
  35.         ManagedReference<PlayerObject*> playerGhost = creature->getPlayerObject();
  36.         SovRPFunc* sov = new SovRPFunc();
  37.         StringTokenizer args(arguments.toString());
  38.  
  39.         if (playerGhost == NULL)
  40.             return GENERALERROR;
  41.  
  42.         if (!CollisionManager::checkLineOfSight(creature, targetCreature)) {
  43.             creature->sendSystemMessage("@cbt_spam:los_fail");// You lost sight of your target.
  44.             return GENERALERROR;
  45.         }
  46.  
  47.         if (!checkDistance(creature, targetCreature, range))
  48.             return TOOFAR;
  49.  
  50.         if (true) {
  51.             String animString = "";
  52.            
  53.             String command, subCommand;
  54.            
  55.             bool isMelee = sov->IsWeaponMelee(creature->getWeapon());
  56.  
  57.             if(args.hasMoreTokens()){
  58.                 args.getStringToken(command);
  59.                
  60.                 command = command.toLowerCase();
  61.                 animString = command;
  62.             } else {
  63.                 if(isMelee) {
  64.                     animString = "combo_4a_light";
  65.                 } else {
  66.                     animString = "fire_1_special_single_light";
  67.                 }
  68.             }
  69.  
  70.             //uint32 animCRC = getAnimationString().hashCode();
  71.             // hitstatus: 0x0-MISS 0x1-HIT 0x2-BLOCK 0x3-DODGE 0x5-COUNTER 0x7-RICOCHET 0x8-REFLECT 0x9-REFLECT_TO_TARGET
  72.             uint32 animCRC = animString.hashCode();
  73.             creature->doCombatAnimation(targetCreature, animCRC, 0x1, 0xFF);
  74.             //CombatManager::instance()->broadcastCombatSpam(creature, targetCreature, NULL, 0, "cbt_spam", combatSpam, 0);
  75.  
  76.             return SUCCESS;
  77.         }
  78.  
  79.         return GENERALERROR;
  80.     }
  81.  
  82.     float getCommandDuration(CreatureObject* object, const UnicodeString& arguments) const {
  83.         return defaultTime * 0.0;
  84.     }
  85.  
  86. };
  87.  
  88. #endif //TRANSFERFORCECOMMAND_H_
  89.  
RAW Paste Data