⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chars.h

📁 这是一个服务端/客户端模式的小型网络游戏
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifndef _CHARS_H_
#define _CHARS_H_

#include "Frustum.h"
#include "CharICS.h"
#include "MCL.h"
#include "MIL.h"
#include "MSL.h"
#include "Extern.h"
#include <queue>
#include "Client.h"
using namespace std;

// Spell references
class  cSpellController;
struct sSpellTracker;

// Number of characters in file
#define NUM_CHARACTER_DEFINITIONS   256

// Character types
#define CHAR_PC          0
#define CHAR_NPC         1
#define CHAR_MONSTER     2

// AI types
#define CHAR_STAND       0
#define CHAR_WANDER      1
#define CHAR_ROUTE       2
#define CHAR_FOLLOW      3
#define CHAR_EVADE       4

// Action/Animation types
#define CHAR_IDLE        0
#define CHAR_MOVE        1
#define CHAR_ATTACK      2
#define CHAR_SPELL       3
#define CHAR_ITEM        4
#define CHAR_HURT        5
#define CHAR_DIE         6
#define CHAR_TALK        7

// Status ailments
#define AILMENT_POISON          1
#define AILMENT_SLEEP           2
#define AILMENT_PARALYZE        4
#define AILMENT_WEAK            8
#define AILMENT_STRONG         16
#define AILMENT_ENCHANTED      32
#define AILMENT_BARRIER        64
#define AILMENT_DUMBFOUNDED   128
#define AILMENT_CLUMSY        256
#define AILMENT_SUREFOOTED    512 
#define AILMENT_SLOW         1024
#define AILMENT_FAST         2048
#define AILMENT_BLIND        4096
#define AILMENT_HAWKEYE      8192
#define AILMENT_SILENCED    16384

// Animation info
typedef struct {
  char Name[32];    // Name of animation
  BOOL Loop;        // To loop flag
} sCharAnimationInfo;

// A mesh list
typedef struct sCharacterMeshList {
  char       Filename[MAX_PATH];  // Filename of mesh/anim
  long       Count;               // # characters using mesh
  cMesh      Mesh;                // Mesh object
  cAnimation Animation;           // Animation object

  sCharacterMeshList()  { Count = 0;                     }
  ~sCharacterMeshList() { Mesh.Free(); Animation.Free(); }
} sCharacterMeshList;

// Path/Route structure
typedef struct {
  float XPos, YPos, ZPos;   // Target position
} sRoutePoint;

typedef struct sCharacter
{
  long  Definition;         // Character definition #
  long  ID;                 // ID # of character


 // char  Name[64];        // Name of player
  long  Time;               // Time of last state update

  DPNID dpnidPlayer;        // DirectPlay Player ID #
  long  Type;               // PC, NPC, or MONSTER
  long  AI;                 // STAND, WANDER, etc
  deque<sMessage> m_Messages;	
    CRITICAL_SECTION m_UpdateCS;    // Critical sections
  BOOL  Enabled;            // Enabled flag (for updates)

  sCharacterDefinition Def; // Loaded definition
  cCharICS *CharICS;        // PC character's ICS

  char ScriptFilename[MAX_PATH]; // Associated script

  long  HealthPoints;       // Current health points
  long  ManaPoints;         // Current mana points
 // long  Ailments;           // Ailments against character
  float Charge;             // Attack charge

  long  Action;             // Current action
  float XPos, YPos, ZPos;   // Current coordinates
  float Direction;          // Angle character is facing
  long  LastAnim;           // Last animation
  long  LastAnimTime;       // Last animation time
	long Elapsed;

  BOOL  Locked;             // Specific action lock
  long  ActionTimer;        // Lock action countdown timer

  sCharacter *Attacker;     // Attacking character (if any)
  sCharacter *Victim;       // Character to attack

  long  SpellNum;           // Spell to cast when ready
  long  SpellTarget;        // Target type of spell
  float TargetX, TargetY, TargetZ; // Spell target coords

  long ItemNum;             // Item to use when ready
  sCharItem *CharItem;      // Item to remove from inventory

  float Distance;           // Follow/Evade distance
  sCharacter *TargetChar;   // Character to follow
  float MinX, MinY, MinZ;   // Min bounding coordinates
  float MaxX, MaxY, MaxZ;   // Max bounding coordiantes

  long  NumPoints;          // # points in route
  long  CurrentPoint;       // Current route point
  sRoutePoint *Route;       // Route points

  char  Message[128];       // Text message
  long  MessageTimer;       // Text message timer
  D3DCOLOR MessageColor;    // Color of text message
  //long EffectCounter;

  cObject Object;           // Character object class
  cMesh   WeaponMesh;       // Weapon mesh
  cObject WeaponObject;     // Weapon object

  sCharacter *Prev, *Next;  // Linked list of characters

  sCharacter()
  {
    Definition = 0;         // Set to definition #0
    ID = -1;                // Set to no ID
    Type = CHAR_NPC;        // Set to NPC character
    Enabled = FALSE;        // Set to not enabled
    
  //  Ailments = 0;           // Set no ailments
    Charge = 0.0f;          // Set no charge

    // Clear definition
    ZeroMemory(&Def, sizeof(sCharacterDefinition));
    CharICS = NULL;         // Set no ICS

    ScriptFilename[0] = 0;  // Set no script

  //  Action = CHAR_IDLE;     // Set default animation
    LastAnim = -1;          // Reset animation

    Locked = FALSE;         // Set no lock
    ActionTimer = 0;        // Set no action timer

    Attacker = NULL;        // Set no attacker
    Victim = NULL;          // Set no victim

    ItemNum = 0;            // Set no item to use
    CharItem = NULL;        // Set no item to decrease

    Distance = 0.0f;        // Set distance
    TargetChar = NULL;      // Set no target character

    // Clear bounding box (for limiting movement)
    MinX = MinY = MinZ = MaxX = MaxY = MaxZ = 0.0f;

    NumPoints = 0;          // Set no route points
    Route = NULL;           // Set no route

  //  Message[0] = 0;         // Clear message
 //   MessageTimer = 0;       // Set no message timer

    Prev = Next = NULL;     // Clear linked list pointers
  }

  ~sCharacter()
  {
    if(CharICS != NULL) {  // Release character ICS
      CharICS->Free();
      delete CharICS;
    }

    delete [] Route;       // Release route

    WeaponObject.Free();   // Release weapon object
    WeaponMesh.Free();     // Release weapon mesh
    Object.Free();         // Release character object

	// Remove critical section
    DeleteCriticalSection(&m_UpdateCS);
    delete Next;           // Delete next character in list
  }
} sCharacter;

class cCharacterController
{
  private:

    cGraphics  *m_Graphics;            // Parent graphics object
    cFrustum   *m_Frustum;             // Viewing frustum

    char m_DefinitionFile[MAX_PATH];   // Filename of def. file

    sSpell     *m_MSL;                 // Master spell list

    cSpellController *m_SpellController; // Spell controller

    long        m_NumCharacters;       // # characters in list

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -