Advertisement
Guest User

Untitled

a guest
Apr 27th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.64 KB | None | 0 0
  1. /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
  2. /* If you are missing that file, acquire a complete release at teeworlds.com. */
  3. #ifndef GAME_SERVER_ENTITIES_CHARACTER_H
  4. #define GAME_SERVER_ENTITIES_CHARACTER_H
  5.  
  6. #include <game/server/entity.h>
  7. #include <game/generated/server_data.h>
  8. #include <game/generated/protocol.h>
  9.  
  10. #include <game/gamecore.h>
  11.  
  12.  
  13.  
  14. class CGameTeams;
  15.  
  16. enum
  17. {
  18. WEAPON_GAME = -3, // team switching etc
  19. WEAPON_SELF = -2, // console kill command
  20. WEAPON_WORLD = -1, // death tiles etc
  21. };
  22.  
  23. class CCharacter : public CEntity
  24. {
  25. MACRO_ALLOC_POOL_ID()
  26.  
  27. public:
  28. //character's size
  29. static const int ms_PhysSize = 28;
  30.  
  31. CCharacter(CGameWorld *pWorld);
  32.  
  33. virtual void Reset();
  34. virtual void Destroy();
  35. virtual void Tick();
  36. virtual void TickDefered();
  37. virtual void TickPaused();
  38. virtual void Snap(int SnappingClient);
  39.  
  40. bool IsGrounded();
  41.  
  42. void SetWeapon(int W);
  43. void HandleWeaponSwitch();
  44. void DoWeaponSwitch();
  45.  
  46. void HandleWeapons();
  47. void HandleNinja();
  48.  
  49. void OnPredictedInput(CNetObj_PlayerInput *pNewInput);
  50. void OnDirectInput(CNetObj_PlayerInput *pNewInput);
  51. void ResetInput();
  52. void FireWeapon();
  53.  
  54. void Die(int Killer, int Weapon);
  55. bool TakeDamage(vec2 Force, int Dmg, int From, int Weapon);
  56.  
  57. bool Spawn(class CPlayer *pPlayer, vec2 Pos);
  58. bool Remove();
  59.  
  60. bool IncreaseHealth(int Amount);
  61. bool IncreaseArmor(int Amount);
  62.  
  63. bool GiveWeapon(int Weapon, int Ammo);
  64. void GiveNinja();
  65.  
  66. void SetEmote(int Emote, int Tick);
  67.  
  68. bool IsAlive() const { return m_Alive; }
  69. bool IsPaused() const { return m_Paused; }
  70. class CPlayer *GetPlayer() { return m_pPlayer; }
  71.  
  72. private:
  73. // player controlling this character
  74. class CPlayer *m_pPlayer;
  75.  
  76. bool m_Alive;
  77. bool m_Paused;
  78.  
  79. // weapon info
  80. CEntity *m_apHitObjects[10];
  81. int m_NumObjectsHit;
  82.  
  83. struct WeaponStat
  84. {
  85. int m_AmmoRegenStart;
  86. int m_Ammo;
  87. int m_Ammocost;
  88. bool m_Got;
  89.  
  90. } m_aWeapons[NUM_WEAPONS];
  91.  
  92. int m_ActiveWeapon;
  93. int m_LastWeapon;
  94. int m_QueuedWeapon;
  95.  
  96. int m_ReloadTimer;
  97. //UPGRmod
  98. int m_aReloadtimer[NUM_WEAPONS];
  99. //UpgrmodEND
  100. int m_AttackTick;
  101.  
  102. int m_DamageTaken;
  103.  
  104. int m_EmoteType;
  105. int m_EmoteStop;
  106.  
  107. // last tick that the player took any action ie some input
  108. int m_LastAction;
  109.  
  110. // these are non-heldback inputs
  111. CNetObj_PlayerInput m_LatestPrevInput;
  112. CNetObj_PlayerInput m_LatestInput;
  113.  
  114. // input
  115. CNetObj_PlayerInput m_PrevInput;
  116. CNetObj_PlayerInput m_Input;
  117. int m_NumInputs;
  118. int m_Jumped;
  119.  
  120. int m_DamageTakenTick;
  121.  
  122. int m_Health;
  123. int m_Armor;
  124.  
  125. // ninja
  126. struct
  127. {
  128. vec2 m_ActivationDir;
  129. int m_ActivationTick;
  130. int m_CurrentMoveTime;
  131. int m_OldVelAmount;
  132. } m_Ninja;
  133.  
  134. // the player core for the physics
  135. CCharacterCore m_Core;
  136.  
  137. // info for dead reckoning
  138. int m_ReckoningTick; // tick that we are performing dead reckoning From
  139. CCharacterCore m_SendCore; // core that we should send
  140. CCharacterCore m_ReckoningCore; // the dead reckoning core
  141.  
  142. // DDRace
  143.  
  144.  
  145. void HandleTiles(int Index);
  146. float m_Time;
  147. int m_LastBroadcast;
  148. void DDRaceInit();
  149. void HandleSkippableTiles(int Index);
  150. void DDRaceTick();
  151. void DDRacePostCoreTick();
  152. void HandleBroadcast();
  153.  
  154. //XXLmod
  155. void XXLDDRaceInit();
  156. void XXLDDRaceTick();
  157. void XXLDDRacePostCoreTick();
  158. void HandleRainbow();
  159. void HandleBlood();
  160. void HandleRescue();
  161. void HandleJumps();
  162. void HandleFly();
  163.  
  164. //upgrmod
  165. void UPGRDDRaceInit();
  166.  
  167. public:
  168. CGameTeams* Teams();
  169. void Pause(bool Pause);
  170. bool Freeze(int Time);
  171. bool Freeze();
  172. bool UnFreeze();
  173. void GiveAllWeapons();
  174. int m_DDRaceState;
  175. int Team();
  176. bool CanCollide(int ClientID);
  177. bool SameTeam(int ClientID);
  178. bool m_Super;
  179. int m_TeamBeforeSuper;
  180. int m_FreezeTime;
  181. int m_FreezeTick;
  182. bool m_DeepFreeze;
  183. bool m_EndlessHook;
  184. enum
  185. {
  186. HIT_ALL=0,
  187. DISABLE_HIT_HAMMER=1,
  188. DISABLE_HIT_SHOTGUN=2,
  189. DISABLE_HIT_GRENADE=4,
  190. DISABLE_HIT_RIFLE=8
  191. };
  192. int m_Hit;
  193. int m_PainSoundTimer;
  194. int m_LastMove;
  195. int m_StartTime;
  196. vec2 m_PrevPos;
  197. int m_TeleCheckpoint;
  198. int m_CpTick;
  199. int m_CpActive;
  200. int m_CpLastBroadcast;
  201. float m_CpCurrent[25];
  202. int m_TileIndex;
  203. int m_TileFlags;
  204. int m_TileFIndex;
  205. int m_TileFFlags;
  206. int m_TileSIndex;
  207. int m_TileSFlags;
  208. int m_TileIndexL;
  209. int m_TileFlagsL;
  210. int m_TileFIndexL;
  211. int m_TileFFlagsL;
  212. int m_TileSIndexL;
  213. int m_TileSFlagsL;
  214. int m_TileIndexR;
  215. int m_TileFlagsR;
  216. int m_TileFIndexR;
  217. int m_TileFFlagsR;
  218. int m_TileSIndexR;
  219. int m_TileSFlagsR;
  220. int m_TileIndexT;
  221. int m_TileFlagsT;
  222. int m_TileFIndexT;
  223. int m_TileFFlagsT;
  224. int m_TileSIndexT;
  225. int m_TileSFlagsT;
  226. int m_TileIndexB;
  227. int m_TileFlagsB;
  228. int m_TileFIndexB;
  229. int m_TileFFlagsB;
  230. int m_TileSIndexB;
  231. int m_TileSFlagsB;
  232. vec2 m_Intersection;
  233. int64 m_LastStartWarning;
  234. // Setters/Getters because i don't want to modify vanilla vars access modifiers
  235. int GetLastWeapon() { return m_LastWeapon; };
  236. void SetLastWeapon(int LastWeap) {m_LastWeapon = LastWeap; };
  237. int GetActiveWeapon() { return m_ActiveWeapon; };
  238. void SetActiveWeapon(int ActiveWeap) {m_ActiveWeapon = ActiveWeap; };
  239. void SetLastAction(int LastAction) {m_LastAction = LastAction; };
  240. int GetArmor() { return m_Armor; };
  241. void SetArmor(int Armor) {m_Armor = Armor; };
  242. CCharacterCore GetCore() { return m_Core; };
  243. void SetCore(CCharacterCore Core) {m_Core = Core; };
  244. CCharacterCore* Core() { return &m_Core; };
  245. bool GetWeaponGot(int Type) { return m_aWeapons[Type].m_Got; };
  246. void SetWeaponGot(int Type, bool Value) { m_aWeapons[Type].m_Got = Value; };
  247. int GetWeaponAmmo(int Type) { return m_aWeapons[Type].m_Ammo; };
  248. void SetWeaponAmmo(int Type, int Value) { m_aWeapons[Type].m_Ammo = Value; };
  249. bool IsAlive() { return m_Alive; };
  250. void SetEmoteType(int EmoteType) { m_EmoteType = EmoteType; };
  251. void SetEmoteStop(int EmoteStop) { m_EmoteStop = EmoteStop; };
  252. void SetNinjaActivationDir(vec2 ActivationDir) { m_Ninja.m_ActivationDir = ActivationDir; };
  253. void SetNinjaActivationTick(int ActivationTick) { m_Ninja.m_ActivationTick = ActivationTick; };
  254. void SetNinjaCurrentMoveTime(int CurrentMoveTime) { m_Ninja.m_CurrentMoveTime = CurrentMoveTime; };
  255. //XXLmod
  256. int m_ReloadMultiplier;
  257. bool m_FastReload;
  258. int m_LastIndexTile;
  259. int m_LastIndexFrontTile;
  260. bool m_Bloody;
  261. vec2 m_RescuePos;
  262. int m_LastRescue;
  263. int m_LastRescueSave;
  264. bool m_IceHammer;
  265. bool m_Fly;
  266. int m_HammerType;
  267. //upgrmod
  268. int m_ReloadMultiplierGrenade;
  269. int m_ReloadMultiplierShotgun;
  270. int m_ReloadMultiplierRifle;
  271. };
  272.  
  273. enum
  274. {
  275. DDRACE_NONE = 0,
  276. DDRACE_STARTED,
  277. DDRACE_CHEAT, // no time and won't start again unless ordered by a mod or death
  278. DDRACE_FINISHED
  279. };
  280.  
  281. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement