#pragma once #include using namespace std; #include "../../src/NetServer.h" #include "../../src/CompiledPacket.h" #include "Vertex.h" #include "VitalStatus.h" #define USES_BATTLE_DATA mAgentType==AGENT_PLAYER //Packet stuff #define UGV_PUBLIC_LEVEL 0x1f #define UGV_CURRENT_HP 0x25 #define UGV_CURRENT_ENERGY 0x24 //Agent action exclusives #define AGENT_ACTION_NO_EXCLUSION 0 #define AGENT_ACTION_MOVEMENT 1 #define AGENT_ACTION_VITAL_STATUS 2 #define AGENT_ACTION_LEVEL 3 #define AGENT_ACTION_HP 4 #define AGENT_ACTION_ENERGY 5 #define AGENT_ACTION_DESTROY 6//All actions for agent will be removed. /////// #define MOVE_TYPE_STOP 9 //Agent action defines #define NO_EXPIRATION 0 #define AGENT_PLAYER 0 #define QueueAction(excID, expIn, AAFlags) AGENT_ACTION aa;aa.flags=AAFlags;aa.agentId=mAgentId;aa.pPckData=pck.GetString(&aa.dataSize);aa.exclusionId=excID;aa.expiresIn=expIn;((Instance*)mpInstance)->RelayAction(&aa); #define FinishAgentAction(excID, expIn, AAFlags) if (networkId==0){return pck.GetMiniPck();}else{QueueAction(excID, expIn, AAFlags);MiniCompPck mp;return mp;} #define GET_AGENT_POINTERS(id) unsigned char _data[4];memcpy(_data, &id, 4);unsigned short ins_id=Read_uShort(_data+2);unsigned short ag_id=Read_uShort(_data);Instance* pAg_instance=AccessInstance(ins_id);if (pAg_instance==NULL){GM_EXCEPTION_MSG("InstanceId(%u) not an instance!", ins_id);return GM_EXCEPTION;}Agent* pAgent=pAg_instance->AccessAgent(ag_id);if (pAgent==NULL){GM_EXCEPTION_MSG("AgentId(%u) not an agent!", ag_id);return GM_EXCEPTION;} #define RELAY_TO_ALL 1 //Action structure #define AG_ACT_FLAG_CIH_BEFORE 1 #define AG_ACT_FLAG_CIH_AFTER 2 #define AG_ACT_FLAG_EXPIRED 0x80 struct AGENT_ACTION { unsigned char* pPckData; short dataSize; long agentId; unsigned long startTime; unsigned short exclusionId; unsigned long expiresIn; unsigned char flags; }; //Battle data structure struct BattleData { bitset<32> vitalStatus; unsigned short maxHp; unsigned short maxEnergy; unsigned short currentHp; unsigned short currentEnergy; unsigned short level; short currentMorale; unsigned char professions[2]; short equippedSkills[16];//Players only get the first 8 }; class Agent { public: Agent(); Agent(unsigned long agentId, unsigned char agentType, void* pController, void* pData); ~Agent(); void Update(); void Destroy(); unsigned long GetAgentId(); void Init(); void* ControllerIs(int agentType); //Agent movement stuff Vertex GetCurrentPos(); Vertex GotoLocation(Vertex location, bool useCih); void MoveKeyboard(Vertex* pStart, Vertex* pDelta, int moveType); Vertex StopMovement(Vertex* pStop); void RotateAgent(Vertex rad); void SetCurrentPosition(Vertex pos); void SetCurrentSpeed(float speed); float GetCurrentSpeed(); float GetCurrentRotation(); //Agent packets O_O :: Prefixed with AP MiniCompPck APSetFreeAtrribPoints(unsigned char freeAttribPoints, unsigned short networkId); MiniCompPck APSetPrivateProfession(char primary, char secondary, unsigned short networkId); MiniCompPck APGotoLocation(Vertex position, unsigned short networkId); MiniCompPck APStartMovement(Vertex position, int moveType, unsigned short networkId); MiniCompPck APStopMovement(float flo, int moveType, unsigned short networkId); MiniCompPck APRotateAgent(Vertex rotation, unsigned short networkId); MiniCompPck APSetSkillBar(unsigned short networkId); //Agent action packets :: Prefixed with AA MiniCompPck AADestroyAgent(unsigned short networkId); MiniCompPck AASetEquippedItems(unsigned long weaponIsa, unsigned long offhandIsa, unsigned long chestIsa, unsigned long feetIsa, unsigned long legsIsa, unsigned long armsIsa, unsigned long headIsa, unsigned short networkId); MiniCompPck AAAgentItem(unsigned long eIsa, void* pItem, unsigned short networkId); MiniCompPck AASetVitalStatus(unsigned short networkId); MiniCompPck AAAgentMsg(unsigned long statId, unsigned long newValue, short exclusionId, long expiresIn, unsigned short networkId); MiniCompPck AASetMorale(unsigned short networkId); MiniCompPck AASetPublicProfession(unsigned short networkId); //Functions for agent types that use BATTLE_DATA BattleData* GetBattleData();//Use for setting default values void UpdateVitalStatus(int status, bool value); bool GetVitalFlag(int status); unsigned long GetVitalStatus(); unsigned short GetLevel(); void SetLevel(unsigned short level); short GetMorale(); void SetMorale(short morale); void SetProfession(int profession, bool secondary); private: unsigned long GetLatency(); unsigned char mAgentType; unsigned long mAgentId; void* mpController; void* mpData; void* mpInstance; //Movement tracker crap Vertex mDirection; unsigned char mMoveType; //Internal variables only Vertex mDestPosition; Vertex mLastPosition; unsigned long mTimeLastMoved; bool mRotating; float mRotation; float mCurrentSpeed; friend class Instance; friend class Player; };