📄 chars.h
字号:
#ifndef _CHARACTERCONTROLLER_H_
#define _CHARACTERCONTROLLER_H_
//#include "WinMain.h"
#include "Extern.h"
#include "Global.h"
#include <queue>
using namespace std;
#define MAX_ACTION 8
// 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
// Global names of character meshes
const float con_Bounds[][MAX_ACTION] = {
{ -38.314499f, -0.756000f, -5.946800f, 38.700699f, 71.939697f, 8.268400f, 76.631775f },
{ -61.534500f, -0.020300f, -100.249603f, 61.994801f, 77.043297f, 37.044800f, 187.605789f }
};
// Global names of character meshes
const int AnimationLength[][MAX_ACTION] = {
{ 40, 23, 12, 29, 12, 14, 20, 40 }, // Mesh # 0
{ 40, 23, 19, 14, 19, 14, 31, 40 } // Mesh # 1
};
// 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
DPNID dpnidPlayer; // DirectPlay Player ID #
long Time; // Time of last state update
long Latency; // Half of round trip latency in ms
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
float Radius;
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
// MessageID = 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:
cServer *m_Server;
// cGraphics *m_Graphics; // Parent graphics object
cFont *m_Font; // Font object to use
char m_DefinitionFile[MAX_PATH]; // Filename of def. file
sItem *m_MIL; // Master item list
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -