Changeset 8dad966 in network-game for common


Ignore:
Timestamp:
Jun 3, 2013, 11:05:20 PM (12 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
d03ec0f
Parents:
8a4ed74
Message:

Added server support for player attack animations and cooldowns and firing projectiles for ranged attacks

Location:
common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • common/Message.h

    r8a4ed74 r8dad966  
    22#define _MESSAGE_H
    33
    4 #define MSG_TYPE_REGISTER      1
    5 #define MSG_TYPE_LOGIN         2
    6 #define MSG_TYPE_LOGOUT        3
    7 #define MSG_TYPE_CHAT          4
    8 #define MSG_TYPE_PLAYER        5  // server sends this to update player positions
    9 #define MSG_TYPE_PLAYER_MOVE   6  // client sends this when a player wants to move
    10 #define MSG_TYPE_OBJECT        7
    11 #define MSG_TYPE_REMOVE_OBJECT 8
    12 #define MSG_TYPE_PICKUP_FLAG   9
    13 #define MSG_TYPE_DROP_FLAG     10
    14 #define MSG_TYPE_SCORE         11
    15 #define MSG_TYPE_START_ATTACK  12
    16 #define MSG_TYPE_ATTACK        13
     4#define MSG_TYPE_REGISTER          1
     5#define MSG_TYPE_LOGIN             2
     6#define MSG_TYPE_LOGOUT            3
     7#define MSG_TYPE_CHAT              4
     8#define MSG_TYPE_PLAYER            5  // server sends this to update player positions
     9#define MSG_TYPE_PLAYER_MOVE       6  // client sends this when a player wants to move
     10#define MSG_TYPE_OBJECT            7
     11#define MSG_TYPE_REMOVE_OBJECT     8
     12#define MSG_TYPE_PICKUP_FLAG       9
     13#define MSG_TYPE_DROP_FLAG         10
     14#define MSG_TYPE_SCORE             11
     15#define MSG_TYPE_START_ATTACK      12
     16#define MSG_TYPE_ATTACK            13
     17#define MSG_TYPE_PROJECTILE        14
     18#define MSG_TYPE_REMOVE_PROJECTILE 14
    1719
    1820typedef struct
  • common/Player.cpp

    r8a4ed74 r8dad966  
    1616   this->pos.y = this->target.y = 0;
    1717   this->timeLastUpdated = 0;
     18   this->timeAttackStarted = 0;
     19   this->isAttacking = false;
    1820
    1921   this->playerClass = CLASS_NONE;
     
    2224   this->attackType = ATTACK_NONE;
    2325   this->damage = 0;
     26   this->attackCooldown = 0;
    2427   this->team = 0;   // blue team by default
    2528   this->hasBlueFlag = false;
     
    3841   this->target.y = p.target.y;
    3942   this->timeLastUpdated = p.timeLastUpdated;
     43   this->timeAttackStarted = p.timeAttackStarted;
     44   this->isAttacking = p.isAttacking;
    4045
    4146   this->playerClass = p.playerClass;
     
    4449   this->attackType = p.attackType;
    4550   this->damage = p.damage;
     51   this->attackCooldown = p.attackCooldown;
    4652   this->team = p.team;
    4753   this->hasBlueFlag = p.hasBlueFlag;
     
    5763   this->pos.x = this->target.x = 200;
    5864   this->pos.y = this->target.y = 200;
     65   this->timeLastUpdated = 0;
     66   this->timeAttackStarted = 0;
     67   this->isAttacking = false;
    5968
    6069   this->playerClass = CLASS_NONE;
     
    6372   this->attackType = ATTACK_NONE;
    6473   this->damage = 0;
     74   this->attackCooldown = 0;
    6575   this->team = 0;   // blue team by default
    6676   this->hasBlueFlag = false;
     
    8797      case CLASS_WARRIOR:
    8898         this->playerClass = CLASS_WARRIOR;
    89          this->maxHealth = this->health = 100;
     99         this->maxHealth = this->health = 120;
    90100         this->attackType = ATTACK_MELEE;
    91101         this->damage = 10;
     102         this->attackCooldown = 800;
    92103         break;
    93104      case CLASS_RANGER:
     
    96107         this->attackType = ATTACK_RANGED;
    97108         this->damage = 6;
     109         this->attackCooldown = 1000;
    98110         break;
    99111      case CLASS_NONE:
  • common/Player.h

    r8a4ed74 r8dad966  
    5858   POSITION target;
    5959   unsigned long long timeLastUpdated;
     60   unsigned long long timeAttackStarted;
     61   bool isAttacking;
     62   int targetPlayer;
    6063
    6164   int playerClass;
     
    6467   int attackType;
    6568   int damage;
     69   unsigned long long attackCooldown;
    6670   int team; // 0 is blue, 1 is red
    6771   bool hasBlueFlag;
Note: See TracChangeset for help on using the changeset viewer.